-
-
Notifications
You must be signed in to change notification settings - Fork 246
fix: correct Jupiter quote-swap estimateAmountIn for BUY orders #477
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
Merged
Conversation
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
… an example address
Previously, estimateAmountIn was incorrectly returning the base token amount for BUY orders instead of the quote token amount needed. This fix ensures: - BUY orders: estimateAmountIn = quote token amount needed - SELL orders: estimateAmountIn = base token amount to sell - Balance changes correctly reflect token movements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…nParticle-feat/startup_noise
Wuon particle feat/startup noise
2 tasks
nikspz
approved these changes
Jul 2, 2025
Contributor
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.
- Test performed:
- GET /chains/solana/status: ok
- GET /chains/solana/tokens: ok
- wallet/add: ok
- POST /chains/solana/balances: ok
- GET /connectors/jupiter/quote-swap
- Reviewed for BUY 0.1 SOL:
- "estimatedAmountIn": 14.873755, "estimatedAmountOut": 0.1,
- SELL 0.1 SOL:
- "estimatedAmountIn": 0.1, "estimatedAmountOut": 14.869012,
- Reviewed for BUY 0.1 SOL:
- POST /connectors/jupiter/execute-swap: ok
- BUY JUP
- "totalInputSwapped": 4.365742, "totalOutputSwapped": 10,
- SELL JUP
- "totalInputSwapped": 10, "totalOutputSwapped": 4.3660000000000005,
- BUY JUP
- GET /connectors/meteora/clmm/quote-swap: ok
- BUY SOL 0.01
- "estimatedAmountIn": 1.491476, "estimatedAmountOut": 0.01,
- SELL SOL 0.01
- "poolAddress": "5rCf1DM8LjKTw4YqhnoLcngyZYeNnQqztScTogYHAS6",
- "estimatedAmountIn": 0.01, "estimatedAmountOut": 1.492549,
- BUY SOL 0.01
- POST /connectors/meteora/clmm/execute-swap: ok
- BUY 0.01 SOL
- "totalInputSwapped": 0.00992, "totalOutputSwapped": 1.492528,
- SELL 0.01 SOL
- "totalInputSwapped": 0.01008, "totalOutputSwapped": 1.490278,
- BUY 0.01 SOL
- connected raydium/amm, raydium/clmm, meteora/clmm, uniswap/amm, uniswap/clmm successfully
- GET /connectors/raydium/amm/quote-swap
- pool address not found 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2 (Going to create separate issue for it)
- changed pool address to another - not go
- GET /connectors/raydium/clmm/quote-swap Internal Server Error (Going to create separate issue for it)
- 500 Undocumented Error: Internal Server Error
- 2025-07-02 03:00:57 | error | Unhandled error: { "error": "Converting circular structure to JSON\n --> starting at object with constructor 'TLSSocket'\n | property '_httpMessage' -> object with constructor 'ClientRequest'\n --- property 'socket' closes the circle", "url": "/connectors/raydium/clmm/quote-swap?network=mainnet-beta&baseToken=SOL"eToken=USDC&amount=0.01&side=BUY&slippagePct=1", "params": {} } 1751454069757 Raydium_Api sdk logger error GET https://api-v3.raydium.io/pools/info/ids?ids=58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
- Error: Internal Server Error
- 2025-07-02 03:01:09 | error | Unhandled error: { "error": "Converting circular structure to JSON\n --> starting at object with constructor 'TLSSocket'\n | property '_httpMessage' -> object with constructor 'ClientRequest'\n --- property 'socket' closes the circle", "url": "/connectors/raydium/clmm/quote-swap?network=mainnet-beta&baseToken=SOL"eToken=USDC&amount=0.01&side=SELL&slippagePct=1&poolAddress=58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2", "params": {} }
- 500 Undocumented Error: Internal Server Error
- GET /connectors/raydium/clmm/pool-info: ok
Note: Going to create separate issue for raydium
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.
Summary
estimateAmountInreturning incorrect values for BUY orders in Jupiter quote-swap endpointDetails
The Jupiter quote-swap endpoint was incorrectly mapping response values for BUY orders:
estimateAmountInreturned 0.01 SOL (the amount to buy) instead of the USDC neededestimateAmountIncorrectly returns ~1.47 USDC (the input token amount)This ensures consistency where:
estimatedAmountIn= input token amount (quote for BUY, base for SELL)estimatedAmountOut= output token amount (base for BUY, quote for SELL)Additional Changes (from @WuonParticle)
Test plan
SOL/USDC amount=0.01 side=BUY- correctly returns USDC neededSOL/USDC amount=0.01 side=SELL- still works correctly🤖 Generated with Claude Code