Skip to content
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

Merged
merged 4 commits into from
Nov 25, 2024
Merged

Conversation

joncinque
Copy link
Contributor

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.

cc @jnwng

#### 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`.
@joncinque joncinque marked this pull request as draft November 20, 2024 23:43
@joncinque
Copy link
Contributor Author

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

@joncinque joncinque marked this pull request as ready for review November 21, 2024 19:33
@joncinque
Copy link
Contributor Author

Ok, this should be ready for another look!

Copy link
Contributor

@samkim-crypto samkim-crypto left a 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.

@joncinque
Copy link
Contributor Author

This should be ready for another look

Copy link
Contributor

@samkim-crypto samkim-crypto left a 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!

@joncinque joncinque merged commit 4349310 into solana-labs:master Nov 25, 2024
35 checks passed
@joncinque joncinque deleted the scale branch November 25, 2024 09:27
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.

2 participants