Skip to content

Price wrap and unwrap at the escrow / wrapped supply rate - #694

Open
staccDOTsol wants to merge 1 commit into
solana-program:mainfrom
staccDOTsol:rs-economics
Open

staccDOTsol wants to merge 1 commit into
solana-program:mainfrom
staccDOTsol:rs-economics

Conversation

@staccDOTsol

Copy link
Copy Markdown

Summary

Prices Wrap and Unwrap at the escrow / wrapped supply rate instead of a fixed 1:1.

This does not change any wrapped token whatsoever, unless wrapped tokens have been burned (or the wrapped supply has otherwise been reduced), or unwrapped tokens have been donated to the escrow. While escrow balance equals wrapped supply, which is the case for every wrapped mint that has only ever been wrapped and unwrapped, the result is exactly the existing 1:1 behavior.

Why

Today, unwrapped tokens sent directly to an escrow, and the backing of wrapped tokens that were burned directly, are stranded: nobody can ever redeem them. With this change they accrue pro rata to the remaining wrapped token holders.

What changes

  • Wrap mints amount * wrapped_supply / escrow, rounded down. An empty wrapped mint still mints 1:1.
  • Unwrap pays amount * escrow / wrapped_supply, rounded down.
  • Rounding is always in favor of remaining holders, so escrow per wrapped token never falls.
  • An amount that rounds down to zero is rejected.

What does not change

  • Instruction names, account lists and instruction data.
  • The CLI, JS client and IDL.
  • CreateMint, CloseStuckEscrow, metadata sync and the canonical pointer.

Tests

  • Existing suite passes. The wrap and unwrap fixtures previously paired a 500M wrapped supply with a 0 or 100k escrow, a state that cannot occur; they now start with matching escrow and supply.
  • Added one test each for wrap and unwrap at a non-1:1 rate, including round-down.

🤖 Generated with Claude Code

Wrap mints amount * supply / escrow and unwrap pays
amount * escrow / supply, both rounded down. While escrow equals
supply this is exactly the existing 1:1 behavior. Instructions,
accounts and instruction data are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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