Skip to content

Perps: the funding rate is fixed at creation, and Maria signs only collect_fees - #192

Merged
mikemaccana merged 2 commits into
mainfrom
claude/perps-fixed-funding-rate
Sep 30, 2026
Merged

mikemaccana merged 2 commits into
mainfrom
claude/perps-fixed-funding-rate

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Follows quicknode/solana-program-examples#172, which removed set_funding_rate(). Before that change, Maria could open a small position on the side that receives funding, raise the rate, and close the position to take the liquidity providers' deposits. initialize_pool() now refuses a rate above MAX_FUNDING_RATE_PER_SECOND (277, just under 0.1% of a position's size per hour), and nothing can change the rate afterwards.

This PR was stacked on #190. It now targets main, and main has been merged in.

Changes to the Perpetual Futures chapter

  • Creating the market: the funding rate is set in initialize_pool(), and no handler can change it once the pool exists.
  • Funding section:
    • The set_funding_rate() sentence is replaced by the fixed, capped rate.
    • It says what Maria could have done if she could change the rate.
    • It names test_operator_on_the_lighter_side_earns_only_the_fixed_rate.
  • Funding example: it now uses the maximum rate, so it reads 2.77 USDC over 2,000 seconds instead of 50 USDC at a rate of 5,000. The funding-index figure changes to match.
  • "The payment goes to the pool" said the lighter side isn't paid. In fact the pool pays the lighter side at the same rate, out of liquidity, and the bullet now says so.
  • Maria's summary: collect_fees() is again her only signed handler once the pool exists.
  • Share-inflation paragraph: it uses the test's new figures. The attacker holds a long for ten simulated years at the maximum rate and pumps AUM to about 88,000 minor units. They get back 88 of about 87,000 paid.

npm run lint, node scripts/check-figure-geometry.mjs and npm run build-pdf all pass. Every identifier named exists on the companion repo's main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JGEoAUjMm7Evv69k46eNcn

…llect_fees

quicknode/solana-program-examples#172 removed set_funding_rate(), and
initialize_pool() now refuses a rate above MAX_FUNDING_RATE_PER_SECOND (277).
The chapter follows:

- The funding section says the rate is fixed at creation and capped. It says
  what Maria could have done if she could change it, and names
  test_operator_on_the_lighter_side_earns_only_the_fixed_rate.
- The funding example uses the maximum rate (2.77 USDC over 2,000 seconds),
  in the text and in the funding-index figure.
- The "payment goes to the pool" bullet said the lighter side is not paid. The
  pool pays the lighter side at the same rate, out of liquidity.
- collect_fees() is again Maria's only signed handler once the pool exists.
- The share-inflation paragraph uses the test's new figures: ten simulated
  years at the maximum rate.

Claude-Session: https://claude.ai/code/session_01JGEoAUjMm7Evv69k46eNcn
@mikemaccana
mikemaccana changed the base branch from claude/plain-wording-sweep to main September 30, 2026 23:16
@mikemaccana
mikemaccana merged commit ebc9db4 into main Sep 30, 2026
1 check passed
@mikemaccana
mikemaccana deleted the claude/perps-fixed-funding-rate 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