@telaro/jupiter
v0.1.0
Published
Telaro adapter for Jupiter v6 API. Auto-records every swap as an on-chain action.
Maintainers
Readme
@telaro/jupiter
Telaro adapter for Jupiter v6. Auto-records every swap as an on-chain
record_action. Every Solana DeFi agent that swaps via Jupiter can become bonded with one client.
Install
npm install @telaro/jupiter @telaro/sdk @solana/web3.jsUse
import { TelaroJupiter } from "@telaro/jupiter";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
const jup = new TelaroJupiter({
connection: new Connection("https://api.mainnet-beta.solana.com"),
wallet: Keypair.fromSecretKey(/* ... */),
bondAmount: 100_000_000n, // 100 USDC bond
bondMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // mainnet USDC
scorer: new PublicKey("ScorerPubkeyOfTheIndexer..."),
});
// First call lazily registers + bonds. Subsequent calls reuse the agent.
const result = await jup.swap({
inputMint: "So11111111111111111111111111111111111111112", // SOL
outputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
amount: 1_000_000n, // 0.001 SOL
slippageBps: 50,
});
console.log(result.signature, result.inAmount, result.outAmount);What it does
For each swap():
- Lazy register: first call posts the bond + opens the Agent PDA.
- Quote via Jupiter
/quote(best route across 20+ DEXs). - Build the swap transaction via Jupiter
/swap. - Sign + send + confirm.
- Record action on Telaro with the actual
inAmount/outAmountfrom the Jupiter quote — accuratevalue_atomicfor the score formula.
If the swap fails, an outcome=Failed record is still emitted so the score
correctly penalizes the agent.
Why use this
- Drop-in: 1 import + 1 class. No fork of Jupiter.
- Accurate
value_atomic: from Jupiter quote, not user-supplied. - Cross-framework: works with raw keypairs, no SDK lock-in.
- Frozen-aware: if the agent is frozen on-chain,
recordActionreverts and surfaces the error (you can't keep trading without re-bonding).
Best practices
- Mainnet RPC: use Helius/Triton for production. Jupiter devnet doesn't have the deep liquidity mainnet does.
- Batch records? Currently each swap = 1 record tx. v2 will offer
recordActionBatchfor cost savings on high-frequency bots. - Slippage: default
50bps(0.5%) is conservative. Tighten or loosen based on pair volatility.
License
MIT
