Skip to content

Commit

Permalink
Merge pull request #71 from marinade-finance/feat/expose-withdraw-to-…
Browse files Browse the repository at this point in the history
…stake-acc

feat: expose withdraw stake acc method
  • Loading branch information
AlexStefan authored Nov 5, 2024
2 parents 3c00ad6 + 1857652 commit 8117e77
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v5.0.14

### Feat:

- Expose withdraw stake account method from program

## v5.0.13

### Fix:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marinade.finance/marinade-ts-sdk",
"version": "5.0.13",
"version": "5.0.14",
"description": "Marinade SDK for Typescript",
"main": "dist/src/index.js",
"repository": {
Expand Down
46 changes: 46 additions & 0 deletions src/programs/marinade-finance-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,50 @@ export class MarinadeFinanceProgram {
tokenProgram: TOKEN_PROGRAM_ID,
})
.instruction()

withdrawStakeAccountInstructionBuilder = async ({
marinadeState,
ownerAddress,
associatedMSolTokenAccountAddress, // burnMsolFrom
stakeAccountAddress,
splitStakeAccountAddress,
splitStakeRentPayer,
stakeIndex,
validatorIndex,
msolAmount,
beneficiary,
}: {
marinadeState: MarinadeState
ownerAddress: web3.PublicKey
associatedMSolTokenAccountAddress: web3.PublicKey
stakeAccountAddress: web3.PublicKey
splitStakeAccountAddress: web3.PublicKey
splitStakeRentPayer: web3.PublicKey
stakeIndex: number
validatorIndex: number
msolAmount: BN
beneficiary: web3.PublicKey
}): Promise<web3.TransactionInstruction> =>
await this.program.methods
.withdrawStakeAccount(stakeIndex, validatorIndex, msolAmount, beneficiary)
.accountsStrict({
state: marinadeState.marinadeStateAddress,
msolMint: marinadeState.mSolMintAddress,
burnMsolFrom: associatedMSolTokenAccountAddress,
burnMsolAuthority: ownerAddress,
treasuryMsolAccount: marinadeState.treasuryMsolAccount,
validatorList:
marinadeState.state.validatorSystem.validatorList.account,
stakeList: marinadeState.state.stakeSystem.stakeList.account,
stakeWithdrawAuthority: await marinadeState.stakeWithdrawAuthority(),
stakeDepositAuthority: await marinadeState.stakeDepositAuthority(),
stakeAccount: stakeAccountAddress,
splitStakeAccount: splitStakeAccountAddress,
splitStakeRentPayer,
clock: web3.SYSVAR_CLOCK_PUBKEY,
systemProgram: SYSTEM_PROGRAM_ID,
tokenProgram: TOKEN_PROGRAM_ID,
stakeProgram: STAKE_PROGRAM_ID,
})
.instruction()
}

0 comments on commit 8117e77

Please sign in to comment.