@zebec-network/zebec-vault-sdk 5.2.4 → 5.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2188,6 +2188,151 @@ export type ZebecVault = {
2188
2188
  }
2189
2189
  ];
2190
2190
  },
2191
+ {
2192
+ name: "unstakeZbcn";
2193
+ discriminator: [90, 202, 101, 187, 218, 99, 244, 1];
2194
+ accounts: [
2195
+ {
2196
+ name: "vaultOwner";
2197
+ writable: true;
2198
+ signer: true;
2199
+ },
2200
+ {
2201
+ name: "vault";
2202
+ pda: {
2203
+ seeds: [
2204
+ {
2205
+ kind: "const";
2206
+ value: [
2207
+ 122,
2208
+ 101,
2209
+ 98,
2210
+ 101,
2211
+ 99,
2212
+ 95,
2213
+ 117,
2214
+ 115,
2215
+ 101,
2216
+ 114,
2217
+ 95,
2218
+ 118,
2219
+ 97,
2220
+ 117,
2221
+ 108,
2222
+ 116
2223
+ ];
2224
+ },
2225
+ {
2226
+ kind: "account";
2227
+ path: "vaultOwner";
2228
+ }
2229
+ ];
2230
+ };
2231
+ },
2232
+ {
2233
+ name: "vaultSigner";
2234
+ writable: true;
2235
+ pda: {
2236
+ seeds: [
2237
+ {
2238
+ kind: "const";
2239
+ value: [
2240
+ 122,
2241
+ 101,
2242
+ 98,
2243
+ 101,
2244
+ 99,
2245
+ 95,
2246
+ 118,
2247
+ 97,
2248
+ 117,
2249
+ 108,
2250
+ 116,
2251
+ 95,
2252
+ 115,
2253
+ 105,
2254
+ 103,
2255
+ 110,
2256
+ 101,
2257
+ 114
2258
+ ];
2259
+ },
2260
+ {
2261
+ kind: "account";
2262
+ path: "vault";
2263
+ }
2264
+ ];
2265
+ };
2266
+ },
2267
+ {
2268
+ name: "vaultSignerStakeAta";
2269
+ writable: true;
2270
+ },
2271
+ {
2272
+ name: "vaultSignerRewardAta";
2273
+ writable: true;
2274
+ },
2275
+ {
2276
+ name: "lockup";
2277
+ writable: true;
2278
+ },
2279
+ {
2280
+ name: "stakePda";
2281
+ writable: true;
2282
+ },
2283
+ {
2284
+ name: "stakeToken";
2285
+ },
2286
+ {
2287
+ name: "rewardToken";
2288
+ },
2289
+ {
2290
+ name: "stakeVault";
2291
+ writable: true;
2292
+ },
2293
+ {
2294
+ name: "rewardVault";
2295
+ writable: true;
2296
+ },
2297
+ {
2298
+ name: "stakeVaultTokenAccount";
2299
+ writable: true;
2300
+ },
2301
+ {
2302
+ name: "rewardVaultTokenAccount";
2303
+ writable: true;
2304
+ },
2305
+ {
2306
+ name: "feeVault";
2307
+ },
2308
+ {
2309
+ name: "feeVaultTokenAccount";
2310
+ writable: true;
2311
+ },
2312
+ {
2313
+ name: "zebecStakeProgram";
2314
+ address: "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv";
2315
+ },
2316
+ {
2317
+ name: "tokenProgram";
2318
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2319
+ },
2320
+ {
2321
+ name: "associatedTokenProgram";
2322
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
2323
+ },
2324
+ {
2325
+ name: "systemProgram";
2326
+ address: "11111111111111111111111111111111";
2327
+ }
2328
+ ];
2329
+ args: [
2330
+ {
2331
+ name: "nonce";
2332
+ type: "u64";
2333
+ }
2334
+ ];
2335
+ },
2191
2336
  {
2192
2337
  name: "withdrawSol";
2193
2338
  discriminator: [145, 131, 74, 136, 65, 137, 42, 38];
@@ -1469,6 +1469,121 @@
1469
1469
  "discriminator": [103, 60, 61, 79, 56, 61, 76, 49],
1470
1470
  "name": "transfer_fees"
1471
1471
  },
1472
+ {
1473
+ "accounts": [
1474
+ {
1475
+ "name": "vault_owner",
1476
+ "signer": true,
1477
+ "writable": true
1478
+ },
1479
+ {
1480
+ "name": "vault",
1481
+ "pda": {
1482
+ "seeds": [
1483
+ {
1484
+ "kind": "const",
1485
+ "value": [
1486
+ 122, 101, 98, 101, 99, 95, 117, 115, 101, 114, 95, 118, 97,
1487
+ 117, 108, 116
1488
+ ]
1489
+ },
1490
+ {
1491
+ "kind": "account",
1492
+ "path": "vault_owner"
1493
+ }
1494
+ ]
1495
+ }
1496
+ },
1497
+ {
1498
+ "name": "vault_signer",
1499
+ "pda": {
1500
+ "seeds": [
1501
+ {
1502
+ "kind": "const",
1503
+ "value": [
1504
+ 122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115,
1505
+ 105, 103, 110, 101, 114
1506
+ ]
1507
+ },
1508
+ {
1509
+ "kind": "account",
1510
+ "path": "vault"
1511
+ }
1512
+ ]
1513
+ },
1514
+ "writable": true
1515
+ },
1516
+ {
1517
+ "name": "vault_signer_stake_ata",
1518
+ "writable": true
1519
+ },
1520
+ {
1521
+ "name": "vault_signer_reward_ata",
1522
+ "writable": true
1523
+ },
1524
+ {
1525
+ "name": "lockup",
1526
+ "writable": true
1527
+ },
1528
+ {
1529
+ "name": "stake_pda",
1530
+ "writable": true
1531
+ },
1532
+ {
1533
+ "name": "stake_token"
1534
+ },
1535
+ {
1536
+ "name": "reward_token"
1537
+ },
1538
+ {
1539
+ "name": "stake_vault",
1540
+ "writable": true
1541
+ },
1542
+ {
1543
+ "name": "reward_vault",
1544
+ "writable": true
1545
+ },
1546
+ {
1547
+ "name": "stake_vault_token_account",
1548
+ "writable": true
1549
+ },
1550
+ {
1551
+ "name": "reward_vault_token_account",
1552
+ "writable": true
1553
+ },
1554
+ {
1555
+ "name": "fee_vault"
1556
+ },
1557
+ {
1558
+ "name": "fee_vault_token_account",
1559
+ "writable": true
1560
+ },
1561
+ {
1562
+ "address": "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv",
1563
+ "name": "zebec_stake_program"
1564
+ },
1565
+ {
1566
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
1567
+ "name": "token_program"
1568
+ },
1569
+ {
1570
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
1571
+ "name": "associated_token_program"
1572
+ },
1573
+ {
1574
+ "address": "11111111111111111111111111111111",
1575
+ "name": "system_program"
1576
+ }
1577
+ ],
1578
+ "args": [
1579
+ {
1580
+ "name": "nonce",
1581
+ "type": "u64"
1582
+ }
1583
+ ],
1584
+ "discriminator": [90, 202, 101, 187, 218, 99, 244, 1],
1585
+ "name": "unstake_zbcn"
1586
+ },
1472
1587
  {
1473
1588
  "accounts": [
1474
1589
  {
package/dist/service.d.ts CHANGED
@@ -6,7 +6,7 @@ import { type ZebecStakeIdlV1 } from "@zebec-network/zebec-stake-sdk";
6
6
  import { type ZebecStreamIdl } from "@zebec-network/zebec-stream-sdk";
7
7
  import { type ZebecVaultV1Idl } from "./artifacts";
8
8
  import type { RpcNetwork } from "./constants";
9
- import type { CancelStreamParams, ChangeStreamReceiverParams, CreateSilverCardInstructionData, CreateSilverCardParams, CreateStreamFromVaultParams, createMultipleStreamFromVaultParams, LoadCarbonCardInstructionData, LoadCarbonCardParams, Numeric, PauseResumeStreamParams, ProposalAction, ProposalInfo, StakeInstructionData, StakeUserNonceInfo, StreamMetadataInfo, SwapAndCreateSilverCardParams, SwapAndLoadCarbonCardParams, TokenFeeRecord, VaultInfo, WithdrawStreamParams } from "./types";
9
+ import type { CancelStreamParams, ChangeStreamReceiverParams, createMultipleStreamFromVaultParams, CreateSilverCardInstructionData, CreateSilverCardParams, CreateStreamFromVaultParams, LoadCarbonCardInstructionData, LoadCarbonCardParams, Numeric, PauseResumeStreamParams, ProposalAction, ProposalInfo, StakeInstructionData, StakeUserNonceInfo, StreamMetadataInfo, SwapAndCreateSilverCardParams, SwapAndLoadCarbonCardParams, TokenFeeRecord, VaultInfo, WithdrawStreamParams } from "./types";
10
10
  export declare class ZebecVaultService {
11
11
  readonly provider: Provider;
12
12
  readonly vaultV1Program: Program<ZebecVaultV1Idl>;
@@ -342,7 +342,7 @@ export declare class ZebecVaultService {
342
342
  withdrawStream(params: WithdrawStreamParams): Promise<TransactionPayload>;
343
343
  getStreamMetadataInfo(streamMetadata: Address, commitment?: Commitment): Promise<StreamMetadataInfo>;
344
344
  getStakeInstruction(feePayer: PublicKey, lockup: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, userNonce: PublicKey, stakePda: PublicKey, stakeVaultTokenAccount: PublicKey, data: StakeInstructionData): Promise<TransactionInstruction>;
345
- getUnstakeInstruction(feePayer: PublicKey, feeVault: PublicKey, lockup: PublicKey, stakePda: PublicKey, rewardToken: PublicKey, rewardVault: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, stakerTokenAccount: PublicKey, nonce: BN): Promise<TransactionInstruction>;
345
+ getUnstakeInstruction(feeVault: PublicKey, lockup: PublicKey, stakePda: PublicKey, rewardVault: PublicKey, stakeToken: PublicKey, rewardToken: PublicKey, stakeVault: PublicKey, vault: PublicKey, vaultOwner: PublicKey, vaultSigner: PublicKey, vaultSignerStakeAta: PublicKey, vaultSignerRewardAta: PublicKey, feeVaultTokenAccount: PublicKey, rewardVaultTokenAccount: PublicKey, stakeVaultTokenAccount: PublicKey, nonce: BN): Promise<TransactionInstruction>;
346
346
  stake(params: {
347
347
  lockupName: string;
348
348
  vaultOwner?: Address;
package/dist/service.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ZebecVaultService = void 0;
4
+ const bignumber_js_1 = require("bignumber.js");
7
5
  const anchor_1 = require("@coral-xyz/anchor");
8
6
  const spl_token_1 = require("@solana/spl-token");
9
7
  const web3_js_1 = require("@solana/web3.js");
@@ -12,8 +10,6 @@ const solana_common_1 = require("@zebec-network/solana-common");
12
10
  const zebec_card_v2_sdk_1 = require("@zebec-network/zebec-card-v2-sdk");
13
11
  const zebec_stake_sdk_1 = require("@zebec-network/zebec-stake-sdk");
14
12
  const zebec_stream_sdk_1 = require("@zebec-network/zebec-stream-sdk");
15
- const assert_1 = __importDefault(require("assert"));
16
- const bignumber_js_1 = require("bignumber.js");
17
13
  const artifacts_1 = require("./artifacts");
18
14
  const errors_1 = require("./errors");
19
15
  const pda_1 = require("./pda");
@@ -355,7 +351,8 @@ class ZebecVaultService {
355
351
  const promises = params.addressLookupTables.map(async (lookupTable) => {
356
352
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(lookupTable));
357
353
  const lookupTableAccount = lookupTables.value;
358
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
354
+ if (!lookupTableAccount)
355
+ throw new Error("Lookup table account not found");
359
356
  return lookupTableAccount;
360
357
  });
361
358
  const accounts = await Promise.all(promises);
@@ -392,7 +389,8 @@ class ZebecVaultService {
392
389
  const promises = params.addressLookupTables.map(async (lookupTable) => {
393
390
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(lookupTable));
394
391
  const lookupTableAccount = lookupTables.value;
395
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
392
+ if (!lookupTableAccount)
393
+ throw new Error("Lookup table account not found");
396
394
  return lookupTableAccount;
397
395
  });
398
396
  const accounts = await Promise.all(promises);
@@ -419,7 +417,8 @@ class ZebecVaultService {
419
417
  }
420
418
  async getAllVaultsInfo() {
421
419
  const vaultAccount = this.vaultV1Program.idl.accounts.find((acc) => acc.name === "vault");
422
- (0, assert_1.default)(vaultAccount, "Vault account not found in IDL");
420
+ if (!vaultAccount)
421
+ throw new Error("Vault account not found in IDL");
423
422
  const accountInfos = await this.connection.getProgramAccounts(this.vaultV1ProgramId, {
424
423
  commitment: this.connection.commitment,
425
424
  filters: [
@@ -446,7 +445,8 @@ class ZebecVaultService {
446
445
  async getProposalsInfoOfVault(vaultAddress) {
447
446
  const vault = (0, anchor_1.translateAddress)(vaultAddress);
448
447
  const proposalAccount = this.vaultV1Program.idl.accounts.find((acc) => acc.name === "proposal");
449
- (0, assert_1.default)(proposalAccount, "Proposal account not found in IDL");
448
+ if (!proposalAccount)
449
+ throw new Error("Proposal account not found in IDL");
450
450
  const accountInfos = await this.connection.getProgramAccounts(this.vaultV1ProgramId, {
451
451
  commitment: this.connection.commitment,
452
452
  filters: [
@@ -653,7 +653,8 @@ class ZebecVaultService {
653
653
  }, []);
654
654
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.CARD_LOOKUP_TABLE_ADDRESS[this.network]));
655
655
  const lookupTableAccount = lookupTables.value;
656
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
656
+ if (!lookupTableAccount)
657
+ throw new Error("Lookup table account not found");
657
658
  const executeProposalDirectIx = await this.getExecuteProposalDirectInstruction(vaultOwner, actions, remainingAccounts);
658
659
  return this._createTransactionPayload(vaultOwner, [executeProposalDirectIx], [], [lookupTableAccount]);
659
660
  }
@@ -707,7 +708,8 @@ class ZebecVaultService {
707
708
  }, []);
708
709
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.CARD_LOOKUP_TABLE_ADDRESS[this.network]));
709
710
  const lookupTableAccount = lookupTables.value;
710
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
711
+ if (!lookupTableAccount)
712
+ throw new Error("Lookup table account not found");
711
713
  const executeProposalDirectIx = await this.getExecuteProposalDirectInstruction(vaultOwner, actions, remainingAccounts);
712
714
  return this._createTransactionPayload(vaultOwner, [executeProposalDirectIx], [], [lookupTableAccount]);
713
715
  }
@@ -816,7 +818,8 @@ class ZebecVaultService {
816
818
  addressLookupTableAccounts: addressLookupTableAccounts,
817
819
  });
818
820
  const swapInstruction = message.instructions.find((ix) => ix.programId.equals((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.JUPITER_AGGREGATOR_PROGRAM_ID)));
819
- (0, assert_1.default)(swapInstruction, "Swap instruction not found in the transaction message");
821
+ if (!swapInstruction)
822
+ throw new Error("Swap instruction not found in the transaction message");
820
823
  const otherIxs = message.instructions.filter((ix) => !ix.programId.equals((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.JUPITER_AGGREGATOR_PROGRAM_ID)) &&
821
824
  !ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId));
822
825
  const index = new anchor_1.BN(params.nextCardCounter.toString());
@@ -935,7 +938,8 @@ class ZebecVaultService {
935
938
  addressLookupTableAccounts: addressLookupTableAccounts,
936
939
  });
937
940
  const swapInstruction = message.instructions.find((ix) => ix.programId.equals((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.JUPITER_AGGREGATOR_PROGRAM_ID)));
938
- (0, assert_1.default)(swapInstruction, "Swap instruction not found in the transaction message");
941
+ if (!swapInstruction)
942
+ throw new Error("Swap instruction not found in the transaction message");
939
943
  const otherIxs = message.instructions.filter((ix) => !ix.programId.equals((0, anchor_1.translateAddress)(zebec_card_v2_sdk_1.JUPITER_AGGREGATOR_PROGRAM_ID)) &&
940
944
  !ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId));
941
945
  const index = new anchor_1.BN(params.nextCardCounter.toString());
@@ -1076,6 +1080,7 @@ class ZebecVaultService {
1076
1080
  const vaultOwner = (0, anchor_1.translateAddress)(params.vaultOwner);
1077
1081
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1078
1082
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1083
+ console.log("vaultSigner:", vaultSigner.toString());
1079
1084
  const receiver = (0, anchor_1.translateAddress)(params.receiver);
1080
1085
  const [receiverVault] = (0, pda_1.deriveUserVault)(receiver, this.vaultV1ProgramId);
1081
1086
  const [receiverVaultSigner] = (0, pda_1.deriveVaultSigner)(receiverVault, this.vaultV1ProgramId);
@@ -1094,6 +1099,7 @@ class ZebecVaultService {
1094
1099
  .times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals))
1095
1100
  .toFixed(0);
1096
1101
  const feeInfo = await (0, zebec_stream_sdk_1.getFeeInfoForStream)(streamToken, amount, streamTokenDecimals, this.network);
1102
+ console.debug("feeInfo:", feeInfo);
1097
1103
  const feeToken = (0, anchor_1.translateAddress)(feeInfo.feeToken.mintAddress);
1098
1104
  const feeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, feeToken);
1099
1105
  const parsedFeeAmount = feeInfo.feeAmountRaw;
@@ -1451,20 +1457,25 @@ class ZebecVaultService {
1451
1457
  })
1452
1458
  .instruction();
1453
1459
  }
1454
- async getUnstakeInstruction(feePayer, feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, nonce) {
1455
- return this.stakeProgram.methods
1460
+ async getUnstakeInstruction(feeVault, lockup, stakePda, rewardVault, stakeToken, rewardToken, stakeVault, vault, vaultOwner, vaultSigner, vaultSignerStakeAta, vaultSignerRewardAta, feeVaultTokenAccount, rewardVaultTokenAccount, stakeVaultTokenAccount, nonce) {
1461
+ return this.vaultV1Program.methods
1456
1462
  .unstakeZbcn(nonce)
1457
1463
  .accountsPartial({
1458
- feePayer,
1459
- feeVault,
1464
+ feeVaultTokenAccount,
1465
+ rewardVaultTokenAccount,
1466
+ stakeVaultTokenAccount,
1467
+ vault,
1468
+ vaultOwner,
1469
+ vaultSigner,
1460
1470
  rewardToken,
1471
+ vaultSignerStakeAta,
1472
+ vaultSignerRewardAta,
1473
+ feeVault,
1461
1474
  stakeToken,
1462
- staker,
1463
1475
  lockup,
1464
1476
  stakeVault,
1465
1477
  stakePda,
1466
1478
  rewardVault,
1467
- stakerTokenAccount,
1468
1479
  })
1469
1480
  .instruction();
1470
1481
  }
@@ -1522,7 +1533,8 @@ class ZebecVaultService {
1522
1533
  const ixFinal = await this.getExecuteProposalDirectInstruction(vaultOwner, actions, remainingAccounts);
1523
1534
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_stake_sdk_1.STAKE_LOOKUP_TABLE_ADDRESS[this.network]));
1524
1535
  const lookupTableAccount = lookupTables.value;
1525
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
1536
+ if (!lookupTableAccount)
1537
+ throw new Error("Lookup table account not found");
1526
1538
  return this._createTransactionPayload(vaultOwner, [ixFinal], [], [lookupTableAccount]);
1527
1539
  }
1528
1540
  async unstake(params) {
@@ -1534,7 +1546,6 @@ class ZebecVaultService {
1534
1546
  }
1535
1547
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1536
1548
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1537
- const feePayer = vaultOwner;
1538
1549
  const lockup = (0, zebec_stake_sdk_1.deriveLockupAddress)(params.lockupName, this.stakeProgramId);
1539
1550
  const lockupAccount = await this.stakeProgram.account.lockup.fetchNullable(lockup, this.connection.commitment);
1540
1551
  if (!lockupAccount) {
@@ -1544,29 +1555,20 @@ class ZebecVaultService {
1544
1555
  const rewardToken = lockupAccount.rewardToken.tokenAddress;
1545
1556
  const feeVault = lockupAccount.feeInfo.feeVault;
1546
1557
  const stakePda = (0, zebec_stake_sdk_1.deriveStakeAddress)(vaultSigner, lockup, params.nonce, this.stakeProgramId);
1558
+ console.log("StakePda:", stakePda.toString());
1547
1559
  const rewardVault = (0, zebec_stake_sdk_1.deriveRewardVaultAddress)(lockup, this.stakeProgramId);
1548
1560
  const stakeVault = (0, zebec_stake_sdk_1.deriveStakeVaultAddress)(lockup, this.stakeProgramId);
1549
- const stakerTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, vaultSigner, true);
1550
- const instruction = await this.getUnstakeInstruction(feePayer, feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, vaultSigner, stakerTokenAccount, new anchor_1.BN(params.nonce.toString()));
1551
- const actions = [(0, utils_1.transactionInstructionToPropoalAction)(instruction)];
1552
- const remainingAccounts = actions.reduce((acc, current) => {
1553
- const accounts = current.accountSpecs.map((spec) => ({
1554
- pubkey: spec.pubkey,
1555
- isSigner: spec.pubkey.equals(vaultSigner) ? false : spec.isSigner,
1556
- isWritable: spec.isWritable,
1557
- }));
1558
- acc.push(...accounts, {
1559
- isSigner: false,
1560
- isWritable: false,
1561
- pubkey: current.programId,
1562
- });
1563
- return acc;
1564
- }, []);
1565
- const ixFinal = await this.getExecuteProposalDirectInstruction(vaultOwner, actions, remainingAccounts);
1561
+ const vaultSignerStakeTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, vaultSigner, true);
1562
+ const vaultSignerRewardTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(rewardToken, vaultSigner, true);
1563
+ const feeVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, feeVault, true);
1564
+ const rewardVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(rewardToken, rewardVault, true);
1565
+ const stakeVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, stakeVault, true);
1566
+ const instruction = await this.getUnstakeInstruction(feeVault, lockup, stakePda, rewardVault, stakeToken, rewardToken, stakeVault, vault, vaultOwner, vaultSigner, vaultSignerStakeTokenAccount, vaultSignerRewardTokenAccount, feeVaultTokenAccount, rewardVaultTokenAccount, stakeVaultTokenAccount, new anchor_1.BN(params.nonce.toString()));
1566
1567
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_stake_sdk_1.STAKE_LOOKUP_TABLE_ADDRESS[this.network]));
1567
1568
  const lookupTableAccount = lookupTables.value;
1568
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
1569
- return this._createTransactionPayload(vaultOwner, [ixFinal], [], [lookupTableAccount]);
1569
+ if (!lookupTableAccount)
1570
+ throw new Error("Lookup table account not found");
1571
+ return this._createTransactionPayload(vaultOwner, [instruction], [], [lookupTableAccount]);
1570
1572
  }
1571
1573
  async getStakeUserNonceInfo(lockupName, vaultOwnerAddress, commitment) {
1572
1574
  const vaultOwner = (0, anchor_1.translateAddress)(vaultOwnerAddress);
package/package.json CHANGED
@@ -47,5 +47,5 @@
47
47
  "test:single": "ts-mocha -p ./tsconfig.json -t 1000000000"
48
48
  },
49
49
  "types": "dist/index.d.ts",
50
- "version": "5.2.4"
50
+ "version": "5.2.5"
51
51
  }