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

Commit 773e2ee

Browse files
authored
token-2022: Add interest-bearing extension (#3013)
* token-2022: Add interest-bearing extension * Rename / comment feedback * Rename interest-bearing -> interest-bearing mint
1 parent 37265fc commit 773e2ee

File tree

12 files changed

+1147
-32
lines changed

12 files changed

+1147
-32
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/client/src/token.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use {
1717
},
1818
spl_token_2022::{
1919
extension::{
20-
confidential_transfer, default_account_state, memo_transfer, transfer_fee,
21-
ExtensionType, StateWithExtensionsOwned,
20+
confidential_transfer, default_account_state, interest_bearing_mint, memo_transfer,
21+
transfer_fee, ExtensionType, StateWithExtensionsOwned,
2222
},
2323
instruction, native_mint,
2424
solana_zk_token_sdk::{
@@ -84,6 +84,10 @@ pub enum ExtensionInitializationParams {
8484
transfer_fee_basis_points: u16,
8585
maximum_fee: u64,
8686
},
87+
InterestBearingConfig {
88+
rate_authority: Option<Pubkey>,
89+
rate: i16,
90+
},
8791
}
8892
impl ExtensionInitializationParams {
8993
/// Get the extension type associated with the init params
@@ -93,6 +97,7 @@ impl ExtensionInitializationParams {
9397
Self::DefaultAccountState { .. } => ExtensionType::DefaultAccountState,
9498
Self::MintCloseAuthority { .. } => ExtensionType::MintCloseAuthority,
9599
Self::TransferFeeConfig { .. } => ExtensionType::TransferFeeConfig,
100+
Self::InterestBearingConfig { .. } => ExtensionType::InterestBearingConfig,
96101
}
97102
}
98103
/// Generate an appropriate initialization instruction for the given mint
@@ -136,6 +141,15 @@ impl ExtensionInitializationParams {
136141
transfer_fee_basis_points,
137142
maximum_fee,
138143
),
144+
Self::InterestBearingConfig {
145+
rate_authority,
146+
rate,
147+
} => interest_bearing_mint::instruction::initialize(
148+
token_program_id,
149+
mint,
150+
rate_authority,
151+
rate,
152+
),
139153
}
140154
}
141155
}
@@ -913,6 +927,25 @@ where
913927
.await
914928
}
915929

930+
/// Update interest rate
931+
pub async fn update_interest_rate<S2: Signer>(
932+
&self,
933+
authority: &S2,
934+
new_rate: i16,
935+
) -> TokenResult<T::Output> {
936+
self.process_ixs(
937+
&[interest_bearing_mint::instruction::update_rate(
938+
&self.program_id,
939+
self.get_address(),
940+
&authority.pubkey(),
941+
&[],
942+
new_rate,
943+
)?],
944+
&[authority],
945+
)
946+
.await
947+
}
948+
916949
/// Update confidential transfer mint
917950
pub async fn confidential_transfer_update_mint<S2: Signer>(
918951
&self,

0 commit comments

Comments
 (0)