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: include claim in unstake fn #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion ts-client/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 9 additions & 1 deletion ts-client/src/farm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand All @@ -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({
Expand All @@ -328,6 +335,7 @@ export class PoolFarmImpl {
user: userPda,
})
.preInstructions(instructions)
.postInstructions(postInstructions)
.transaction();

return new Transaction({
Expand Down
Loading