Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

token-js: Support InterestBearingMint instructions #3263

@joncinque

Description

@joncinque

Problem

token-2022 includes a new mint extension to set an interest rate for tokens, but it isn't supported in the JS bindings. The relevant top-level instruction definition can be found here:

InterestBearingMintExtension,

and the sub-instructions here:

/// Interesting-bearing mint extension instructions
#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum InterestBearingMintInstruction {
/// Initialize a new mint with interest accrual.
///
/// Fails if the mint has already been initialized, so must be called before
/// `InitializeMint`.
///
/// The mint must have exactly enough space allocated for the base mint (82
/// bytes), plus 83 bytes of padding, 1 byte reserved for the account type,
/// then space required for this extension, plus any others.
///
/// Accounts expected by this instruction:
///
/// 0. `[writable]` The mint to initialize.
///
/// Data expected by this instruction:
/// `crate::extension::interest_bearing::instruction::InitializeInstructionData`
///
Initialize,
/// Update the interest rate. Only supported for mints that include the
/// `InterestBearingConfig` extension.
///
/// Accounts expected by this instruction:
///
/// * Single authority
/// 0. `[writable]` The mint.
/// 1. `[signer]` The mint rate authority.
///
/// * Multisignature authority
/// 0. `[writable]` The mint.
/// 1. `[]` The mint's multisignature rate authority.
/// 2. ..2+M `[signer]` M signer accounts.
///
/// Data expected by this instruction:
/// `crate::extension::interest_bearing::BasisPoints`
///
UpdateRate,
}

Solution

Following the model in #2951 , add support for these new instructions, state, and extension type, including some end-to-end tests.

This is the first step for support, since we also need a client-side way to convert from token amount to tokens + interest accrued.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions