fix / use on-chain data for real-time Orca pool price#603
Merged
fengtality merged 6 commits intodevelopmentfrom Feb 20, 2026
Merged
fix / use on-chain data for real-time Orca pool price#603fengtality merged 6 commits intodevelopmentfrom
fengtality merged 6 commits intodevelopmentfrom
Conversation
The Orca API can return stale price data. This change fetches the whirlpool data directly from the blockchain and calculates the price from sqrtPrice for accurate real-time pricing. - Fetch on-chain whirlpool data using getWhirlpool() - Calculate price from sqrtPrice using PriceMath.sqrtPriceX64ToPrice() - Fetch vault balances for accurate token amounts - Keep API data for analytics fields (tvlUsdc, yieldOverTvl) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
@mlguys I added this PR since I found that the Orca API pool prices may not reflect actual on-chain prices, resulting in incorrect positions placed. Also, I think we should standardize the API pool data returned by this route. I saw that you added |
Update tests to mock new dependencies: - Mock Solana.getInstance for connection access - Mock getMint from @solana/spl-token for decimal info - Mock PriceMath.sqrtPriceX64ToPrice for price calculation - Mock getWhirlpool for on-chain pool data - Use valid Solana base58 addresses for vault mocks - Add proper beforeEach reset for mock isolation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add _fetchTransactionWithRetry method with configurable retries - Use retry logic in WebSocket and polling confirmation flows - Use configurable timeout for WebSocket monitoring - Apply retry to extractBalanceChangesAndFee for reliability Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Commit 3d5510b
Steps to reproduce:
|
Replace getMint from @solana/spl-token with fetchAllMint from @solana-program/token-2022 to support both standard SPL Token and Token2022 (Token Extensions) programs. This fixes TokenInvalidAccountOwnerError when querying pools with Token2022 tokens like PYUSD. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Commit a406998
|
rapcmia
approved these changes
Feb 20, 2026
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.
Summary
getWhirlpool()for real-time pricesqrtPriceusingPriceMath.sqrtPriceX64ToPrice()instead of relying on potentially stale API datatvlUsdc,yieldOverTvl)Problem
The Orca API (
api.orca.so/v2/solana/pools/search) can return stale price data, causing LP positions to be created with incorrect price bounds.Solution
Fetch the whirlpool data directly from the blockchain and calculate the price from
sqrtPricefor accurate real-time pricing.Test plan
🤖 Generated with Claude Code