Enforce per-side MINIMUM_LIQUIDITY floor on first deposit (F-9) - #151
Merged
Conversation
calc_liquidity_for_deposit floored only the geometric mean (sqrt(amount0*amount1)) on the first deposit into an empty pool, so a highly asymmetric seed such as (20, 500_000_000) passed (sqrt = 100_000 >> MINIMUM_LIQUIDITY) yet left reserve0 at 20 — below the floor the swap path and maybe_auto_pause_on_low_liquidity both assume every live pool upholds, leaving the pool swap-broken on one side. The stateful fuzz harness surfaced this as minimum_liquidity_breached; it predated the F-1/F-2 fixes. The genuinely-empty first deposit now requires both credited amounts >= MINIMUM_LIQUIDITY. Adds a deterministic regression test (first_deposit_rejects_subfloor_reserve_side); the fuzz harness that found it is now green and a 3,000-case stateful run is clean. Updates SECURITY_AUDIT.md to mark F-9 fixed.
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.
calc_liquidity_for_deposit floored only the geometric mean (sqrt(amount0*amount1)) on the first deposit into an empty pool, so a highly asymmetric seed such as (20, 500_000_000) passed (sqrt = 100_000 >> MINIMUM_LIQUIDITY) yet left reserve0 at 20 — below the floor the swap path and maybe_auto_pause_on_low_liquidity both assume every live pool upholds, leaving the pool swap-broken on one side. The stateful fuzz harness surfaced this as minimum_liquidity_breached; it predated the F-1/F-2 fixes.
The genuinely-empty first deposit now requires both credited amounts