flash-sdk 2.46.3 → 2.46.5-alpha.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.
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
@@ -2618,14 +2618,18 @@ var PerpetualsClient = (function () {
2618
2618
  }
2619
2619
  });
2620
2620
  }); };
2621
- this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2622
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2623
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2624
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2625
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2626
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2627
- return __awaiter(_this, void 0, void 0, function () {
2621
+ this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
2622
+ var args_1 = [];
2623
+ for (var _i = 8; _i < arguments.length; _i++) {
2624
+ args_1[_i - 8] = arguments[_i];
2625
+ }
2626
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2628
2627
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
2628
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2629
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2630
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2631
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2632
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2629
2633
  return __generator(this, function (_c) {
2630
2634
  switch (_c.label) {
2631
2635
  case 0:
@@ -2729,15 +2733,19 @@ var PerpetualsClient = (function () {
2729
2733
  });
2730
2734
  });
2731
2735
  };
2732
- this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2733
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2734
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2735
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2736
- if (createUserATA === void 0) { createUserATA = true; }
2737
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2738
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2739
- return __awaiter(_this, void 0, void 0, function () {
2736
+ this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
2737
+ var args_1 = [];
2738
+ for (var _i = 6; _i < arguments.length; _i++) {
2739
+ args_1[_i - 6] = arguments[_i];
2740
+ }
2741
+ return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2740
2742
  var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_2;
2743
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2744
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2745
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2746
+ if (createUserATA === void 0) { createUserATA = true; }
2747
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2748
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2741
2749
  return __generator(this, function (_b) {
2742
2750
  switch (_b.label) {
2743
2751
  case 0:
@@ -2834,14 +2842,18 @@ var PerpetualsClient = (function () {
2834
2842
  });
2835
2843
  });
2836
2844
  };
2837
- this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2838
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2839
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2840
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2841
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2842
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2843
- return __awaiter(_this, void 0, void 0, function () {
2845
+ this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
2846
+ var args_1 = [];
2847
+ for (var _i = 10; _i < arguments.length; _i++) {
2848
+ args_1[_i - 10] = arguments[_i];
2849
+ }
2850
+ return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2844
2851
  var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_2;
2852
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2853
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2854
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2855
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2856
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2845
2857
  return __generator(this, function (_c) {
2846
2858
  switch (_c.label) {
2847
2859
  case 0:
@@ -2981,13 +2993,17 @@ var PerpetualsClient = (function () {
2981
2993
  });
2982
2994
  });
2983
2995
  };
2984
- this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
2985
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2986
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2987
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2988
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2989
- return __awaiter(_this, void 0, void 0, function () {
2996
+ this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
2997
+ var args_1 = [];
2998
+ for (var _i = 8; _i < arguments.length; _i++) {
2999
+ args_1[_i - 8] = arguments[_i];
3000
+ }
3001
+ return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
2990
3002
  var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_3;
3003
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3004
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3005
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3006
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2991
3007
  return __generator(this, function (_a) {
2992
3008
  switch (_a.label) {
2993
3009
  case 0:
@@ -3101,16 +3117,20 @@ var PerpetualsClient = (function () {
3101
3117
  });
3102
3118
  });
3103
3119
  };
3104
- this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
3105
- if (useFeesPool === void 0) { useFeesPool = false; }
3106
- if (createUserATA === void 0) { createUserATA = true; }
3107
- if (unWrapSol === void 0) { unWrapSol = false; }
3108
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3109
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3110
- return __awaiter(_this, void 0, void 0, function () {
3111
- var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _i, _e, custody, params, inx, closeWsolATAIns, err_4;
3112
- return __generator(this, function (_f) {
3113
- switch (_f.label) {
3120
+ this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
3121
+ var args_1 = [];
3122
+ for (var _i = 5; _i < arguments.length; _i++) {
3123
+ args_1[_i - 5] = arguments[_i];
3124
+ }
3125
+ return __awaiter(_this, __spreadArray([userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1], args_1, true), void 0, function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
3126
+ var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_4;
3127
+ if (useFeesPool === void 0) { useFeesPool = false; }
3128
+ if (createUserATA === void 0) { createUserATA = true; }
3129
+ if (unWrapSol === void 0) { unWrapSol = false; }
3130
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3131
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3132
+ return __generator(this, function (_g) {
3133
+ switch (_g.label) {
3114
3134
  case 0:
3115
3135
  userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
3116
3136
  if (!userInputCustodyConfig) {
@@ -3128,10 +3148,10 @@ var PerpetualsClient = (function () {
3128
3148
  if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
3129
3149
  return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
3130
3150
  case 1:
3131
- wsolAssociatedTokenAccount = _f.sent();
3151
+ wsolAssociatedTokenAccount = _g.sent();
3132
3152
  return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
3133
3153
  case 2:
3134
- wsolATAExist = _f.sent();
3154
+ wsolATAExist = _g.sent();
3135
3155
  if (!wsolATAExist) {
3136
3156
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
3137
3157
  }
@@ -3139,11 +3159,11 @@ var PerpetualsClient = (function () {
3139
3159
  _a = anchor_1.BN.bind;
3140
3160
  return [4, this.provider.connection.getBalance(publicKey)];
3141
3161
  case 3:
3142
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
3162
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
3143
3163
  if (unWrappedSolBalance.lt(amountIn)) {
3144
3164
  throw "Insufficient SOL Funds";
3145
3165
  }
3146
- _f.label = 4;
3166
+ _g.label = 4;
3147
3167
  case 4:
3148
3168
  instructions.push(web3_js_1.SystemProgram.transfer({
3149
3169
  fromPubkey: publicKey,
@@ -3165,20 +3185,20 @@ var PerpetualsClient = (function () {
3165
3185
  additionalSigners: additionalSigners
3166
3186
  }];
3167
3187
  }
3168
- _f.label = 6;
3188
+ _g.label = 6;
3169
3189
  case 6:
3170
- _f.trys.push([6, 19, , 20]);
3190
+ _g.trys.push([6, 19, , 20]);
3171
3191
  if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
3172
3192
  console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
3173
3193
  return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
3174
3194
  case 7:
3175
- accCreationLamports = (_f.sent());
3195
+ accCreationLamports = (_g.sent());
3176
3196
  console.log("accCreationLamports:", accCreationLamports);
3177
3197
  lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
3178
3198
  _b = anchor_1.BN.bind;
3179
3199
  return [4, this.provider.connection.getBalance(publicKey)];
3180
3200
  case 8:
3181
- unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _f.sent()]))();
3201
+ unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
3182
3202
  if (unWrappedSolBalance.lt(amountIn)) {
3183
3203
  throw "Insufficient SOL Funds";
3184
3204
  }
@@ -3205,18 +3225,18 @@ var PerpetualsClient = (function () {
3205
3225
  userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
3206
3226
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
3207
3227
  case 10:
3208
- if (!(_f.sent())) {
3228
+ if (!(_g.sent())) {
3209
3229
  throw "Insufficient Funds , Token Account doesn't exist";
3210
3230
  }
3211
3231
  if (!!skipBalanceChecks) return [3, 12];
3212
3232
  _c = anchor_1.BN.bind;
3213
3233
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
3214
3234
  case 11:
3215
- tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
3235
+ tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3216
3236
  if (tokenAccountBalance.lt(amountIn)) {
3217
3237
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
3218
3238
  }
3219
- _f.label = 12;
3239
+ _g.label = 12;
3220
3240
  case 12:
3221
3241
  if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
3222
3242
  lamports = (this.minimumBalanceForRentExemptAccountLamports);
@@ -3241,23 +3261,23 @@ var PerpetualsClient = (function () {
3241
3261
  return [3, 17];
3242
3262
  case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
3243
3263
  case 14:
3244
- userOutputTokenAccount = _f.sent();
3264
+ userOutputTokenAccount = _g.sent();
3245
3265
  _d = createUserATA;
3246
3266
  if (!_d) return [3, 16];
3247
3267
  return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
3248
3268
  case 15:
3249
- _d = !(_f.sent());
3250
- _f.label = 16;
3269
+ _d = !(_g.sent());
3270
+ _g.label = 16;
3251
3271
  case 16:
3252
3272
  if (_d) {
3253
3273
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
3254
3274
  }
3255
- _f.label = 17;
3275
+ _g.label = 17;
3256
3276
  case 17:
3257
3277
  custodyAccountMetas = [];
3258
3278
  custodyOracleAccountMetas = [];
3259
- for (_i = 0, _e = poolConfig.custodies; _i < _e.length; _i++) {
3260
- custody = _e[_i];
3279
+ for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
3280
+ custody = _f[_e];
3261
3281
  custodyAccountMetas.push({
3262
3282
  pubkey: custody.custodyAccount,
3263
3283
  isSigner: false,
@@ -3297,7 +3317,7 @@ var PerpetualsClient = (function () {
3297
3317
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
3298
3318
  .instruction()];
3299
3319
  case 18:
3300
- inx = _f.sent();
3320
+ inx = _g.sent();
3301
3321
  instructions.push(inx);
3302
3322
  if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
3303
3323
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
@@ -3305,7 +3325,7 @@ var PerpetualsClient = (function () {
3305
3325
  }
3306
3326
  return [3, 20];
3307
3327
  case 19:
3308
- err_4 = _f.sent();
3328
+ err_4 = _g.sent();
3309
3329
  console.error("perpClient Swap error:: ", err_4);
3310
3330
  throw err_4;
3311
3331
  case 20: return [2, {
@@ -3387,11 +3407,15 @@ var PerpetualsClient = (function () {
3387
3407
  }
3388
3408
  });
3389
3409
  }); };
3390
- this.addCollateral = function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3391
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3392
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3393
- return __awaiter(_this, void 0, void 0, function () {
3410
+ this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3411
+ var args_1 = [];
3412
+ for (var _i = 6; _i < arguments.length; _i++) {
3413
+ args_1[_i - 6] = arguments[_i];
3414
+ }
3415
+ return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3394
3416
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
3417
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3418
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3395
3419
  return __generator(this, function (_c) {
3396
3420
  switch (_c.label) {
3397
3421
  case 0:
@@ -3485,11 +3509,15 @@ var PerpetualsClient = (function () {
3485
3509
  });
3486
3510
  });
3487
3511
  };
3488
- this.swapAndAddCollateral = function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3489
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3490
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3491
- return __awaiter(_this, void 0, void 0, function () {
3512
+ this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
3513
+ var args_1 = [];
3514
+ for (var _i = 8; _i < arguments.length; _i++) {
3515
+ args_1[_i - 8] = arguments[_i];
3516
+ }
3517
+ return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3492
3518
  var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
3519
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3520
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3493
3521
  return __generator(this, function (_c) {
3494
3522
  switch (_c.label) {
3495
3523
  case 0:
@@ -3600,12 +3628,16 @@ var PerpetualsClient = (function () {
3600
3628
  });
3601
3629
  });
3602
3630
  };
3603
- this.removeCollateral = function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3604
- if (createUserATA === void 0) { createUserATA = true; }
3605
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3606
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3607
- return __awaiter(_this, void 0, void 0, function () {
3631
+ this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3632
+ var args_1 = [];
3633
+ for (var _i = 6; _i < arguments.length; _i++) {
3634
+ args_1[_i - 6] = arguments[_i];
3635
+ }
3636
+ return __awaiter(_this, __spreadArray([collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3608
3637
  var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_3;
3638
+ if (createUserATA === void 0) { createUserATA = true; }
3639
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3640
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3609
3641
  return __generator(this, function (_b) {
3610
3642
  switch (_b.label) {
3611
3643
  case 0:
@@ -3706,10 +3738,14 @@ var PerpetualsClient = (function () {
3706
3738
  });
3707
3739
  });
3708
3740
  };
3709
- this.removeCollateralAndSwap = function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
3710
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3711
- return __awaiter(_this, void 0, void 0, function () {
3741
+ this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
3742
+ var args_1 = [];
3743
+ for (var _i = 7; _i < arguments.length; _i++) {
3744
+ args_1[_i - 7] = arguments[_i];
3745
+ }
3746
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
3712
3747
  var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
3748
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3713
3749
  return __generator(this, function (_a) {
3714
3750
  switch (_a.label) {
3715
3751
  case 0:
@@ -3802,12 +3838,16 @@ var PerpetualsClient = (function () {
3802
3838
  });
3803
3839
  });
3804
3840
  };
3805
- this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3806
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3807
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3808
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3809
- return __awaiter(_this, void 0, void 0, function () {
3841
+ this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3842
+ var args_1 = [];
3843
+ for (var _i = 8; _i < arguments.length; _i++) {
3844
+ args_1[_i - 8] = arguments[_i];
3845
+ }
3846
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3810
3847
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3848
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3849
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3850
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3811
3851
  return __generator(this, function (_a) {
3812
3852
  switch (_a.label) {
3813
3853
  case 0:
@@ -3862,12 +3902,16 @@ var PerpetualsClient = (function () {
3862
3902
  });
3863
3903
  });
3864
3904
  };
3865
- this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3866
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3867
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3868
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3869
- return __awaiter(_this, void 0, void 0, function () {
3905
+ this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3906
+ var args_1 = [];
3907
+ for (var _i = 8; _i < arguments.length; _i++) {
3908
+ args_1[_i - 8] = arguments[_i];
3909
+ }
3910
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3870
3911
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3912
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3913
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3914
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3871
3915
  return __generator(this, function (_a) {
3872
3916
  switch (_a.label) {
3873
3917
  case 0:
@@ -3922,13 +3966,17 @@ var PerpetualsClient = (function () {
3922
3966
  });
3923
3967
  });
3924
3968
  };
3925
- this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3926
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3927
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3928
- return __awaiter(_this, void 0, void 0, function () {
3929
- var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, tokenAccountBalance, _e, instruction, err_6;
3930
- return __generator(this, function (_f) {
3931
- switch (_f.label) {
3969
+ this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
3970
+ var args_1 = [];
3971
+ for (var _i = 4; _i < arguments.length; _i++) {
3972
+ args_1[_i - 4] = arguments[_i];
3973
+ }
3974
+ return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3975
+ var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, instruction, err_6;
3976
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3977
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3978
+ return __generator(this, function (_g) {
3979
+ switch (_g.label) {
3932
3980
  case 0:
3933
3981
  publicKey = this.provider.wallet.publicKey;
3934
3982
  payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
@@ -3939,16 +3987,16 @@ var PerpetualsClient = (function () {
3939
3987
  instructions = [];
3940
3988
  postInstructions = [];
3941
3989
  additionalSigners = [];
3942
- _f.label = 1;
3990
+ _g.label = 1;
3943
3991
  case 1:
3944
- _f.trys.push([1, 10, , 11]);
3992
+ _g.trys.push([1, 10, , 11]);
3945
3993
  userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
3946
3994
  lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
3947
3995
  custodyAccountMetas = [];
3948
3996
  custodyOracleAccountMetas = [];
3949
3997
  markets = [];
3950
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
3951
- custody = _a[_i];
3998
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
3999
+ custody = _b[_a];
3952
4000
  custodyAccountMetas.push({
3953
4001
  pubkey: custody.custodyAccount,
3954
4002
  isSigner: false,
@@ -3960,8 +4008,8 @@ var PerpetualsClient = (function () {
3960
4008
  isWritable: false,
3961
4009
  });
3962
4010
  }
3963
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
3964
- market = _c[_b];
4011
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4012
+ market = _d[_c];
3965
4013
  markets.push({
3966
4014
  pubkey: market.marketAccount,
3967
4015
  isSigner: false,
@@ -3970,21 +4018,21 @@ var PerpetualsClient = (function () {
3970
4018
  }
3971
4019
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
3972
4020
  case 2:
3973
- if (!(_f.sent())) {
4021
+ if (!(_g.sent())) {
3974
4022
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
3975
4023
  }
3976
4024
  if (!(payTokenSymbol == 'SOL')) return [3, 5];
3977
4025
  console.log("payTokenSymbol === SOL", payTokenSymbol);
3978
4026
  lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
3979
4027
  if (!!skipBalanceChecks) return [3, 4];
3980
- _d = anchor_1.BN.bind;
4028
+ _e = anchor_1.BN.bind;
3981
4029
  return [4, this.provider.connection.getBalance(publicKey)];
3982
4030
  case 3:
3983
- unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _f.sent()]))();
4031
+ unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
3984
4032
  if (unWrappedSolBalance.lt(lamports)) {
3985
4033
  throw "Insufficient SOL Funds";
3986
4034
  }
3987
- _f.label = 4;
4035
+ _g.label = 4;
3988
4036
  case 4:
3989
4037
  if (!ephemeralSignerPubkey) {
3990
4038
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -4008,17 +4056,17 @@ var PerpetualsClient = (function () {
4008
4056
  if (!!skipBalanceChecks) return [3, 8];
4009
4057
  return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
4010
4058
  case 6:
4011
- if (!(_f.sent())) {
4059
+ if (!(_g.sent())) {
4012
4060
  throw "Insufficient Funds , token Account doesn't exist";
4013
4061
  }
4014
- _e = anchor_1.BN.bind;
4062
+ _f = anchor_1.BN.bind;
4015
4063
  return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
4016
4064
  case 7:
4017
- tokenAccountBalance = new (_e.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4065
+ tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4018
4066
  if (tokenAccountBalance.lt(tokenAmountIn)) {
4019
4067
  throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
4020
4068
  }
4021
- _f.label = 8;
4069
+ _g.label = 8;
4022
4070
  case 8: return [4, this.program.methods
4023
4071
  .addLiquidity({
4024
4072
  amountIn: tokenAmountIn,
@@ -4043,11 +4091,11 @@ var PerpetualsClient = (function () {
4043
4091
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4044
4092
  .instruction()];
4045
4093
  case 9:
4046
- instruction = _f.sent();
4094
+ instruction = _g.sent();
4047
4095
  instructions.push(instruction);
4048
4096
  return [3, 11];
4049
4097
  case 10:
4050
- err_6 = _f.sent();
4098
+ err_6 = _g.sent();
4051
4099
  console.error("perpClient addLiquidity error:: ", err_6);
4052
4100
  throw err_6;
4053
4101
  case 11: return [2, {
@@ -4058,13 +4106,17 @@ var PerpetualsClient = (function () {
4058
4106
  });
4059
4107
  });
4060
4108
  };
4061
- this.addLiquidityAndStake = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
4062
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4063
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4064
- return __awaiter(_this, void 0, void 0, function () {
4065
- var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, instruction;
4066
- return __generator(this, function (_f) {
4067
- switch (_f.label) {
4109
+ this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
4110
+ var args_1 = [];
4111
+ for (var _i = 4; _i < arguments.length; _i++) {
4112
+ args_1[_i - 4] = arguments[_i];
4113
+ }
4114
+ return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
4115
+ var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, instruction;
4116
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4117
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4118
+ return __generator(this, function (_g) {
4119
+ switch (_g.label) {
4068
4120
  case 0:
4069
4121
  publicKey = this.provider.wallet.publicKey;
4070
4122
  preInstructions = [];
@@ -4084,14 +4136,14 @@ var PerpetualsClient = (function () {
4084
4136
  _a = anchor_1.BN.bind;
4085
4137
  return [4, this.provider.connection.getBalance(publicKey)];
4086
4138
  case 1:
4087
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
4139
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
4088
4140
  if (unWrappedSolBalance.lt(lamports)) {
4089
4141
  throw "Insufficient SOL Funds";
4090
4142
  }
4091
- _f.label = 2;
4143
+ _g.label = 2;
4092
4144
  case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4093
4145
  case 3:
4094
- if (!(_f.sent())) {
4146
+ if (!(_g.sent())) {
4095
4147
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4096
4148
  }
4097
4149
  if (!ephemeralSignerPubkey) {
@@ -4117,23 +4169,23 @@ var PerpetualsClient = (function () {
4117
4169
  if (!!skipBalanceChecks) return [3, 7];
4118
4170
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
4119
4171
  case 5:
4120
- if (!(_f.sent())) {
4172
+ if (!(_g.sent())) {
4121
4173
  throw "Insufficient Funds , token Account doesn't exist";
4122
4174
  }
4123
4175
  _b = anchor_1.BN.bind;
4124
4176
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
4125
4177
  case 6:
4126
- tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4178
+ tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4127
4179
  if (tokenAccountBalance.lt(amountIn)) {
4128
4180
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
4129
4181
  }
4130
- _f.label = 7;
4182
+ _g.label = 7;
4131
4183
  case 7:
4132
4184
  custodyAccountMetas = [];
4133
4185
  custodyOracleAccountMetas = [];
4134
4186
  markets = [];
4135
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
4136
- custody = _c[_i];
4187
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
4188
+ custody = _d[_c];
4137
4189
  custodyAccountMetas.push({
4138
4190
  pubkey: custody.custodyAccount,
4139
4191
  isSigner: false,
@@ -4145,8 +4197,8 @@ var PerpetualsClient = (function () {
4145
4197
  isWritable: false,
4146
4198
  });
4147
4199
  }
4148
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
4149
- market = _e[_d];
4200
+ for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
4201
+ market = _f[_e];
4150
4202
  markets.push({
4151
4203
  pubkey: market.marketAccount,
4152
4204
  isSigner: false,
@@ -4178,7 +4230,7 @@ var PerpetualsClient = (function () {
4178
4230
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4179
4231
  .instruction()];
4180
4232
  case 8:
4181
- instruction = _f.sent();
4233
+ instruction = _g.sent();
4182
4234
  instructions.push(instruction);
4183
4235
  return [2, {
4184
4236
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4188,15 +4240,19 @@ var PerpetualsClient = (function () {
4188
4240
  });
4189
4241
  });
4190
4242
  };
4191
- this.removeLiquidity = function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
4192
- if (closeLpATA === void 0) { closeLpATA = false; }
4193
- if (createUserATA === void 0) { createUserATA = true; }
4194
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4195
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4196
- return __awaiter(_this, void 0, void 0, function () {
4197
- var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns, err_7;
4198
- return __generator(this, function (_e) {
4199
- switch (_e.label) {
4243
+ this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
4244
+ var args_1 = [];
4245
+ for (var _i = 4; _i < arguments.length; _i++) {
4246
+ args_1[_i - 4] = arguments[_i];
4247
+ }
4248
+ return __awaiter(_this, __spreadArray([recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1], args_1, true), void 0, function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
4249
+ var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, removeLiquidityTx, closeInx, closeWsolATAIns, err_7;
4250
+ if (closeLpATA === void 0) { closeLpATA = false; }
4251
+ if (createUserATA === void 0) { createUserATA = true; }
4252
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4253
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4254
+ return __generator(this, function (_f) {
4255
+ switch (_f.label) {
4200
4256
  case 0:
4201
4257
  recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
4202
4258
  if (!recieveTokenCustodyConfig) {
@@ -4207,15 +4263,15 @@ var PerpetualsClient = (function () {
4207
4263
  instructions = [];
4208
4264
  postInstructions = [];
4209
4265
  additionalSigners = [];
4210
- _e.label = 1;
4266
+ _f.label = 1;
4211
4267
  case 1:
4212
- _e.trys.push([1, 7, , 8]);
4268
+ _f.trys.push([1, 7, , 8]);
4213
4269
  stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4214
4270
  custodyAccountMetas = [];
4215
4271
  custodyOracleAccountMetas = [];
4216
4272
  markets = [];
4217
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4218
- custody = _a[_i];
4273
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4274
+ custody = _b[_a];
4219
4275
  custodyAccountMetas.push({
4220
4276
  pubkey: custody.custodyAccount,
4221
4277
  isSigner: false,
@@ -4227,8 +4283,8 @@ var PerpetualsClient = (function () {
4227
4283
  isWritable: false,
4228
4284
  });
4229
4285
  }
4230
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4231
- market = _c[_b];
4286
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4287
+ market = _d[_c];
4232
4288
  markets.push({
4233
4289
  pubkey: market.marketAccount,
4234
4290
  isSigner: false,
@@ -4257,17 +4313,17 @@ var PerpetualsClient = (function () {
4257
4313
  return [3, 5];
4258
4314
  case 2:
4259
4315
  userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
4260
- _d = createUserATA;
4261
- if (!_d) return [3, 4];
4316
+ _e = createUserATA;
4317
+ if (!_e) return [3, 4];
4262
4318
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
4263
4319
  case 3:
4264
- _d = !(_e.sent());
4265
- _e.label = 4;
4320
+ _e = !(_f.sent());
4321
+ _f.label = 4;
4266
4322
  case 4:
4267
- if (_d) {
4323
+ if (_e) {
4268
4324
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
4269
4325
  }
4270
- _e.label = 5;
4326
+ _f.label = 5;
4271
4327
  case 5: return [4, this.program.methods
4272
4328
  .removeLiquidity({
4273
4329
  lpAmountIn: liquidityAmountIn,
@@ -4292,7 +4348,7 @@ var PerpetualsClient = (function () {
4292
4348
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4293
4349
  .instruction()];
4294
4350
  case 6:
4295
- removeLiquidityTx = _e.sent();
4351
+ removeLiquidityTx = _f.sent();
4296
4352
  instructions.push(removeLiquidityTx);
4297
4353
  if (closeLpATA) {
4298
4354
  closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
@@ -4304,7 +4360,7 @@ var PerpetualsClient = (function () {
4304
4360
  }
4305
4361
  return [3, 8];
4306
4362
  case 7:
4307
- err_7 = _e.sent();
4363
+ err_7 = _f.sent();
4308
4364
  console.log("perpClient removeLiquidity error:: ", err_7);
4309
4365
  throw err_7;
4310
4366
  case 8: return [2, {
@@ -4667,8 +4723,63 @@ var PerpetualsClient = (function () {
4667
4723
  }
4668
4724
  });
4669
4725
  }); };
4726
+ this.refreshStakeWithAllFlpStakeAccounts = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4727
+ var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_15;
4728
+ return __generator(this, function (_c) {
4729
+ switch (_c.label) {
4730
+ case 0:
4731
+ _c.trys.push([0, 2, , 3]);
4732
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4733
+ rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4734
+ pool = poolConfig.poolAddress;
4735
+ feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4736
+ custodyAccountMetas = [];
4737
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4738
+ custody = _a[_i];
4739
+ custodyAccountMetas.push({
4740
+ pubkey: custody.custodyAccount,
4741
+ isSigner: false,
4742
+ isWritable: false,
4743
+ });
4744
+ }
4745
+ maxFlpStakeAccountPkLength = 32 - 4 + custodyAccountMetas.length;
4746
+ if (flpStakeAccountPks.length > maxFlpStakeAccountPkLength) {
4747
+ throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
4748
+ }
4749
+ flpStakeAccountMetas = [];
4750
+ for (_b = 0, flpStakeAccountPks_1 = flpStakeAccountPks; _b < flpStakeAccountPks_1.length; _b++) {
4751
+ flpStakeAccountPk = flpStakeAccountPks_1[_b];
4752
+ flpStakeAccountMetas.push({
4753
+ pubkey: flpStakeAccountPk,
4754
+ isSigner: false,
4755
+ isWritable: true,
4756
+ });
4757
+ }
4758
+ return [4, this.program.methods
4759
+ .refreshStake({})
4760
+ .accounts({
4761
+ perpetuals: this.perpetuals.publicKey,
4762
+ pool: pool,
4763
+ rewardCustody: rewardCustodyConfig.custodyAccount,
4764
+ feeDistributionTokenAccount: feeDistributionTokenAccount,
4765
+ eventAuthority: this.eventAuthority.publicKey,
4766
+ program: this.program.programId,
4767
+ })
4768
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), flpStakeAccountMetas, true))
4769
+ .instruction()];
4770
+ case 1:
4771
+ refreshStakeInstruction = _c.sent();
4772
+ return [2, refreshStakeInstruction];
4773
+ case 2:
4774
+ err_15 = _c.sent();
4775
+ console.log("perpClient refreshStaking error:: ", err_15);
4776
+ throw err_15;
4777
+ case 3: return [2];
4778
+ }
4779
+ });
4780
+ }); };
4670
4781
  this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk) { return __awaiter(_this, void 0, void 0, function () {
4671
- var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_15;
4782
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
4672
4783
  return __generator(this, function (_b) {
4673
4784
  switch (_b.label) {
4674
4785
  case 0:
@@ -4715,15 +4826,15 @@ var PerpetualsClient = (function () {
4715
4826
  refreshStakeInstruction = _b.sent();
4716
4827
  return [2, refreshStakeInstruction];
4717
4828
  case 2:
4718
- err_15 = _b.sent();
4719
- console.log("perpClient refreshStaking error:: ", err_15);
4720
- throw err_15;
4829
+ err_16 = _b.sent();
4830
+ console.log("perpClient refreshStaking error:: ", err_16);
4831
+ throw err_16;
4721
4832
  case 3: return [2];
4722
4833
  }
4723
4834
  });
4724
4835
  }); };
4725
4836
  this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4726
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_16;
4837
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
4727
4838
  return __generator(this, function (_b) {
4728
4839
  switch (_b.label) {
4729
4840
  case 0:
@@ -4774,9 +4885,9 @@ var PerpetualsClient = (function () {
4774
4885
  instructions.push(unstakeInstantInstruction);
4775
4886
  return [3, 6];
4776
4887
  case 5:
4777
- err_16 = _b.sent();
4778
- console.log("perpClient unstakeInstant error:: ", err_16);
4779
- throw err_16;
4888
+ err_17 = _b.sent();
4889
+ console.log("perpClient unstakeInstant error:: ", err_17);
4890
+ throw err_17;
4780
4891
  case 6: return [2, {
4781
4892
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4782
4893
  additionalSigners: additionalSigners
@@ -4785,7 +4896,7 @@ var PerpetualsClient = (function () {
4785
4896
  });
4786
4897
  }); };
4787
4898
  this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4788
- var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_17;
4899
+ var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_18;
4789
4900
  return __generator(this, function (_c) {
4790
4901
  switch (_c.label) {
4791
4902
  case 0:
@@ -4806,8 +4917,8 @@ var PerpetualsClient = (function () {
4806
4917
  throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
4807
4918
  }
4808
4919
  flpStakeAccountMetas = [];
4809
- for (_b = 0, flpStakeAccountPks_1 = flpStakeAccountPks; _b < flpStakeAccountPks_1.length; _b++) {
4810
- flpStakeAccountPk = flpStakeAccountPks_1[_b];
4920
+ for (_b = 0, flpStakeAccountPks_2 = flpStakeAccountPks; _b < flpStakeAccountPks_2.length; _b++) {
4921
+ flpStakeAccountPk = flpStakeAccountPks_2[_b];
4811
4922
  flpStakeAccountMetas.push({
4812
4923
  pubkey: flpStakeAccountPk,
4813
4924
  isSigner: false,
@@ -4829,15 +4940,15 @@ var PerpetualsClient = (function () {
4829
4940
  refreshStakeInstruction = _c.sent();
4830
4941
  return [2, refreshStakeInstruction];
4831
4942
  case 2:
4832
- err_17 = _c.sent();
4833
- console.log("perpClient refreshStaking error:: ", err_17);
4834
- throw err_17;
4943
+ err_18 = _c.sent();
4944
+ console.log("perpClient refreshStaking error:: ", err_18);
4945
+ throw err_18;
4835
4946
  case 3: return [2];
4836
4947
  }
4837
4948
  });
4838
4949
  }); };
4839
4950
  this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4840
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_18;
4951
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_19;
4841
4952
  return __generator(this, function (_a) {
4842
4953
  switch (_a.label) {
4843
4954
  case 0:
@@ -4871,9 +4982,9 @@ var PerpetualsClient = (function () {
4871
4982
  instructions.push(unstakeRequestInstruction);
4872
4983
  return [3, 4];
4873
4984
  case 3:
4874
- err_18 = _a.sent();
4875
- console.log("perpClient unstakeRequest error:: ", err_18);
4876
- throw err_18;
4985
+ err_19 = _a.sent();
4986
+ console.log("perpClient unstakeRequest error:: ", err_19);
4987
+ throw err_19;
4877
4988
  case 4: return [2, {
4878
4989
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4879
4990
  additionalSigners: additionalSigners
@@ -4881,12 +4992,16 @@ var PerpetualsClient = (function () {
4881
4992
  }
4882
4993
  });
4883
4994
  }); };
4884
- this.withdrawStake = function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
4885
- if (pendingActivation === void 0) { pendingActivation = true; }
4886
- if (deactivated === void 0) { deactivated = true; }
4887
- if (createUserLPTA === void 0) { createUserLPTA = true; }
4888
- return __awaiter(_this, void 0, void 0, function () {
4889
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_19;
4995
+ this.withdrawStake = function (poolConfig_1) {
4996
+ var args_1 = [];
4997
+ for (var _i = 1; _i < arguments.length; _i++) {
4998
+ args_1[_i - 1] = arguments[_i];
4999
+ }
5000
+ return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
5001
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_20;
5002
+ if (pendingActivation === void 0) { pendingActivation = true; }
5003
+ if (deactivated === void 0) { deactivated = true; }
5004
+ if (createUserLPTA === void 0) { createUserLPTA = true; }
4890
5005
  return __generator(this, function (_b) {
4891
5006
  switch (_b.label) {
4892
5007
  case 0:
@@ -4937,9 +5052,9 @@ var PerpetualsClient = (function () {
4937
5052
  instructions.push(withdrawStakeInstruction);
4938
5053
  return [3, 6];
4939
5054
  case 5:
4940
- err_19 = _b.sent();
4941
- console.log("perpClient withdrawStake error:: ", err_19);
4942
- throw err_19;
5055
+ err_20 = _b.sent();
5056
+ console.log("perpClient withdrawStake error:: ", err_20);
5057
+ throw err_20;
4943
5058
  case 6: return [2, {
4944
5059
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4945
5060
  additionalSigners: additionalSigners
@@ -4948,10 +5063,14 @@ var PerpetualsClient = (function () {
4948
5063
  });
4949
5064
  });
4950
5065
  };
4951
- this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
4952
- if (createUserATA === void 0) { createUserATA = true; }
4953
- return __awaiter(_this, void 0, void 0, function () {
4954
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_20;
5066
+ this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
5067
+ var args_1 = [];
5068
+ for (var _i = 3; _i < arguments.length; _i++) {
5069
+ args_1[_i - 3] = arguments[_i];
5070
+ }
5071
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
5072
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
5073
+ if (createUserATA === void 0) { createUserATA = true; }
4955
5074
  return __generator(this, function (_b) {
4956
5075
  switch (_b.label) {
4957
5076
  case 0:
@@ -5010,9 +5129,9 @@ var PerpetualsClient = (function () {
5010
5129
  instructions.push(withdrawStakeInstruction);
5011
5130
  return [3, 6];
5012
5131
  case 5:
5013
- err_20 = _b.sent();
5014
- console.log("perpClient withdrawStake error:: ", err_20);
5015
- throw err_20;
5132
+ err_21 = _b.sent();
5133
+ console.log("perpClient withdrawStake error:: ", err_21);
5134
+ throw err_21;
5016
5135
  case 6: return [2, {
5017
5136
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5018
5137
  additionalSigners: additionalSigners
@@ -5022,7 +5141,7 @@ var PerpetualsClient = (function () {
5022
5141
  });
5023
5142
  };
5024
5143
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5025
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_21;
5144
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_22;
5026
5145
  return __generator(this, function (_a) {
5027
5146
  switch (_a.label) {
5028
5147
  case 0:
@@ -5063,9 +5182,9 @@ var PerpetualsClient = (function () {
5063
5182
  instructions.push(initTokenVaultInstruction);
5064
5183
  return [3, 4];
5065
5184
  case 3:
5066
- err_21 = _a.sent();
5067
- console.log("perpClient InitTokenVaultInstruction error:: ", err_21);
5068
- throw err_21;
5185
+ err_22 = _a.sent();
5186
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_22);
5187
+ throw err_22;
5069
5188
  case 4: return [2, {
5070
5189
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5071
5190
  additionalSigners: additionalSigners
@@ -5074,7 +5193,7 @@ var PerpetualsClient = (function () {
5074
5193
  });
5075
5194
  }); };
5076
5195
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5077
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_22;
5196
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_23;
5078
5197
  return __generator(this, function (_a) {
5079
5198
  switch (_a.label) {
5080
5199
  case 0:
@@ -5104,9 +5223,9 @@ var PerpetualsClient = (function () {
5104
5223
  instructions.push(setTokenVaultConfigInstruction);
5105
5224
  return [3, 4];
5106
5225
  case 3:
5107
- err_22 = _a.sent();
5108
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_22);
5109
- throw err_22;
5226
+ err_23 = _a.sent();
5227
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_23);
5228
+ throw err_23;
5110
5229
  case 4: return [2, {
5111
5230
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5112
5231
  additionalSigners: additionalSigners
@@ -5115,7 +5234,7 @@ var PerpetualsClient = (function () {
5115
5234
  });
5116
5235
  }); };
5117
5236
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5118
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_23;
5237
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_24;
5119
5238
  return __generator(this, function (_a) {
5120
5239
  switch (_a.label) {
5121
5240
  case 0:
@@ -5153,9 +5272,9 @@ var PerpetualsClient = (function () {
5153
5272
  instructions.push(withdrawInstantFeeInstruction);
5154
5273
  return [3, 6];
5155
5274
  case 5:
5156
- err_23 = _a.sent();
5157
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_23);
5158
- throw err_23;
5275
+ err_24 = _a.sent();
5276
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_24);
5277
+ throw err_24;
5159
5278
  case 6: return [2, {
5160
5279
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5161
5280
  additionalSigners: additionalSigners
@@ -5164,7 +5283,7 @@ var PerpetualsClient = (function () {
5164
5283
  });
5165
5284
  }); };
5166
5285
  this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
5167
- var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_24;
5286
+ var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_25;
5168
5287
  return __generator(this, function (_b) {
5169
5288
  switch (_b.label) {
5170
5289
  case 0:
@@ -5228,9 +5347,9 @@ var PerpetualsClient = (function () {
5228
5347
  instructions.push(burnAndClaimInstruction);
5229
5348
  return [3, 8];
5230
5349
  case 7:
5231
- err_24 = _b.sent();
5232
- console.log("perpClient burnAndClaimInstruction error:: ", err_24);
5233
- throw err_24;
5350
+ err_25 = _b.sent();
5351
+ console.log("perpClient burnAndClaimInstruction error:: ", err_25);
5352
+ throw err_25;
5234
5353
  case 8: return [2, {
5235
5354
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5236
5355
  additionalSigners: additionalSigners
@@ -5239,7 +5358,7 @@ var PerpetualsClient = (function () {
5239
5358
  });
5240
5359
  }); };
5241
5360
  this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5242
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_25;
5361
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_26;
5243
5362
  return __generator(this, function (_a) {
5244
5363
  switch (_a.label) {
5245
5364
  case 0:
@@ -5290,9 +5409,9 @@ var PerpetualsClient = (function () {
5290
5409
  instructions.push(burnAndStakeInstruction);
5291
5410
  return [3, 4];
5292
5411
  case 3:
5293
- err_25 = _a.sent();
5294
- console.log("perpClient burnAndStakeInstruction error:: ", err_25);
5295
- throw err_25;
5412
+ err_26 = _a.sent();
5413
+ console.log("perpClient burnAndStakeInstruction error:: ", err_26);
5414
+ throw err_26;
5296
5415
  case 4: return [2, {
5297
5416
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5298
5417
  additionalSigners: additionalSigners
@@ -5301,7 +5420,7 @@ var PerpetualsClient = (function () {
5301
5420
  });
5302
5421
  }); };
5303
5422
  this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5304
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_26;
5423
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_27;
5305
5424
  return __generator(this, function (_a) {
5306
5425
  switch (_a.label) {
5307
5426
  case 0:
@@ -5342,9 +5461,9 @@ var PerpetualsClient = (function () {
5342
5461
  instructions.push(depositTokenStakeInstruction);
5343
5462
  return [3, 5];
5344
5463
  case 4:
5345
- err_26 = _a.sent();
5346
- console.log("perpClient depositStakingInstruction error:: ", err_26);
5347
- throw err_26;
5464
+ err_27 = _a.sent();
5465
+ console.log("perpClient depositStakingInstruction error:: ", err_27);
5466
+ throw err_27;
5348
5467
  case 5: return [2, {
5349
5468
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5350
5469
  additionalSigners: additionalSigners
@@ -5353,7 +5472,7 @@ var PerpetualsClient = (function () {
5353
5472
  });
5354
5473
  }); };
5355
5474
  this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5356
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_27;
5475
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_28;
5357
5476
  return __generator(this, function (_a) {
5358
5477
  switch (_a.label) {
5359
5478
  case 0:
@@ -5382,9 +5501,9 @@ var PerpetualsClient = (function () {
5382
5501
  instructions.push(unstakeTokenRequestInstruction);
5383
5502
  return [3, 4];
5384
5503
  case 3:
5385
- err_27 = _a.sent();
5386
- console.log("perpClient unstakeTokenRequestInstruction error:: ", err_27);
5387
- throw err_27;
5504
+ err_28 = _a.sent();
5505
+ console.log("perpClient unstakeTokenRequestInstruction error:: ", err_28);
5506
+ throw err_28;
5388
5507
  case 4: return [2, {
5389
5508
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5390
5509
  additionalSigners: additionalSigners
@@ -5393,7 +5512,7 @@ var PerpetualsClient = (function () {
5393
5512
  });
5394
5513
  }); };
5395
5514
  this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5396
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_28;
5515
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_29;
5397
5516
  return __generator(this, function (_a) {
5398
5517
  switch (_a.label) {
5399
5518
  case 0:
@@ -5433,9 +5552,9 @@ var PerpetualsClient = (function () {
5433
5552
  instructions.push(unstakeTokenInstantInstruction);
5434
5553
  return [3, 5];
5435
5554
  case 4:
5436
- err_28 = _a.sent();
5437
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_28);
5438
- throw err_28;
5555
+ err_29 = _a.sent();
5556
+ console.log("perpClient unstakeTokenInstantInstruction error:: ", err_29);
5557
+ throw err_29;
5439
5558
  case 5: return [2, {
5440
5559
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5441
5560
  additionalSigners: additionalSigners
@@ -5444,7 +5563,7 @@ var PerpetualsClient = (function () {
5444
5563
  });
5445
5564
  }); };
5446
5565
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5447
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_29;
5566
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_30;
5448
5567
  return __generator(this, function (_a) {
5449
5568
  switch (_a.label) {
5450
5569
  case 0:
@@ -5484,9 +5603,9 @@ var PerpetualsClient = (function () {
5484
5603
  instructions.push(withdrawTokenInstruction);
5485
5604
  return [3, 5];
5486
5605
  case 4:
5487
- err_29 = _a.sent();
5488
- console.log("perpClient withdrawTokenInstruction error:: ", err_29);
5489
- throw err_29;
5606
+ err_30 = _a.sent();
5607
+ console.log("perpClient withdrawTokenInstruction error:: ", err_30);
5608
+ throw err_30;
5490
5609
  case 5: return [2, {
5491
5610
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5492
5611
  additionalSigners: additionalSigners
@@ -5495,7 +5614,7 @@ var PerpetualsClient = (function () {
5495
5614
  });
5496
5615
  }); };
5497
5616
  this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5498
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_30;
5617
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_31;
5499
5618
  return __generator(this, function (_a) {
5500
5619
  switch (_a.label) {
5501
5620
  case 0:
@@ -5524,9 +5643,9 @@ var PerpetualsClient = (function () {
5524
5643
  instructions.push(cancelUnstakeRequestInstruction);
5525
5644
  return [3, 4];
5526
5645
  case 3:
5527
- err_30 = _a.sent();
5528
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_30);
5529
- throw err_30;
5646
+ err_31 = _a.sent();
5647
+ console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_31);
5648
+ throw err_31;
5530
5649
  case 4: return [2, {
5531
5650
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5532
5651
  additionalSigners: additionalSigners
@@ -5535,7 +5654,7 @@ var PerpetualsClient = (function () {
5535
5654
  });
5536
5655
  }); };
5537
5656
  this.distributeTokenReward = function (amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5538
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_31;
5657
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_32;
5539
5658
  return __generator(this, function (_a) {
5540
5659
  switch (_a.label) {
5541
5660
  case 0:
@@ -5571,9 +5690,9 @@ var PerpetualsClient = (function () {
5571
5690
  instructions.push(distributeTokenRewardInstruction);
5572
5691
  return [3, 4];
5573
5692
  case 3:
5574
- err_31 = _a.sent();
5575
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_31);
5576
- throw err_31;
5693
+ err_32 = _a.sent();
5694
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_32);
5695
+ throw err_32;
5577
5696
  case 4: return [2, {
5578
5697
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5579
5698
  additionalSigners: additionalSigners
@@ -5582,7 +5701,7 @@ var PerpetualsClient = (function () {
5582
5701
  });
5583
5702
  }); };
5584
5703
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5585
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_32;
5704
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_33;
5586
5705
  return __generator(this, function (_a) {
5587
5706
  switch (_a.label) {
5588
5707
  case 0:
@@ -5614,9 +5733,9 @@ var PerpetualsClient = (function () {
5614
5733
  instructions.push(setTokenRewardInstruction);
5615
5734
  return [3, 4];
5616
5735
  case 3:
5617
- err_32 = _a.sent();
5618
- console.log("perpClient setTokenRewardInstruction error:: ", err_32);
5619
- throw err_32;
5736
+ err_33 = _a.sent();
5737
+ console.log("perpClient setTokenRewardInstruction error:: ", err_33);
5738
+ throw err_33;
5620
5739
  case 4: return [2, {
5621
5740
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5622
5741
  additionalSigners: additionalSigners
@@ -5624,10 +5743,14 @@ var PerpetualsClient = (function () {
5624
5743
  }
5625
5744
  });
5626
5745
  }); };
5627
- this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5628
- if (createUserATA === void 0) { createUserATA = true; }
5629
- return __awaiter(_this, void 0, void 0, function () {
5630
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_33;
5746
+ this.collectTokenReward = function (owner_1, poolConfig_1) {
5747
+ var args_1 = [];
5748
+ for (var _i = 2; _i < arguments.length; _i++) {
5749
+ args_1[_i - 2] = arguments[_i];
5750
+ }
5751
+ return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5752
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
5753
+ if (createUserATA === void 0) { createUserATA = true; }
5631
5754
  return __generator(this, function (_b) {
5632
5755
  switch (_b.label) {
5633
5756
  case 0:
@@ -5671,9 +5794,9 @@ var PerpetualsClient = (function () {
5671
5794
  instructions.push(collectTokenRewardInstruction);
5672
5795
  return [3, 6];
5673
5796
  case 5:
5674
- err_33 = _b.sent();
5675
- console.log("perpClient collectTokenRewardInstruction error:: ", err_33);
5676
- throw err_33;
5797
+ err_34 = _b.sent();
5798
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_34);
5799
+ throw err_34;
5677
5800
  case 6: return [2, {
5678
5801
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5679
5802
  additionalSigners: additionalSigners
@@ -5683,7 +5806,7 @@ var PerpetualsClient = (function () {
5683
5806
  });
5684
5807
  };
5685
5808
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
5686
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_34;
5809
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_35;
5687
5810
  return __generator(this, function (_a) {
5688
5811
  switch (_a.label) {
5689
5812
  case 0:
@@ -5711,9 +5834,9 @@ var PerpetualsClient = (function () {
5711
5834
  instructions.push(setTokenStakeLevelInstruction);
5712
5835
  return [3, 4];
5713
5836
  case 3:
5714
- err_34 = _a.sent();
5715
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_34);
5716
- throw err_34;
5837
+ err_35 = _a.sent();
5838
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_35);
5839
+ throw err_35;
5717
5840
  case 4: return [2, {
5718
5841
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5719
5842
  additionalSigners: additionalSigners
@@ -5722,7 +5845,7 @@ var PerpetualsClient = (function () {
5722
5845
  });
5723
5846
  }); };
5724
5847
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5725
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_35;
5848
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_36;
5726
5849
  return __generator(this, function (_a) {
5727
5850
  switch (_a.label) {
5728
5851
  case 0:
@@ -5759,9 +5882,9 @@ var PerpetualsClient = (function () {
5759
5882
  instructions.push(initRewardVault);
5760
5883
  return [3, 4];
5761
5884
  case 3:
5762
- err_35 = _a.sent();
5763
- console.log("perpClient InitRewardVault error:: ", err_35);
5764
- throw err_35;
5885
+ err_36 = _a.sent();
5886
+ console.log("perpClient InitRewardVault error:: ", err_36);
5887
+ throw err_36;
5765
5888
  case 4: return [2, {
5766
5889
  instructions: __spreadArray([], instructions, true),
5767
5890
  additionalSigners: additionalSigners
@@ -5770,7 +5893,7 @@ var PerpetualsClient = (function () {
5770
5893
  });
5771
5894
  }); };
5772
5895
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5773
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_36;
5896
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_37;
5774
5897
  return __generator(this, function (_a) {
5775
5898
  switch (_a.label) {
5776
5899
  case 0:
@@ -5801,9 +5924,9 @@ var PerpetualsClient = (function () {
5801
5924
  instructions.push(distributeReward);
5802
5925
  return [3, 4];
5803
5926
  case 3:
5804
- err_36 = _a.sent();
5805
- console.log("perpClient distributeReward error:: ", err_36);
5806
- throw err_36;
5927
+ err_37 = _a.sent();
5928
+ console.log("perpClient distributeReward error:: ", err_37);
5929
+ throw err_37;
5807
5930
  case 4: return [2, {
5808
5931
  instructions: __spreadArray([], instructions, true),
5809
5932
  additionalSigners: additionalSigners
@@ -5811,10 +5934,14 @@ var PerpetualsClient = (function () {
5811
5934
  }
5812
5935
  });
5813
5936
  }); };
5814
- this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5815
- if (createUserATA === void 0) { createUserATA = true; }
5816
- return __awaiter(_this, void 0, void 0, function () {
5817
- var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_37;
5937
+ this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
5938
+ var args_1 = [];
5939
+ for (var _i = 3; _i < arguments.length; _i++) {
5940
+ args_1[_i - 3] = arguments[_i];
5941
+ }
5942
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5943
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_38;
5944
+ if (createUserATA === void 0) { createUserATA = true; }
5818
5945
  return __generator(this, function (_b) {
5819
5946
  switch (_b.label) {
5820
5947
  case 0:
@@ -5864,8 +5991,8 @@ var PerpetualsClient = (function () {
5864
5991
  instructions.push(collectNftReward);
5865
5992
  return [3, 6];
5866
5993
  case 5:
5867
- err_37 = _b.sent();
5868
- throw err_37;
5994
+ err_38 = _b.sent();
5995
+ throw err_38;
5869
5996
  case 6: return [2, {
5870
5997
  instructions: __spreadArray([], instructions, true),
5871
5998
  additionalSigners: additionalSigners
@@ -5874,10 +6001,14 @@ var PerpetualsClient = (function () {
5874
6001
  });
5875
6002
  });
5876
6003
  };
5877
- this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5878
- if (createUserATA === void 0) { createUserATA = true; }
5879
- return __awaiter(_this, void 0, void 0, function () {
5880
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_38;
6004
+ this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
6005
+ var args_1 = [];
6006
+ for (var _i = 2; _i < arguments.length; _i++) {
6007
+ args_1[_i - 2] = arguments[_i];
6008
+ }
6009
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6010
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_39;
6011
+ if (createUserATA === void 0) { createUserATA = true; }
5881
6012
  return __generator(this, function (_b) {
5882
6013
  switch (_b.label) {
5883
6014
  case 0:
@@ -5941,9 +6072,9 @@ var PerpetualsClient = (function () {
5941
6072
  instructions.push(withdrawStakeInstruction);
5942
6073
  return [3, 6];
5943
6074
  case 5:
5944
- err_38 = _b.sent();
5945
- console.log("perpClient withdrawStake error:: ", err_38);
5946
- throw err_38;
6075
+ err_39 = _b.sent();
6076
+ console.log("perpClient withdrawStake error:: ", err_39);
6077
+ throw err_39;
5947
6078
  case 6: return [2, {
5948
6079
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5949
6080
  additionalSigners: additionalSigners
@@ -5953,7 +6084,7 @@ var PerpetualsClient = (function () {
5953
6084
  });
5954
6085
  };
5955
6086
  this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5956
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_39;
6087
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_40;
5957
6088
  return __generator(this, function (_a) {
5958
6089
  switch (_a.label) {
5959
6090
  case 0:
@@ -5992,9 +6123,9 @@ var PerpetualsClient = (function () {
5992
6123
  instructions.push(setTriggerPrice);
5993
6124
  return [3, 4];
5994
6125
  case 3:
5995
- err_39 = _a.sent();
5996
- console.log("perpClient setTriggerPrice error:: ", err_39);
5997
- throw err_39;
6126
+ err_40 = _a.sent();
6127
+ console.log("perpClient setTriggerPrice error:: ", err_40);
6128
+ throw err_40;
5998
6129
  case 4: return [2, {
5999
6130
  instructions: __spreadArray([], instructions, true),
6000
6131
  additionalSigners: additionalSigners
@@ -6002,12 +6133,16 @@ var PerpetualsClient = (function () {
6002
6133
  }
6003
6134
  });
6004
6135
  }); };
6005
- this.forceClosePosition = function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6006
- if (createUserATA === void 0) { createUserATA = true; }
6007
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6008
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6009
- return __awaiter(_this, void 0, void 0, function () {
6010
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_40;
6136
+ this.forceClosePosition = function (positionAccount_1, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
6137
+ var args_1 = [];
6138
+ for (var _i = 6; _i < arguments.length; _i++) {
6139
+ args_1[_i - 6] = arguments[_i];
6140
+ }
6141
+ return __awaiter(_this, __spreadArray([positionAccount_1, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1], args_1, true), void 0, function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6142
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_41;
6143
+ if (createUserATA === void 0) { createUserATA = true; }
6144
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6145
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6011
6146
  return __generator(this, function (_b) {
6012
6147
  switch (_b.label) {
6013
6148
  case 0:
@@ -6068,9 +6203,9 @@ var PerpetualsClient = (function () {
6068
6203
  }
6069
6204
  return [3, 7];
6070
6205
  case 6:
6071
- err_40 = _b.sent();
6072
- console.log("perpClient forceClosePosition error:: ", err_40);
6073
- throw err_40;
6206
+ err_41 = _b.sent();
6207
+ console.log("perpClient forceClosePosition error:: ", err_41);
6208
+ throw err_41;
6074
6209
  case 7: return [2, {
6075
6210
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6076
6211
  additionalSigners: additionalSigners
@@ -6079,11 +6214,15 @@ var PerpetualsClient = (function () {
6079
6214
  });
6080
6215
  });
6081
6216
  };
6082
- this.placeLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6083
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6084
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6085
- return __awaiter(_this, void 0, void 0, function () {
6086
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_41;
6217
+ this.placeLimitOrder = function (targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1) {
6218
+ var args_1 = [];
6219
+ for (var _i = 11; _i < arguments.length; _i++) {
6220
+ args_1[_i - 11] = arguments[_i];
6221
+ }
6222
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6223
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_42;
6224
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6225
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6087
6226
  return __generator(this, function (_c) {
6088
6227
  switch (_c.label) {
6089
6228
  case 0:
@@ -6188,9 +6327,9 @@ var PerpetualsClient = (function () {
6188
6327
  instructions.push(placeLimitOrder);
6189
6328
  return [3, 11];
6190
6329
  case 10:
6191
- err_41 = _c.sent();
6192
- console.log("perpClient placeLimitOrder error:: ", err_41);
6193
- throw err_41;
6330
+ err_42 = _c.sent();
6331
+ console.log("perpClient placeLimitOrder error:: ", err_42);
6332
+ throw err_42;
6194
6333
  case 11: return [2, {
6195
6334
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6196
6335
  additionalSigners: additionalSigners
@@ -6199,11 +6338,15 @@ var PerpetualsClient = (function () {
6199
6338
  });
6200
6339
  });
6201
6340
  };
6202
- this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6203
- if (createUserATA === void 0) { createUserATA = true; }
6204
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6205
- return __awaiter(_this, void 0, void 0, function () {
6206
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_42;
6341
+ this.editLimitOrder = function (targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1) {
6342
+ var args_1 = [];
6343
+ for (var _i = 11; _i < arguments.length; _i++) {
6344
+ args_1[_i - 11] = arguments[_i];
6345
+ }
6346
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6347
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_43;
6348
+ if (createUserATA === void 0) { createUserATA = true; }
6349
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6207
6350
  return __generator(this, function (_b) {
6208
6351
  switch (_b.label) {
6209
6352
  case 0:
@@ -6291,9 +6434,9 @@ var PerpetualsClient = (function () {
6291
6434
  instructions.push(editLimitOrder);
6292
6435
  return [3, 8];
6293
6436
  case 7:
6294
- err_42 = _b.sent();
6295
- console.log("perpClient editLimitOrder error:: ", err_42);
6296
- throw err_42;
6437
+ err_43 = _b.sent();
6438
+ console.log("perpClient editLimitOrder error:: ", err_43);
6439
+ throw err_43;
6297
6440
  case 8: return [2, {
6298
6441
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6299
6442
  additionalSigners: additionalSigners
@@ -6302,12 +6445,16 @@ var PerpetualsClient = (function () {
6302
6445
  });
6303
6446
  });
6304
6447
  };
6305
- this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6306
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6307
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6308
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6309
- return __awaiter(_this, void 0, void 0, function () {
6310
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_43;
6448
+ this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6449
+ var args_1 = [];
6450
+ for (var _i = 7; _i < arguments.length; _i++) {
6451
+ args_1[_i - 7] = arguments[_i];
6452
+ }
6453
+ return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6454
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_44;
6455
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6456
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6457
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6311
6458
  return __generator(this, function (_a) {
6312
6459
  switch (_a.label) {
6313
6460
  case 0:
@@ -6356,9 +6503,9 @@ var PerpetualsClient = (function () {
6356
6503
  instructions.push(executeLimitOrder);
6357
6504
  return [3, 4];
6358
6505
  case 3:
6359
- err_43 = _a.sent();
6360
- console.log("perpClient executeLimitOrder error:: ", err_43);
6361
- throw err_43;
6506
+ err_44 = _a.sent();
6507
+ console.log("perpClient executeLimitOrder error:: ", err_44);
6508
+ throw err_44;
6362
6509
  case 4: return [2, {
6363
6510
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6364
6511
  additionalSigners: additionalSigners
@@ -6367,12 +6514,16 @@ var PerpetualsClient = (function () {
6367
6514
  });
6368
6515
  });
6369
6516
  };
6370
- this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6371
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6372
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6373
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6374
- return __awaiter(_this, void 0, void 0, function () {
6375
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_44;
6517
+ this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6518
+ var args_1 = [];
6519
+ for (var _i = 8; _i < arguments.length; _i++) {
6520
+ args_1[_i - 8] = arguments[_i];
6521
+ }
6522
+ return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6523
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_45;
6524
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6525
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6526
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6376
6527
  return __generator(this, function (_a) {
6377
6528
  switch (_a.label) {
6378
6529
  case 0:
@@ -6424,9 +6575,9 @@ var PerpetualsClient = (function () {
6424
6575
  instructions.push(executeLimitWithSwap);
6425
6576
  return [3, 4];
6426
6577
  case 3:
6427
- err_44 = _a.sent();
6428
- console.log("perpClient executeLimitWithSwap error:: ", err_44);
6429
- throw err_44;
6578
+ err_45 = _a.sent();
6579
+ console.log("perpClient executeLimitWithSwap error:: ", err_45);
6580
+ throw err_45;
6430
6581
  case 4: return [2, {
6431
6582
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6432
6583
  additionalSigners: additionalSigners
@@ -6436,7 +6587,7 @@ var PerpetualsClient = (function () {
6436
6587
  });
6437
6588
  };
6438
6589
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6439
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_45;
6590
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_46;
6440
6591
  return __generator(this, function (_a) {
6441
6592
  switch (_a.label) {
6442
6593
  case 0:
@@ -6484,9 +6635,9 @@ var PerpetualsClient = (function () {
6484
6635
  instructions.push(placeTriggerOrder);
6485
6636
  return [3, 4];
6486
6637
  case 3:
6487
- err_45 = _a.sent();
6488
- console.log("perpClient placeTriggerOrder error:: ", err_45);
6489
- throw err_45;
6638
+ err_46 = _a.sent();
6639
+ console.log("perpClient placeTriggerOrder error:: ", err_46);
6640
+ throw err_46;
6490
6641
  case 4: return [2, {
6491
6642
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6492
6643
  additionalSigners: additionalSigners
@@ -6495,7 +6646,7 @@ var PerpetualsClient = (function () {
6495
6646
  });
6496
6647
  }); };
6497
6648
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6498
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_46;
6649
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_47;
6499
6650
  return __generator(this, function (_a) {
6500
6651
  switch (_a.label) {
6501
6652
  case 0:
@@ -6542,9 +6693,9 @@ var PerpetualsClient = (function () {
6542
6693
  instructions.push(editTriggerOrder);
6543
6694
  return [3, 4];
6544
6695
  case 3:
6545
- err_46 = _a.sent();
6546
- console.log("perpClient editTriggerOrder error:: ", err_46);
6547
- throw err_46;
6696
+ err_47 = _a.sent();
6697
+ console.log("perpClient editTriggerOrder error:: ", err_47);
6698
+ throw err_47;
6548
6699
  case 4: return [2, {
6549
6700
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6550
6701
  additionalSigners: additionalSigners
@@ -6553,7 +6704,7 @@ var PerpetualsClient = (function () {
6553
6704
  });
6554
6705
  }); };
6555
6706
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6556
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_47;
6707
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_48;
6557
6708
  return __generator(this, function (_a) {
6558
6709
  switch (_a.label) {
6559
6710
  case 0:
@@ -6586,9 +6737,9 @@ var PerpetualsClient = (function () {
6586
6737
  instructions.push(cancelTriggerOrder);
6587
6738
  return [3, 4];
6588
6739
  case 3:
6589
- err_47 = _a.sent();
6590
- console.log("perpClient cancelTriggerOrder error:: ", err_47);
6591
- throw err_47;
6740
+ err_48 = _a.sent();
6741
+ console.log("perpClient cancelTriggerOrder error:: ", err_48);
6742
+ throw err_48;
6592
6743
  case 4: return [2, {
6593
6744
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6594
6745
  additionalSigners: additionalSigners
@@ -6597,7 +6748,7 @@ var PerpetualsClient = (function () {
6597
6748
  });
6598
6749
  }); };
6599
6750
  this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6600
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_48;
6751
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_49;
6601
6752
  return __generator(this, function (_a) {
6602
6753
  switch (_a.label) {
6603
6754
  case 0:
@@ -6628,9 +6779,9 @@ var PerpetualsClient = (function () {
6628
6779
  instructions.push(cancelAllTriggerOrders);
6629
6780
  return [3, 4];
6630
6781
  case 3:
6631
- err_48 = _a.sent();
6632
- console.log("perpClient cancelAllTriggerOrders error:: ", err_48);
6633
- throw err_48;
6782
+ err_49 = _a.sent();
6783
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_49);
6784
+ throw err_49;
6634
6785
  case 4: return [2, {
6635
6786
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6636
6787
  additionalSigners: additionalSigners
@@ -6638,16 +6789,20 @@ var PerpetualsClient = (function () {
6638
6789
  }
6639
6790
  });
6640
6791
  }); };
6641
- this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6642
- if (createUserATA === void 0) { createUserATA = true; }
6643
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6644
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6645
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6646
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6647
- return __awaiter(_this, void 0, void 0, function () {
6648
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_49;
6649
- return __generator(this, function (_d) {
6650
- switch (_d.label) {
6792
+ this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
6793
+ var args_1 = [];
6794
+ for (var _i = 9; _i < arguments.length; _i++) {
6795
+ args_1[_i - 9] = arguments[_i];
6796
+ }
6797
+ return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6798
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_50;
6799
+ if (createUserATA === void 0) { createUserATA = true; }
6800
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6801
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6802
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6803
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6804
+ return __generator(this, function (_e) {
6805
+ switch (_e.label) {
6651
6806
  case 0:
6652
6807
  payerPubkey = this.provider.wallet.publicKey;
6653
6808
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
@@ -6658,9 +6813,9 @@ var PerpetualsClient = (function () {
6658
6813
  instructions = [];
6659
6814
  postInstructions = [];
6660
6815
  additionalSigners = [];
6661
- _d.label = 1;
6816
+ _e.label = 1;
6662
6817
  case 1:
6663
- _d.trys.push([1, 9, , 10]);
6818
+ _e.trys.push([1, 9, , 10]);
6664
6819
  if (!false) return [3, 2];
6665
6820
  return [3, 7];
6666
6821
  case 2:
@@ -6669,8 +6824,8 @@ var PerpetualsClient = (function () {
6669
6824
  if (!_a) return [3, 4];
6670
6825
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6671
6826
  case 3:
6672
- _a = !(_d.sent());
6673
- _d.label = 4;
6827
+ _a = !(_e.sent());
6828
+ _e.label = 4;
6674
6829
  case 4:
6675
6830
  if (_a) {
6676
6831
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
@@ -6680,20 +6835,20 @@ var PerpetualsClient = (function () {
6680
6835
  if (!_b) return [3, 6];
6681
6836
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
6682
6837
  case 5:
6683
- _b = !(_d.sent());
6684
- _d.label = 6;
6838
+ _b = !(_e.sent());
6839
+ _e.label = 6;
6685
6840
  case 6:
6686
6841
  if (_b) {
6687
6842
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
6688
6843
  }
6689
- _d.label = 7;
6844
+ _e.label = 7;
6690
6845
  case 7:
6691
6846
  positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
6692
6847
  orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
6693
6848
  custodyAccountMetas = [];
6694
6849
  custodyOracleAccountMetas = [];
6695
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
6696
- custody = _c[_i];
6850
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
6851
+ custody = _d[_c];
6697
6852
  custodyAccountMetas.push({
6698
6853
  pubkey: custody.custodyAccount,
6699
6854
  isSigner: false,
@@ -6738,13 +6893,13 @@ var PerpetualsClient = (function () {
6738
6893
  .remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
6739
6894
  .instruction()];
6740
6895
  case 8:
6741
- executeTriggerWithSwap = _d.sent();
6896
+ executeTriggerWithSwap = _e.sent();
6742
6897
  instructions.push(executeTriggerWithSwap);
6743
6898
  return [3, 10];
6744
6899
  case 9:
6745
- err_49 = _d.sent();
6746
- console.log("perpClient executeTriggerWithSwap error:: ", err_49);
6747
- throw err_49;
6900
+ err_50 = _e.sent();
6901
+ console.log("perpClient executeTriggerWithSwap error:: ", err_50);
6902
+ throw err_50;
6748
6903
  case 10: return [2, {
6749
6904
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6750
6905
  additionalSigners: additionalSigners
@@ -6753,14 +6908,18 @@ var PerpetualsClient = (function () {
6753
6908
  });
6754
6909
  });
6755
6910
  };
6756
- this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6757
- if (createUserATA === void 0) { createUserATA = true; }
6758
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6759
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6760
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6761
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6762
- return __awaiter(_this, void 0, void 0, function () {
6763
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_50;
6911
+ this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
6912
+ var args_1 = [];
6913
+ for (var _i = 8; _i < arguments.length; _i++) {
6914
+ args_1[_i - 8] = arguments[_i];
6915
+ }
6916
+ return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6917
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_51;
6918
+ if (createUserATA === void 0) { createUserATA = true; }
6919
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6920
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6921
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6922
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6764
6923
  return __generator(this, function (_b) {
6765
6924
  switch (_b.label) {
6766
6925
  case 0:
@@ -6826,9 +6985,9 @@ var PerpetualsClient = (function () {
6826
6985
  instructions.push(executeTriggerOrder);
6827
6986
  return [3, 8];
6828
6987
  case 7:
6829
- err_50 = _b.sent();
6830
- console.log("perpClient executeTriggerOrder error:: ", err_50);
6831
- throw err_50;
6988
+ err_51 = _b.sent();
6989
+ console.log("perpClient executeTriggerOrder error:: ", err_51);
6990
+ throw err_51;
6832
6991
  case 8: return [2, {
6833
6992
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6834
6993
  additionalSigners: additionalSigners
@@ -6838,7 +6997,7 @@ var PerpetualsClient = (function () {
6838
6997
  });
6839
6998
  };
6840
6999
  this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6841
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_51;
7000
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_52;
6842
7001
  return __generator(this, function (_a) {
6843
7002
  switch (_a.label) {
6844
7003
  case 0:
@@ -6868,9 +7027,9 @@ var PerpetualsClient = (function () {
6868
7027
  instructions.push(migrateTriggerOrder);
6869
7028
  return [3, 4];
6870
7029
  case 3:
6871
- err_51 = _a.sent();
6872
- console.log("perpClient migrateTriggerOrder error:: ", err_51);
6873
- throw err_51;
7030
+ err_52 = _a.sent();
7031
+ console.log("perpClient migrateTriggerOrder error:: ", err_52);
7032
+ throw err_52;
6874
7033
  case 4: return [2, {
6875
7034
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6876
7035
  additionalSigners: additionalSigners
@@ -6879,7 +7038,7 @@ var PerpetualsClient = (function () {
6879
7038
  });
6880
7039
  }); };
6881
7040
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6882
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_52;
7041
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_53;
6883
7042
  return __generator(this, function (_a) {
6884
7043
  switch (_a.label) {
6885
7044
  case 0:
@@ -6908,15 +7067,15 @@ var PerpetualsClient = (function () {
6908
7067
  console.log(getPositionData);
6909
7068
  return [2, getPositionData];
6910
7069
  case 3:
6911
- err_52 = _a.sent();
6912
- console.log("perpClient setPool error:: ", err_52);
6913
- throw err_52;
7070
+ err_53 = _a.sent();
7071
+ console.log("perpClient setPool error:: ", err_53);
7072
+ throw err_53;
6914
7073
  case 4: return [2];
6915
7074
  }
6916
7075
  });
6917
7076
  }); };
6918
7077
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6919
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_53;
7078
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_54;
6920
7079
  return __generator(this, function (_a) {
6921
7080
  switch (_a.label) {
6922
7081
  case 0:
@@ -6949,9 +7108,9 @@ var PerpetualsClient = (function () {
6949
7108
  instructions.push(withdrawFeesIx);
6950
7109
  return [3, 5];
6951
7110
  case 4:
6952
- err_53 = _a.sent();
6953
- console.log("perpClient setPool error:: ", err_53);
6954
- throw err_53;
7111
+ err_54 = _a.sent();
7112
+ console.log("perpClient setPool error:: ", err_54);
7113
+ throw err_54;
6955
7114
  case 5: return [2, {
6956
7115
  instructions: __spreadArray([], instructions, true),
6957
7116
  additionalSigners: additionalSigners
@@ -6960,7 +7119,7 @@ var PerpetualsClient = (function () {
6960
7119
  });
6961
7120
  }); };
6962
7121
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
6963
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_54;
7122
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_55;
6964
7123
  return __generator(this, function (_a) {
6965
7124
  switch (_a.label) {
6966
7125
  case 0:
@@ -6987,9 +7146,9 @@ var PerpetualsClient = (function () {
6987
7146
  instructions.push(setPermissionsInstruction);
6988
7147
  return [3, 4];
6989
7148
  case 3:
6990
- err_54 = _a.sent();
6991
- console.log("perpClient setPool error:: ", err_54);
6992
- throw err_54;
7149
+ err_55 = _a.sent();
7150
+ console.log("perpClient setPool error:: ", err_55);
7151
+ throw err_55;
6993
7152
  case 4: return [2, {
6994
7153
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6995
7154
  additionalSigners: additionalSigners
@@ -6998,7 +7157,7 @@ var PerpetualsClient = (function () {
6998
7157
  });
6999
7158
  }); };
7000
7159
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7001
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_55;
7160
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_56;
7002
7161
  var _f;
7003
7162
  return __generator(this, function (_g) {
7004
7163
  switch (_g.label) {
@@ -7058,9 +7217,9 @@ var PerpetualsClient = (function () {
7058
7217
  instructions.push(reimburse);
7059
7218
  return [3, 5];
7060
7219
  case 4:
7061
- err_55 = _g.sent();
7062
- console.log("perpClient setPool error:: ", err_55);
7063
- throw err_55;
7220
+ err_56 = _g.sent();
7221
+ console.log("perpClient setPool error:: ", err_56);
7222
+ throw err_56;
7064
7223
  case 5: return [2, {
7065
7224
  instructions: __spreadArray([], instructions, true),
7066
7225
  additionalSigners: additionalSigners
@@ -7069,7 +7228,7 @@ var PerpetualsClient = (function () {
7069
7228
  });
7070
7229
  }); };
7071
7230
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7072
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_56;
7231
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_57;
7073
7232
  return __generator(this, function (_a) {
7074
7233
  switch (_a.label) {
7075
7234
  case 0:
@@ -7102,9 +7261,9 @@ var PerpetualsClient = (function () {
7102
7261
  instructions.push(setInternalOraclePrice);
7103
7262
  return [3, 4];
7104
7263
  case 3:
7105
- err_56 = _a.sent();
7106
- console.log("perpClient setInternalOracleAccount error:: ", err_56);
7107
- throw err_56;
7264
+ err_57 = _a.sent();
7265
+ console.log("perpClient setInternalOracleAccount error:: ", err_57);
7266
+ throw err_57;
7108
7267
  case 4: return [2, {
7109
7268
  instructions: __spreadArray([], instructions, true),
7110
7269
  additionalSigners: additionalSigners
@@ -7112,13 +7271,17 @@ var PerpetualsClient = (function () {
7112
7271
  }
7113
7272
  });
7114
7273
  }); };
7115
- this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
7116
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7117
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7118
- return __awaiter(_this, void 0, void 0, function () {
7119
- var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, addCompoundingLiquidity, err_57;
7120
- return __generator(this, function (_e) {
7121
- switch (_e.label) {
7274
+ this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
7275
+ var args_1 = [];
7276
+ for (var _i = 5; _i < arguments.length; _i++) {
7277
+ args_1[_i - 5] = arguments[_i];
7278
+ }
7279
+ return __awaiter(_this, __spreadArray([amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
7280
+ var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, addCompoundingLiquidity, err_58;
7281
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7282
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7283
+ return __generator(this, function (_f) {
7284
+ switch (_f.label) {
7122
7285
  case 0:
7123
7286
  publicKey = this.provider.wallet.publicKey;
7124
7287
  preInstructions = [];
@@ -7135,8 +7298,8 @@ var PerpetualsClient = (function () {
7135
7298
  custodyAccountMetas = [];
7136
7299
  custodyOracleAccountMetas = [];
7137
7300
  markets = [];
7138
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7139
- custody = _a[_i];
7301
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7302
+ custody = _b[_a];
7140
7303
  custodyAccountMetas.push({
7141
7304
  pubkey: custody.custodyAccount,
7142
7305
  isSigner: false,
@@ -7148,8 +7311,8 @@ var PerpetualsClient = (function () {
7148
7311
  isWritable: false,
7149
7312
  });
7150
7313
  }
7151
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7152
- market = _c[_b];
7314
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7315
+ market = _d[_c];
7153
7316
  markets.push({
7154
7317
  pubkey: market.marketAccount,
7155
7318
  isSigner: false,
@@ -7158,26 +7321,26 @@ var PerpetualsClient = (function () {
7158
7321
  }
7159
7322
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
7160
7323
  case 1:
7161
- if (!(_e.sent())) {
7324
+ if (!(_f.sent())) {
7162
7325
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
7163
7326
  }
7164
7327
  return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
7165
7328
  case 2:
7166
- if (!(_e.sent())) {
7329
+ if (!(_f.sent())) {
7167
7330
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
7168
7331
  }
7169
7332
  if (!(inTokenSymbol == 'SOL')) return [3, 5];
7170
7333
  console.log("inTokenSymbol === SOL", inTokenSymbol);
7171
7334
  lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
7172
7335
  if (!!skipBalanceChecks) return [3, 4];
7173
- _d = anchor_1.BN.bind;
7336
+ _e = anchor_1.BN.bind;
7174
7337
  return [4, this.provider.connection.getBalance(publicKey)];
7175
7338
  case 3:
7176
- unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _e.sent()]))();
7339
+ unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
7177
7340
  if (unWrappedSolBalance.lt(lamports)) {
7178
7341
  throw "Insufficient SOL Funds";
7179
7342
  }
7180
- _e.label = 4;
7343
+ _f.label = 4;
7181
7344
  case 4:
7182
7345
  if (!ephemeralSignerPubkey) {
7183
7346
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -7201,12 +7364,12 @@ var PerpetualsClient = (function () {
7201
7364
  if (!!skipBalanceChecks) return [3, 7];
7202
7365
  return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
7203
7366
  case 6:
7204
- if (!(_e.sent())) {
7367
+ if (!(_f.sent())) {
7205
7368
  throw "Insufficient Funds , token Account doesn't exist";
7206
7369
  }
7207
- _e.label = 7;
7370
+ _f.label = 7;
7208
7371
  case 7:
7209
- _e.trys.push([7, 9, , 10]);
7372
+ _f.trys.push([7, 9, , 10]);
7210
7373
  return [4, this.program.methods
7211
7374
  .addCompoundingLiquidity({
7212
7375
  amountIn: amountIn,
@@ -7235,12 +7398,12 @@ var PerpetualsClient = (function () {
7235
7398
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7236
7399
  .instruction()];
7237
7400
  case 8:
7238
- addCompoundingLiquidity = _e.sent();
7401
+ addCompoundingLiquidity = _f.sent();
7239
7402
  instructions.push(addCompoundingLiquidity);
7240
7403
  return [3, 10];
7241
7404
  case 9:
7242
- err_57 = _e.sent();
7243
- console.log("perpClient addCompoundingLiquidity error:: ", err_57);
7405
+ err_58 = _f.sent();
7406
+ console.log("perpClient addCompoundingLiquidity error:: ", err_58);
7244
7407
  return [3, 10];
7245
7408
  case 10: return [2, {
7246
7409
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7250,13 +7413,17 @@ var PerpetualsClient = (function () {
7250
7413
  });
7251
7414
  });
7252
7415
  };
7253
- this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey) {
7254
- if (createUserATA === void 0) { createUserATA = true; }
7255
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7256
- return __awaiter(_this, void 0, void 0, function () {
7257
- var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, removeCompoundingLiquidity, err_58;
7258
- return __generator(this, function (_e) {
7259
- switch (_e.label) {
7416
+ this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
7417
+ var args_1 = [];
7418
+ for (var _i = 5; _i < arguments.length; _i++) {
7419
+ args_1[_i - 5] = arguments[_i];
7420
+ }
7421
+ return __awaiter(_this, __spreadArray([compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey) {
7422
+ var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, removeCompoundingLiquidity, err_59;
7423
+ if (createUserATA === void 0) { createUserATA = true; }
7424
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7425
+ return __generator(this, function (_f) {
7426
+ switch (_f.label) {
7260
7427
  case 0:
7261
7428
  publicKey = this.provider.wallet.publicKey;
7262
7429
  preInstructions = [];
@@ -7293,19 +7460,19 @@ var PerpetualsClient = (function () {
7293
7460
  if (!_a) return [3, 3];
7294
7461
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
7295
7462
  case 2:
7296
- _a = !(_e.sent());
7297
- _e.label = 3;
7463
+ _a = !(_f.sent());
7464
+ _f.label = 3;
7298
7465
  case 3:
7299
7466
  if (_a) {
7300
7467
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
7301
7468
  }
7302
- _e.label = 4;
7469
+ _f.label = 4;
7303
7470
  case 4:
7304
7471
  custodyAccountMetas = [];
7305
7472
  custodyOracleAccountMetas = [];
7306
7473
  markets = [];
7307
- for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
7308
- custody = _b[_i];
7474
+ for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
7475
+ custody = _c[_b];
7309
7476
  custodyAccountMetas.push({
7310
7477
  pubkey: custody.custodyAccount,
7311
7478
  isSigner: false,
@@ -7317,8 +7484,8 @@ var PerpetualsClient = (function () {
7317
7484
  isWritable: false,
7318
7485
  });
7319
7486
  }
7320
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7321
- market = _d[_c];
7487
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7488
+ market = _e[_d];
7322
7489
  markets.push({
7323
7490
  pubkey: market.marketAccount,
7324
7491
  isSigner: false,
@@ -7326,9 +7493,9 @@ var PerpetualsClient = (function () {
7326
7493
  });
7327
7494
  }
7328
7495
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
7329
- _e.label = 5;
7496
+ _f.label = 5;
7330
7497
  case 5:
7331
- _e.trys.push([5, 7, , 8]);
7498
+ _f.trys.push([5, 7, , 8]);
7332
7499
  return [4, this.program.methods
7333
7500
  .removeCompoundingLiquidity({
7334
7501
  compoundingAmountIn: compoundingAmountIn,
@@ -7357,12 +7524,12 @@ var PerpetualsClient = (function () {
7357
7524
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7358
7525
  .instruction()];
7359
7526
  case 6:
7360
- removeCompoundingLiquidity = _e.sent();
7527
+ removeCompoundingLiquidity = _f.sent();
7361
7528
  instructions.push(removeCompoundingLiquidity);
7362
7529
  return [3, 8];
7363
7530
  case 7:
7364
- err_58 = _e.sent();
7365
- console.log("perpClient removeCompoundingLiquidity error:: ", err_58);
7531
+ err_59 = _f.sent();
7532
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_59);
7366
7533
  return [3, 8];
7367
7534
  case 8: return [2, {
7368
7535
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7372,12 +7539,16 @@ var PerpetualsClient = (function () {
7372
7539
  });
7373
7540
  });
7374
7541
  };
7375
- this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7376
- if (createUserATA === void 0) { createUserATA = true; }
7377
- return __awaiter(_this, void 0, void 0, function () {
7378
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, migrateStake, err_59;
7379
- return __generator(this, function (_f) {
7380
- switch (_f.label) {
7542
+ this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
7543
+ var args_1 = [];
7544
+ for (var _i = 3; _i < arguments.length; _i++) {
7545
+ args_1[_i - 3] = arguments[_i];
7546
+ }
7547
+ return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
7548
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_60;
7549
+ if (createUserATA === void 0) { createUserATA = true; }
7550
+ return __generator(this, function (_g) {
7551
+ switch (_g.label) {
7381
7552
  case 0:
7382
7553
  publicKey = this.provider.wallet.publicKey;
7383
7554
  preInstructions = [];
@@ -7392,8 +7563,8 @@ var PerpetualsClient = (function () {
7392
7563
  if (!_a) return [3, 2];
7393
7564
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
7394
7565
  case 1:
7395
- _a = !(_f.sent());
7396
- _f.label = 2;
7566
+ _a = !(_g.sent());
7567
+ _g.label = 2;
7397
7568
  case 2:
7398
7569
  if (_a) {
7399
7570
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
@@ -7405,8 +7576,8 @@ var PerpetualsClient = (function () {
7405
7576
  if (!_b) return [3, 4];
7406
7577
  return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
7407
7578
  case 3:
7408
- _b = (_f.sent());
7409
- _f.label = 4;
7579
+ _b = (_g.sent());
7580
+ _g.label = 4;
7410
7581
  case 4:
7411
7582
  if (_b) {
7412
7583
  tokenStakeAccounts.push({
@@ -7419,8 +7590,8 @@ var PerpetualsClient = (function () {
7419
7590
  custodyAccountMetas = [];
7420
7591
  custodyOracleAccountMetas = [];
7421
7592
  markets = [];
7422
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
7423
- custody = _c[_i];
7593
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7594
+ custody = _d[_c];
7424
7595
  custodyAccountMetas.push({
7425
7596
  pubkey: custody.custodyAccount,
7426
7597
  isSigner: false,
@@ -7432,17 +7603,17 @@ var PerpetualsClient = (function () {
7432
7603
  isWritable: false,
7433
7604
  });
7434
7605
  }
7435
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7436
- market = _e[_d];
7606
+ for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
7607
+ market = _f[_e];
7437
7608
  markets.push({
7438
7609
  pubkey: market.marketAccount,
7439
7610
  isSigner: false,
7440
7611
  isWritable: false,
7441
7612
  });
7442
7613
  }
7443
- _f.label = 5;
7614
+ _g.label = 5;
7444
7615
  case 5:
7445
- _f.trys.push([5, 7, , 8]);
7616
+ _g.trys.push([5, 7, , 8]);
7446
7617
  return [4, this.program.methods
7447
7618
  .migrateStake({
7448
7619
  amount: amount
@@ -7468,12 +7639,12 @@ var PerpetualsClient = (function () {
7468
7639
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
7469
7640
  .instruction()];
7470
7641
  case 6:
7471
- migrateStake = _f.sent();
7642
+ migrateStake = _g.sent();
7472
7643
  instructions.push(migrateStake);
7473
7644
  return [3, 8];
7474
7645
  case 7:
7475
- err_59 = _f.sent();
7476
- console.log("perpClient migrateStake error:: ", err_59);
7646
+ err_60 = _g.sent();
7647
+ console.log("perpClient migrateStake error:: ", err_60);
7477
7648
  return [3, 8];
7478
7649
  case 8: return [2, {
7479
7650
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7484,7 +7655,7 @@ var PerpetualsClient = (function () {
7484
7655
  });
7485
7656
  };
7486
7657
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7487
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_60;
7658
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_61;
7488
7659
  return __generator(this, function (_d) {
7489
7660
  switch (_d.label) {
7490
7661
  case 0:
@@ -7556,8 +7727,8 @@ var PerpetualsClient = (function () {
7556
7727
  instructions.push(migrateFlp);
7557
7728
  return [3, 4];
7558
7729
  case 3:
7559
- err_60 = _d.sent();
7560
- console.log("perpClient migrateFlp error:: ", err_60);
7730
+ err_61 = _d.sent();
7731
+ console.log("perpClient migrateFlp error:: ", err_61);
7561
7732
  return [3, 4];
7562
7733
  case 4: return [2, {
7563
7734
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7566,12 +7737,16 @@ var PerpetualsClient = (function () {
7566
7737
  }
7567
7738
  });
7568
7739
  }); };
7569
- this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7570
- if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7571
- return __awaiter(_this, void 0, void 0, function () {
7572
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_61;
7573
- return __generator(this, function (_d) {
7574
- switch (_d.label) {
7740
+ this.compoundingFee = function (poolConfig_1) {
7741
+ var args_1 = [];
7742
+ for (var _i = 1; _i < arguments.length; _i++) {
7743
+ args_1[_i - 1] = arguments[_i];
7744
+ }
7745
+ return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
7746
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_62;
7747
+ if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7748
+ return __generator(this, function (_e) {
7749
+ switch (_e.label) {
7575
7750
  case 0:
7576
7751
  instructions = [];
7577
7752
  additionalSigners = [];
@@ -7580,8 +7755,8 @@ var PerpetualsClient = (function () {
7580
7755
  custodyAccountMetas = [];
7581
7756
  custodyOracleAccountMetas = [];
7582
7757
  markets = [];
7583
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7584
- custody = _a[_i];
7758
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7759
+ custody = _b[_a];
7585
7760
  custodyAccountMetas.push({
7586
7761
  pubkey: custody.custodyAccount,
7587
7762
  isSigner: false,
@@ -7593,17 +7768,17 @@ var PerpetualsClient = (function () {
7593
7768
  isWritable: false,
7594
7769
  });
7595
7770
  }
7596
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7597
- market = _c[_b];
7771
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7772
+ market = _d[_c];
7598
7773
  markets.push({
7599
7774
  pubkey: market.marketAccount,
7600
7775
  isSigner: false,
7601
7776
  isWritable: false,
7602
7777
  });
7603
7778
  }
7604
- _d.label = 1;
7779
+ _e.label = 1;
7605
7780
  case 1:
7606
- _d.trys.push([1, 3, , 4]);
7781
+ _e.trys.push([1, 3, , 4]);
7607
7782
  return [4, this.program.methods
7608
7783
  .compoundFees({})
7609
7784
  .accounts({
@@ -7622,12 +7797,12 @@ var PerpetualsClient = (function () {
7622
7797
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7623
7798
  .instruction()];
7624
7799
  case 2:
7625
- compoundingFee = _d.sent();
7800
+ compoundingFee = _e.sent();
7626
7801
  instructions.push(compoundingFee);
7627
7802
  return [3, 4];
7628
7803
  case 3:
7629
- err_61 = _d.sent();
7630
- console.log("perpClient compoundingFee error:: ", err_61);
7804
+ err_62 = _e.sent();
7805
+ console.log("perpClient compoundingFee error:: ", err_62);
7631
7806
  return [3, 4];
7632
7807
  case 4: return [2, {
7633
7808
  instructions: __spreadArray([], instructions, true),
@@ -7638,7 +7813,7 @@ var PerpetualsClient = (function () {
7638
7813
  });
7639
7814
  };
7640
7815
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7641
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_62;
7816
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_63;
7642
7817
  return __generator(this, function (_a) {
7643
7818
  switch (_a.label) {
7644
7819
  case 0:
@@ -7676,8 +7851,8 @@ var PerpetualsClient = (function () {
7676
7851
  instructions.push(renameFlp);
7677
7852
  return [3, 4];
7678
7853
  case 3:
7679
- err_62 = _a.sent();
7680
- console.log("perpClient renameFlp error:: ", err_62);
7854
+ err_63 = _a.sent();
7855
+ console.log("perpClient renameFlp error:: ", err_63);
7681
7856
  return [3, 4];
7682
7857
  case 4: return [2, {
7683
7858
  instructions: __spreadArray([], instructions, true),
@@ -7787,9 +7962,9 @@ var PerpetualsClient = (function () {
7787
7962
  }
7788
7963
  }
7789
7964
  };
7790
- PerpetualsClient.prototype.sendTransaction = function (ixs, opts) {
7791
- if (opts === void 0) { opts = {}; }
7792
- return __awaiter(this, void 0, void 0, function () {
7965
+ PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
7966
+ return __awaiter(this, arguments, void 0, function (ixs, opts) {
7967
+ if (opts === void 0) { opts = {}; }
7793
7968
  return __generator(this, function (_a) {
7794
7969
  switch (_a.label) {
7795
7970
  case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
@@ -7798,9 +7973,9 @@ var PerpetualsClient = (function () {
7798
7973
  });
7799
7974
  });
7800
7975
  };
7801
- PerpetualsClient.prototype.sendTransactionV3 = function (ixs, opts) {
7802
- if (opts === void 0) { opts = {}; }
7803
- return __awaiter(this, void 0, void 0, function () {
7976
+ PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
7977
+ return __awaiter(this, arguments, void 0, function (ixs, opts) {
7978
+ if (opts === void 0) { opts = {}; }
7804
7979
  return __generator(this, function (_a) {
7805
7980
  switch (_a.label) {
7806
7981
  case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];