Repository navigation
jupiter: simulate the swap before signing - #1644
Open
Timothymycompc wants to merge 1 commit into
Open
Timothymycompc wants to merge 1 commit into
Timothymycompc wants to merge 1 commit into
Conversation
The swap action signed whatever transaction Jupiter's API returned. It now simulates the unsigned transaction first and refuses to sign when the simulation fails, the wallet would give up more than the quoted input amount, or it would receive less than the quote's minimum output (otherAmountThreshold).
🟡 Heimdall Review Status
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Jupiter
swapaction signs whatever transaction Jupiter's/swapendpoint returns. Agents sign without a person reviewing a wallet popup, so if that response were ever wrong (a misconfiguration, a compromised endpoint or proxy), the agent's wallet would sign it anyway.This PR simulates the unsigned transaction before signing (
swapCheck.ts, using the wallet provider's own connection, no new dependencies) and refuses to sign when:inAmount,otherAmountThreshold,When it refuses, the action returns
Refused to sign the swap transaction: <reason>instead of signing.Tests
swapCheck.test.ts: a swap that does what the quote says passes (including one that opens the output token account); swaps that pay someone else, take extra SOL, take more of the input token, or fail in simulation are refused.jupiterActionProvider.test.ts: a refused check meanssignAndSendTransactionis never called.Disclosure: I maintain an open-source pre-sign checker for Solana agents (Solana Pulse); this PR doesn't depend on it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYNBQQhnYiveWR3NW9fyjP