@symmetry-hq/temp-v3-sdk 0.0.32 → 0.0.33

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.
package/dist/src/index.js CHANGED
@@ -525,9 +525,8 @@ class SymmetryCore {
525
525
  }
526
526
  buyBasketTx(params) {
527
527
  return __awaiter(this, void 0, void 0, function* () {
528
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
528
+ var _a, _b, _c, _d, _e, _f;
529
529
  let buyer = new web3_js_1.PublicKey(params.buyer);
530
- let basketMint = new web3_js_1.PublicKey(params.basket_mint);
531
530
  let contributions = params.contributions.map(contribution => ({
532
531
  mint: new web3_js_1.PublicKey(contribution.mint),
533
532
  amount: new anchor_1.BN(contribution.amount),
@@ -537,16 +536,15 @@ class SymmetryCore {
537
536
  let executionStartTime = (_c = params.execution_start_time) !== null && _c !== void 0 ? _c : 0;
538
537
  let minBountyAmount = (_d = params.min_bounty_amount) !== null && _d !== void 0 ? _d : 0;
539
538
  let maxBountyAmount = (_e = params.max_bounty_amount) !== null && _e !== void 0 ? _e : 0;
540
- const basket = (0, pda_1.getBasketState)(basketMint);
541
- const rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, buyer);
539
+ const basket = yield this.fetchBasket((0, pda_1.getBasketState)(new web3_js_1.PublicKey(params.basket_mint)).toBase58());
540
+ const rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, buyer);
542
541
  let rentPayer = (0, pda_1.getRentPayerPda)();
543
- let accountInfos = yield (0, txUtils_1.getMultipleAccountsInfoBatched)(this.sdkParams.connection, [rentPayer, basket]);
542
+ let renPayerAi = yield this.sdkParams.connection.getAccountInfo(rentPayer);
544
543
  let rebalanceIntentRentPayer = buyer;
545
544
  // TODO: check actual lamports required for rent
546
- if (((_g = (_f = accountInfos.get(rentPayer.toBase58())) === null || _f === void 0 ? void 0 : _f.lamports) !== null && _g !== void 0 ? _g : 0) > 0)
545
+ if ((_f = renPayerAi === null || renPayerAi === void 0 ? void 0 : renPayerAi.lamports) !== null && _f !== void 0 ? _f : 0 > 0)
547
546
  rebalanceIntentRentPayer = rentPayer;
548
- let basketState = basket_1.BasketLayout.decode((_j = (_h = accountInfos.get(basket.toBase58())) === null || _h === void 0 ? void 0 : _h.data.slice(8)) !== null && _j !== void 0 ? _j : Buffer.alloc(0));
549
- let bountyMint = basketState.settings.bountyMint;
547
+ let bountyMint = basket.settings.bountyMint;
550
548
  let txBatchData = { batches: [
551
549
  [{
552
550
  payer: buyer,
@@ -554,14 +552,14 @@ class SymmetryCore {
554
552
  (0, rebalanceIntent_1.createRebalanceIntentIx)({
555
553
  signer: buyer,
556
554
  owner: buyer,
557
- basket: basket,
555
+ basket: basket.ownAddress,
558
556
  }),
559
557
  (0, rebalanceIntent_1.resizeRebalanceIntentIx)(rebalanceIntent),
560
558
  (0, rebalanceIntent_1.initRebalanceIntentIx)({
561
559
  signer: buyer,
562
560
  owner: buyer,
563
- basket,
564
- basketTokenMint: basketMint,
561
+ basket: basket.ownAddress,
562
+ basketTokenMint: basket.mint,
565
563
  rebalanceIntentRentPayer: rebalanceIntentRentPayer,
566
564
  bountyMint: bountyMint,
567
565
  rebalanceType: rebalanceIntent_2.RebalanceType.Deposit,
@@ -579,7 +577,7 @@ class SymmetryCore {
579
577
  }],
580
578
  (0, deposit_1.depositTokensIx)({
581
579
  owner: buyer,
582
- basket: basket,
580
+ basket: basket.ownAddress,
583
581
  contributions: contributions,
584
582
  }).map(ix => {
585
583
  return {
@@ -597,11 +595,11 @@ class SymmetryCore {
597
595
  instructions: [
598
596
  (0, deposit_1.lockDepositsIx)({
599
597
  owner: buyer,
600
- basket: basket,
598
+ basket: basket.ownAddress,
601
599
  }),
602
600
  executionStartTime == 0 ? (0, priceUpdate_1.startPriceUpdatesIx)({
603
601
  keeper: buyer,
604
- basket: basket,
602
+ basket: basket.ownAddress,
605
603
  rebalanceIntent: rebalanceIntent,
606
604
  }) : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
607
605
  web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
@@ -746,6 +744,7 @@ class SymmetryCore {
746
744
  return __awaiter(this, void 0, void 0, function* () {
747
745
  let keeper = new web3_js_1.PublicKey(params.keeper);
748
746
  let rebalanceIntent = new web3_js_1.PublicKey(params.rebalance_intent);
747
+ let basketRebalanceIntent = (0, pda_1.getRebalanceIntentPda)(new web3_js_1.PublicKey(params.basket), new web3_js_1.PublicKey(params.basket));
749
748
  let basket = yield this.fetchBasket(params.basket);
750
749
  let ixs = [];
751
750
  let batchSize = 7;
@@ -770,6 +769,7 @@ class SymmetryCore {
770
769
  }
771
770
  while (tokenIndices.length < 20)
772
771
  tokenIndices.push(0);
772
+ // TODO: in last instruction we should include performance fee accounts
773
773
  ixs.push((0, priceUpdate_1.updateTokenPricesIx)({
774
774
  keeper: keeper,
775
775
  basket: basket.ownAddress,
@@ -778,6 +778,7 @@ class SymmetryCore {
778
778
  lookupTable1: basket.lookupTables.active[1],
779
779
  tokenIndices: tokenIndices,
780
780
  additionalOracleAccounts: allKeys,
781
+ basketRebalanceIntent: basket.settings.activeRebalance.eq(new anchor_1.BN(0)) ? undefined : basketRebalanceIntent,
781
782
  }));
782
783
  }
783
784
  let txBatchData = { batches: [ixs.map(ix => ({
@@ -818,17 +819,22 @@ class SymmetryCore {
818
819
  };
819
820
  let ixWithdraw = (0, flashSwap_1.flashWithdrawIx)(flashParams);
820
821
  let ixDeposit = (0, flashSwap_1.flashDepositIx)(flashParams);
822
+ let ixs = [
823
+ (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintIn), keeper, mintIn),
824
+ (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintOut), keeper, mintOut),
825
+ ixWithdraw,
826
+ ];
827
+ if (params.jup_swap_ix) {
828
+ ixs.push(params.jup_swap_ix);
829
+ }
830
+ ixs = ixs.concat([
831
+ ixDeposit,
832
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
833
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
834
+ ]);
821
835
  let txBatchData = { batches: [[{
822
836
  payer: keeper,
823
- instructions: [
824
- (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintIn), keeper, mintIn),
825
- (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintOut), keeper, mintOut),
826
- ixWithdraw,
827
- params.jup_swap_ix ? params.jup_swap_ix : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
828
- ixDeposit,
829
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
830
- web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
831
- ],
837
+ instructions: ixs,
832
838
  lookupTables: [],
833
839
  }]] };
834
840
  let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
@@ -841,11 +847,13 @@ class SymmetryCore {
841
847
  let keeper = new web3_js_1.PublicKey(params.keeper);
842
848
  let rebalanceIntent = yield this.fetchRebalanceIntent(params.rebalance_intent);
843
849
  let basket = yield this.fetchBasket(rebalanceIntent.basket.toBase58());
850
+ let basketRebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, rebalanceIntent.owner);
844
851
  let ix = (0, deposit_1.mintBasketIx)({
845
852
  keeper: keeper,
846
853
  basket: basket.ownAddress,
847
854
  basketTokenMint: basket.mint,
848
855
  buyer: rebalanceIntent.owner,
856
+ basketRebalanceIntent: basket.settings.activeRebalance.eq(new anchor_1.BN(0)) ? undefined : basketRebalanceIntent,
849
857
  });
850
858
  let txBatchData = { batches: [[{
851
859
  payer: keeper,
@@ -9,6 +9,7 @@ const pda_1 = require("../pda");
9
9
  const FLASH_WITHDRAW_DISCRIMINATOR = Buffer.from([164, 84, 46, 132, 94, 220, 214, 156]);
10
10
  const FLASH_DEPOSIT_DISCRIMINATOR = Buffer.from([21, 4, 89, 84, 131, 84, 128, 21]);
11
11
  function flashWithdrawIx(params) {
12
+ var _a, _b;
12
13
  const { keeper, basket, mintIn, mintOut, amountIn, amountOut, mode } = params;
13
14
  let keeperFromATA = (0, pda_1.getAta)(keeper, mintIn);
14
15
  let keeperToATA = (0, pda_1.getAta)(keeper, mintOut);
@@ -17,8 +18,8 @@ function flashWithdrawIx(params) {
17
18
  const keys = [
18
19
  { pubkey: params.keeper, isWritable: true, isSigner: true },
19
20
  { pubkey: params.basket, isWritable: true, isSigner: false },
20
- { pubkey: params.rebalanceIntent ? params.rebalanceIntent : constants_1.BASKETS_V3_PROGRAM_ID, isWritable: params.rebalanceIntent ? true : false, isSigner: false },
21
- { pubkey: params.intent ? params.intent : constants_1.BASKETS_V3_PROGRAM_ID, isWritable: params.intent ? true : false, isSigner: false },
21
+ { pubkey: (_a = params.rebalanceIntent) !== null && _a !== void 0 ? _a : constants_1.BASKETS_V3_PROGRAM_ID, isWritable: params.rebalanceIntent ? true : false, isSigner: false },
22
+ { pubkey: (_b = params.intent) !== null && _b !== void 0 ? _b : constants_1.BASKETS_V3_PROGRAM_ID, isWritable: params.intent ? true : false, isSigner: false },
22
23
  { pubkey: params.mintIn, isWritable: false, isSigner: false },
23
24
  { pubkey: params.mintOut, isWritable: false, isSigner: false },
24
25
  { pubkey: keeperFromATA, isWritable: true, isSigner: false },
@@ -33,7 +34,7 @@ function flashWithdrawIx(params) {
33
34
  const discriminator = FLASH_WITHDRAW_DISCRIMINATOR;
34
35
  const amountInBuffer = Buffer.from(amountIn.toArray("le", 8));
35
36
  const amountOutBuffer = Buffer.from(amountOut.toArray("le", 8));
36
- const modeBuffer = mode ? Buffer.from([mode]) : Buffer.from([]);
37
+ const modeBuffer = Buffer.from([mode !== null && mode !== void 0 ? mode : 0]);
37
38
  const data = Buffer.concat([discriminator, amountInBuffer, amountOutBuffer, modeBuffer]);
38
39
  return new web3_js_1.TransactionInstruction({
39
40
  keys,
@@ -9,6 +9,7 @@ export declare function updateTokenPricesIx(params: {
9
9
  keeper: PublicKey;
10
10
  basket: PublicKey;
11
11
  rebalanceIntent: PublicKey;
12
+ basketRebalanceIntent?: PublicKey;
12
13
  lookupTable0: PublicKey;
13
14
  lookupTable1: PublicKey;
14
15
  tokenIndices: number[];
@@ -16,6 +16,7 @@ function startPriceUpdatesIx(params) {
16
16
  { pubkey: params.keeper, isSigner: true, isWritable: true },
17
17
  { pubkey: params.basket, isSigner: false, isWritable: true },
18
18
  { pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
19
+ { pubkey: (0, pda_1.getGlobalConfigPda)(), isSigner: false, isWritable: false },
19
20
  ];
20
21
  const data = START_PRICE_UPDATES_DISCRIMINATOR;
21
22
  return new web3_js_1.TransactionInstruction({
@@ -26,6 +27,7 @@ function startPriceUpdatesIx(params) {
26
27
  }
27
28
  ;
28
29
  function updateTokenPricesIx(params) {
30
+ var _a;
29
31
  let globalConfig = (0, pda_1.getGlobalConfigPda)();
30
32
  const tokenIndices = params.tokenIndices.slice(0, 20);
31
33
  while (tokenIndices.length < 20) {
@@ -44,6 +46,7 @@ function updateTokenPricesIx(params) {
44
46
  { pubkey: constants_1.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT, isSigner: false, isWritable: true },
45
47
  { pubkey: params.lookupTable0, isSigner: false, isWritable: true },
46
48
  { pubkey: params.lookupTable1, isSigner: false, isWritable: true },
49
+ { pubkey: (_a = params.basketRebalanceIntent) !== null && _a !== void 0 ? _a : constants_1.BASKETS_V3_PROGRAM_ID, isSigner: false, isWritable: params.basketRebalanceIntent ? true : false },
47
50
  ];
48
51
  // remaining accounts
49
52
  keys.push(...params.additionalOracleAccounts.map((pubkey) => ({ pubkey, isSigner: false, isWritable: false })));
@@ -16,4 +16,5 @@ export declare function mintBasketIx(params: {
16
16
  basket: PublicKey;
17
17
  basketTokenMint: PublicKey;
18
18
  buyer: PublicKey;
19
+ basketRebalanceIntent?: PublicKey;
19
20
  }): TransactionInstruction;
@@ -64,6 +64,7 @@ function lockDepositsIx(params) {
64
64
  });
65
65
  }
66
66
  function mintBasketIx(params) {
67
+ var _a;
67
68
  const { keeper, basket, basketTokenMint, buyer } = params;
68
69
  let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, buyer);
69
70
  let basketFees = (0, pda_1.getBasketFeesPda)(basket);
@@ -80,6 +81,7 @@ function mintBasketIx(params) {
80
81
  { pubkey: globalConfig, isWritable: false, isSigner: false },
81
82
  { pubkey: basketFees, isWritable: true, isSigner: false },
82
83
  { pubkey: basketFeesAta, isWritable: true, isSigner: false },
84
+ { pubkey: (_a = params.basketRebalanceIntent) !== null && _a !== void 0 ? _a : constants_1.BASKETS_V3_PROGRAM_ID, isWritable: params.basketRebalanceIntent ? true : false, isSigner: false },
83
85
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
84
86
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
85
87
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
@@ -166,14 +166,14 @@ function sendVersionedTransaction(connection, tx, blockhash, lastValidBlockHeigh
166
166
  blockhash,
167
167
  lastValidBlockHeight,
168
168
  signature: txId,
169
- }, "confirmed").then((res) => confirmation = res);
170
- let iterations = 15;
169
+ }, "confirmed").catch(() => null).then((res) => confirmation = res);
170
+ let iterations = 10;
171
171
  while (confirmation === null && result === null && iterations > 0) {
172
- yield delay(2500);
172
+ yield delay(1000);
173
173
  result = yield connection.getTransaction(txId, {
174
174
  commitment: "confirmed",
175
175
  maxSupportedTransactionVersion: 0,
176
- });
176
+ }).catch(() => null);
177
177
  if (result && result.meta && ((_a = result.meta) === null || _a === void 0 ? void 0 : _a.err)) {
178
178
  console.log(result.meta.err);
179
179
  throw new Error(txId);
@@ -262,6 +262,7 @@ function signTxPayloadBatchSequence(wallet, txPayloadBatchSequence) {
262
262
  }
263
263
  function sendTxPayloadBatchSequence(connection_1, txPayloadBatchSequence_1) {
264
264
  return __awaiter(this, arguments, void 0, function* (connection, txPayloadBatchSequence, simulateTransactions = false) {
265
+ var _a, _b;
265
266
  let txs = [];
266
267
  for (const batch of txPayloadBatchSequence.batches) {
267
268
  let batchTxs = [];
@@ -270,7 +271,7 @@ function sendTxPayloadBatchSequence(connection_1, txPayloadBatchSequence_1) {
270
271
  txs.push(batchTxs);
271
272
  }
272
273
  return yield sendVersionedTxs(connection, {
273
- blockhash: txPayloadBatchSequence.batches[0].transactions[0].recent_blockhash,
274
+ blockhash: (_b = (_a = txPayloadBatchSequence.batches[0].transactions[0]) === null || _a === void 0 ? void 0 : _a.recent_blockhash) !== null && _b !== void 0 ? _b : "",
274
275
  lastValidBlockHeight: 0,
275
276
  batches: txs,
276
277
  }, simulateTransactions);
package/dist/test.js CHANGED
@@ -12,10 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const web3_js_1 = require("@solana/web3.js");
13
13
  const anchor_1 = require("@coral-xyz/anchor");
14
14
  const src_1 = require("./src");
15
+ const pda_1 = require("./src/instructions/pda");
16
+ const constants_1 = require("./src/constants");
15
17
  let kp = Array.from(web3_js_1.Keypair.generate().secretKey);
16
18
  let connection = new web3_js_1.Connection("https://api.devnet.solana.com");
17
19
  function testStates() {
18
20
  return __awaiter(this, void 0, void 0, function* () {
21
+ var _a;
19
22
  return;
20
23
  let wallet = new anchor_1.Wallet(web3_js_1.Keypair.fromSecretKey(new Uint8Array(kp)));
21
24
  console.log(wallet.publicKey.toBase58());
@@ -30,7 +33,13 @@ function testStates() {
30
33
  let basket = yield sdk.fetchBasket("GrBFFvtdRL25o7gcRnV1kGvz1Qc7iscUmDp1ZvyBSyUa");
31
34
  basket = yield sdk.loadBasketPrice(basket);
32
35
  console.log(basket.formatted);
33
- return;
36
+ let allBaskets = yield sdk.fetchAllBaskets();
37
+ console.log(allBaskets.length);
38
+ for (let basket of allBaskets) {
39
+ basket = yield sdk.loadBasketPrice(basket);
40
+ console.log(basket.ownAddress.toBase58(), (_a = basket.formatted) === null || _a === void 0 ? void 0 : _a.start_price);
41
+ }
42
+ // return;
34
43
  let tests = {
35
44
  createGlobalConfig: false, // TESTED
36
45
  editGlobalConfig: false, // TESTED
@@ -49,22 +58,23 @@ function testStates() {
49
58
  editAddTokenDelay: false, // NOT TESTED
50
59
  editUpdateWeightsDelay: false, // NOT TESTED
51
60
  editMakeDirectSwapDelay: false, // NOT TESTED
52
- addOrEditToken: false, // NOT TESTED
61
+ addOrEditToken: false, // TESTED
53
62
  updateWeights: false, // NOT TESTED
54
63
  makeDirectSwap: false, // NOT TESTED
55
64
  executeIntent: false, // NOT TESTED
56
- buyBasket: false, // NOT TESTED
57
- depositTokens: false, // NOT TESTED
58
- lockDeposits: false, // NOT TESTED
65
+ buyBasket: false, // TESTED
66
+ depositTokens: false, // TESTED
67
+ lockDeposits: false, // TESTED
59
68
  sellBasket: false, // NOT TESTED
60
69
  rebalanceBasket: false, // NOT TESTED
61
70
  rebalanceBasketCustom: false, // NOT TESTED
62
- startPriceUpdates: false, // NOT TESTED
63
- updateTokenPrices: false, // NOT TESTED
71
+ startPriceUpdates: false, // TESTED
72
+ updateTokenPrices: false, // TESTED
64
73
  updateTokenPricesCustom: false, // NOT TESTED
65
- rebalanceSwap: false, // NOT TESTED
66
- redeemTokens: false, // NOT TESTED
67
- claimBounty: false, // NOT TESTED
74
+ rebalanceSwap: false, // TESTED
75
+ mintBasket: false, // TESTED
76
+ redeemTokens: false, // TESTED
77
+ claimBounty: false, // TESTED
68
78
  };
69
79
  if (tests.createBasket) {
70
80
  let createBasketTx = yield sdk.createBasketTx({
@@ -243,14 +253,14 @@ function testStates() {
243
253
  active: true,
244
254
  min_oracles_thresh: 1,
245
255
  min_conf_bps: 100,
246
- conf_thresh_bps: 100,
256
+ conf_thresh_bps: 200,
247
257
  conf_multiplier: 1,
248
258
  oracles: [
249
259
  {
250
260
  oracle_type: "pyth",
251
261
  account_lut_id: 0,
252
262
  account_lut_index: 0,
253
- account: "So11111111111111111111111111111111111111112",
263
+ account: constants_1.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT.toBase58(),
254
264
  num_required_accounts: 1,
255
265
  weight: 100,
256
266
  is_required: true,
@@ -258,7 +268,7 @@ function testStates() {
258
268
  volatility_thresh_bps: 100,
259
269
  max_slippage_bps: 100,
260
270
  min_liquidity: 100,
261
- staleness_thresh: 100,
271
+ staleness_thresh: 10000,
262
272
  staleness_conf_rate_bps: 100,
263
273
  token_decimals: 9,
264
274
  twap_seconds_ago: 100,
@@ -305,6 +315,71 @@ function testStates() {
305
315
  let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
306
316
  console.log(res);
307
317
  }
318
+ if (tests.buyBasket) {
319
+ let tx = yield sdk.buyBasketTx({
320
+ buyer: wallet.publicKey.toBase58(),
321
+ basket_mint: basket.mint.toBase58(),
322
+ contributions: [
323
+ { mint: "So11111111111111111111111111111111111111112", amount: 0 },
324
+ { mint: "USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT", amount: 20000000 },
325
+ ],
326
+ });
327
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
328
+ console.log(res);
329
+ }
330
+ if (tests.updateTokenPrices) {
331
+ let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, wallet.publicKey);
332
+ let tx = yield sdk.updateTokenPricesTx({
333
+ keeper: wallet.publicKey.toBase58(),
334
+ basket: basket.ownAddress.toBase58(),
335
+ rebalance_intent: rebalanceIntent.toBase58(),
336
+ });
337
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
338
+ console.log(res);
339
+ }
340
+ if (tests.rebalanceSwap) {
341
+ let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, wallet.publicKey);
342
+ let tx = yield sdk.flashSwapTx({
343
+ keeper: wallet.publicKey.toBase58(),
344
+ basket: basket.ownAddress.toBase58(),
345
+ rebalance_intent: rebalanceIntent.toBase58(),
346
+ mint_in: "So11111111111111111111111111111111111111112",
347
+ mint_out: "USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT",
348
+ amount_in: 50000000,
349
+ amount_out: 1000000,
350
+ mode: 2,
351
+ });
352
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
353
+ console.log(res);
354
+ }
355
+ if (tests.mintBasket) {
356
+ let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, wallet.publicKey);
357
+ let tx = yield sdk.mintTx({
358
+ keeper: wallet.publicKey.toBase58(),
359
+ rebalance_intent: rebalanceIntent.toBase58(),
360
+ });
361
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
362
+ console.log(res);
363
+ return;
364
+ }
365
+ if (tests.redeemTokens) {
366
+ let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, wallet.publicKey);
367
+ let tx = yield sdk.redeemTokensTx({
368
+ keeper: wallet.publicKey.toBase58(),
369
+ rebalance_intent: rebalanceIntent.toBase58(),
370
+ });
371
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
372
+ console.log(res);
373
+ }
374
+ if (tests.claimBounty) {
375
+ let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, wallet.publicKey);
376
+ let tx = yield sdk.claimBountyTx({
377
+ keeper: wallet.publicKey.toBase58(),
378
+ rebalance_intent: rebalanceIntent.toBase58(),
379
+ });
380
+ let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
381
+ console.log(res);
382
+ }
308
383
  if (tests.editGlobalConfig) {
309
384
  let editGlobalConfigTx = yield sdk.editGlobalConfigTx({
310
385
  signer: wallet.publicKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symmetry-hq/temp-v3-sdk",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "Symmetry Baskets V3 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import Decimal from 'decimal.js';
2
2
 
3
3
  import { BN } from '@coral-xyz/anchor';
4
- import { createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction } from '@solana/spl-token';
4
+ import { createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createSyncNativeInstruction } from '@solana/spl-token';
5
5
  import {
6
6
  ComputeBudgetProgram, Connection, Keypair, PublicKey, TransactionInstruction,
7
7
  TransactionSignature
@@ -571,7 +571,6 @@ export class SymmetryCore {
571
571
  max_bounty_amount?: number,
572
572
  }): Promise<TxPayloadBatchSequence> {
573
573
  let buyer = new PublicKey(params.buyer);
574
- let basketMint = new PublicKey(params.basket_mint);
575
574
  let contributions = params.contributions.map(contribution => ({
576
575
  mint: new PublicKey(contribution.mint),
577
576
  amount: new BN(contribution.amount),
@@ -582,22 +581,18 @@ export class SymmetryCore {
582
581
  let minBountyAmount = params.min_bounty_amount ?? 0;
583
582
  let maxBountyAmount = params.max_bounty_amount ?? 0;
584
583
 
585
- const basket = getBasketState(basketMint);
586
- const rebalanceIntent = getRebalanceIntentPda(basket, buyer);
584
+ const basket = await this.fetchBasket(getBasketState(new PublicKey(params.basket_mint)).toBase58());
585
+ const rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, buyer);
587
586
 
588
587
  let rentPayer = getRentPayerPda();
589
588
 
590
- let accountInfos = await getMultipleAccountsInfoBatched(
591
- this.sdkParams.connection,
592
- [rentPayer, basket]
593
- );
589
+ let renPayerAi = await this.sdkParams.connection.getAccountInfo(rentPayer);
594
590
 
595
591
  let rebalanceIntentRentPayer = buyer;
596
592
  // TODO: check actual lamports required for rent
597
- if ((accountInfos.get(rentPayer.toBase58())?.lamports ?? 0) > 0)
593
+ if (renPayerAi?.lamports ?? 0 > 0)
598
594
  rebalanceIntentRentPayer = rentPayer;
599
- let basketState: Basket = BasketLayout.decode(accountInfos.get(basket.toBase58())?.data.slice(8) ?? Buffer.alloc(0));
600
- let bountyMint = basketState.settings.bountyMint;
595
+ let bountyMint = basket.settings.bountyMint;
601
596
 
602
597
  let txBatchData: TxBatchData = {batches: [
603
598
  [{
@@ -606,14 +601,14 @@ export class SymmetryCore {
606
601
  createRebalanceIntentIx({
607
602
  signer: buyer,
608
603
  owner: buyer,
609
- basket: basket,
604
+ basket: basket.ownAddress,
610
605
  }),
611
606
  resizeRebalanceIntentIx(rebalanceIntent),
612
607
  initRebalanceIntentIx({
613
608
  signer: buyer,
614
609
  owner: buyer,
615
- basket,
616
- basketTokenMint: basketMint,
610
+ basket: basket.ownAddress,
611
+ basketTokenMint: basket.mint,
617
612
  rebalanceIntentRentPayer: rebalanceIntentRentPayer,
618
613
  bountyMint: bountyMint,
619
614
  rebalanceType: RebalanceType.Deposit,
@@ -631,7 +626,7 @@ export class SymmetryCore {
631
626
  }],
632
627
  depositTokensIx({
633
628
  owner: buyer,
634
- basket: basket,
629
+ basket: basket.ownAddress,
635
630
  contributions: contributions,
636
631
  }).map(ix => {
637
632
  return {
@@ -649,11 +644,11 @@ export class SymmetryCore {
649
644
  instructions: [
650
645
  lockDepositsIx({
651
646
  owner: buyer,
652
- basket: basket,
647
+ basket: basket.ownAddress,
653
648
  }),
654
649
  executionStartTime == 0 ? startPriceUpdatesIx({
655
650
  keeper: buyer,
656
- basket: basket,
651
+ basket: basket.ownAddress,
657
652
  rebalanceIntent: rebalanceIntent,
658
653
  }) : ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
659
654
  ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
@@ -827,6 +822,7 @@ export class SymmetryCore {
827
822
  }): Promise<TxPayloadBatchSequence> {
828
823
  let keeper = new PublicKey(params.keeper);
829
824
  let rebalanceIntent = new PublicKey(params.rebalance_intent);
825
+ let basketRebalanceIntent = getRebalanceIntentPda(new PublicKey(params.basket), new PublicKey(params.basket));
830
826
  let basket = await this.fetchBasket(params.basket);
831
827
  let ixs: TransactionInstruction[] = [];
832
828
  let batchSize = 7;
@@ -848,6 +844,7 @@ export class SymmetryCore {
848
844
  }
849
845
  }
850
846
  while (tokenIndices.length < 20) tokenIndices.push(0);
847
+ // TODO: in last instruction we should include performance fee accounts
851
848
  ixs.push(
852
849
  updateTokenPricesIx({
853
850
  keeper: keeper,
@@ -857,6 +854,7 @@ export class SymmetryCore {
857
854
  lookupTable1: basket.lookupTables.active[1],
858
855
  tokenIndices: tokenIndices,
859
856
  additionalOracleAccounts: allKeys,
857
+ basketRebalanceIntent: basket.settings.activeRebalance.eq(new BN(0)) ? undefined : basketRebalanceIntent,
860
858
  }),
861
859
  );
862
860
  }
@@ -908,17 +906,22 @@ export class SymmetryCore {
908
906
  };
909
907
  let ixWithdraw = flashWithdrawIx(flashParams);
910
908
  let ixDeposit = flashDepositIx(flashParams);
909
+ let ixs: TransactionInstruction[] = [
910
+ createAssociatedTokenAccountIdempotentInstruction(keeper, getAta(keeper, mintIn), keeper, mintIn),
911
+ createAssociatedTokenAccountIdempotentInstruction(keeper, getAta(keeper, mintOut), keeper, mintOut),
912
+ ixWithdraw,
913
+ ];
914
+ if (params.jup_swap_ix) {
915
+ ixs.push(params.jup_swap_ix);
916
+ }
917
+ ixs = ixs.concat([
918
+ ixDeposit,
919
+ ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
920
+ ComputeBudgetProgram.setComputeUnitPrice({microLamports: this.sdkParams.priorityFee}),
921
+ ]);
911
922
  let txBatchData: TxBatchData = {batches: [[{
912
923
  payer: keeper,
913
- instructions: [
914
- createAssociatedTokenAccountIdempotentInstruction(keeper, getAta(keeper, mintIn), keeper, mintIn),
915
- createAssociatedTokenAccountIdempotentInstruction(keeper, getAta(keeper, mintOut), keeper, mintOut),
916
- ixWithdraw,
917
- params.jup_swap_ix ? params.jup_swap_ix : ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
918
- ixDeposit,
919
- ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
920
- ComputeBudgetProgram.setComputeUnitPrice({microLamports: this.sdkParams.priorityFee}),
921
- ],
924
+ instructions: ixs,
922
925
  lookupTables: [],
923
926
  }]]};
924
927
  let versionedTxs = await prepareVersionedTxs(this.sdkParams.connection, txBatchData);
@@ -933,11 +936,13 @@ export class SymmetryCore {
933
936
  let keeper = new PublicKey(params.keeper);
934
937
  let rebalanceIntent = await this.fetchRebalanceIntent(params.rebalance_intent);
935
938
  let basket = await this.fetchBasket(rebalanceIntent.basket.toBase58());
939
+ let basketRebalanceIntent = getRebalanceIntentPda(basket.ownAddress, rebalanceIntent.owner);
936
940
  let ix = mintBasketIx({
937
941
  keeper: keeper,
938
942
  basket: basket.ownAddress,
939
943
  basketTokenMint: basket.mint,
940
944
  buyer: rebalanceIntent.owner,
945
+ basketRebalanceIntent: basket.settings.activeRebalance.eq(new BN(0)) ? undefined : basketRebalanceIntent,
941
946
  });
942
947
  let txBatchData: TxBatchData = {batches: [[{
943
948
  payer: keeper,
@@ -30,8 +30,8 @@ export function flashWithdrawIx(params: {
30
30
  const keys = [
31
31
  { pubkey: params.keeper, isWritable: true, isSigner: true },
32
32
  { pubkey: params.basket, isWritable: true, isSigner: false },
33
- { pubkey: params.rebalanceIntent ? params.rebalanceIntent : BASKETS_V3_PROGRAM_ID, isWritable: params.rebalanceIntent ? true : false, isSigner: false },
34
- { pubkey: params.intent ? params.intent : BASKETS_V3_PROGRAM_ID, isWritable: params.intent ? true : false, isSigner: false },
33
+ { pubkey: params.rebalanceIntent ?? BASKETS_V3_PROGRAM_ID, isWritable: params.rebalanceIntent ? true : false, isSigner: false },
34
+ { pubkey: params.intent ?? BASKETS_V3_PROGRAM_ID, isWritable: params.intent ? true : false, isSigner: false },
35
35
  { pubkey: params.mintIn, isWritable: false, isSigner: false },
36
36
  { pubkey: params.mintOut, isWritable: false, isSigner: false },
37
37
  { pubkey: keeperFromATA, isWritable: true, isSigner: false },
@@ -48,7 +48,7 @@ export function flashWithdrawIx(params: {
48
48
 
49
49
  const amountInBuffer = Buffer.from(amountIn.toArray("le", 8));
50
50
  const amountOutBuffer = Buffer.from(amountOut.toArray("le", 8));
51
- const modeBuffer = mode ? Buffer.from([mode]) : Buffer.from([]);
51
+ const modeBuffer = Buffer.from([mode ?? 0]);
52
52
 
53
53
  const data = Buffer.concat([discriminator, amountInBuffer, amountOutBuffer, modeBuffer]);
54
54
 
@@ -22,6 +22,7 @@ export function startPriceUpdatesIx(params: {
22
22
  { pubkey: params.keeper, isSigner: true, isWritable: true },
23
23
  { pubkey: params.basket, isSigner: false, isWritable: true },
24
24
  { pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
25
+ { pubkey: getGlobalConfigPda(), isSigner: false, isWritable: false },
25
26
  ];
26
27
 
27
28
  const data = START_PRICE_UPDATES_DISCRIMINATOR;
@@ -39,6 +40,7 @@ export function updateTokenPricesIx(params: {
39
40
  keeper: PublicKey,
40
41
  basket: PublicKey,
41
42
  rebalanceIntent: PublicKey,
43
+ basketRebalanceIntent?: PublicKey,
42
44
  lookupTable0: PublicKey,
43
45
  lookupTable1: PublicKey,
44
46
  tokenIndices: number[], // length 20
@@ -67,6 +69,7 @@ export function updateTokenPricesIx(params: {
67
69
  { pubkey: PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT, isSigner: false, isWritable: true },
68
70
  { pubkey: params.lookupTable0, isSigner: false, isWritable: true },
69
71
  { pubkey: params.lookupTable1, isSigner: false, isWritable: true },
72
+ { pubkey: params.basketRebalanceIntent ?? BASKETS_V3_PROGRAM_ID, isSigner: false, isWritable: params.basketRebalanceIntent ? true : false },
70
73
  ];
71
74
 
72
75
  // remaining accounts
@@ -100,6 +100,7 @@ export function mintBasketIx(params: {
100
100
  basket: PublicKey;
101
101
  basketTokenMint: PublicKey;
102
102
  buyer: PublicKey;
103
+ basketRebalanceIntent?: PublicKey;
103
104
  }): TransactionInstruction {
104
105
 
105
106
  const { keeper, basket, basketTokenMint, buyer } = params;
@@ -122,6 +123,7 @@ export function mintBasketIx(params: {
122
123
  { pubkey: globalConfig, isWritable: false, isSigner: false },
123
124
  { pubkey: basketFees, isWritable: true, isSigner: false },
124
125
  { pubkey: basketFeesAta, isWritable: true, isSigner: false },
126
+ { pubkey: params.basketRebalanceIntent ?? BASKETS_V3_PROGRAM_ID, isWritable: params.basketRebalanceIntent ? true : false, isSigner: false },
125
127
  { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
126
128
  { pubkey: TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
127
129
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
package/src/txUtils.ts CHANGED
@@ -236,15 +236,15 @@ export async function sendVersionedTransaction(
236
236
  blockhash,
237
237
  lastValidBlockHeight,
238
238
  signature: txId,
239
- }, "confirmed").then((res) => confirmation = res);
239
+ }, "confirmed").catch(() => null).then((res) => confirmation = res);
240
240
 
241
- let iterations = 15;
241
+ let iterations = 10;
242
242
  while (confirmation === null && result === null && iterations > 0) {
243
- await delay(2500);
243
+ await delay(1000);
244
244
  result = await connection.getTransaction(txId, {
245
245
  commitment: "confirmed",
246
246
  maxSupportedTransactionVersion: 0,
247
- });
247
+ }).catch(() => null);
248
248
  if (result && result.meta && result.meta?.err) {
249
249
  console.log(result.meta.err);
250
250
  throw new Error(txId);
@@ -376,7 +376,7 @@ export async function sendTxPayloadBatchSequence(
376
376
  txs.push(batchTxs);
377
377
  }
378
378
  return await sendVersionedTxs(connection, {
379
- blockhash: txPayloadBatchSequence.batches[0].transactions[0].recent_blockhash,
379
+ blockhash: txPayloadBatchSequence.batches[0].transactions[0]?.recent_blockhash ?? "",
380
380
  lastValidBlockHeight: 0,
381
381
  batches: txs,
382
382
  }, simulateTransactions);
package/test.ts CHANGED
@@ -4,6 +4,8 @@ import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
4
4
  import { SymmetryCore, TaskContext } from "./src";
5
5
  import { AddOrEditTokenInput, UpdateWeightsInput, MakeDirectSwapInput } from "./src";
6
6
  import { EditCreatorSettings, EditManagerSettings, EditFeeSettings, EditScheduleSettings, EditAutomationSettings, EditLpSettings, EditMetadataSettings, EditDepositsSettings, EditForceRebalanceSettings, EditCustomRebalanceSettings, EditAddTokenSettings, EditUpdateWeightsSettings, EditMakeDirectSwapSettings } from "./src";
7
+ import { getRebalanceIntentPda } from "./src/instructions/pda";
8
+ import { PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT } from "./src/constants";
7
9
 
8
10
 
9
11
  let kp = Array.from(Keypair.generate().secretKey);
@@ -29,7 +31,13 @@ async function testStates() {
29
31
  let basket = await sdk.fetchBasket("GrBFFvtdRL25o7gcRnV1kGvz1Qc7iscUmDp1ZvyBSyUa");
30
32
  basket = await sdk.loadBasketPrice(basket);
31
33
  console.log(basket.formatted);
32
- return;
34
+ let allBaskets = await sdk.fetchAllBaskets();
35
+ console.log(allBaskets.length);
36
+ for (let basket of allBaskets) {
37
+ basket = await sdk.loadBasketPrice(basket);
38
+ console.log(basket.ownAddress.toBase58(), basket.formatted?.start_price);
39
+ }
40
+ // return;
33
41
 
34
42
  let tests = {
35
43
 
@@ -53,29 +61,31 @@ async function testStates() {
53
61
  editUpdateWeightsDelay: false, // NOT TESTED
54
62
  editMakeDirectSwapDelay: false, // NOT TESTED
55
63
 
56
- addOrEditToken: false, // NOT TESTED
64
+ addOrEditToken: false, // TESTED
57
65
  updateWeights: false, // NOT TESTED
58
66
  makeDirectSwap: false, // NOT TESTED
59
67
 
60
68
  executeIntent: false, // NOT TESTED
61
69
 
62
- buyBasket: false, // NOT TESTED
63
- depositTokens: false, // NOT TESTED
64
- lockDeposits: false, // NOT TESTED
70
+ buyBasket: false, // TESTED
71
+ depositTokens: false, // TESTED
72
+ lockDeposits: false, // TESTED
65
73
 
66
74
  sellBasket: false, // NOT TESTED
67
75
 
68
76
  rebalanceBasket: false, // NOT TESTED
69
77
  rebalanceBasketCustom: false, // NOT TESTED
70
78
 
71
- startPriceUpdates: false, // NOT TESTED
72
- updateTokenPrices: false, // NOT TESTED
79
+ startPriceUpdates: false, // TESTED
80
+ updateTokenPrices: false, // TESTED
73
81
  updateTokenPricesCustom: false, // NOT TESTED
74
82
 
75
- rebalanceSwap: false, // NOT TESTED
83
+ rebalanceSwap: false, // TESTED
84
+
85
+ mintBasket: false, // TESTED
76
86
 
77
- redeemTokens: false, // NOT TESTED
78
- claimBounty: false, // NOT TESTED
87
+ redeemTokens: false, // TESTED
88
+ claimBounty: false, // TESTED
79
89
  }
80
90
 
81
91
  if (tests.createBasket) {
@@ -270,14 +280,14 @@ async function testStates() {
270
280
  active: true,
271
281
  min_oracles_thresh: 1,
272
282
  min_conf_bps: 100,
273
- conf_thresh_bps: 100,
283
+ conf_thresh_bps: 200,
274
284
  conf_multiplier: 1,
275
285
  oracles: [
276
286
  {
277
287
  oracle_type: "pyth",
278
288
  account_lut_id: 0,
279
289
  account_lut_index: 0,
280
- account: "So11111111111111111111111111111111111111112",
290
+ account: PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT.toBase58(),
281
291
  num_required_accounts: 1,
282
292
  weight: 100,
283
293
  is_required: true,
@@ -285,7 +295,7 @@ async function testStates() {
285
295
  volatility_thresh_bps: 100,
286
296
  max_slippage_bps: 100,
287
297
  min_liquidity: 100,
288
- staleness_thresh: 100,
298
+ staleness_thresh: 10000,
289
299
  staleness_conf_rate_bps: 100,
290
300
  token_decimals: 9,
291
301
  twap_seconds_ago: 100,
@@ -335,6 +345,76 @@ async function testStates() {
335
345
  console.log(res);
336
346
  }
337
347
 
348
+ if (tests.buyBasket) {
349
+ let tx = await sdk.buyBasketTx({
350
+ buyer: wallet.publicKey.toBase58(),
351
+ basket_mint: basket.mint.toBase58(),
352
+ contributions: [
353
+ {mint: "So11111111111111111111111111111111111111112", amount: 0},
354
+ {mint: "USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT", amount: 20000000},
355
+ ],
356
+ });
357
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
358
+ console.log(res);
359
+ }
360
+
361
+ if (tests.updateTokenPrices) {
362
+ let rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, wallet.publicKey);
363
+ let tx = await sdk.updateTokenPricesTx({
364
+ keeper: wallet.publicKey.toBase58(),
365
+ basket: basket.ownAddress.toBase58(),
366
+ rebalance_intent: rebalanceIntent.toBase58(),
367
+ });
368
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
369
+ console.log(res);
370
+ }
371
+
372
+ if (tests.rebalanceSwap) {
373
+ let rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, wallet.publicKey);
374
+ let tx = await sdk.flashSwapTx({
375
+ keeper: wallet.publicKey.toBase58(),
376
+ basket: basket.ownAddress.toBase58(),
377
+ rebalance_intent: rebalanceIntent.toBase58(),
378
+ mint_in: "So11111111111111111111111111111111111111112",
379
+ mint_out: "USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT",
380
+ amount_in: 50000000,
381
+ amount_out: 1000000,
382
+ mode: 2,
383
+ });
384
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
385
+ console.log(res);
386
+ }
387
+
388
+ if (tests.mintBasket) {
389
+ let rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, wallet.publicKey);
390
+ let tx = await sdk.mintTx({
391
+ keeper: wallet.publicKey.toBase58(),
392
+ rebalance_intent: rebalanceIntent.toBase58(),
393
+ });
394
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
395
+ console.log(res);
396
+ return;
397
+ }
398
+
399
+ if (tests.redeemTokens) {
400
+ let rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, wallet.publicKey);
401
+ let tx = await sdk.redeemTokensTx({
402
+ keeper: wallet.publicKey.toBase58(),
403
+ rebalance_intent: rebalanceIntent.toBase58(),
404
+ });
405
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
406
+ console.log(res);
407
+ }
408
+
409
+ if (tests.claimBounty) {
410
+ let rebalanceIntent = getRebalanceIntentPda(basket.ownAddress, wallet.publicKey);
411
+ let tx = await sdk.claimBountyTx({
412
+ keeper: wallet.publicKey.toBase58(),
413
+ rebalance_intent: rebalanceIntent.toBase58(),
414
+ });
415
+ let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
416
+ console.log(res);
417
+ }
338
418
 
339
419
  if (tests.editGlobalConfig) {
340
420
  let editGlobalConfigTx = await sdk.editGlobalConfigTx({