Skip to content

The constant-product pool opens with its first deposit - #259

Merged
mikemaccana merged 1 commit into
mainfrom
claude/wonderful-hawking-5gg014-amm-seed
Oct 4, 2026
Merged

mikemaccana merged 1 commit into
mainfrom
claude/wonderful-hawking-5gg014-amm-seed

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Merge after quicknode/solana-program-examples#192, which it describes: the book never describes a defense that has not shipped.

The companion's initialize_pool() now takes the first deposit in the same instruction, so pool creation cannot be front-run. In the chapter:

  • Maria's walkthrough opens the pool with her 400 ACME and 900 USDC in one initialize_pool() step; the separate seeding call is gone. No walkthrough number changes.
  • The first-deposit arithmetic is attributed to initialize_pool(), initial_lp_amount() and integer_sqrt(), with deposit_and_mint_lp_tokens() named as the shared transfers-plus-mint.
  • The invariants gain "both effective reserves are positive from creation on".
  • The failure mode that said "the first deposit sets the price, and anyone can be first" now describes the defense and names test_pool_creation_cannot_be_front_run, with its numbers (a 400 ACME against 100 USDC deposit right after creation is clamped to 44.44 ACME, and the pool still prices at $2.25).
  • amm-first-deposit.svg becomes initialize_pool()'s figure, with the pool config, vaults and LP mint it creates badged NEW.

Every identifier grepped against the companion branch. npm run lint clean, geometry clean across 115 figures, PDF builds (312 pages).

🤖 Generated with Claude Code

https://claude.ai/code/session_01UX53A6YR1Hjr8z6WzJxf2q


Generated by Claude Code

The companion's initialize_pool() now takes the first deposit in the
same instruction, so Maria's walkthrough opens the pool with her 400
ACME and 900 USDC in one step, the first-deposit arithmetic is
attributed to initialize_pool() and initial_lp_amount(), the invariants
gain "both effective reserves are positive from creation on", and the
failure mode that said anyone can be first now describes the defense
and names test_pool_creation_cannot_be_front_run. The first-deposit
figure becomes initialize_pool()'s, with the accounts it creates badged
NEW. No walkthrough number changes.

Claude-Session: https://claude.ai/code/session_01UX53A6YR1Hjr8z6WzJxf2q
@mikemaccana
mikemaccana merged commit c8bf33e into main Oct 4, 2026
1 check passed
@mikemaccana
mikemaccana deleted the claude/wonderful-hawking-5gg014-amm-seed branch October 13, 2026 00:23
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