-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token-2022: Add scaled amount extension #7511
Conversation
#### Problem The interest-bearing extension is useful for tokens that accrue in value constantly, but many "rebasing" tokens on other blockchains employ a different method of updating the number of tokens in accounts. Rather than setting a rate and allowing the number to change automatically over time, they set a scaling factor for the tokens by hand. #### Summary of changes Add a new `ScaledUiAmount` extension to token-2022 for doing just that. This is essentially a simplified version of the interest-bearing extension, where someone just sets a scaling value into the mint directly. The scale has no impact on the operation of the token, just on the output of `amount_to_ui_amount` and `ui_amount_to_amount`.
I got feedback that issuers want to be able to set the multiplier in the future, so I'll implement that and then re-open this PR |
Ok, this should be ready for another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good to me! Just minor questions and comments regarding the docs and tests.
token/program-2022/src/extension/scaled_ui_amount/instruction.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: samkim-crypto <[email protected]>
This should be ready for another look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Everything looks find to me!
Problem
The interest-bearing extension is useful for tokens that accrue in value constantly, but many "rebasing" tokens on other blockchains employ a different method of updating the number of tokens in accounts.
Rather than setting a rate and allowing the number to change automatically over time, they set a scaling factor for the tokens by hand.
Summary of changes
Add a new
ScaledUiAmount
extension to token-2022 for doing just that. This is essentially a simplified version of the interest-bearing extension, where someone just sets a scaling value into the mint directly. The scale has no impact on the operation of the token, just on the output ofamount_to_ui_amount
andui_amount_to_amount
.cc @jnwng