fix: abort v17 pre-submit recheck on RPC error instead of proceeding with stale data - #353
Open
Ayomisco wants to merge 1 commit into
Open
fix: abort v17 pre-submit recheck on RPC error instead of proceeding with stale data#353Ayomisco wants to merge 1 commit into
Ayomisco wants to merge 1 commit into
Conversation
…with stale data The catch block at liquidation.ts:1244 was bare — any RPC failure during the pre-submit portfolio recheck (getAccountInfo, fetchSlabWithRetry, getSlot) would silently swallow the error and fall through to submitting the liquidation with scan-time data. The oracle drift guard (checking freshPrice vs scanPriceE6) lives inside this try block, so it was also bypassed on failure, allowing a stale-price liquidation when the oracle had moved more than MAX_LIQUIDATION_DRIFT_BPS between scan and submit. Fail closed: log a warn and return null so the position is re-scanned next cycle. The on-chain program check that was cited as the safety net does not apply here because the drift guard must run before the send, not after.
📝 WalkthroughWalkthrough
Changesv17 liquidation recheck failure handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #352
What
Replace the bare
catch {}atliquidation.ts:1244with a named catch that logs a warning and returnsnull.Why
The bare catch silently swallows RPC errors thrown during the pre-submit portfolio recheck. The oracle drift guard (lines 1171-1187) lives inside that try block. When the catch fires and execution falls through, the drift guard is bypassed and the keeper submits the liquidation using scan-time
closeQandscanPriceE6, regardless of how much the oracle has moved since scan.The on-chain program may still reject if the position is already closed, but it cannot enforce the keeper-side drift budget. Returning
nullputs the position back in the scan queue for the next cycle so the drift guard runs on fresh data.Change