Skip to content

​What Is an Interest Bearing Mint?

The Token Extension Program’s InterestBearingConfig mint extension lets a mint store an annualized interest rate directly onchain. Interest bearing tokens do not add more tokens to token accounts over time. The token amount stored in each token account stays the same until a token program instruction changes it, such as minting, transferring, or burning. As time passes, the calculated UI amount with interest can increase even though the token amount and token supply stay the same.
Security: Do math on raw amountsPrograms should compute balances, shares, and prices from the raw amount in the token account. The UI amount changes with time and with the rate the rate authority sets, so logic that mixes UI amounts with raw amounts produces wrong values. Convert to UI amounts only for display.

​How Historical Rate Changes Are Calculated

  • InterestBearingConfig stores initialization_timestamp, pre_update_average_rate, last_update_timestamp, and current_rate.
  • amount_to_ui_amount calculates the UI amount in two steps: it first calculates interest from initialization to last_update_timestamp using pre_update_average_rate, then calculates interest from last_update_timestamp to the current timestamp using current_rate.
  • When UpdateRate runs, process_update_rate calls time_weighted_average_rate and updates pre_update_average_rate to a new time-weighted historical average, then records a new last_update_timestamp and current_rate.
  • After rate changes over time, the earlier changes are represented by pre_update_average_rate, while the period from last_update_timestamp to the current time is calculated with current_rate.

​Before you start

The examples on this page run against a local validator at http://localhost:8899 (WebSocket ws://localhost:8900) and fund their accounts with airdrops from it. Start one in a separate terminal with Surfpool (surfpool start) or solana-test-validator. Each code section below lists the packages or crates it needs. The TypeScript examples use top-level await, so run them as ES modules, for example with npx tsx index.ts in a project whose package.json sets "type": "module".

​How to Create and Use Interest Bearing Tokens

To create and use interest bearing tokens:
  1. Calculate the mint account size and rent needed for the mint and the InterestBearingConfig extension.
  2. Create the mint account with CreateAccount, initialize InterestBearingConfig, and initialize the mint with InitializeMint.
  3. Mint tokens as usual.
  4. Use UpdateRate to change the mint’s current rate over time.
  5. Convert token amounts into a UI amount with interest with AmountToUiAmount or helper methods that fetch the mint account and clock sysvar, then calculate the UI amount without sending a transaction.
Offchain and Onchain UI Amount ConversionThe offchain helper path fetches the mint account and the clock sysvar, then calculates the UI amount locally without sending a transaction. The onchain path uses AmountToUiAmount, which runs in the token program and returns the UI amount in transaction return data. AmountToUiAmount can be sent in a transaction or simulated.
1

Calculate account size

Calculate the mint account size for the base mint plus the InterestBearingConfig extension. This is the size used in CreateAccount.
Example
2

Calculate rent

Calculate rent using the size needed for the mint plus the InterestBearingConfig extension.
Example
3

Create the mint account

Create the mint account with the calculated space and lamports.
Example
4

Initialize InterestBearingConfig

Initialize the InterestBearingConfig extension on the mint.
Example
5

Initialize the mint

Initialize the mint with InitializeMint in the same transaction.
Example
6

Create a token account and mint tokens

Create a token account for the mint, then mint tokens to that token account.
Example
7

Calculate the UI amount with the offchain helper

Fetch the mint account and clock sysvar, then calculate the UI amount without sending a transaction.
Example
Instruction OrderInterestBearingMintInstruction::Initialize must come before InitializeMint. CreateAccount, InterestBearingMintInstruction::Initialize, and InitializeMint must be included in the same transaction.

​Source Reference

ItemDescriptionSource
InterestBearingConfigMint extension that stores the interest rate authority, timestamps, and current and historical rates.Source
InterestBearingMintInstruction::InitializeInstruction that initializes the interest bearing config before InitializeMint.Source
InterestBearingMintInstruction::UpdateRateInstruction that changes the mint’s current interest rate.Source
AmountToUiAmountInstruction that returns the current UI amount string for a token amount using the mint’s active config.Source
InterestBearingConfig::amount_to_ui_amountHelper that converts a token amount into a UI amount with interest for a timestamp.Source
process_initializeProcessor logic that initializes InterestBearingConfig and records the initial timestamps and rate.Source
process_update_rateProcessor logic that updates the current rate, recalculates the time-weighted average rate, and records the update timestamp.Source
process_amount_to_ui_amountProcessor logic that returns the UI amount string using the mint’s active interest bearing configuration.Source

​Kit

These examples use the generated Token-2022 instructions directly.
Terminal
Instructions

​Web3.js v3

These examples use the class-based @solana/web3.js v3 API with @solana-program instruction builders.
Terminal
Instructions

​Rust

Add these dependencies to Cargo.toml (tested with Rust 1.89, 1.98, and 1.99):
Cargo.toml
Rust

​Web3.js (legacy)

These examples use legacy @solana/web3.js with @solana/spl-token.
@solana/web3.js 1.x is no longer actively maintainedIt receives critical fixes only. Use Kit for new code. To migrate existing code, follow the Kit upgrade guide, or the web3.js v3 migration guide to keep the class-based API.To run this code, install 1.x with npm install @solana/web3.js@1. A plain npm install @solana/web3.js installs v3, which this code doesn’t run on.
Terminal
Instructions