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

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
@@ -126,7 +126,7 @@ export declare class ZebecVaultService {
126
126
  }): Promise<TransactionInstruction>;
127
127
  getPauseResumeStreamInstruction(streamMetadata: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
128
128
  getCancelStreamInstruction(feePayer: PublicKey, otherParty: PublicKey, otherPartyAta: PublicKey, signer: PublicKey, signerAta: PublicKey, streamMetadata: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey): Promise<TransactionInstruction>;
129
- getWithdrawStreamInstruction(receiver: PublicKey, receiverAta: PublicKey, streamMetadata: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey, withdrawer: PublicKey, feePayer: PublicKey): Promise<TransactionInstruction>;
129
+ getWithdrawStreamInstruction(receiver: PublicKey, receiverAta: PublicKey, streamMetadata: PublicKey, streamConfig: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey, withdrawer: PublicKey, feePayer: PublicKey): Promise<TransactionInstruction>;
130
130
  getChangeStreamReceiverInstruction(streamMetadata: PublicKey, newRecipient: PublicKey, signer: PublicKey): Promise<TransactionInstruction>;
131
131
  getTransferFeesForStreamInstruction(feeVault: PublicKey, tokenMint: PublicKey, vaultOwner: PublicKey, feeVaultTokenAccount: PublicKey, vault: PublicKey, vaultSigner: PublicKey, vaultSignerTokenAccount: PublicKey, data: {
132
132
  decimals: number;
@@ -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,7 +1,4 @@
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;
7
4
  const anchor_1 = require("@coral-xyz/anchor");
@@ -12,7 +9,6 @@ const solana_common_1 = require("@zebec-network/solana-common");
12
9
  const zebec_card_v2_sdk_1 = require("@zebec-network/zebec-card-v2-sdk");
13
10
  const zebec_stake_sdk_1 = require("@zebec-network/zebec-stake-sdk");
14
11
  const zebec_stream_sdk_1 = require("@zebec-network/zebec-stream-sdk");
15
- const assert_1 = __importDefault(require("assert"));
16
12
  const bignumber_js_1 = require("bignumber.js");
17
13
  const artifacts_1 = require("./artifacts");
18
14
  const errors_1 = require("./errors");
@@ -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());
@@ -1034,7 +1038,7 @@ class ZebecVaultService {
1034
1038
  })
1035
1039
  .instruction();
1036
1040
  }
1037
- async getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer, feePayer) {
1041
+ async getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamConfig, streamToken, streamVault, streamVaultAta, withdrawer, feePayer) {
1038
1042
  return this.streamProgram.methods
1039
1043
  .withdrawStream()
1040
1044
  .accountsPartial({
@@ -1046,6 +1050,7 @@ class ZebecVaultService {
1046
1050
  receiverAta,
1047
1051
  withdrawer,
1048
1052
  feePayer,
1053
+ streamConfig,
1049
1054
  })
1050
1055
  .instruction();
1051
1056
  }
@@ -1076,6 +1081,7 @@ class ZebecVaultService {
1076
1081
  const vaultOwner = (0, anchor_1.translateAddress)(params.vaultOwner);
1077
1082
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1078
1083
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1084
+ console.log("vaultSigner:", vaultSigner.toString());
1079
1085
  const receiver = (0, anchor_1.translateAddress)(params.receiver);
1080
1086
  const [receiverVault] = (0, pda_1.deriveUserVault)(receiver, this.vaultV1ProgramId);
1081
1087
  const [receiverVaultSigner] = (0, pda_1.deriveVaultSigner)(receiverVault, this.vaultV1ProgramId);
@@ -1094,6 +1100,7 @@ class ZebecVaultService {
1094
1100
  .times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals))
1095
1101
  .toFixed(0);
1096
1102
  const feeInfo = await (0, zebec_stream_sdk_1.getFeeInfoForStream)(streamToken, amount, streamTokenDecimals, this.network);
1103
+ console.debug("feeInfo:", feeInfo);
1097
1104
  const feeToken = (0, anchor_1.translateAddress)(feeInfo.feeToken.mintAddress);
1098
1105
  const feeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, feeToken);
1099
1106
  const parsedFeeAmount = feeInfo.feeAmountRaw;
@@ -1363,6 +1370,7 @@ class ZebecVaultService {
1363
1370
  }
1364
1371
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1365
1372
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1373
+ const [streamConfig] = (0, zebec_stream_sdk_1.deriveStreamConfigPda)(params.streamConfigName, this.streamProgramId);
1366
1374
  const feePayer = vaultOwner;
1367
1375
  const withdrawer = vaultSigner;
1368
1376
  const streamMetadata = (0, anchor_1.translateAddress)(params.streamMetadata);
@@ -1371,7 +1379,7 @@ class ZebecVaultService {
1371
1379
  const vaultSignerAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, vaultSigner, true);
1372
1380
  const [streamVault] = (0, zebec_stream_sdk_1.deriveStreamVaultPda)(streamMetadata, this.streamProgramId);
1373
1381
  const streamVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, streamVault, true);
1374
- const ix = await this.getWithdrawStreamInstruction(vaultSigner, vaultSignerAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer, feePayer);
1382
+ const ix = await this.getWithdrawStreamInstruction(vaultSigner, vaultSignerAta, streamMetadata, streamConfig, streamToken, streamVault, streamVaultAta, withdrawer, feePayer);
1375
1383
  const actions = [(0, utils_1.transactionInstructionToPropoalAction)(ix)];
1376
1384
  const remainingAccounts = actions.reduce((acc, current) => {
1377
1385
  const accounts = current.accountSpecs.map((spec) => ({
@@ -1451,20 +1459,25 @@ class ZebecVaultService {
1451
1459
  })
1452
1460
  .instruction();
1453
1461
  }
1454
- async getUnstakeInstruction(feePayer, feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, nonce) {
1455
- return this.stakeProgram.methods
1462
+ async getUnstakeInstruction(feeVault, lockup, stakePda, rewardVault, stakeToken, rewardToken, stakeVault, vault, vaultOwner, vaultSigner, vaultSignerStakeAta, vaultSignerRewardAta, feeVaultTokenAccount, rewardVaultTokenAccount, stakeVaultTokenAccount, nonce) {
1463
+ return this.vaultV1Program.methods
1456
1464
  .unstakeZbcn(nonce)
1457
1465
  .accountsPartial({
1458
- feePayer,
1459
- feeVault,
1466
+ feeVaultTokenAccount,
1467
+ rewardVaultTokenAccount,
1468
+ stakeVaultTokenAccount,
1469
+ vault,
1470
+ vaultOwner,
1471
+ vaultSigner,
1460
1472
  rewardToken,
1473
+ vaultSignerStakeAta,
1474
+ vaultSignerRewardAta,
1475
+ feeVault,
1461
1476
  stakeToken,
1462
- staker,
1463
1477
  lockup,
1464
1478
  stakeVault,
1465
1479
  stakePda,
1466
1480
  rewardVault,
1467
- stakerTokenAccount,
1468
1481
  })
1469
1482
  .instruction();
1470
1483
  }
@@ -1522,7 +1535,8 @@ class ZebecVaultService {
1522
1535
  const ixFinal = await this.getExecuteProposalDirectInstruction(vaultOwner, actions, remainingAccounts);
1523
1536
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_stake_sdk_1.STAKE_LOOKUP_TABLE_ADDRESS[this.network]));
1524
1537
  const lookupTableAccount = lookupTables.value;
1525
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
1538
+ if (!lookupTableAccount)
1539
+ throw new Error("Lookup table account not found");
1526
1540
  return this._createTransactionPayload(vaultOwner, [ixFinal], [], [lookupTableAccount]);
1527
1541
  }
1528
1542
  async unstake(params) {
@@ -1534,7 +1548,6 @@ class ZebecVaultService {
1534
1548
  }
1535
1549
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1536
1550
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1537
- const feePayer = vaultOwner;
1538
1551
  const lockup = (0, zebec_stake_sdk_1.deriveLockupAddress)(params.lockupName, this.stakeProgramId);
1539
1552
  const lockupAccount = await this.stakeProgram.account.lockup.fetchNullable(lockup, this.connection.commitment);
1540
1553
  if (!lockupAccount) {
@@ -1544,29 +1557,20 @@ class ZebecVaultService {
1544
1557
  const rewardToken = lockupAccount.rewardToken.tokenAddress;
1545
1558
  const feeVault = lockupAccount.feeInfo.feeVault;
1546
1559
  const stakePda = (0, zebec_stake_sdk_1.deriveStakeAddress)(vaultSigner, lockup, params.nonce, this.stakeProgramId);
1560
+ console.log("StakePda:", stakePda.toString());
1547
1561
  const rewardVault = (0, zebec_stake_sdk_1.deriveRewardVaultAddress)(lockup, this.stakeProgramId);
1548
1562
  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);
1563
+ const vaultSignerStakeTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, vaultSigner, true);
1564
+ const vaultSignerRewardTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(rewardToken, vaultSigner, true);
1565
+ const feeVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, feeVault, true);
1566
+ const rewardVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(rewardToken, rewardVault, true);
1567
+ const stakeVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, stakeVault, true);
1568
+ 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
1569
  const lookupTables = await this.connection.getAddressLookupTable((0, anchor_1.translateAddress)(zebec_stake_sdk_1.STAKE_LOOKUP_TABLE_ADDRESS[this.network]));
1567
1570
  const lookupTableAccount = lookupTables.value;
1568
- (0, assert_1.default)(lookupTableAccount, "Lookup table account not found");
1569
- return this._createTransactionPayload(vaultOwner, [ixFinal], [], [lookupTableAccount]);
1571
+ if (!lookupTableAccount)
1572
+ throw new Error("Lookup table account not found");
1573
+ return this._createTransactionPayload(vaultOwner, [instruction], [], [lookupTableAccount]);
1570
1574
  }
1571
1575
  async getStakeUserNonceInfo(lockupName, vaultOwnerAddress, commitment) {
1572
1576
  const vaultOwner = (0, anchor_1.translateAddress)(vaultOwnerAddress);
package/dist/types.d.ts CHANGED
@@ -224,6 +224,7 @@ export type ChangeStreamReceiverParams = {
224
224
  };
225
225
  export type WithdrawStreamParams = {
226
226
  streamMetadata: Address;
227
+ streamConfigName: string;
227
228
  vaultOwner?: Address;
228
229
  };
229
230
  export type StakeInstructionData = {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "@zebec-network/solana-common": "^2.3.1",
10
10
  "@zebec-network/zebec-card-v2-sdk": "^2.6.0",
11
11
  "@zebec-network/zebec-stake-sdk": "^1.3.1",
12
- "@zebec-network/zebec-stream-sdk": "^3.3.0",
12
+ "@zebec-network/zebec-stream-sdk": "^3.3.1",
13
13
  "bignumber.js": "^9.3.1",
14
14
  "buffer": "^6.0.3"
15
15
  },
@@ -43,9 +43,10 @@
43
43
  "build": "npm run clean && tsc",
44
44
  "clean": "rimraf ./dist",
45
45
  "format": "npx @biomejs/biome format --write ",
46
- "test": "ts-mocha -p ./tsconfig.json -t 1000000000 test/**/*.test.ts",
46
+ "prepare": "npm run build",
47
+ "test": "ts-mocha -p ./tsconfig.json -b -t 1000000000 test/**/*.test.ts",
47
48
  "test:single": "ts-mocha -p ./tsconfig.json -t 1000000000"
48
49
  },
49
50
  "types": "dist/index.d.ts",
50
- "version": "5.2.4"
51
- }
51
+ "version": "5.3.0"
52
+ }