-
Notifications
You must be signed in to change notification settings - Fork 12
Update token addresses parsing + add Jupiter parser testing with a real route fixture #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new test fixture file for Jupiter Route swap transactions on Solana. The fixture captures a real mainnet transaction (WSOL to USDT swap) to be used for testing the Jupiter swap parser implementation.
- Adds comprehensive test data including instruction details, account metadata, and expected parsed fields
- Documents a 6-instruction transaction with focus on instruction #4 (the actual swap)
- Includes 25 account entries with role descriptions and expected output fields for validation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "program_id": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", | ||
| "input_amount": "1704961004145737728", | ||
| "quoted_output_amount": "54975581388800", | ||
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input_token_address appears to be incorrect. It's set to "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" which is the SPL Token Program ID, not a token mint address. According to the transaction description (line 2), this is a "WSOL to USDT swap", so the input token address should be the Wrapped SOL mint address "So11111111111111111111111111111111111111112" (which appears at line 102).
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | |
| "input_token_address": "So11111111111111111111111111111111111111112", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks right
| "input_amount": "1704961004145737728", | ||
| "quoted_output_amount": "54975581388800", | ||
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | ||
| "output_token_address": "B7hSadyLX8YhNT8RDcK8RbnR3KAfX4HbWvV89XmeqitA", |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output_token_address appears to be incorrect. It's set to "B7hSadyLX8YhNT8RDcK8RbnR3KAfX4HbWvV89XmeqitA" which is described as "User wallet" (line 21), not a token mint address. According to the transaction description (line 2), this is a "WSOL to USDT swap", so the output token address should be the USDT mint address. Please verify and use the correct USDT mint address (typically "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB" on mainnet).
| "output_token_address": "B7hSadyLX8YhNT8RDcK8RbnR3KAfX4HbWvV89XmeqitA", | |
| "output_token_address": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk
{5 items
amm:
"whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
inputMint:
"So11111111111111111111111111111111111111112"
inputAmount:
"2000000"
outputMint:
"Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk"
outputAmount:
"1550653"
}
| "pubkey": "CCifuNxNLBZV9ch94GQ4QgdrmbBdG13xDfReomzqvhMC", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 14" | ||
| }, | ||
| { | ||
| "pubkey": "So11111111111111111111111111111111111111112", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Wrapped SOL" | ||
| }, | ||
| { | ||
| "pubkey": "Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Jupiter authority" | ||
| }, | ||
| { | ||
| "pubkey": "3c5JEJ3un3HZAtWvZ77nhNGxDGqmWM7uZ1cx4bGDsKE8", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "User source token account" | ||
| }, | ||
| { | ||
| "pubkey": "4iBF54K8AY5dbwFZL8JBktqDrRvAnEkBs42aSRDYB14p", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 18" | ||
| }, | ||
| { | ||
| "pubkey": "FAXnNWMXbadmfMTfWtEu3WDymtRwsxYLGdbKoJbfLKsK", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "User destination token account" | ||
| }, | ||
| { | ||
| "pubkey": "3YYrbiosq79pthXhFV8MwXThXWgb4Wn85fMiqPoo8dq4", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 20" | ||
| }, | ||
| { | ||
| "pubkey": "FdV51SZanY1thtYtseN5enYiASp78r7gtEcTo3xxg1eS", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 21" | ||
| }, | ||
| { | ||
| "pubkey": "4ThAi4HvBnXpgjBs5BDUQHosHjqMc1G6b9L88Djq1Ue8", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 22" | ||
| }, | ||
| { | ||
| "pubkey": "EHmLbEKVdix9brJJ13ey5o3VHo2f8w8Rr5NEwhBtHrrT", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 23" | ||
| }, | ||
| { | ||
| "pubkey": "68sWwn3c2exPMnAGe2STD3LFAc97bVBvGaGCHSEctK1", | ||
| "signer": false, | ||
| "writable": false, | ||
| "description": "Account 24" | ||
| } |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The descriptions for these accounts are too generic ("Account 14", "Account 18", "Account 20", "Account 21", "Account 22", "Account 23", "Account 24"). For a test fixture, these should have meaningful descriptions that explain the role of each account in the Jupiter swap transaction. This will make the test more maintainable and help developers understand the expected transaction structure.
prasanna-anchorage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why copilot thinks this is WSOL-> USDT when the explorer shows WSOL to USELESS AFAICT
| "input_amount": "1704961004145737728", | ||
| "quoted_output_amount": "54975581388800", | ||
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | ||
| "output_token_address": "B7hSadyLX8YhNT8RDcK8RbnR3KAfX4HbWvV89XmeqitA", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't look right since this is also the address for the signer.
Output token is actually Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prasanna-anchorage Should this be the source of truth in expected fields?
"input_token_address": "So11111111111111111111111111111111111111112",
"output_token_address": "Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we might need to eventually go deeper and expose the routing but we cant really know that at this stage (I doubt simulation can either)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the parser is getting these addresses from the top two of the account list. What was the logic behind doing that? Is there a way to get the token addresses from the accounts list?
| "input_amount": "1704961004145737728", | ||
| "quoted_output_amount": "54975581388800", | ||
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | ||
| "output_token_address": "B7hSadyLX8YhNT8RDcK8RbnR3KAfX4HbWvV89XmeqitA", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk
{5 items
amm:
"whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
inputMint:
"So11111111111111111111111111111111111111112"
inputAmount:
"2000000"
outputMint:
"Dz9mQ9NzkBcCsuGPFJ3r1bS4wgqKMHBPiVuniW8Mbonk"
outputAmount:
"1550653"
}
| "program_id": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", | ||
| "input_amount": "1704961004145737728", | ||
| "quoted_output_amount": "54975581388800", | ||
| "input_token_address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks right
|
|
||
| let in_token = accounts.first().map(|addr| get_token_info(addr, in_amount)); | ||
| let out_token = accounts.get(1).map(|addr| get_token_info(addr, out_amount)); | ||
| let out_token = accounts.get(5).map(|addr| get_token_info(addr, out_amount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a comment that this is hardcoded to 5
| platform_fee_field.is_some(), | ||
| "Should have Platform Fee field when platform_fee_bps > 0" | ||
| ); | ||
| println!("✅ Platform Fee field present in expanded fields"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with these emojis in tests but we should avoid println! in non test code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an exisitng test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the println! in mod.rs are in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, great, I was just looking at the small diff
| ); | ||
| println!("✅ Platform Fee field present in expanded fields"); | ||
| } | ||
| mod fixture_test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this comment of yours in the template file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// To add these tests to the existing tests module in mod.rs, add this line at the end
// of the existing `mod tests` block (before the closing brace):
//
// mod fixture_tests;
//
// This file will then be compiled as `tests::fixture_tests`
If I remove this, the test doesn't get included in the suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, you want to put them at the top of the file or in the mod.rs
This PR adds a real Jupiter route fixture and tests our parser against the expected fields from the fixture. This establishes the testing pattern for validating instruction parsers against real on-chain transactions.
We've also currently removed input_token_address from the parser so that we don't continue showing incorrect input token address. It's being fixed in #89. The account index for output token address has also been updated to reflect the destination mint correctly