flash-sdk 2.13.9 → 2.14.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.
@@ -2220,7 +2220,10 @@ var PerpetualsClient = (function () {
2220
2220
  }
2221
2221
  });
2222
2222
  }); };
2223
- this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege, skipBalanceChecks) {
2223
+ this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, skipBalanceChecks) {
2224
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
2225
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
2226
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
2224
2227
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2225
2228
  return __awaiter(_this, void 0, void 0, function () {
2226
2229
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
@@ -2325,7 +2328,10 @@ var PerpetualsClient = (function () {
2325
2328
  });
2326
2329
  });
2327
2330
  };
2328
- this.openPositionWithSwap = function (targetSymbol, collateralSymbol, inputSymbol, amountIn, minAmountOut, priceWithSlippage, size, side, swapPoolConfig, positionPoolConfig, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege, skipBalanceChecks) {
2331
+ this.openPositionWithSwap = function (targetSymbol, collateralSymbol, inputSymbol, amountIn, minAmountOut, priceWithSlippage, size, side, swapPoolConfig, positionPoolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, skipBalanceChecks) {
2332
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
2333
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
2334
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
2329
2335
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2330
2336
  return __awaiter(_this, void 0, void 0, function () {
2331
2337
  var publicKey, targetCustodyConfig, collateralCustodyConfig, swapOutCustodyConfig, swapInCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userOutputTokenAccount, marketAccount, positionAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, instruction;
@@ -2463,7 +2469,10 @@ var PerpetualsClient = (function () {
2463
2469
  });
2464
2470
  });
2465
2471
  };
2466
- this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege, createUserATA, closeUsersWSOLATA) {
2472
+ this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, createUserATA, closeUsersWSOLATA) {
2473
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
2474
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
2475
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
2467
2476
  if (createUserATA === void 0) { createUserATA = true; }
2468
2477
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2469
2478
  return __awaiter(_this, void 0, void 0, function () {
@@ -2565,121 +2574,126 @@ var PerpetualsClient = (function () {
2565
2574
  });
2566
2575
  });
2567
2576
  };
2568
- this.closePositionWithSwap = function (targetSymbol, outputSymbol, collateralSymbol, minAmountOut, priceAfterSlippage, side, swapPoolConfig, positionPoolConfig, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege) { return __awaiter(_this, void 0, void 0, function () {
2569
- var publicKey, targetCustodyConfig, collateralCustodyConfig, swapInCustodyConfig, swapOutCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody, instruction;
2570
- return __generator(this, function (_b) {
2571
- switch (_b.label) {
2572
- case 0:
2573
- publicKey = this.provider.wallet.publicKey;
2574
- targetCustodyConfig = positionPoolConfig.custodies.find(function (i) { return i.mintKey.equals(positionPoolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
2575
- collateralCustodyConfig = positionPoolConfig.custodies.find(function (i) { return i.mintKey.equals(positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
2576
- swapInCustodyConfig = swapPoolConfig.custodies.find(function (i) { return i.mintKey.equals(swapPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
2577
- swapOutCustodyConfig = swapPoolConfig.custodies.find(function (i) { return i.mintKey.equals(swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey); });
2578
- if (swapOutCustodyConfig.mintKey.equals(collateralCustodyConfig.mintKey)) {
2579
- throw "Dont use swap, just call close position";
2580
- }
2581
- preInstructions = [];
2582
- instructions = [];
2583
- postInstructions = [];
2584
- additionalSigners = [];
2585
- if (!(outputSymbol == 'SOL')) return [3, 2];
2586
- console.log("outputSymbol === SOL", outputSymbol);
2587
- wrappedSolAccount = new web3_js_1.Keypair();
2588
- return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
2589
- case 1:
2590
- lamports = (_b.sent());
2591
- preInstructions = [
2592
- web3_js_1.SystemProgram.createAccount({
2593
- fromPubkey: publicKey,
2594
- newAccountPubkey: wrappedSolAccount.publicKey,
2595
- lamports: lamports,
2596
- space: 165,
2597
- programId: spl_token_1.TOKEN_PROGRAM_ID,
2598
- }),
2599
- (0, spl_token_1.createInitializeAccount3Instruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, publicKey),
2600
- ];
2601
- postInstructions = [
2602
- (0, spl_token_1.createCloseAccountInstruction)(wrappedSolAccount.publicKey, publicKey, publicKey),
2603
- ];
2604
- additionalSigners.push(wrappedSolAccount);
2605
- return [3, 5];
2606
- case 2: return [4, (0, spl_token_1.getAssociatedTokenAddress)(swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey, publicKey)];
2607
- case 3:
2608
- userReceivingTokenAccount = _b.sent();
2609
- return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
2610
- case 4:
2611
- if (!(_b.sent())) {
2612
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey));
2613
- }
2614
- _b.label = 5;
2615
- case 5:
2616
- userCollateralTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true);
2617
- return [4, (0, utils_1.checkIfAccountExists)(userCollateralTokenAccount, this.provider.connection)];
2618
- case 6:
2619
- if (!(_b.sent())) {
2620
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userCollateralTokenAccount, publicKey, positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
2621
- }
2622
- marketAccount = positionPoolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
2623
- positionAccount = positionPoolConfig.getPositionFromMarketPk(publicKey, marketAccount);
2624
- custodyAccountMetas = [];
2625
- custodyOracleAccountMetas = [];
2626
- for (_i = 0, _a = swapPoolConfig.custodies; _i < _a.length; _i++) {
2627
- custody = _a[_i];
2628
- custodyAccountMetas.push({
2629
- pubkey: custody.custodyAccount,
2630
- isSigner: false,
2631
- isWritable: false,
2632
- });
2633
- custodyOracleAccountMetas.push({
2634
- pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
2635
- isSigner: false,
2636
- isWritable: false,
2637
- });
2638
- }
2639
- return [4, this.programPerpComposability.methods
2640
- .closeAndSwap({
2641
- minAmountOut: minAmountOut,
2642
- closePriceWithSlippage: priceAfterSlippage,
2643
- privilege: privilege,
2644
- })
2645
- .accounts({
2646
- perpProgram: this.programId,
2647
- owner: publicKey,
2648
- fundingAccount: userCollateralTokenAccount,
2649
- receivingAccount: outputSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
2650
- transferAuthority: swapPoolConfig.transferAuthority,
2651
- perpetuals: swapPoolConfig.perpetuals,
2652
- swapPool: swapPoolConfig.poolAddress,
2653
- receivingCustody: swapInCustodyConfig.custodyAccount,
2654
- receivingCustodyOracleAccount: this.useExtOracleAccount ? swapInCustodyConfig.extOracleAccount : swapInCustodyConfig.intOracleAccount,
2655
- receivingCustodyTokenAccount: swapInCustodyConfig.tokenAccount,
2656
- dispensingCustody: swapOutCustodyConfig.custodyAccount,
2657
- dispensingCustodyOracleAccount: this.useExtOracleAccount ? swapOutCustodyConfig.extOracleAccount : swapOutCustodyConfig.intOracleAccount,
2658
- dispensingCustodyTokenAccount: swapOutCustodyConfig.tokenAccount,
2659
- positionPool: positionPoolConfig.poolAddress,
2660
- position: positionAccount,
2661
- market: marketAccount,
2662
- targetCustody: targetCustodyConfig.custodyAccount,
2663
- targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
2664
- collateralCustody: collateralCustodyConfig.custodyAccount,
2665
- collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
2666
- collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2667
- eventAuthority: this.eventAuthority.publicKey,
2668
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2669
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2670
- })
2671
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true), custodyAccountMetas, true), custodyOracleAccountMetas, true))
2672
- .instruction()];
2673
- case 7:
2674
- instruction = _b.sent();
2675
- instructions.push(instruction);
2676
- return [2, {
2677
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
2678
- additionalSigners: additionalSigners
2679
- }];
2680
- }
2577
+ this.closePositionWithSwap = function (targetSymbol, outputSymbol, collateralSymbol, minAmountOut, priceAfterSlippage, side, swapPoolConfig, positionPoolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
2578
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
2579
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
2580
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
2581
+ return __awaiter(_this, void 0, void 0, function () {
2582
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, swapInCustodyConfig, swapOutCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody, instruction;
2583
+ return __generator(this, function (_b) {
2584
+ switch (_b.label) {
2585
+ case 0:
2586
+ publicKey = this.provider.wallet.publicKey;
2587
+ targetCustodyConfig = positionPoolConfig.custodies.find(function (i) { return i.mintKey.equals(positionPoolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
2588
+ collateralCustodyConfig = positionPoolConfig.custodies.find(function (i) { return i.mintKey.equals(positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
2589
+ swapInCustodyConfig = swapPoolConfig.custodies.find(function (i) { return i.mintKey.equals(swapPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
2590
+ swapOutCustodyConfig = swapPoolConfig.custodies.find(function (i) { return i.mintKey.equals(swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey); });
2591
+ if (swapOutCustodyConfig.mintKey.equals(collateralCustodyConfig.mintKey)) {
2592
+ throw "Dont use swap, just call close position";
2593
+ }
2594
+ preInstructions = [];
2595
+ instructions = [];
2596
+ postInstructions = [];
2597
+ additionalSigners = [];
2598
+ if (!(outputSymbol == 'SOL')) return [3, 2];
2599
+ console.log("outputSymbol === SOL", outputSymbol);
2600
+ wrappedSolAccount = new web3_js_1.Keypair();
2601
+ return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
2602
+ case 1:
2603
+ lamports = (_b.sent());
2604
+ preInstructions = [
2605
+ web3_js_1.SystemProgram.createAccount({
2606
+ fromPubkey: publicKey,
2607
+ newAccountPubkey: wrappedSolAccount.publicKey,
2608
+ lamports: lamports,
2609
+ space: 165,
2610
+ programId: spl_token_1.TOKEN_PROGRAM_ID,
2611
+ }),
2612
+ (0, spl_token_1.createInitializeAccount3Instruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, publicKey),
2613
+ ];
2614
+ postInstructions = [
2615
+ (0, spl_token_1.createCloseAccountInstruction)(wrappedSolAccount.publicKey, publicKey, publicKey),
2616
+ ];
2617
+ additionalSigners.push(wrappedSolAccount);
2618
+ return [3, 5];
2619
+ case 2: return [4, (0, spl_token_1.getAssociatedTokenAddress)(swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey, publicKey)];
2620
+ case 3:
2621
+ userReceivingTokenAccount = _b.sent();
2622
+ return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
2623
+ case 4:
2624
+ if (!(_b.sent())) {
2625
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, swapPoolConfig.getTokenFromSymbol(outputSymbol).mintKey));
2626
+ }
2627
+ _b.label = 5;
2628
+ case 5:
2629
+ userCollateralTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true);
2630
+ return [4, (0, utils_1.checkIfAccountExists)(userCollateralTokenAccount, this.provider.connection)];
2631
+ case 6:
2632
+ if (!(_b.sent())) {
2633
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userCollateralTokenAccount, publicKey, positionPoolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
2634
+ }
2635
+ marketAccount = positionPoolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
2636
+ positionAccount = positionPoolConfig.getPositionFromMarketPk(publicKey, marketAccount);
2637
+ custodyAccountMetas = [];
2638
+ custodyOracleAccountMetas = [];
2639
+ for (_i = 0, _a = swapPoolConfig.custodies; _i < _a.length; _i++) {
2640
+ custody = _a[_i];
2641
+ custodyAccountMetas.push({
2642
+ pubkey: custody.custodyAccount,
2643
+ isSigner: false,
2644
+ isWritable: false,
2645
+ });
2646
+ custodyOracleAccountMetas.push({
2647
+ pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
2648
+ isSigner: false,
2649
+ isWritable: false,
2650
+ });
2651
+ }
2652
+ return [4, this.programPerpComposability.methods
2653
+ .closeAndSwap({
2654
+ minAmountOut: minAmountOut,
2655
+ closePriceWithSlippage: priceAfterSlippage,
2656
+ privilege: privilege,
2657
+ })
2658
+ .accounts({
2659
+ perpProgram: this.programId,
2660
+ owner: publicKey,
2661
+ fundingAccount: userCollateralTokenAccount,
2662
+ receivingAccount: outputSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
2663
+ transferAuthority: swapPoolConfig.transferAuthority,
2664
+ perpetuals: swapPoolConfig.perpetuals,
2665
+ swapPool: swapPoolConfig.poolAddress,
2666
+ receivingCustody: swapInCustodyConfig.custodyAccount,
2667
+ receivingCustodyOracleAccount: this.useExtOracleAccount ? swapInCustodyConfig.extOracleAccount : swapInCustodyConfig.intOracleAccount,
2668
+ receivingCustodyTokenAccount: swapInCustodyConfig.tokenAccount,
2669
+ dispensingCustody: swapOutCustodyConfig.custodyAccount,
2670
+ dispensingCustodyOracleAccount: this.useExtOracleAccount ? swapOutCustodyConfig.extOracleAccount : swapOutCustodyConfig.intOracleAccount,
2671
+ dispensingCustodyTokenAccount: swapOutCustodyConfig.tokenAccount,
2672
+ positionPool: positionPoolConfig.poolAddress,
2673
+ position: positionAccount,
2674
+ market: marketAccount,
2675
+ targetCustody: targetCustodyConfig.custodyAccount,
2676
+ targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
2677
+ collateralCustody: collateralCustodyConfig.custodyAccount,
2678
+ collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
2679
+ collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2680
+ eventAuthority: this.eventAuthority.publicKey,
2681
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2682
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2683
+ })
2684
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true), custodyAccountMetas, true), custodyOracleAccountMetas, true))
2685
+ .instruction()];
2686
+ case 7:
2687
+ instruction = _b.sent();
2688
+ instructions.push(instruction);
2689
+ return [2, {
2690
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
2691
+ additionalSigners: additionalSigners
2692
+ }];
2693
+ }
2694
+ });
2681
2695
  });
2682
- }); };
2696
+ };
2683
2697
  this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks) {
2684
2698
  if (useFeesPool === void 0) { useFeesPool = false; }
2685
2699
  if (createUserATA === void 0) { createUserATA = true; }
@@ -3413,116 +3427,126 @@ var PerpetualsClient = (function () {
3413
3427
  }
3414
3428
  });
3415
3429
  }); };
3416
- this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege) { return __awaiter(_this, void 0, void 0, function () {
3417
- var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3418
- return __generator(this, function (_a) {
3419
- switch (_a.label) {
3420
- case 0:
3421
- publicKey = this.provider.wallet.publicKey;
3422
- collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3423
- return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3424
- });
3425
- targetCustodyConfig = poolConfig.custodies.find(function (i) {
3426
- return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey);
3427
- });
3428
- marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
3429
- if (!collateralCustodyConfig || !targetCustodyConfig) {
3430
- throw "collateralCustodyConfig/marketCustodyConfig not found";
3431
- }
3432
- preInstructions = [];
3433
- instructions = [];
3434
- postInstructions = [];
3435
- additionalSigners = [];
3436
- return [4, this.program.methods
3437
- .increaseSize({
3438
- priceWithSlippage: priceWithSlippage,
3439
- sizeDelta: sizeDelta,
3440
- privilege: privilege
3441
- })
3442
- .accounts({
3443
- owner: publicKey,
3444
- transferAuthority: poolConfig.transferAuthority,
3445
- perpetuals: poolConfig.perpetuals,
3446
- pool: poolConfig.poolAddress,
3447
- position: positionPubKey,
3448
- market: marketAccount,
3449
- targetCustody: targetCustodyConfig.custodyAccount,
3450
- targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
3451
- collateralCustody: collateralCustodyConfig.custodyAccount,
3452
- collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
3453
- collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
3454
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3455
- eventAuthority: this.eventAuthority.publicKey,
3456
- program: this.programId,
3457
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3458
- })
3459
- .remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
3460
- .instruction()];
3461
- case 1:
3462
- instruction = _a.sent();
3463
- instructions.push(instruction);
3464
- return [2, {
3465
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3466
- additionalSigners: additionalSigners
3467
- }];
3468
- }
3430
+ this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
3431
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
3432
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
3433
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
3434
+ return __awaiter(_this, void 0, void 0, function () {
3435
+ var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3436
+ return __generator(this, function (_a) {
3437
+ switch (_a.label) {
3438
+ case 0:
3439
+ publicKey = this.provider.wallet.publicKey;
3440
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3441
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3442
+ });
3443
+ targetCustodyConfig = poolConfig.custodies.find(function (i) {
3444
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey);
3445
+ });
3446
+ marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
3447
+ if (!collateralCustodyConfig || !targetCustodyConfig) {
3448
+ throw "collateralCustodyConfig/marketCustodyConfig not found";
3449
+ }
3450
+ preInstructions = [];
3451
+ instructions = [];
3452
+ postInstructions = [];
3453
+ additionalSigners = [];
3454
+ return [4, this.program.methods
3455
+ .increaseSize({
3456
+ priceWithSlippage: priceWithSlippage,
3457
+ sizeDelta: sizeDelta,
3458
+ privilege: privilege
3459
+ })
3460
+ .accounts({
3461
+ owner: publicKey,
3462
+ transferAuthority: poolConfig.transferAuthority,
3463
+ perpetuals: poolConfig.perpetuals,
3464
+ pool: poolConfig.poolAddress,
3465
+ position: positionPubKey,
3466
+ market: marketAccount,
3467
+ targetCustody: targetCustodyConfig.custodyAccount,
3468
+ targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
3469
+ collateralCustody: collateralCustodyConfig.custodyAccount,
3470
+ collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
3471
+ collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
3472
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3473
+ eventAuthority: this.eventAuthority.publicKey,
3474
+ program: this.programId,
3475
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3476
+ })
3477
+ .remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
3478
+ .instruction()];
3479
+ case 1:
3480
+ instruction = _a.sent();
3481
+ instructions.push(instruction);
3482
+ return [2, {
3483
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3484
+ additionalSigners: additionalSigners
3485
+ }];
3486
+ }
3487
+ });
3469
3488
  });
3470
- }); };
3471
- this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege) { return __awaiter(_this, void 0, void 0, function () {
3472
- var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3473
- return __generator(this, function (_a) {
3474
- switch (_a.label) {
3475
- case 0:
3476
- publicKey = this.provider.wallet.publicKey;
3477
- collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3478
- return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3479
- });
3480
- targetCustodyConfig = poolConfig.custodies.find(function (i) {
3481
- return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey);
3482
- });
3483
- marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
3484
- if (!collateralCustodyConfig || !targetCustodyConfig) {
3485
- throw "collateralCustodyConfig/marketCustodyConfig not found";
3486
- }
3487
- preInstructions = [];
3488
- instructions = [];
3489
- postInstructions = [];
3490
- additionalSigners = [];
3491
- return [4, this.program.methods
3492
- .decreaseSize({
3493
- priceWithSlippage: priceWithSlippage,
3494
- sizeDelta: sizeDelta,
3495
- privilege: privilege
3496
- })
3497
- .accounts({
3498
- owner: publicKey,
3499
- transferAuthority: poolConfig.transferAuthority,
3500
- perpetuals: poolConfig.perpetuals,
3501
- pool: poolConfig.poolAddress,
3502
- position: positionPubKey,
3503
- market: marketAccount,
3504
- targetCustody: targetCustodyConfig.custodyAccount,
3505
- targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
3506
- collateralCustody: collateralCustodyConfig.custodyAccount,
3507
- collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
3508
- collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
3509
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3510
- eventAuthority: this.eventAuthority.publicKey,
3511
- program: this.programId,
3512
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3513
- })
3514
- .remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
3515
- .instruction()];
3516
- case 1:
3517
- instruction = _a.sent();
3518
- instructions.push(instruction);
3519
- return [2, {
3520
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3521
- additionalSigners: additionalSigners
3522
- }];
3523
- }
3489
+ };
3490
+ this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
3491
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
3492
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
3493
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
3494
+ return __awaiter(_this, void 0, void 0, function () {
3495
+ var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3496
+ return __generator(this, function (_a) {
3497
+ switch (_a.label) {
3498
+ case 0:
3499
+ publicKey = this.provider.wallet.publicKey;
3500
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3501
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3502
+ });
3503
+ targetCustodyConfig = poolConfig.custodies.find(function (i) {
3504
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey);
3505
+ });
3506
+ marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
3507
+ if (!collateralCustodyConfig || !targetCustodyConfig) {
3508
+ throw "collateralCustodyConfig/marketCustodyConfig not found";
3509
+ }
3510
+ preInstructions = [];
3511
+ instructions = [];
3512
+ postInstructions = [];
3513
+ additionalSigners = [];
3514
+ return [4, this.program.methods
3515
+ .decreaseSize({
3516
+ priceWithSlippage: priceWithSlippage,
3517
+ sizeDelta: sizeDelta,
3518
+ privilege: privilege
3519
+ })
3520
+ .accounts({
3521
+ owner: publicKey,
3522
+ transferAuthority: poolConfig.transferAuthority,
3523
+ perpetuals: poolConfig.perpetuals,
3524
+ pool: poolConfig.poolAddress,
3525
+ position: positionPubKey,
3526
+ market: marketAccount,
3527
+ targetCustody: targetCustodyConfig.custodyAccount,
3528
+ targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
3529
+ collateralCustody: collateralCustodyConfig.custodyAccount,
3530
+ collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
3531
+ collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
3532
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3533
+ eventAuthority: this.eventAuthority.publicKey,
3534
+ program: this.programId,
3535
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3536
+ })
3537
+ .remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
3538
+ .instruction()];
3539
+ case 1:
3540
+ instruction = _a.sent();
3541
+ instructions.push(instruction);
3542
+ return [2, {
3543
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3544
+ additionalSigners: additionalSigners
3545
+ }];
3546
+ }
3547
+ });
3524
3548
  });
3525
- }); };
3549
+ };
3526
3550
  this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks) {
3527
3551
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3528
3552
  return __awaiter(_this, void 0, void 0, function () {
@@ -5617,7 +5641,7 @@ var PerpetualsClient = (function () {
5617
5641
  pool: poolConfig.poolAddress,
5618
5642
  flpStakeAccount: flpStakeAccount,
5619
5643
  rewardCustody: rewardCustody.custodyAccount,
5620
- rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
5644
+ rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
5621
5645
  poolStakedLpVault: poolStakedLpVault,
5622
5646
  poolCompoundingLpVault: poolConfig.compoundingLpVault,
5623
5647
  lpTokenMint: lpTokenMint,
@@ -5645,96 +5669,10 @@ var PerpetualsClient = (function () {
5645
5669
  });
5646
5670
  });
5647
5671
  };
5648
- this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5649
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, compoundingLpVault, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_33;
5650
- return __generator(this, function (_d) {
5651
- switch (_d.label) {
5652
- case 0:
5653
- publicKey = this.provider.wallet.publicKey;
5654
- preInstructions = [];
5655
- instructions = [];
5656
- postInstructions = [];
5657
- additionalSigners = [];
5658
- rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
5659
- lpTokenMint = poolConfig.stakedLpTokenMint;
5660
- compoundingTokenMint = poolConfig.compoundingTokenMint;
5661
- return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
5662
- case 1:
5663
- compoudingTokenAccount = _d.sent();
5664
- flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
5665
- compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_token_account"), poolConfig.poolAddress.toBuffer(), poolConfig.stakedLpTokenMint.toBuffer()], this.programId)[0];
5666
- poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
5667
- custodyAccountMetas = [];
5668
- custodyOracleAccountMetas = [];
5669
- markets = [];
5670
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
5671
- custody = _a[_i];
5672
- custodyAccountMetas.push({
5673
- pubkey: custody.custodyAccount,
5674
- isSigner: false,
5675
- isWritable: false,
5676
- });
5677
- custodyOracleAccountMetas.push({
5678
- pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
5679
- isSigner: false,
5680
- isWritable: false,
5681
- });
5682
- }
5683
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
5684
- market = _c[_b];
5685
- markets.push({
5686
- pubkey: market.marketAccount,
5687
- isSigner: false,
5688
- isWritable: false,
5689
- });
5690
- }
5691
- _d.label = 2;
5692
- case 2:
5693
- _d.trys.push([2, 4, , 5]);
5694
- return [4, this.program.methods
5695
- .migrateFlp({
5696
- compoundingTokenAmount: amount
5697
- })
5698
- .accounts({
5699
- owner: publicKey,
5700
- compoundingTokenAccount: compoudingTokenAccount,
5701
- transferAuthority: poolConfig.transferAuthority,
5702
- perpetuals: poolConfig.perpetuals,
5703
- pool: poolConfig.poolAddress,
5704
- flpStakeAccount: flpStakeAccount,
5705
- rewardCustody: rewardCustody.custodyAccount,
5706
- rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
5707
- poolStakedLpVault: poolStakedLpVault,
5708
- poolCompoundingLpVault: compoundingLpVault,
5709
- lpTokenMint: lpTokenMint,
5710
- compoundingTokenMint: compoundingTokenMint,
5711
- systemProgram: web3_js_1.SystemProgram.programId,
5712
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5713
- eventAuthority: this.eventAuthority.publicKey,
5714
- program: this.program.programId,
5715
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5716
- })
5717
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
5718
- .instruction()];
5719
- case 3:
5720
- migrateFlp = _d.sent();
5721
- instructions.push(migrateFlp);
5722
- return [3, 5];
5723
- case 4:
5724
- err_33 = _d.sent();
5725
- console.log("perpClient migrateFlp error:: ", err_33);
5726
- return [3, 5];
5727
- case 5: return [2, {
5728
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5729
- additionalSigners: additionalSigners
5730
- }];
5731
- }
5732
- });
5733
- }); };
5734
5672
  this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
5735
5673
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
5736
5674
  return __awaiter(_this, void 0, void 0, function () {
5737
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_34;
5675
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_33;
5738
5676
  return __generator(this, function (_d) {
5739
5677
  switch (_d.label) {
5740
5678
  case 0:
@@ -5791,8 +5729,8 @@ var PerpetualsClient = (function () {
5791
5729
  instructions.push(compoundingFee);
5792
5730
  return [3, 4];
5793
5731
  case 3:
5794
- err_34 = _d.sent();
5795
- console.log("perpClient compoundingFee error:: ", err_34);
5732
+ err_33 = _d.sent();
5733
+ console.log("perpClient compoundingFee error:: ", err_33);
5796
5734
  return [3, 4];
5797
5735
  case 4: return [2, {
5798
5736
  instructions: __spreadArray([], instructions, true),
@@ -5803,7 +5741,7 @@ var PerpetualsClient = (function () {
5803
5741
  });
5804
5742
  };
5805
5743
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5806
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_35;
5744
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_34;
5807
5745
  return __generator(this, function (_a) {
5808
5746
  switch (_a.label) {
5809
5747
  case 0:
@@ -5841,8 +5779,8 @@ var PerpetualsClient = (function () {
5841
5779
  instructions.push(renameFlp);
5842
5780
  return [3, 4];
5843
5781
  case 3:
5844
- err_35 = _a.sent();
5845
- console.log("perpClient renameFlp error:: ", err_35);
5782
+ err_34 = _a.sent();
5783
+ console.log("perpClient renameFlp error:: ", err_34);
5846
5784
  return [3, 4];
5847
5785
  case 4: return [2, {
5848
5786
  instructions: __spreadArray([], instructions, true),
@@ -5852,7 +5790,7 @@ var PerpetualsClient = (function () {
5852
5790
  });
5853
5791
  }); };
5854
5792
  this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5855
- var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_36;
5793
+ var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_35;
5856
5794
  return __generator(this, function (_a) {
5857
5795
  switch (_a.label) {
5858
5796
  case 0:
@@ -5886,9 +5824,9 @@ var PerpetualsClient = (function () {
5886
5824
  instructions.push(initRewardVault);
5887
5825
  return [3, 4];
5888
5826
  case 3:
5889
- err_36 = _a.sent();
5890
- console.log("rewardDistribution InitRewardVault error:: ", err_36);
5891
- throw err_36;
5827
+ err_35 = _a.sent();
5828
+ console.log("rewardDistribution InitRewardVault error:: ", err_35);
5829
+ throw err_35;
5892
5830
  case 4: return [2, {
5893
5831
  instructions: __spreadArray([], instructions, true),
5894
5832
  additionalSigners: additionalSigners
@@ -5897,7 +5835,7 @@ var PerpetualsClient = (function () {
5897
5835
  });
5898
5836
  }); };
5899
5837
  this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
5900
- var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_37;
5838
+ var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_36;
5901
5839
  return __generator(this, function (_a) {
5902
5840
  switch (_a.label) {
5903
5841
  case 0:
@@ -5920,9 +5858,9 @@ var PerpetualsClient = (function () {
5920
5858
  instructions.push(updateCounter);
5921
5859
  return [3, 4];
5922
5860
  case 3:
5923
- err_37 = _a.sent();
5924
- console.log("rewardDistribution updateCounter error:: ", err_37);
5925
- throw err_37;
5861
+ err_36 = _a.sent();
5862
+ console.log("rewardDistribution updateCounter error:: ", err_36);
5863
+ throw err_36;
5926
5864
  case 4: return [2, {
5927
5865
  instructions: __spreadArray([], instructions, true),
5928
5866
  additionalSigners: additionalSigners
@@ -5931,7 +5869,7 @@ var PerpetualsClient = (function () {
5931
5869
  });
5932
5870
  }); };
5933
5871
  this.rewardDistribution = function (counter, owner, rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5934
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_38;
5872
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_37;
5935
5873
  return __generator(this, function (_a) {
5936
5874
  switch (_a.label) {
5937
5875
  case 0:
@@ -5972,9 +5910,9 @@ var PerpetualsClient = (function () {
5972
5910
  instructions.push(distributeReward);
5973
5911
  return [3, 5];
5974
5912
  case 4:
5975
- err_38 = _a.sent();
5976
- console.log("rewardDistribution distributeReward error:: ", err_38);
5977
- throw err_38;
5913
+ err_37 = _a.sent();
5914
+ console.log("rewardDistribution distributeReward error:: ", err_37);
5915
+ throw err_37;
5978
5916
  case 5: return [2, {
5979
5917
  instructions: __spreadArray([], instructions, true),
5980
5918
  additionalSigners: additionalSigners
@@ -5985,7 +5923,7 @@ var PerpetualsClient = (function () {
5985
5923
  this.collectReward = function (counter, owner, rewardSymbol, poolConfig, createUserATA) {
5986
5924
  if (createUserATA === void 0) { createUserATA = true; }
5987
5925
  return __awaiter(_this, void 0, void 0, function () {
5988
- var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectNftReward, err_39;
5926
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectNftReward, err_38;
5989
5927
  return __generator(this, function (_b) {
5990
5928
  switch (_b.label) {
5991
5929
  case 0:
@@ -6033,8 +5971,8 @@ var PerpetualsClient = (function () {
6033
5971
  instructions.push(collectNftReward);
6034
5972
  return [3, 7];
6035
5973
  case 6:
6036
- err_39 = _b.sent();
6037
- throw err_39;
5974
+ err_38 = _b.sent();
5975
+ throw err_38;
6038
5976
  case 7: return [2, {
6039
5977
  instructions: __spreadArray([], instructions, true),
6040
5978
  additionalSigners: additionalSigners