Scaled UI Amount Integration Guide

Supporting Scaled UI Amount Extension on Solana

Background

The Scaled UI Amount extension allows token issuers to specify a multiplier to be used when calculating the UI amount of a user’s token balance. This enables issuers to create rebasing tokens and to enable things like stock splits. This extension, like the interest bearing token extension, provides a purely cosmetic UI amount which means teams need to do some additional work to provide a good experience. Underlying calculations and transfers all occur using the raw amounts in the program.

Resources:

TL;DR

  • End users should interact with the UIAmount (raw amount * multiplier) for the token price, token balance, and token amounts whenever possible
  • dApps and service providers should use the raw amount and non-scaled prices for all calculations and convert for users at the edge
  • Historical price feeds need to be provided for both scaled and non-scaled amounts for easier integration
  • Historical multiplier values need to be accessible for accurate historical data

Terms Definitions

  • Multiplier: static updatable multiplier that’s used for UI Amount calculations
  • UIAmount: multiplier * raw amount (AKA: scaled amount)
  • Raw Amount: amount (AKA: non-scaled amount)

Current Balance

Current Amount for Display

  • Anytime you display amounts for tokens that use the scaled UI amount extension to end users you should use either:
    • UIAmount/UIAmountString (preferred)
    • A manual calculation of raw amount * multiplier
    • We recommend truncating this value based on the number of decimals the token has.
      • Ex: if yUSD has 6 decimals and a user has a UIAmount of 1.123456789 you should display “1.123456”

Where to get this data:

  • For a user’s live balance you can get updated information on the above amounts by calling either getTokenAccountBalance or getAccountInfo
  • If you need to know the UI Amount for an arbitrary amount you can get this calculation by calling the amountToUiAmountForMintWithoutSimulation (web3.js v1) function or simulating a transaction using amountToUiAmount.
    • Note: amountToUiAmount requires a transaction simulation which means it also needs a valid fee payer with balance. Because of this, this should not be the default way to get a balance.

Updating the Current Amount

Because Issuers can update the multiplier at any given time you can consider occasionally polling in order to keep the account balance updated. Issuers are unlikely to update this multiplier more than once per day. If a multiplier is set for a future date, you can automatically poll at this update time

Token Amounts in Transactions (transfers / swaps etc)

  • Users should enter amounts to be interpreted as the scaled “UIAmount”. The app that has to process this should convert to the raw token amount for the transaction.
    • If there are rounding issues, round down and prefer leaving a tiny amount of dust rather than risk the transaction failing
    • To do this conversion you can use the uiAmountToAmountForMintWithoutSimulation (web3.js v1) function or simulating a transaction using amountToUiAmount.
  • Apps should use the total raw amount when a user requests to do an action with “max” or “all” of their balance. This ensures that there is no dust left over.
    • Optional: You can consider automatically closing an account when “max” is used to refund the user of their storage deposit

Token Price

  • Token price should always be displayed as the scaled price wherever possible.
  • If you are a price feed service provider, such as an oracle, you should expose both the scaled and non-scaled price.
    • Wherever possible provide an SDK/API that abstracts the scaled UI amount extension complexities away.

Current Multiplier

  • The current multiplier can be read from the token mint at any time by calling getAccountInfo. Additionally, if a future multiplier is set, this information is also available from the token mint. We recommend not showing this multiplier as it can confuse the UX.

Historical Data

Historical Data for Price Feed

  • Services who provide historical data should store and surface both the scaled and non-scaled prices for the scaled UI amount extension.
  • We expect scaled amounts to be used most frequently as this aligns with how the traditional finance world treats charts related to tokens with stock splits.

Historical Data for Amounts

  • If you would like to show the balance transferred in the past you need access to the multiplier at that given slot. You can also save the UiAmount for transfers as you process transactions to avoid doing this calculation in the future.

Backwards Compatibility

  • By default wallets and applications that do not understand the scaled UI amount extension will show the correct total price of an activity by multiplying the non-scaled price * raw amount.
  • They would, however, display the non-scaled price causing some user confusion.
  • We hope this encourages teams to update their dapps to be compatible with tokens that use the scaled UI amount extension and are happy to provide support during this process.

General Requirements

RequirementDescriptionPriority
Support User Actions Using UiAmountAll user actions should be entered in UiAmount when UiAmount is enabled throughout the app. If UiAmount is not visible in the app, they should use raw amounts until the app is updated.P0

Wallets

RequirementDescriptionPriority
Display Scaled BalanceShow the scaled amount (uiAmount) as the primary balance.P0
Support for Token TransfersEnd users should input transfer amounts with their scaled balances (raw amount * balance).P0
Display Spot PriceDisplay the scaled spot price for usersP0
Transaction History MetadataShow the scaled amount (UIAmount) for each transfer wherever possible.P1
Show Multiplier Updates in Transaction HistoryWhen multiplier updates occur, show this as an event in the user’s transaction history including the amount gainedP2
Display Price History GraphReflect the scaled prices in the price graphP1
Onboarding/TooltipsOffer tooltips or onboarding to educate users about tokens that use the scaled ui amount extensionP2

Explorers

RequirementDescriptionPriority
Token Details Page EnhancementsDisplay metadata such as total scaled market cap and current multiplierP0
Display Scaled Balance for BalancesDisplay scaled balances (UiAmount) for current balances.P0
Display Scaled Balance for TransactionsDisplay scaled balances (UiAmount) for transfer amounts for historical transactions.P0
Display Scaled Price for TransactionsDisplay scaled prices for previous transactionsP1
Properly Parse and Display Multiplier Update TransactionsProperly show details about the multiplier updateP2

Market Data Aggregators (Ex: CoinGecko)

RequirementDescriptionPriority
API Updates for Scaled DataExtend API functionality to include multiplier changes over time as well as the scaled price feed.P0
Total Supply With Scaled AdjustmentWhen displaying total supply and total market cap, take the scaled balances into accountP0
Historical Price TrackingProvide a historical chart of prices using the scaled price over time.P1
Historical Multiplier TrackingProvide historical markers of multiplier updates for interest-bearing tokens.P2
Educational Content or ExplanationsInclude brief descriptions or tooltips explaining how scaled tokens work.P2

Price Feed Providers

RequirementDescriptionPriority
Scaled & non-scaled Price FeedsProvide price feeds for both scaled and non-scaled prices.P0
Historical Multiplier DataOffer APIs with historical multiplier changes.P0
Historical Price DataOffer APIs with historical prices based on both scaled and non-scaled amounts.P0

DEXes

RequirementDescriptionPriority
Display Rebased Token BalancesShow scaled balances for trading or liquidity provision on the UI. (backend can still use raw amounts)P0
Support for Token ActionsEnd users should input action amounts with their UiAmount balances (multiplier * raw amount).P0
Price Feed AdaptationAnywhere a price feed is used to display current price, provide the scaled price to end users.P1
Display Price History GraphReflect the scaled prices in the price graphP1

Is this page helpful?