feat(contract): flash-loan prevention via sequence ID and price snapshot checks#294
Merged
Solomonsolomonsolomon merged 2 commits intogear5labs:masterfrom Mar 30, 2026
Conversation
|
@success-OG Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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 #267
[Contract] Flash-Loan Prevention via Sequence ID Checks
Summary
Implements an on-chain price snapshot guard that detects and blocks flash-loan-driven
price manipulation within the same ledger close, protecting the Chen Pilot vault.
What's included
flash_loan_guardcontract added to the workspaceinitialize/update_config— configures oracle, guarded asset, deviationthreshold (bps), and minimum ledger gap between snapshots
record_snapshot— pulls the current oracle price and stores it with the currentledger sequence number. Enforces
min_ledger_gapso an attacker cannot reset thebaseline and exploit in the same ledger.
assert_price_safe— the guard gate called before any price-sensitive vault op:(same-block manipulation detection — the core flash-loan defense)
deviation_bps > max_intra_ledger_deviation_bpsFlashBlkevent on block,PriceSafeevent on passget_snapshot/get_config— read-only viewsprice spike blocked, small move allowed, min ledger gap enforced, snapshot update
after gap, price drop blocked, double-init blocked