@@ -157,6 +157,28 @@ type InitializeOnRampInstruction = Instruction<typeof SINGLE_POOL_PROGRAM_ID> &
157157 > &
158158 InstructionWithData < Uint8Array > ;
159159
160+ type DepositSolInstruction = Instruction < typeof SINGLE_POOL_PROGRAM_ID > &
161+ InstructionWithAccounts <
162+ [
163+ ReadonlyAccount < VoteAccountAddress > ,
164+ ReadonlyAccount < PoolAddress > ,
165+ WritableAccount < PoolStakeAddress > ,
166+ WritableAccount < PoolOnRampAddress > ,
167+ WritableAccount < PoolMintAddress > ,
168+ ReadonlyAccount < PoolStakeAuthorityAddress > ,
169+ ReadonlyAccount < PoolMintAuthorityAddress > ,
170+ WritableSignerAccount < Address > , // user lamport
171+ WritableAccount < Address > , // user token
172+ ReadonlyAccount < typeof SYSVAR_CLOCK_ID > ,
173+ ReadonlyAccount < typeof SYSVAR_STAKE_HISTORY_ID > ,
174+ ReadonlyAccount < typeof STAKE_CONFIG_ID > ,
175+ ReadonlyAccount < typeof SYSTEM_PROGRAM_ID > ,
176+ ReadonlyAccount < typeof TOKEN_PROGRAM_ID > ,
177+ ReadonlyAccount < typeof STAKE_PROGRAM_ID > ,
178+ ]
179+ > &
180+ InstructionWithData < Uint8Array > ;
181+
160182const enum SinglePoolInstructionType {
161183 InitializePool = 0 ,
162184 ReplenishPool ,
@@ -165,6 +187,7 @@ const enum SinglePoolInstructionType {
165187 CreateTokenMetadata ,
166188 UpdateTokenMetadata ,
167189 InitializeOnRamp ,
190+ DepositSol ,
168191}
169192
170193export const SinglePoolInstruction = {
@@ -175,6 +198,7 @@ export const SinglePoolInstruction = {
175198 createTokenMetadata : createTokenMetadataInstruction ,
176199 updateTokenMetadata : updateTokenMetadataInstruction ,
177200 initializeOnRamp : initializeOnRampInstruction ,
201+ depositSol : depositSolInstruction ,
178202} ;
179203
180204export async function initializePoolInstruction (
@@ -430,3 +454,44 @@ export async function initializeOnRampInstruction(
430454 programAddress,
431455 } ;
432456}
457+
458+ export async function depositSolInstruction (
459+ voteAccount : VoteAccountAddress ,
460+ userLamportAccount : Address ,
461+ userTokenAccount : Address ,
462+ lamports : bigint ,
463+ ) : Promise < DepositSolInstruction > {
464+ const programAddress = SINGLE_POOL_PROGRAM_ID ;
465+ const pool = await findPoolAddress ( programAddress , voteAccount ) ;
466+ const [ stake , onramp , mint , stakeAuthority , mintAuthority ] = await Promise . all ( [
467+ findPoolStakeAddress ( programAddress , pool ) ,
468+ findPoolOnRampAddress ( programAddress , pool ) ,
469+ findPoolMintAddress ( programAddress , pool ) ,
470+ findPoolStakeAuthorityAddress ( programAddress , pool ) ,
471+ findPoolMintAuthorityAddress ( programAddress , pool ) ,
472+ ] ) ;
473+
474+ const data = new Uint8Array ( [ SinglePoolInstructionType . DepositSol , ...u64 ( lamports ) ] ) ;
475+
476+ return {
477+ data,
478+ accounts : [
479+ { address : voteAccount , role : AccountRole . READONLY } ,
480+ { address : pool , role : AccountRole . READONLY } ,
481+ { address : stake , role : AccountRole . WRITABLE } ,
482+ { address : onramp , role : AccountRole . WRITABLE } ,
483+ { address : mint , role : AccountRole . WRITABLE } ,
484+ { address : stakeAuthority , role : AccountRole . READONLY } ,
485+ { address : mintAuthority , role : AccountRole . READONLY } ,
486+ { address : userLamportAccount , role : AccountRole . WRITABLE_SIGNER } ,
487+ { address : userTokenAccount , role : AccountRole . WRITABLE } ,
488+ { address : SYSVAR_CLOCK_ID , role : AccountRole . READONLY } ,
489+ { address : SYSVAR_STAKE_HISTORY_ID , role : AccountRole . READONLY } ,
490+ { address : STAKE_CONFIG_ID , role : AccountRole . READONLY } ,
491+ { address : SYSTEM_PROGRAM_ID , role : AccountRole . READONLY } ,
492+ { address : TOKEN_PROGRAM_ID , role : AccountRole . READONLY } ,
493+ { address : STAKE_PROGRAM_ID , role : AccountRole . READONLY } ,
494+ ] ,
495+ programAddress,
496+ } ;
497+ }
0 commit comments