Repository navigation
fix: slippage units, unbounded position enumeration, and two misleading guards #699
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
94911bc
fix(meteora): open a position with the slippage that was asked for
fengtality 092a14f
fix(raydium): list positions without pulling the wallet's whole token…
fengtality c6e9bd9
docs(clmm): say what the tick bitmap actually saves
fengtality fb5a626
fix(meteora): stop serving pool state frozen at the moment Gateway fi…
fengtality 9724900
fix(clmm): report a concurrent position change instead of guessing at it
fengtality File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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 TTL refresh mutates the shared cached DLMM instance after earlier callers may already have received it. A long-running quote or position request can read the active bin, await other RPC work, and then have another request refresh
lbPairbefore the builder runs. The first request can therefore select swap arrays or calculate a position range from one pool snapshot, but build against another. Pool state needs to remain consistent for the full read-and-build operation.Knowledge Base Used:
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.
Correct that the shared instance is mutated under in-flight readers, but this is pre-existing rather than introduced here — and the SDK is the one doing it on the hottest route.
getBinArrayForSwapopens withawait this.refetchStates()(@meteora-ag/dlmm/dist/index.js:15358), so everyclmm/quote-swaphas always refreshed the sharedlbPairmid-request, on every call, long before this change. Bounding staleness makes it reachable on more routes; it is not a new class of hazard.Severity is also lower than the comment implies, and inverted on one of the two builders:
active_idbaked into the instruction fresher, so it is closer to the value the program validates against withinmax_active_bin_slippage. That direction helps rather than hurts.getBinArrayForSwap's own RPC, leaving arrays selected for one active bin andswapQuoteiterating from another. A bin array spans 70 bins, so the move has to be large to escape the fetched window.Chasing this down did catch a real error in the description, now fixed: it listed
swapQuoteamong the readers left stale by the cache. It never was, because of that samerefetchStates(). The three genuinely affected readers aregetBinsAroundActiveBinand the two position builders.Keeping it as a documented residual. Closing it properly means per-request instances or copy-on-read — the shared mutable SDK object is the root cause, and a better refresh policy cannot fix it.
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.
That’s a fair correction. The shared mutable-instance race is pre-existing, and
getBinArrayForSwap()already refreshes the SDK state on the quote path, so this change does not introduce a new class of inconsistency there. The position-builder case is also not uniformly harmful: a refresh makes the bakedactive_idfresher, while the remaining quote risk requires the active bin to move enough duringgetBinArrayForSwap()to invalidate the fetched array window. I agree this should remain a documented residual rather than a blocking finding.