Add realistic-scale fork tests for full lifecycle and sandwich/DOS cost - #100
Merged
Conversation
holyfuchs
force-pushed
the
holyfuchs/sandwich-attack
branch
from
July 31, 2026 10:39
49bd7ca to
454e97e
Compare
holyfuchs
force-pushed
the
holyfuchs/sandwich-attack
branch
from
July 31, 2026 10:44
454e97e to
20e59c2
Compare
holyfuchs
marked this pull request as ready for review
July 31, 2026 10:49
tim-barry
approved these changes
Aug 7, 2026
holyfuchs
force-pushed
the
holyfuchs/sandwich-attack
branch
from
August 16, 2026 01:29
3ebeed1 to
3b50c34
Compare
holyfuchs
force-pushed
the
holyfuchs/sandwich-attack
branch
from
August 16, 2026 01:44
3b50c34 to
e88cb18
Compare
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.
Added IntegrationFork.t.sol and SandwichFork.t.sol: fork tests against real Morpho, real FlowSwap V3 pools, and real tokens on Flow mainnet (only the market oracle is mocked), at a realistic ~$1M TVL vs. the real ~$20k-liquidity yield/debt pool.
IntegrationFork.t.sol builds the vault from 100 individual $10k deposits (arbed back to clean spot after each), pushes the collateral price +10% and rebalances until back in band, then -10% and rebalances again, then has all 100 users redeem one at a time. Users recover ~99.92% of principal, and each shock re-levers/delevers in a single rebalance() call — the amount needing correction is only ~2.3% of current debt, not a fraction of TVL, because the band's re-entry targets sit close to its bounds.
SandwichFork.t.sol runs the existing 3 attack tests (single-sweep, soft DOS, hard DOS) against the same $1M setup. A single sandwiched rebalance caps attacker profit at ~$38 and vault overpayment at ~1%, independent of TVL. Pushing the pool ≥45bps blocks reconvergence within 100 rebalance calls but costs the attacker ~$820-913. Holding the pool 1% off-spot for 100 rounds fully blocks lever rebalancing for ~$9.21/round — the cheapest sustained DOS found. Documented that the cliff around 40-50bps is the real pool's lumpy, stable-pair-style liquidity distribution, not a maxSlippageBps bug.