Franklin icon indicating copy to clipboard operation
Franklin copied to clipboard

Jupiter swaps: a way to verify every instruction and asset movement before signing

Open Timothymycompc opened this issue 2 weeks ago • 2 comments

Hi, I was reading src/tools/jupiter.ts: executeJupiterSwap() (line 462) keeps live swaps off until Franklin "can locally verify every instruction and asset movement" (line 476), and the reference path signs the Ultra order as-is (line 403). That's the right call.

That verification is what I've been building, so in case it helps you turn swaps back on: check_tx takes the unsigned transaction, decodes each instruction, dry-runs it on mainnet and answers OK, REVIEW or BLOCK with every wallet's SOL and token changes. tx_matches goes one step further for swaps: give it what you asked for (sell token, amount, buy token) and it confirms the transaction sells exactly that and pays the bought token back to your own wallet.

// npm install solana-pulse   (no dependencies)
import { checkBeforeSign } from "solana-pulse";

await checkBeforeSign(order.transaction);  // throws unless Pulse answers OK
// for a swap, also confirm it's the one you asked for:
// await checkBeforeSign(tx, { expected: { action: "swap", sell: "SOL", amount: "0.5", buy: USDC_MINT } });

Disclosure: I built this (Solana Pulse, open source: https://github.com/Timothymycompc/solana-pulse-ai-agent-gateway). Anyone gets 25 free calls per tool per day. If you want more than that for Franklin, I'll give you a key with no limit, free for a month. No strings attached. And if you'd rather keep it all local, simulateTransaction with the wallet in accounts and comparing the balance changes to the order's in and out amounts covers most of the same ground.

Timothymycompc avatar Nov 12 '26 23:11 Timothymycompc

Thanks for the detailed write-up and for the disclosure. Swap signing is a money path, so we want the pre-sign check to run entirely locally without depending on an external service. When we re-enable live swaps, we'll implement the approach you outlined at the end: simulateTransaction with the wallet in accounts, then compare the resulting balance changes against the order's in/out amounts and mints. Closing for now, but appreciate you pointing at this.

VickyXAI avatar Nov 18 '26 22:11 VickyXAI

Verifying every instruction and net asset movement before signing is essential once an agent holds a live wallet—blind-signing swap payloads is where most prompt-injection and routing exploits land.

In our own autonomous-agent stress tests, pairing pre-sign simulation with hard, fail-closed execution guardrails made the biggest difference: strict monotonic nonces, per-TX and cumulative spend caps, and allowlisted recipients/programs enforced below the agent runtime. That way, even if an LLM enters a recursive retry loop or receives a manipulated payload, the transaction fails closed before funds leave the wallet.

NyxSynth avatar Nov 25 '26 17:11 NyxSynth