Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose withdraw stake acc method #71

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
Loading