Skip to content

Fundraiser and Perpetual Futures: address Noah Prince's review - #200

Merged
mikemaccana merged 8 commits into
mainfrom
claude/jolly-sagan-u8rgr1
Oct 2, 2026
Merged

mikemaccana merged 8 commits into
mainfrom
claude/jolly-sagan-u8rgr1

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Answers each point in Noah Prince's review, and follows the perpetual futures program to the Percolator haircut model. Merge after the companion pull requests the chapters describe, in this order:

  1. Fundraiser: stop receipts carrying into the next raise; drop the per-backer cap solana-program-examples#175: fundraiser fix
  2. Perpetual futures: initial margin, and a pool-maintained price average with a trading band solana-program-examples#176: perps initial margin and price band
  3. Perpetual futures: Percolator haircut risk model and an insurance fund solana-program-examples#179: perps haircut risk model and insurance fund (replaces the closed Rewrite "How This Book Was Produced" as a provenance story #83)

Fundraiser

  • Charts wrong / goal not shown / 100 USDC beside a 900 receipt / "9,000 each" reading: one set of numbers everywhere: Alice 1,000, Bob 800, Carol 500 + 500, eleven receipts reaching 9,000; 3,600 on the failed path. All figures redrawn; two new ones for closing the receipts and the fundraiser.
  • Per-contributor cap is contrived: removed from the program and the chapter. The chapter now says what the program guarantees (Maria is paid only when the full 9,000 is in the counter) and that a per-wallet limit could not stop one person funding a raise.
  • Re-creating the fundraiser with old receipts: a real bug, fixed in the program. The fundraiser stays open until every receipt is closed; new section "The Fundraiser Outlives Every Receipt", with the test that runs the attack.
  • Claude-speak: both passages Noah quoted are gone; the counter-versus-balance section now gives its actual reason (the claim and refunds must read the same number).

Perpetual Futures

  • "Her income is ... every funding payment": rewritten. LPs hold the opposite of the traders' net position and earn only the net funding.
  • Program-maintained TWAP band: new section on the pool's own average price, the 20% band, why liquidations are exempt, and update_price_average().
  • Initial margin: initial_margin_bps (10%) beside the 5% maintenance margin, with the 1:1 link to maximum leverage (10% initial margin = 10x).
  • "Survives into every real implementation": rewritten plainly.
  • Haircut risk model (follows Add --final flag to omit prerelease markings from PDF #179): the reservation and profit cap are gone. New section "Profit Is Paid Only as Far as the Pool Can Pay It" (haircut, never refusing a winner, profit warm-up); the loss waterfall is insurance fund, then LPs, then haircut; a bankrupt position's liquidation fee is forgiven as in Percolator, replacing the paragraph that described that gap. Figures show insurance_fund and the fee split.

Glossary: new initial margin, haircut and profit warm-up; insurance fund, auto-deleveraging, leverage, maintenance margin and TWAP updated; reservation removed.

npm run lint, node scripts/check-figure-geometry.mjs and npm run build-pdf all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu

Mike MacCana added 8 commits October 1, 2026 19:35
Fundraiser: remove the per-backer cap section, give the counter-versus-
balance section its real reason (the claim and refund must read the same
number), and explain why the fundraiser outlives its receipts.

Perps: LPs hold the opposite of the traders' net position and earn only
net funding; rewrite the production-funding sentence plainly. Glossary:
add initial margin.

Figures and the margin and price-band sections follow.

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
Every fundraiser box gains claimed and open_contributor_accounts. One set
of numbers throughout: Alice 1,000, Bob 800, Carol 500 + 500, eleven
receipts to reach 9,000; 3,600 on the failed path. The claim figure no
longer closes the fundraiser or vault. Two new figures: the receipts
closing after the claim, then close_fundraiser().

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
The pool's opening threshold is initial_margin_bps (10%), above the 5%
maintenance margin; maximum leverage is one over the initial margin.

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
…erage

New section on average_price, last_oracle_price and the 20% band:
which handlers check it, why liquidations do not, how
update_price_average() lets the average catch up, and the tests that
run a manipulated read after an idle spell. Failure modes, testing and
What You Learnt follow.

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
…fore the LPs

Follows the haircut risk model (Percolator) in the companion repository:
nothing is reserved at open and profit has no cap; each winner is paid
profit x h, never more than liquidity + insurance_fund, and never refused;
a profit warm-up; half of each fee to an insurance fund that pays a
bankrupt position's deficit before the LPs; an uncollectible liquidation
fee is forgiven. Glossary: haircut, profit warm-up; reservation removed.

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
main's review of the Fundraiser chapter kept the per-backer cap and added
a Sybil boxout. This branch removes the cap, as the companion program
does (quicknode/solana-program-examples#175), so the cap paragraphs and
invariant are dropped and the boxout is rewritten for a program with no
cap: a count of wallets says nothing about how many people backed a raise.
The glossary's Sybil attack entry no longer cites the Fundraiser's cap.

Claude-Session: https://claude.ai/code/session_019G9tytYrS3Qp42fZ1hBnDu
@mikemaccana
mikemaccana merged commit 341eb81 into main Oct 2, 2026
1 check passed
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