Skip to content

fix(contracts): gate deposit on pause in the v3 STX and sBTC pools (F-8) - #68

Open
mattglory wants to merge 1 commit into
mainfrom
fix-f8-v3-pools-pause-gate
Open

mattglory wants to merge 1 commit into
mainfrom
fix-f8-v3-pools-pause-gate

Conversation

@mattglory

Copy link
Copy Markdown
Owner

Summary

Closes F-8 for the two undeployed v3 pools. flashstack-stx-pool-v3 and flashstack-sbtc-pool-v3 are the v2 pool sources plus the two-step admin change, and v2's deposit checks only amount > 0: a paused pool still accepts deposits while flash-loan correctly refuses loans. That's pv3-F3's shape, which was fixed in flashstack-pool-v3 only.

I verified this against the deployed mainnet source of both live v2 pools (same gap). Those are immutable and this PR does not change them; only the undeployed v3 pools can still be fixed. F-8 itself is filed in #65.

The change

One functional line per pool, in deposit, before the zero-amount check (same ordering as pool-v3):

(asserts! (not (var-get paused)) ERR-PAUSED)
  • withdraw stays ungated on purpose, so LPs can always exit.
  • Both pools already defined ERR-PAUSED (u405 / u705) and the paused flag.
  • The contracts/test/ copies get the identical change, so canonical-copy-drift holds.
  • Behaviour change to note: these pools now differ from v2 by the admin change and this gate.

Tests: tests/v3-pools-pause-gate.test.ts (8, four per pool)

Pinned in the directions the failure modes point:

test why
deposit works when not paused the guard must not over-block
deposit refused while paused, ERR-PAUSED, mints nothing the fix
withdraw is not blocked by pause over-gating would strand LP funds
unpausing restores deposit the gate isn't sticky

Mutation-checked. With the gate stripped from the compiled copies, exactly the two fix-dependent tests fail per pool (4 of 8); the two over-blocking guards stay green, as they should.

Verification

  • clarinet check: 211 contracts, 0 errors
  • Full suite 229/229 across 21 files (221 + 8)
  • canonical-copy-drift, mainnet-fidelity, bc1-two-step-fix green

Not in this PR

🤖 Generated with Claude Code

flashstack-stx-pool-v3 and flashstack-sbtc-pool-v3 are the v2 pool sources
plus the two-step admin change. v2's deposit checked only amount > 0, so a
paused pool still accepted deposits while flash-loan correctly refused
loans -- pv3-F3's shape, fixed in flashstack-pool-v3 only. Verified against
the deployed mainnet source of both live v2 pools: same gap there (immutable;
unchanged by this commit).

One functional line per pool: (asserts! (not (var-get paused)) ERR-PAUSED)
in deposit, before the zero-amount check, matching pool-v3's ordering.
withdraw stays ungated on purpose so LPs can always exit. Both pools already
defined ERR-PAUSED (u405 / u705) and the paused flag. The contracts/test/
copies get the identical change, so the canonical-copy drift guard holds.

tests/v3-pools-pause-gate.test.ts pins four behaviours per pool, in the
directions the failure modes point: deposit works when unpaused (must not
over-block), is refused while paused with ERR-PAUSED and mints nothing (the
fix), withdraw is NOT blocked by pause (over-gating would strand funds), and
unpausing restores deposit. Mutation-checked: with the gate stripped from
the compiled copies, exactly the two fix-dependent tests fail per pool (4 of
8), the two over-blocking guards stay green.

Verified: clarinet check 211 contracts / 0 errors; suite 229/229 across 21
files (221 + 8); drift guard, mainnet-fidelity and BC1 suites green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
web Ready Ready Preview Sep 21, 2026 12:06pm UTC

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant