-
Notifications
You must be signed in to change notification settings - Fork 344
Scaled UI Jettons #526
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
Open
krigga
wants to merge
10
commits into
ton-blockchain:master
Choose a base branch
from
the-ton-tech:scaled-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Scaled UI Jettons #526
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
27926ec
Scaled UI Jettons
krigga 23148b8
chore: describe edge cases
krigga 7433a40
Remove the calculation get methods, describe the calculation in the s…
krigga dff99b6
Add a clarification about decimals.
krigga b9beca3
Add `comment` to external-out message
krigga ca172ea
feat: make the multiplier an abstract number, instead of a total disp…
krigga 8ebee92
chore: clarifty get method return values
krigga 1813a72
chore: add reference implementation link
krigga 75e618a
chore: add init event requirement
krigga a3e7e1d
chore: remove section for already existing contracts
krigga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| - **TEP**: [0](https://github.com/ton-blockchain/TEPs/pull/0) | ||
| - **title**: Scaled UI Jettons | ||
| - **status**: Draft | ||
| - **type**: Contract Interface | ||
| - **authors**: [Maxim Gromov](https://github.com/krigga) | ||
| - **created**: 19.09.2025 | ||
| - **replaces**: - | ||
| - **replaced by**: - | ||
|
|
||
| # Summary | ||
|
|
||
| A standard interface for Jettons ([TEP-74](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md)) that allows for arbitrary scaling of the displayed balances. | ||
|
|
||
| # Motivation | ||
|
|
||
| Currently, it is not viable to implement jetton rebasing in any way, since updating the balances of all jetton wallets is not feasible due to TON's architecture. The alternative is scaled UI amounts, which this TEP proposes. | ||
|
|
||
| # Guide | ||
|
|
||
| ## Useful links | ||
|
|
||
| 1. [Reference implementation](https://github.com/the-ton-tech/scaled-ui-jetton) | ||
|
|
||
| # Specification | ||
|
|
||
| > The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. | ||
|
|
||
| ## Jetton Master contract extension | ||
|
|
||
| The jetton master contracts following this TEP are extended versions of [TEP-74](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md) jetton masters. | ||
|
|
||
| They MUST additionally (w.r.t. TEP-74) support the following get method: | ||
| 1. `get_display_multiplier()` returns `(int numerator, int denominator)` | ||
|
|
||
| `numerator` - (integer) - the numerator to be used when calculating displayed amounts from onchain amounts. MUST NOT be `0`. | ||
|
|
||
| `denominator` - (integer) - the denominator to be used when calculating displayed amounts from onchain amounts. MUST NOT be `0`. | ||
|
|
||
| The displayed (that is, the value presented to users in UIs supporting this TEP) balance of a jetton wallet MUST be calculated as `muldiv(onchain_balance, numerator, denominator)`, where `onchain_balance` is the balance of the jetton wallet as reported by `get_wallet_data()`, and `numerator` and `denominator` are the values returned by `get_display_multiplier()`. The displayed balance calculated in such a way and presented to the user MUST still respect the `decimals` reported by jetton's metadata. Similarly, the total displayed supply MUST be calculated as `muldiv(total_onchain_supply, numerator, denominator)`. | ||
|
|
||
| Values inputted by users in UIs supporting this TEP have to be converted to onchain balance (the value used for sending jettons) as follows: `muldiv(displayed_or_inputted_balance, denominator, numerator)`, where `displayed_or_inputted_balance` is the value inputted by the user, and `numerator` and `denominator` are the values returned by `get_display_multiplier()`. | ||
|
|
||
| Jetton master contracts supporting this TEP MUST send the following external-out message (TL-B structure) whenever the values returned by `get_display_multiplier()`: | ||
| ``` | ||
| display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) comment:(Maybe SnakeString) = ExternalOutMsgBody; | ||
| ``` | ||
|
|
||
| `numerator` and `denominator` in the external-out message MUST be the same values as returned by `get_display_multiplier()` after the transaction that sent the message. | ||
|
|
||
| `numerator` and `denominator` reported by `get_display_multiplier()` MUST NOT be changed between transactions that send the `display_multiplier_changed` message. | ||
|
|
||
| `comment` is an optional field that may be used to describe the reason for the change of `numerator` and `denominator`. `SnakeString` is described as `SnakeData` in [TEP-64](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md#data-serialization). | ||
|
|
||
| Jetton master contracts supporting this TEP MUST emit the `display_multiplier_changed` external-out message upon initialization. | ||
|
|
||
| # Drawbacks | ||
|
|
||
| 1. It is not possible to make a mechanism for calculating the displayed balance in a way that is different from the `muldiv` calculation using this TEP. | ||
|
|
||
| # Rationale and alternatives | ||
|
|
||
| ## Why restrict the calculation to `muldiv` and why send the external-out message? | ||
|
|
||
| Both of these points significantly simplify the indexing of jettons that support this TEP by allowing indexers to: | ||
|
|
||
| 1. Only store the multiplier reported by the jetton master contract and use it for displayed balance calculation for both present and historical data, on any reasonable number of jetton wallets. | ||
| 2. Not have to call `get_display_multiplier()` after each transaction in order to obtain the new multiplier and instead rely on the external-out message. | ||
|
|
||
| # Prior art | ||
|
|
||
| [Scaled UI Amount](https://solana.com/docs/tokens/extensions/scaled-ui-amount) | ||
|
|
||
| # Unresolved questions | ||
|
|
||
| \- | ||
|
|
||
| # Future possibilities | ||
|
|
||
| \- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
text/0000-scaled-ui-jettons.md
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.
23148b8