diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 4a80b4a..b62bd6a 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -42,6 +42,7 @@ export * from './initializeDefaultAccountState'; export * from './initializeGroupMemberPointer'; export * from './initializeGroupPointer'; export * from './initializeImmutableOwner'; +export * from './initializeInterestBearingMint'; export * from './initializeMetadataPointer'; export * from './initializeMint'; export * from './initializeMint2'; @@ -73,6 +74,7 @@ export * from './updateDefaultAccountState'; export * from './updateGroupMemberPointer'; export * from './updateGroupPointer'; export * from './updateMetadataPointer'; +export * from './updateRateInterestBearingMint'; export * from './updateTokenGroupMaxSize'; export * from './updateTokenGroupUpdateAuthority'; export * from './updateTokenMetadataField'; diff --git a/clients/js/src/generated/instructions/initializeInterestBearingMint.ts b/clients/js/src/generated/instructions/initializeInterestBearingMint.ts new file mode 100644 index 0000000..c9180f2 --- /dev/null +++ b/clients/js/src/generated/instructions/initializeInterestBearingMint.ts @@ -0,0 +1,212 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getI16Decoder, + getI16Encoder, + getOptionDecoder, + getOptionEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type Option, + type OptionOrNullable, + type WritableAccount, +} from '@solana/web3.js'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_INTEREST_BEARING_MINT_DISCRIMINATOR = 33; + +export function getInitializeInterestBearingMintDiscriminatorBytes() { + return getU8Encoder().encode(INITIALIZE_INTEREST_BEARING_MINT_DISCRIMINATOR); +} + +export const INITIALIZE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR = 0; + +export function getInitializeInterestBearingMintInterestBearingMintDiscriminatorBytes() { + return getU8Encoder().encode( + INITIALIZE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR + ); +} + +export type InitializeInterestBearingMintInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | IAccountMeta = string, + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + ...TRemainingAccounts, + ] + >; + +export type InitializeInterestBearingMintInstructionData = { + discriminator: number; + interestBearingMintDiscriminator: number; + /** The public key for the account that can update the rate */ + rateAuthority: Option
; + /** The initial interest rate */ + rate: number; +}; + +export type InitializeInterestBearingMintInstructionDataArgs = { + /** The public key for the account that can update the rate */ + rateAuthority: OptionOrNullable
; + /** The initial interest rate */ + rate: number; +}; + +export function getInitializeInterestBearingMintInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['interestBearingMintDiscriminator', getU8Encoder()], + [ + 'rateAuthority', + getOptionEncoder(getAddressEncoder(), { + prefix: null, + noneValue: 'zeroes', + }), + ], + ['rate', getI16Encoder()], + ]), + (value) => ({ + ...value, + discriminator: INITIALIZE_INTEREST_BEARING_MINT_DISCRIMINATOR, + interestBearingMintDiscriminator: + INITIALIZE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR, + }) + ); +} + +export function getInitializeInterestBearingMintInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['interestBearingMintDiscriminator', getU8Decoder()], + [ + 'rateAuthority', + getOptionDecoder(getAddressDecoder(), { + prefix: null, + noneValue: 'zeroes', + }), + ], + ['rate', getI16Decoder()], + ]); +} + +export function getInitializeInterestBearingMintInstructionDataCodec(): Codec< + InitializeInterestBearingMintInstructionDataArgs, + InitializeInterestBearingMintInstructionData +> { + return combineCodec( + getInitializeInterestBearingMintInstructionDataEncoder(), + getInitializeInterestBearingMintInstructionDataDecoder() + ); +} + +export type InitializeInterestBearingMintInput< + TAccountMint extends string = string, +> = { + /** The mint to initialize. */ + mint: Address; + rateAuthority: InitializeInterestBearingMintInstructionDataArgs['rateAuthority']; + rate: InitializeInterestBearingMintInstructionDataArgs['rate']; +}; + +export function getInitializeInterestBearingMintInstruction< + TAccountMint extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: InitializeInterestBearingMintInput, + config?: { programAddress?: TProgramAddress } +): InitializeInterestBearingMintInstruction { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [getAccountMeta(accounts.mint)], + programAddress, + data: getInitializeInterestBearingMintInstructionDataEncoder().encode( + args as InitializeInterestBearingMintInstructionDataArgs + ), + } as InitializeInterestBearingMintInstruction; + + return instruction; +} + +export type ParsedInitializeInterestBearingMintInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The mint to initialize. */ + mint: TAccountMetas[0]; + }; + data: InitializeInterestBearingMintInstructionData; +}; + +export function parseInitializeInterestBearingMintInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedInitializeInterestBearingMintInstruction { + if (instruction.accounts.length < 1) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + mint: getNextAccount(), + }, + data: getInitializeInterestBearingMintInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/instructions/updateRateInterestBearingMint.ts b/clients/js/src/generated/instructions/updateRateInterestBearingMint.ts new file mode 100644 index 0000000..97eff4b --- /dev/null +++ b/clients/js/src/generated/instructions/updateRateInterestBearingMint.ts @@ -0,0 +1,236 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + AccountRole, + combineCodec, + getI16Decoder, + getI16Encoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IAccountSignerMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/web3.js'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_RATE_INTEREST_BEARING_MINT_DISCRIMINATOR = 33; + +export function getUpdateRateInterestBearingMintDiscriminatorBytes() { + return getU8Encoder().encode(UPDATE_RATE_INTEREST_BEARING_MINT_DISCRIMINATOR); +} + +export const UPDATE_RATE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR = 1; + +export function getUpdateRateInterestBearingMintInterestBearingMintDiscriminatorBytes() { + return getU8Encoder().encode( + UPDATE_RATE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR + ); +} + +export type UpdateRateInterestBearingMintInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | IAccountMeta = string, + TAccountRateAuthority extends string | IAccountMeta = string, + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountRateAuthority extends string + ? WritableAccount + : TAccountRateAuthority, + ...TRemainingAccounts, + ] + >; + +export type UpdateRateInterestBearingMintInstructionData = { + discriminator: number; + interestBearingMintDiscriminator: number; + /** The interest rate to update. */ + rate: number; +}; + +export type UpdateRateInterestBearingMintInstructionDataArgs = { + /** The interest rate to update. */ + rate: number; +}; + +export function getUpdateRateInterestBearingMintInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['interestBearingMintDiscriminator', getU8Encoder()], + ['rate', getI16Encoder()], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_RATE_INTEREST_BEARING_MINT_DISCRIMINATOR, + interestBearingMintDiscriminator: + UPDATE_RATE_INTEREST_BEARING_MINT_INTEREST_BEARING_MINT_DISCRIMINATOR, + }) + ); +} + +export function getUpdateRateInterestBearingMintInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['interestBearingMintDiscriminator', getU8Decoder()], + ['rate', getI16Decoder()], + ]); +} + +export function getUpdateRateInterestBearingMintInstructionDataCodec(): Codec< + UpdateRateInterestBearingMintInstructionDataArgs, + UpdateRateInterestBearingMintInstructionData +> { + return combineCodec( + getUpdateRateInterestBearingMintInstructionDataEncoder(), + getUpdateRateInterestBearingMintInstructionDataDecoder() + ); +} + +export type UpdateRateInterestBearingMintInput< + TAccountMint extends string = string, + TAccountRateAuthority extends string = string, +> = { + /** The mint. */ + mint: Address; + /** The mint rate authority. */ + rateAuthority: + | Address + | TransactionSigner; + rate: UpdateRateInterestBearingMintInstructionDataArgs['rate']; + multiSigners?: Array; +}; + +export function getUpdateRateInterestBearingMintInstruction< + TAccountMint extends string, + TAccountRateAuthority extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: UpdateRateInterestBearingMintInput< + TAccountMint, + TAccountRateAuthority + >, + config?: { programAddress?: TProgramAddress } +): UpdateRateInterestBearingMintInstruction< + TProgramAddress, + TAccountMint, + (typeof input)['rateAuthority'] extends TransactionSigner + ? WritableSignerAccount & + IAccountSignerMeta + : TAccountRateAuthority +> { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + rateAuthority: { value: input.rateAuthority ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: IAccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.mint), + getAccountMeta(accounts.rateAuthority), + ...remainingAccounts, + ], + programAddress, + data: getUpdateRateInterestBearingMintInstructionDataEncoder().encode( + args as UpdateRateInterestBearingMintInstructionDataArgs + ), + } as UpdateRateInterestBearingMintInstruction< + TProgramAddress, + TAccountMint, + (typeof input)['rateAuthority'] extends TransactionSigner + ? WritableSignerAccount & + IAccountSignerMeta + : TAccountRateAuthority + >; + + return instruction; +} + +export type ParsedUpdateRateInterestBearingMintInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The mint. */ + mint: TAccountMetas[0]; + /** The mint rate authority. */ + rateAuthority: TAccountMetas[1]; + }; + data: UpdateRateInterestBearingMintInstructionData; +}; + +export function parseUpdateRateInterestBearingMintInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedUpdateRateInterestBearingMintInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + mint: getNextAccount(), + rateAuthority: getNextAccount(), + }, + data: getUpdateRateInterestBearingMintInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/programs/token2022.ts b/clients/js/src/generated/programs/token2022.ts index 8b16e3b..15d7508 100644 --- a/clients/js/src/generated/programs/token2022.ts +++ b/clients/js/src/generated/programs/token2022.ts @@ -47,6 +47,7 @@ import { type ParsedInitializeGroupMemberPointerInstruction, type ParsedInitializeGroupPointerInstruction, type ParsedInitializeImmutableOwnerInstruction, + type ParsedInitializeInterestBearingMintInstruction, type ParsedInitializeMetadataPointerInstruction, type ParsedInitializeMint2Instruction, type ParsedInitializeMintCloseAuthorityInstruction, @@ -77,6 +78,7 @@ import { type ParsedUpdateGroupMemberPointerInstruction, type ParsedUpdateGroupPointerInstruction, type ParsedUpdateMetadataPointerInstruction, + type ParsedUpdateRateInterestBearingMintInstruction, type ParsedUpdateTokenGroupMaxSizeInstruction, type ParsedUpdateTokenGroupUpdateAuthorityInstruction, type ParsedUpdateTokenMetadataFieldInstruction, @@ -166,6 +168,8 @@ export enum Token2022Instruction { EnableMemoTransfers, DisableMemoTransfers, InitializeNonTransferableMint, + InitializeInterestBearingMint, + UpdateRateInterestBearingMint, EnableCpiGuard, DisableCpiGuard, InitializeTransferHook, @@ -419,6 +423,18 @@ export function identifyToken2022Instruction( if (containsBytes(data, getU8Encoder().encode(32), 0)) { return Token2022Instruction.InitializeNonTransferableMint; } + if ( + containsBytes(data, getU8Encoder().encode(33), 0) && + containsBytes(data, getU8Encoder().encode(0), 1) + ) { + return Token2022Instruction.InitializeInterestBearingMint; + } + if ( + containsBytes(data, getU8Encoder().encode(33), 0) && + containsBytes(data, getU8Encoder().encode(1), 1) + ) { + return Token2022Instruction.UpdateRateInterestBearingMint; + } if ( containsBytes(data, getU8Encoder().encode(34), 0) && containsBytes(data, getU8Encoder().encode(0), 1) @@ -716,6 +732,12 @@ export type ParsedToken2022Instruction< | ({ instructionType: Token2022Instruction.InitializeNonTransferableMint; } & ParsedInitializeNonTransferableMintInstruction) + | ({ + instructionType: Token2022Instruction.InitializeInterestBearingMint; + } & ParsedInitializeInterestBearingMintInstruction) + | ({ + instructionType: Token2022Instruction.UpdateRateInterestBearingMint; + } & ParsedUpdateRateInterestBearingMintInstruction) | ({ instructionType: Token2022Instruction.EnableCpiGuard; } & ParsedEnableCpiGuardInstruction) diff --git a/clients/js/src/getInitializeInstructionsForExtensions.ts b/clients/js/src/getInitializeInstructionsForExtensions.ts index f9a8fae..cdca33a 100644 --- a/clients/js/src/getInitializeInstructionsForExtensions.ts +++ b/clients/js/src/getInitializeInstructionsForExtensions.ts @@ -16,6 +16,7 @@ import { getInitializeDefaultAccountStateInstruction, getInitializeGroupMemberPointerInstruction, getInitializeGroupPointerInstruction, + getInitializeInterestBearingMintInstruction, getInitializeMetadataPointerInstruction, getInitializeTokenGroupInstruction, getInitializeTokenMetadataInstruction, @@ -68,6 +69,14 @@ export function getPreInitializeInstructionsForMintExtensions( metadataAddress: extension.metadataAddress, }), ]; + case 'InterestBearingConfig': + return [ + getInitializeInterestBearingMintInstruction({ + mint, + rateAuthority: extension.rateAuthority, + rate: extension.currentRate, + }), + ]; case 'GroupPointer': return [ getInitializeGroupPointerInstruction({ diff --git a/clients/js/test/extensions/interestBearingMint/initializeInterestBearingMint.test.ts b/clients/js/test/extensions/interestBearingMint/initializeInterestBearingMint.test.ts new file mode 100644 index 0000000..30f82ba --- /dev/null +++ b/clients/js/test/extensions/interestBearingMint/initializeInterestBearingMint.test.ts @@ -0,0 +1,78 @@ +import test from 'ava'; +import { + createDefaultSolanaClient, + generateKeyPairSignerWithSol, + getCreateMintInstructions, + sendAndConfirmInstructions, +} from '../../_setup'; +import { Account, generateKeyPairSigner, isSome } from '@solana/web3.js'; +import { + extension, + fetchMint, + getInitializeInterestBearingMintInstruction, + Mint, +} from '../../../src'; + +test('it initialize a mint account with an interest bearing mint extension', async (t) => { + const client = createDefaultSolanaClient(); + const [rateAuthority, mint] = await Promise.all([ + generateKeyPairSignerWithSol(client), + generateKeyPairSigner(), + ]); + + // in bips + const rate = 10000; + + // And a interest bearing pointer extension. + const interestBearingMintExtension = extension('InterestBearingConfig', { + rateAuthority: rateAuthority.address, + initializationTimestamp: BigInt(Math.floor(new Date().getTime() / 1000)), + lastUpdateTimestamp: BigInt(Math.floor(new Date().getTime() / 1000)), + preUpdateAverageRate: 10000, + currentRate: rate, + }); + + // When we initialize the mint account with the interest bearing mint extension. + const [createMintInstruction, initMintInstruction] = + await getCreateMintInstructions({ + authority: rateAuthority.address, + client, + extensions: [interestBearingMintExtension], + mint, + payer: rateAuthority, + }); + await sendAndConfirmInstructions(client, rateAuthority, [ + createMintInstruction, + getInitializeInterestBearingMintInstruction({ + rateAuthority: rateAuthority.address, + mint: mint.address, + rate: rate, + }), + initMintInstruction, + ]); + + const mintAccount = await fetchMint(client.rpc, mint.address); + + const extensions = mintAccount.data.extensions; + + t.true(isSome(extensions)); + t.true( + isSome(extensions) && extensions.value[0].__kind === 'InterestBearingConfig' + ); + + // check without need to check timestamp specifically + if ( + isSome(extensions) && + extensions.value[0].__kind === 'InterestBearingConfig' + ) { + t.is(extensions.value[0].rateAuthority, rateAuthority.address); + t.true(typeof extensions.value[0].initializationTimestamp === 'bigint'); + t.true(typeof extensions.value[0].lastUpdateTimestamp === 'bigint'); + t.is(extensions.value[0].preUpdateAverageRate, rate); + t.is(extensions.value[0].currentRate, rate); + } + + t.like(mintAccount, >{ + address: mint.address, + }); +}); diff --git a/clients/js/test/extensions/interestBearingMint/updateInterestBearingMint.test.ts b/clients/js/test/extensions/interestBearingMint/updateInterestBearingMint.test.ts new file mode 100644 index 0000000..92521f9 --- /dev/null +++ b/clients/js/test/extensions/interestBearingMint/updateInterestBearingMint.test.ts @@ -0,0 +1,77 @@ +import test from 'ava'; +import { + createDefaultSolanaClient, + createMint, + generateKeyPairSignerWithSol, + sendAndConfirmInstructions, +} from '../../_setup'; +import { Account, isSome } from '@solana/web3.js'; +import { + extension, + fetchMint, + getUpdateRateInterestBearingMintInstruction, + Mint, +} from '../../../src'; + +test('it updates the interest bearing mint extension on a mint account', async (t) => { + // Given some signer accounts. + const client = createDefaultSolanaClient(); + const [rateAuthority] = await Promise.all([ + generateKeyPairSignerWithSol(client), + ]); + + const oldRate = 10000; + const newRate = 20000; + + // initialize mint with interest bearing mint extension + const mint = await createMint({ + authority: rateAuthority, + client, + extensions: [ + extension('InterestBearingConfig', { + rateAuthority: rateAuthority.address, + initializationTimestamp: BigInt( + Math.floor(new Date().getTime() / 1000) + ), + lastUpdateTimestamp: BigInt(Math.floor(new Date().getTime() / 1000)), + preUpdateAverageRate: oldRate, + currentRate: oldRate, + }), + ], + payer: rateAuthority, + }); + + // then we update the interest bearing mint extension on the mint account + await sendAndConfirmInstructions(client, rateAuthority, [ + getUpdateRateInterestBearingMintInstruction({ + rateAuthority: rateAuthority, + mint: mint, + rate: newRate, + }), + ]); + + const mintAccount = await fetchMint(client.rpc, mint); + + // check without need to check timestamp specifically + const extensions = mintAccount.data.extensions; + + t.true(isSome(extensions)); + t.true( + isSome(extensions) && extensions.value[0].__kind === 'InterestBearingConfig' + ); + + if ( + isSome(extensions) && + extensions.value[0].__kind === 'InterestBearingConfig' + ) { + t.is(extensions.value[0].rateAuthority, rateAuthority.address); + t.true(typeof extensions.value[0].initializationTimestamp === 'bigint'); + t.true(typeof extensions.value[0].lastUpdateTimestamp === 'bigint'); + t.is(extensions.value[0].preUpdateAverageRate, oldRate); + t.is(extensions.value[0].currentRate, newRate); + } + + t.like(mintAccount, >{ + address: mint, + }); +}); diff --git a/program/idl.json b/program/idl.json index 8789869..749986a 100644 --- a/program/idl.json +++ b/program/idl.json @@ -5389,6 +5389,189 @@ } ] }, + { + "kind": "instructionNode", + "name": "initializeInterestBearingMint", + "docs": [ + "Initialize a new mint with the `InterestBearing` extension.", + "", + "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." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The mint to initialize."] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 33 + } + }, + { + "kind": "instructionArgumentNode", + "name": "interestBearingMintDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 0 + } + }, + { + "kind": "instructionArgumentNode", + "name": "rateAuthority", + "docs": ["The public key for the account that can update the rate"], + "type": { + "kind": "zeroableOptionTypeNode", + "item": { + "kind": "publicKeyTypeNode" + } + } + }, + { + "kind": "instructionArgumentNode", + "name": "rate", + "docs": ["The initial interest rate"], + "type": { + "kind": "numberTypeNode", + "format": "i16", + "endian": "le" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "interestBearingMintDiscriminator", + "offset": 1 + } + ] + }, + { + "kind": "instructionNode", + "name": "updateRateInterestBearingMint", + "docs": [ + "Update the interest rate. Only supported for mints that include the", + "`InterestBearingConfig` extension." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The mint."] + }, + { + "kind": "instructionAccountNode", + "name": "rateAuthority", + "isWritable": true, + "isSigner": "either", + "isOptional": false, + "docs": ["The mint rate authority."] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 33 + } + }, + { + "kind": "instructionArgumentNode", + "name": "interestBearingMintDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 1 + } + }, + { + "kind": "instructionArgumentNode", + "name": "rate", + "docs": ["The interest rate to update."], + "type": { + "kind": "numberTypeNode", + "format": "i16", + "endian": "le" + } + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "interestBearingMintDiscriminator", + "offset": 1 + } + ] + }, { "kind": "instructionNode", "name": "enableCpiGuard", @@ -5622,7 +5805,9 @@ { "kind": "instructionArgumentNode", "name": "authority", - "docs": ["The public key for the account that can update the program id"], + "docs": [ + "The public key for the account that can update the program id" + ], "type": { "kind": "zeroableOptionTypeNode", "item": { @@ -5678,7 +5863,7 @@ "docs": ["The mint."] }, { - "kind": "instructionAccountNode", + "kind": "instructionAccountNode", "name": "authority", "isWritable": false, "isSigner": "either", @@ -5749,7 +5934,7 @@ }, { "kind": "fieldDiscriminatorNode", - "name": "transferHookDiscriminator", + "name": "transferHookDiscriminator", "offset": 1 } ]