flash-sdk 2.46.5 → 2.46.6

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, {
@@ -4936,12 +4992,16 @@ var PerpetualsClient = (function () {
4936
4992
  }
4937
4993
  });
4938
4994
  }); };
4939
- this.withdrawStake = function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
4940
- if (pendingActivation === void 0) { pendingActivation = true; }
4941
- if (deactivated === void 0) { deactivated = true; }
4942
- if (createUserLPTA === void 0) { createUserLPTA = true; }
4943
- return __awaiter(_this, void 0, void 0, function () {
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) {
4944
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; }
4945
5005
  return __generator(this, function (_b) {
4946
5006
  switch (_b.label) {
4947
5007
  case 0:
@@ -5003,10 +5063,14 @@ var PerpetualsClient = (function () {
5003
5063
  });
5004
5064
  });
5005
5065
  };
5006
- this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
5007
- if (createUserATA === void 0) { createUserATA = true; }
5008
- return __awaiter(_this, void 0, void 0, function () {
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) {
5009
5072
  var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
5073
+ if (createUserATA === void 0) { createUserATA = true; }
5010
5074
  return __generator(this, function (_b) {
5011
5075
  switch (_b.label) {
5012
5076
  case 0:
@@ -5679,10 +5743,14 @@ var PerpetualsClient = (function () {
5679
5743
  }
5680
5744
  });
5681
5745
  }); };
5682
- this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5683
- if (createUserATA === void 0) { createUserATA = true; }
5684
- return __awaiter(_this, void 0, void 0, function () {
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) {
5685
5752
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
5753
+ if (createUserATA === void 0) { createUserATA = true; }
5686
5754
  return __generator(this, function (_b) {
5687
5755
  switch (_b.label) {
5688
5756
  case 0:
@@ -5866,10 +5934,14 @@ var PerpetualsClient = (function () {
5866
5934
  }
5867
5935
  });
5868
5936
  }); };
5869
- this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5870
- if (createUserATA === void 0) { createUserATA = true; }
5871
- return __awaiter(_this, void 0, void 0, function () {
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) {
5872
5943
  var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_38;
5944
+ if (createUserATA === void 0) { createUserATA = true; }
5873
5945
  return __generator(this, function (_b) {
5874
5946
  switch (_b.label) {
5875
5947
  case 0:
@@ -5929,10 +6001,14 @@ var PerpetualsClient = (function () {
5929
6001
  });
5930
6002
  });
5931
6003
  };
5932
- this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5933
- if (createUserATA === void 0) { createUserATA = true; }
5934
- return __awaiter(_this, void 0, void 0, function () {
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) {
5935
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; }
5936
6012
  return __generator(this, function (_b) {
5937
6013
  switch (_b.label) {
5938
6014
  case 0:
@@ -6057,12 +6133,16 @@ var PerpetualsClient = (function () {
6057
6133
  }
6058
6134
  });
6059
6135
  }); };
6060
- this.forceClosePosition = function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6061
- if (createUserATA === void 0) { createUserATA = true; }
6062
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6063
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6064
- return __awaiter(_this, void 0, void 0, function () {
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) {
6065
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; }
6066
6146
  return __generator(this, function (_b) {
6067
6147
  switch (_b.label) {
6068
6148
  case 0:
@@ -6134,11 +6214,15 @@ var PerpetualsClient = (function () {
6134
6214
  });
6135
6215
  });
6136
6216
  };
6137
- this.placeLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6138
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6139
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6140
- return __awaiter(_this, void 0, void 0, function () {
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) {
6141
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; }
6142
6226
  return __generator(this, function (_c) {
6143
6227
  switch (_c.label) {
6144
6228
  case 0:
@@ -6254,11 +6338,15 @@ var PerpetualsClient = (function () {
6254
6338
  });
6255
6339
  });
6256
6340
  };
6257
- this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6258
- if (createUserATA === void 0) { createUserATA = true; }
6259
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6260
- return __awaiter(_this, void 0, void 0, function () {
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) {
6261
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; }
6262
6350
  return __generator(this, function (_b) {
6263
6351
  switch (_b.label) {
6264
6352
  case 0:
@@ -6357,12 +6445,16 @@ var PerpetualsClient = (function () {
6357
6445
  });
6358
6446
  });
6359
6447
  };
6360
- this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6361
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6362
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6363
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6364
- return __awaiter(_this, void 0, void 0, function () {
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) {
6365
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; }
6366
6458
  return __generator(this, function (_a) {
6367
6459
  switch (_a.label) {
6368
6460
  case 0:
@@ -6422,12 +6514,16 @@ var PerpetualsClient = (function () {
6422
6514
  });
6423
6515
  });
6424
6516
  };
6425
- this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6426
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6427
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6428
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6429
- return __awaiter(_this, void 0, void 0, function () {
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) {
6430
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; }
6431
6527
  return __generator(this, function (_a) {
6432
6528
  switch (_a.label) {
6433
6529
  case 0:
@@ -6693,16 +6789,20 @@ var PerpetualsClient = (function () {
6693
6789
  }
6694
6790
  });
6695
6791
  }); };
6696
- this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6697
- if (createUserATA === void 0) { createUserATA = true; }
6698
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6699
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6700
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6701
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6702
- return __awaiter(_this, void 0, void 0, function () {
6703
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_50;
6704
- return __generator(this, function (_d) {
6705
- 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) {
6706
6806
  case 0:
6707
6807
  payerPubkey = this.provider.wallet.publicKey;
6708
6808
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
@@ -6713,9 +6813,9 @@ var PerpetualsClient = (function () {
6713
6813
  instructions = [];
6714
6814
  postInstructions = [];
6715
6815
  additionalSigners = [];
6716
- _d.label = 1;
6816
+ _e.label = 1;
6717
6817
  case 1:
6718
- _d.trys.push([1, 9, , 10]);
6818
+ _e.trys.push([1, 9, , 10]);
6719
6819
  if (!false) return [3, 2];
6720
6820
  return [3, 7];
6721
6821
  case 2:
@@ -6724,8 +6824,8 @@ var PerpetualsClient = (function () {
6724
6824
  if (!_a) return [3, 4];
6725
6825
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6726
6826
  case 3:
6727
- _a = !(_d.sent());
6728
- _d.label = 4;
6827
+ _a = !(_e.sent());
6828
+ _e.label = 4;
6729
6829
  case 4:
6730
6830
  if (_a) {
6731
6831
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
@@ -6735,20 +6835,20 @@ var PerpetualsClient = (function () {
6735
6835
  if (!_b) return [3, 6];
6736
6836
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
6737
6837
  case 5:
6738
- _b = !(_d.sent());
6739
- _d.label = 6;
6838
+ _b = !(_e.sent());
6839
+ _e.label = 6;
6740
6840
  case 6:
6741
6841
  if (_b) {
6742
6842
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
6743
6843
  }
6744
- _d.label = 7;
6844
+ _e.label = 7;
6745
6845
  case 7:
6746
6846
  positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
6747
6847
  orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
6748
6848
  custodyAccountMetas = [];
6749
6849
  custodyOracleAccountMetas = [];
6750
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
6751
- custody = _c[_i];
6850
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
6851
+ custody = _d[_c];
6752
6852
  custodyAccountMetas.push({
6753
6853
  pubkey: custody.custodyAccount,
6754
6854
  isSigner: false,
@@ -6793,11 +6893,11 @@ var PerpetualsClient = (function () {
6793
6893
  .remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
6794
6894
  .instruction()];
6795
6895
  case 8:
6796
- executeTriggerWithSwap = _d.sent();
6896
+ executeTriggerWithSwap = _e.sent();
6797
6897
  instructions.push(executeTriggerWithSwap);
6798
6898
  return [3, 10];
6799
6899
  case 9:
6800
- err_50 = _d.sent();
6900
+ err_50 = _e.sent();
6801
6901
  console.log("perpClient executeTriggerWithSwap error:: ", err_50);
6802
6902
  throw err_50;
6803
6903
  case 10: return [2, {
@@ -6808,14 +6908,18 @@ var PerpetualsClient = (function () {
6808
6908
  });
6809
6909
  });
6810
6910
  };
6811
- this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6812
- if (createUserATA === void 0) { createUserATA = true; }
6813
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6814
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6815
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6816
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6817
- return __awaiter(_this, void 0, void 0, function () {
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) {
6818
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; }
6819
6923
  return __generator(this, function (_b) {
6820
6924
  switch (_b.label) {
6821
6925
  case 0:
@@ -7167,13 +7271,17 @@ var PerpetualsClient = (function () {
7167
7271
  }
7168
7272
  });
7169
7273
  }); };
7170
- this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
7171
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7172
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7173
- return __awaiter(_this, void 0, void 0, function () {
7174
- 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_58;
7175
- return __generator(this, function (_e) {
7176
- 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) {
7177
7285
  case 0:
7178
7286
  publicKey = this.provider.wallet.publicKey;
7179
7287
  preInstructions = [];
@@ -7190,8 +7298,8 @@ var PerpetualsClient = (function () {
7190
7298
  custodyAccountMetas = [];
7191
7299
  custodyOracleAccountMetas = [];
7192
7300
  markets = [];
7193
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7194
- custody = _a[_i];
7301
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7302
+ custody = _b[_a];
7195
7303
  custodyAccountMetas.push({
7196
7304
  pubkey: custody.custodyAccount,
7197
7305
  isSigner: false,
@@ -7203,8 +7311,8 @@ var PerpetualsClient = (function () {
7203
7311
  isWritable: false,
7204
7312
  });
7205
7313
  }
7206
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7207
- market = _c[_b];
7314
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7315
+ market = _d[_c];
7208
7316
  markets.push({
7209
7317
  pubkey: market.marketAccount,
7210
7318
  isSigner: false,
@@ -7213,26 +7321,26 @@ var PerpetualsClient = (function () {
7213
7321
  }
7214
7322
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
7215
7323
  case 1:
7216
- if (!(_e.sent())) {
7324
+ if (!(_f.sent())) {
7217
7325
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
7218
7326
  }
7219
7327
  return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
7220
7328
  case 2:
7221
- if (!(_e.sent())) {
7329
+ if (!(_f.sent())) {
7222
7330
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
7223
7331
  }
7224
7332
  if (!(inTokenSymbol == 'SOL')) return [3, 5];
7225
7333
  console.log("inTokenSymbol === SOL", inTokenSymbol);
7226
7334
  lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
7227
7335
  if (!!skipBalanceChecks) return [3, 4];
7228
- _d = anchor_1.BN.bind;
7336
+ _e = anchor_1.BN.bind;
7229
7337
  return [4, this.provider.connection.getBalance(publicKey)];
7230
7338
  case 3:
7231
- unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _e.sent()]))();
7339
+ unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
7232
7340
  if (unWrappedSolBalance.lt(lamports)) {
7233
7341
  throw "Insufficient SOL Funds";
7234
7342
  }
7235
- _e.label = 4;
7343
+ _f.label = 4;
7236
7344
  case 4:
7237
7345
  if (!ephemeralSignerPubkey) {
7238
7346
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -7256,12 +7364,12 @@ var PerpetualsClient = (function () {
7256
7364
  if (!!skipBalanceChecks) return [3, 7];
7257
7365
  return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
7258
7366
  case 6:
7259
- if (!(_e.sent())) {
7367
+ if (!(_f.sent())) {
7260
7368
  throw "Insufficient Funds , token Account doesn't exist";
7261
7369
  }
7262
- _e.label = 7;
7370
+ _f.label = 7;
7263
7371
  case 7:
7264
- _e.trys.push([7, 9, , 10]);
7372
+ _f.trys.push([7, 9, , 10]);
7265
7373
  return [4, this.program.methods
7266
7374
  .addCompoundingLiquidity({
7267
7375
  amountIn: amountIn,
@@ -7290,11 +7398,11 @@ var PerpetualsClient = (function () {
7290
7398
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7291
7399
  .instruction()];
7292
7400
  case 8:
7293
- addCompoundingLiquidity = _e.sent();
7401
+ addCompoundingLiquidity = _f.sent();
7294
7402
  instructions.push(addCompoundingLiquidity);
7295
7403
  return [3, 10];
7296
7404
  case 9:
7297
- err_58 = _e.sent();
7405
+ err_58 = _f.sent();
7298
7406
  console.log("perpClient addCompoundingLiquidity error:: ", err_58);
7299
7407
  return [3, 10];
7300
7408
  case 10: return [2, {
@@ -7305,13 +7413,17 @@ var PerpetualsClient = (function () {
7305
7413
  });
7306
7414
  });
7307
7415
  };
7308
- this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey) {
7309
- if (createUserATA === void 0) { createUserATA = true; }
7310
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7311
- return __awaiter(_this, void 0, void 0, function () {
7312
- 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_59;
7313
- return __generator(this, function (_e) {
7314
- 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) {
7315
7427
  case 0:
7316
7428
  publicKey = this.provider.wallet.publicKey;
7317
7429
  preInstructions = [];
@@ -7348,19 +7460,19 @@ var PerpetualsClient = (function () {
7348
7460
  if (!_a) return [3, 3];
7349
7461
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
7350
7462
  case 2:
7351
- _a = !(_e.sent());
7352
- _e.label = 3;
7463
+ _a = !(_f.sent());
7464
+ _f.label = 3;
7353
7465
  case 3:
7354
7466
  if (_a) {
7355
7467
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
7356
7468
  }
7357
- _e.label = 4;
7469
+ _f.label = 4;
7358
7470
  case 4:
7359
7471
  custodyAccountMetas = [];
7360
7472
  custodyOracleAccountMetas = [];
7361
7473
  markets = [];
7362
- for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
7363
- custody = _b[_i];
7474
+ for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
7475
+ custody = _c[_b];
7364
7476
  custodyAccountMetas.push({
7365
7477
  pubkey: custody.custodyAccount,
7366
7478
  isSigner: false,
@@ -7372,8 +7484,8 @@ var PerpetualsClient = (function () {
7372
7484
  isWritable: false,
7373
7485
  });
7374
7486
  }
7375
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7376
- market = _d[_c];
7487
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7488
+ market = _e[_d];
7377
7489
  markets.push({
7378
7490
  pubkey: market.marketAccount,
7379
7491
  isSigner: false,
@@ -7381,9 +7493,9 @@ var PerpetualsClient = (function () {
7381
7493
  });
7382
7494
  }
7383
7495
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
7384
- _e.label = 5;
7496
+ _f.label = 5;
7385
7497
  case 5:
7386
- _e.trys.push([5, 7, , 8]);
7498
+ _f.trys.push([5, 7, , 8]);
7387
7499
  return [4, this.program.methods
7388
7500
  .removeCompoundingLiquidity({
7389
7501
  compoundingAmountIn: compoundingAmountIn,
@@ -7412,11 +7524,11 @@ var PerpetualsClient = (function () {
7412
7524
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7413
7525
  .instruction()];
7414
7526
  case 6:
7415
- removeCompoundingLiquidity = _e.sent();
7527
+ removeCompoundingLiquidity = _f.sent();
7416
7528
  instructions.push(removeCompoundingLiquidity);
7417
7529
  return [3, 8];
7418
7530
  case 7:
7419
- err_59 = _e.sent();
7531
+ err_59 = _f.sent();
7420
7532
  console.log("perpClient removeCompoundingLiquidity error:: ", err_59);
7421
7533
  return [3, 8];
7422
7534
  case 8: return [2, {
@@ -7427,12 +7539,16 @@ var PerpetualsClient = (function () {
7427
7539
  });
7428
7540
  });
7429
7541
  };
7430
- this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7431
- if (createUserATA === void 0) { createUserATA = true; }
7432
- return __awaiter(_this, void 0, void 0, function () {
7433
- 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_60;
7434
- return __generator(this, function (_f) {
7435
- 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) {
7436
7552
  case 0:
7437
7553
  publicKey = this.provider.wallet.publicKey;
7438
7554
  preInstructions = [];
@@ -7447,8 +7563,8 @@ var PerpetualsClient = (function () {
7447
7563
  if (!_a) return [3, 2];
7448
7564
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
7449
7565
  case 1:
7450
- _a = !(_f.sent());
7451
- _f.label = 2;
7566
+ _a = !(_g.sent());
7567
+ _g.label = 2;
7452
7568
  case 2:
7453
7569
  if (_a) {
7454
7570
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
@@ -7460,8 +7576,8 @@ var PerpetualsClient = (function () {
7460
7576
  if (!_b) return [3, 4];
7461
7577
  return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
7462
7578
  case 3:
7463
- _b = (_f.sent());
7464
- _f.label = 4;
7579
+ _b = (_g.sent());
7580
+ _g.label = 4;
7465
7581
  case 4:
7466
7582
  if (_b) {
7467
7583
  tokenStakeAccounts.push({
@@ -7474,8 +7590,8 @@ var PerpetualsClient = (function () {
7474
7590
  custodyAccountMetas = [];
7475
7591
  custodyOracleAccountMetas = [];
7476
7592
  markets = [];
7477
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
7478
- custody = _c[_i];
7593
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7594
+ custody = _d[_c];
7479
7595
  custodyAccountMetas.push({
7480
7596
  pubkey: custody.custodyAccount,
7481
7597
  isSigner: false,
@@ -7487,17 +7603,17 @@ var PerpetualsClient = (function () {
7487
7603
  isWritable: false,
7488
7604
  });
7489
7605
  }
7490
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7491
- market = _e[_d];
7606
+ for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
7607
+ market = _f[_e];
7492
7608
  markets.push({
7493
7609
  pubkey: market.marketAccount,
7494
7610
  isSigner: false,
7495
7611
  isWritable: false,
7496
7612
  });
7497
7613
  }
7498
- _f.label = 5;
7614
+ _g.label = 5;
7499
7615
  case 5:
7500
- _f.trys.push([5, 7, , 8]);
7616
+ _g.trys.push([5, 7, , 8]);
7501
7617
  return [4, this.program.methods
7502
7618
  .migrateStake({
7503
7619
  amount: amount
@@ -7523,11 +7639,11 @@ var PerpetualsClient = (function () {
7523
7639
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
7524
7640
  .instruction()];
7525
7641
  case 6:
7526
- migrateStake = _f.sent();
7642
+ migrateStake = _g.sent();
7527
7643
  instructions.push(migrateStake);
7528
7644
  return [3, 8];
7529
7645
  case 7:
7530
- err_60 = _f.sent();
7646
+ err_60 = _g.sent();
7531
7647
  console.log("perpClient migrateStake error:: ", err_60);
7532
7648
  return [3, 8];
7533
7649
  case 8: return [2, {
@@ -7621,12 +7737,16 @@ var PerpetualsClient = (function () {
7621
7737
  }
7622
7738
  });
7623
7739
  }); };
7624
- this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7625
- if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7626
- return __awaiter(_this, void 0, void 0, function () {
7627
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_62;
7628
- return __generator(this, function (_d) {
7629
- 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) {
7630
7750
  case 0:
7631
7751
  instructions = [];
7632
7752
  additionalSigners = [];
@@ -7635,8 +7755,8 @@ var PerpetualsClient = (function () {
7635
7755
  custodyAccountMetas = [];
7636
7756
  custodyOracleAccountMetas = [];
7637
7757
  markets = [];
7638
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7639
- custody = _a[_i];
7758
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7759
+ custody = _b[_a];
7640
7760
  custodyAccountMetas.push({
7641
7761
  pubkey: custody.custodyAccount,
7642
7762
  isSigner: false,
@@ -7648,17 +7768,17 @@ var PerpetualsClient = (function () {
7648
7768
  isWritable: false,
7649
7769
  });
7650
7770
  }
7651
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7652
- market = _c[_b];
7771
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7772
+ market = _d[_c];
7653
7773
  markets.push({
7654
7774
  pubkey: market.marketAccount,
7655
7775
  isSigner: false,
7656
7776
  isWritable: false,
7657
7777
  });
7658
7778
  }
7659
- _d.label = 1;
7779
+ _e.label = 1;
7660
7780
  case 1:
7661
- _d.trys.push([1, 3, , 4]);
7781
+ _e.trys.push([1, 3, , 4]);
7662
7782
  return [4, this.program.methods
7663
7783
  .compoundFees({})
7664
7784
  .accounts({
@@ -7677,11 +7797,11 @@ var PerpetualsClient = (function () {
7677
7797
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7678
7798
  .instruction()];
7679
7799
  case 2:
7680
- compoundingFee = _d.sent();
7800
+ compoundingFee = _e.sent();
7681
7801
  instructions.push(compoundingFee);
7682
7802
  return [3, 4];
7683
7803
  case 3:
7684
- err_62 = _d.sent();
7804
+ err_62 = _e.sent();
7685
7805
  console.log("perpClient compoundingFee error:: ", err_62);
7686
7806
  return [3, 4];
7687
7807
  case 4: return [2, {
@@ -7842,9 +7962,9 @@ var PerpetualsClient = (function () {
7842
7962
  }
7843
7963
  }
7844
7964
  };
7845
- PerpetualsClient.prototype.sendTransaction = function (ixs, opts) {
7846
- if (opts === void 0) { opts = {}; }
7847
- 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 = {}; }
7848
7968
  return __generator(this, function (_a) {
7849
7969
  switch (_a.label) {
7850
7970
  case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
@@ -7853,9 +7973,9 @@ var PerpetualsClient = (function () {
7853
7973
  });
7854
7974
  });
7855
7975
  };
7856
- PerpetualsClient.prototype.sendTransactionV3 = function (ixs, opts) {
7857
- if (opts === void 0) { opts = {}; }
7858
- 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 = {}; }
7859
7979
  return __generator(this, function (_a) {
7860
7980
  switch (_a.label) {
7861
7981
  case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];