From b7af217720d64a73aa846e97087fe4da2c0d94f1 Mon Sep 17 00:00:00 2001 From: McSam Date: Wed, 20 Dec 2023 15:51:37 +0800 Subject: [PATCH] feat: include claim in unstake fn --- ts-client/package.json | 2 +- ts-client/src/farm.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ts-client/package.json b/ts-client/package.json index fdda69d..a9fc98f 100644 --- a/ts-client/package.json +++ b/ts-client/package.json @@ -1,6 +1,6 @@ { "name": "@mercurial-finance/farming-sdk", - "version": "1.0.14", + "version": "1.0.15", "description": "", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/ts-client/src/farm.ts b/ts-client/src/farm.ts index 9b51766..6380837 100644 --- a/ts-client/src/farm.ts +++ b/ts-client/src/farm.ts @@ -306,7 +306,7 @@ export class PoolFarmImpl { }).add(depositTx); } - public async withdraw(owner: PublicKey, amount: BN) { + public async withdraw(owner: PublicKey, amount: BN, shouldClaim = false) { const userPda = this.getUserPda(owner); const instructions: TransactionInstruction[] = []; @@ -317,6 +317,13 @@ export class PoolFarmImpl { ); userStakingIx && instructions.push(userStakingIx); + const postInstructions = []; + if (shouldClaim) { + const claimMethod = await this.claimMethodBuilder(owner); + const claimIx = await claimMethod.instruction(); + postInstructions.push(claimIx); + } + const withdrawTx = await this.program.methods .withdraw(amount) .accounts({ @@ -328,6 +335,7 @@ export class PoolFarmImpl { user: userPda, }) .preInstructions(instructions) + .postInstructions(postInstructions) .transaction(); return new Transaction({