Skip to content

fix(sbtc-pool-v3): rescale get-share-price so it resolves fee accrual (ajv.3.4, F-11) - #138

Open
unixwhisperer wants to merge 1 commit into
mattglory:mainfrom
unixwhisperer:security-lead/ajv-3-4-sbtc-pool-v3-share-price
Open

unixwhisperer wants to merge 1 commit into
mattglory:mainfrom
unixwhisperer:security-lead/ajv-3-4-sbtc-pool-v3-share-price

Conversation

@unixwhisperer

@unixwhisperer unixwhisperer commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

flashstack-sbtc-pool-v3 (undeployed) had the F-11 resolution gap that #123 pinned on the live sbtc-pool-v2. Deposit mints 1e8 shares per sat, but get-share-price and get-collateral-snapshot.share-price were scaled by only 1e8. So they read 1 at launch, not the documented 1e8, ignored any gain short of +100%, and read 0 below launch value. Matt OK'd the rescale on 2026-10-19, ahead of the §6e testnet run.

Change

  • Adds PRICE-PRECISION = 1e16 (SHARE-PRECISION * 1e8) and uses it in both price expressions, in the canonical file and the drift-checked contracts/test/ copy.
  • Launch now reads 1e8, and a 1-sat fee on a 44,990-sat pool moves the price.
  • Read-only output only. Share mint/burn, VIRTUAL-SHARES/VIRTUAL-ASSETS, deposit, withdraw and flash-loan are untouched.
  • Overflow bound: all sBTC that can ever exist (2.1e15 sats) × 1e16 = 2.1e31, far below the u128 limit.
  • flashstack-stx-pool-v3 has no share-price function, so it's unaffected.

Tests

  • New tests/sbtc-pool-v3-share-price-resolution.test.ts: launch reads 1e8 on both functions; the price moves on a 1-sat gain; deposit and withdraw amounts are identical to v2's (44,990 sats → 4,499,000,000,000 shares → 44,990 sats back).
  • Mutation-checked: putting SHARE-PRECISION back into either expression turns it red.
  • Full suite: 360 passed, 3 skipped (41 files). The drift and registry guards are green.

Docs

FINDINGS_REGISTER F-11 now marks sbtc-pool-v3 as fixed. THREAT_MODEL row 12, CLARITY_AUDIT_V2_POOLS and the TESTNET_STAGING pre-mainnet bullet are updated, so the §6e plan runs against the rescaled source.

Note for #133: this adds 3 tests and 1 file (357 → 360, 40 → 41) and 8 lines to sbtc-pool-v3 (368 → 376, Tier 2 1,159 → 1,167). Whichever of the two merges second needs those figures refreshed.

Closes Flashstack-ajv.3.4.

🤖 Generated with Claude Code

… accrual (ajv.3.4)

sbtc-pool-v3 mints 1e8 shares per sat but scaled its built-in price by
only 1e8, so get-share-price and get-collateral-snapshot.share-price read
1 at launch and ignored any gain short of +100% (F-11 shape, same as the
live sbtc-pool-v2). Both now scale by PRICE-PRECISION (1e16): launch
reads 1e8, as the header always documented, and a 1-sat fee on a
44,990-sat pool moves it. Share mint/burn math is untouched.

stx-pool-v3 has no share-price read-only, so it is unaffected.
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@unixwhisperer is attempting to deploy a commit to the matt glory's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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