flash-sdk 2.48.8 → 2.49.0-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.
@@ -719,7 +719,8 @@ var PerpetualsClient = (function () {
719
719
  return { feeBps: fees.minFee, feeAmount: anchor_1.BN.max(amountAdd, amountRemove).mul(fees.minFee).div(new anchor_1.BN(constants_1.RATE_POWER)) };
720
720
  }
721
721
  var newRatio = _this.getNewRatioHelper(amountAdd, amountRemove, inputTokenCustodyAccount, maxOraclePrice, poolAumUsdMax);
722
- var index = poolAccount.custodies.findIndex(function (c) { return c.equals(inputTokenCustodyAccount.publicKey); });
722
+ var inputCustodyConfig = poolConfig.custodies.find(function (i) { return i.custodyAccount.equals(inputTokenCustodyAccount.publicKey); });
723
+ var index = inputCustodyConfig.custodyId;
723
724
  var ratios = poolAccount.ratios[index];
724
725
  var fee = constants_1.BN_ZERO;
725
726
  if (action == types_1.FeesAction.AddLiquidity || action == types_1.FeesAction.SwapIn || action == types_1.FeesAction.StableSwapIn) {
@@ -2148,40 +2149,36 @@ var PerpetualsClient = (function () {
2148
2149
  }
2149
2150
  });
2150
2151
  }); };
2151
- this.getAddLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
2152
- var args_1 = [];
2153
- for (var _i = 4; _i < arguments.length; _i++) {
2154
- args_1[_i - 4] = arguments[_i];
2155
- }
2156
- return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2157
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2158
- var _e;
2159
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2160
- return __generator(this, function (_f) {
2161
- switch (_f.label) {
2152
+ this.getAddLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2153
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2154
+ return __awaiter(_this, void 0, void 0, function () {
2155
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_5, token, _a, custodies_6, custody, _b, _c, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2156
+ var _d;
2157
+ return __generator(this, function (_e) {
2158
+ switch (_e.label) {
2162
2159
  case 0:
2163
2160
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2164
2161
  custodies = POOL_CONFIG.custodies;
2165
2162
  custodyMetas = [];
2166
2163
  marketMetas = [];
2167
- for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
2168
- token = custodies_5[_a];
2164
+ for (_i = 0, custodies_5 = custodies; _i < custodies_5.length; _i++) {
2165
+ token = custodies_5[_i];
2169
2166
  custodyMetas.push({
2170
2167
  isSigner: false,
2171
2168
  isWritable: false,
2172
2169
  pubkey: token.custodyAccount,
2173
2170
  });
2174
2171
  }
2175
- for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
2176
- custody = custodies_6[_b];
2172
+ for (_a = 0, custodies_6 = custodies; _a < custodies_6.length; _a++) {
2173
+ custody = custodies_6[_a];
2177
2174
  custodyMetas.push({
2178
2175
  isSigner: false,
2179
2176
  isWritable: false,
2180
2177
  pubkey: custody.intOracleAccount,
2181
2178
  });
2182
2179
  }
2183
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2184
- market = _d[_c];
2180
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2181
+ market = _c[_b];
2185
2182
  marketMetas.push({
2186
2183
  pubkey: market.marketAccount,
2187
2184
  isSigner: false,
@@ -2204,14 +2201,14 @@ var PerpetualsClient = (function () {
2204
2201
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2205
2202
  .transaction()];
2206
2203
  case 1:
2207
- transaction = _f.sent();
2204
+ transaction = _e.sent();
2208
2205
  return [4, backUpOracleInstructionPromise];
2209
2206
  case 2:
2210
- backUpOracleInstruction = _f.sent();
2211
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2207
+ backUpOracleInstruction = _e.sent();
2208
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2212
2209
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2213
2210
  case 3:
2214
- result = _f.sent();
2211
+ result = _e.sent();
2215
2212
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
2216
2213
  res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
2217
2214
  return [2, {
@@ -2222,40 +2219,36 @@ var PerpetualsClient = (function () {
2222
2219
  });
2223
2220
  });
2224
2221
  };
2225
- this.getRemoveLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2226
- var args_1 = [];
2227
- for (var _i = 4; _i < arguments.length; _i++) {
2228
- args_1[_i - 4] = arguments[_i];
2229
- }
2230
- return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2231
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2232
- var _e;
2233
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2234
- return __generator(this, function (_f) {
2235
- switch (_f.label) {
2222
+ this.getRemoveLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2223
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2224
+ return __awaiter(_this, void 0, void 0, function () {
2225
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_7, token, _a, custodies_8, custody, _b, _c, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2226
+ var _d;
2227
+ return __generator(this, function (_e) {
2228
+ switch (_e.label) {
2236
2229
  case 0:
2237
2230
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2238
2231
  custodies = POOL_CONFIG.custodies;
2239
2232
  custodyMetas = [];
2240
2233
  marketMetas = [];
2241
- for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
2242
- token = custodies_7[_a];
2234
+ for (_i = 0, custodies_7 = custodies; _i < custodies_7.length; _i++) {
2235
+ token = custodies_7[_i];
2243
2236
  custodyMetas.push({
2244
2237
  isSigner: false,
2245
2238
  isWritable: false,
2246
2239
  pubkey: token.custodyAccount,
2247
2240
  });
2248
2241
  }
2249
- for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
2250
- custody = custodies_8[_b];
2242
+ for (_a = 0, custodies_8 = custodies; _a < custodies_8.length; _a++) {
2243
+ custody = custodies_8[_a];
2251
2244
  custodyMetas.push({
2252
2245
  isSigner: false,
2253
2246
  isWritable: false,
2254
2247
  pubkey: custody.intOracleAccount,
2255
2248
  });
2256
2249
  }
2257
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2258
- market = _d[_c];
2250
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2251
+ market = _c[_b];
2259
2252
  marketMetas.push({
2260
2253
  pubkey: market.marketAccount,
2261
2254
  isSigner: false,
@@ -2278,14 +2271,14 @@ var PerpetualsClient = (function () {
2278
2271
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2279
2272
  .transaction()];
2280
2273
  case 1:
2281
- transaction = _f.sent();
2274
+ transaction = _e.sent();
2282
2275
  return [4, backUpOracleInstructionPromise];
2283
2276
  case 2:
2284
- backUpOracleInstruction = _f.sent();
2285
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2277
+ backUpOracleInstruction = _e.sent();
2278
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2286
2279
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2287
2280
  case 3:
2288
- result = _f.sent();
2281
+ result = _e.sent();
2289
2282
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2290
2283
  if (result.value.err) {
2291
2284
  return [2, {
@@ -2361,40 +2354,36 @@ var PerpetualsClient = (function () {
2361
2354
  }
2362
2355
  });
2363
2356
  }); };
2364
- this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
2365
- var args_1 = [];
2366
- for (var _i = 4; _i < arguments.length; _i++) {
2367
- args_1[_i - 4] = arguments[_i];
2368
- }
2369
- return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2370
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2371
- var _e;
2372
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2373
- return __generator(this, function (_f) {
2374
- switch (_f.label) {
2357
+ this.getAddCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2358
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2359
+ return __awaiter(_this, void 0, void 0, function () {
2360
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_11, token, _a, custodies_12, custody, _b, _c, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2361
+ var _d;
2362
+ return __generator(this, function (_e) {
2363
+ switch (_e.label) {
2375
2364
  case 0:
2376
2365
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2377
2366
  custodies = POOL_CONFIG.custodies;
2378
2367
  custodyMetas = [];
2379
2368
  marketMetas = [];
2380
- for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
2381
- token = custodies_11[_a];
2369
+ for (_i = 0, custodies_11 = custodies; _i < custodies_11.length; _i++) {
2370
+ token = custodies_11[_i];
2382
2371
  custodyMetas.push({
2383
2372
  isSigner: false,
2384
2373
  isWritable: false,
2385
2374
  pubkey: token.custodyAccount,
2386
2375
  });
2387
2376
  }
2388
- for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
2389
- custody = custodies_12[_b];
2377
+ for (_a = 0, custodies_12 = custodies; _a < custodies_12.length; _a++) {
2378
+ custody = custodies_12[_a];
2390
2379
  custodyMetas.push({
2391
2380
  isSigner: false,
2392
2381
  isWritable: false,
2393
2382
  pubkey: custody.intOracleAccount,
2394
2383
  });
2395
2384
  }
2396
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2397
- market = _d[_c];
2385
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2386
+ market = _c[_b];
2398
2387
  marketMetas.push({
2399
2388
  pubkey: market.marketAccount,
2400
2389
  isSigner: false,
@@ -2405,7 +2394,7 @@ var PerpetualsClient = (function () {
2405
2394
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2406
2395
  return [4, backUpOracleInstructionPromise];
2407
2396
  case 1:
2408
- backUpOracleInstruction = _f.sent();
2397
+ backUpOracleInstruction = _e.sent();
2409
2398
  return [4, this.program.methods
2410
2399
  .getAddCompoundingLiquidityAmountAndFee({
2411
2400
  amountIn: amount,
@@ -2424,11 +2413,11 @@ var PerpetualsClient = (function () {
2424
2413
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2425
2414
  .transaction()];
2426
2415
  case 2:
2427
- transaction = _f.sent();
2428
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2416
+ transaction = _e.sent();
2417
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2429
2418
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2430
2419
  case 3:
2431
- result = _f.sent();
2420
+ result = _e.sent();
2432
2421
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2433
2422
  res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
2434
2423
  return [2, {
@@ -2439,40 +2428,36 @@ var PerpetualsClient = (function () {
2439
2428
  });
2440
2429
  });
2441
2430
  };
2442
- this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2443
- var args_1 = [];
2444
- for (var _i = 4; _i < arguments.length; _i++) {
2445
- args_1[_i - 4] = arguments[_i];
2446
- }
2447
- return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2448
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2449
- var _e;
2450
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2451
- return __generator(this, function (_f) {
2452
- switch (_f.label) {
2431
+ this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2432
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2433
+ return __awaiter(_this, void 0, void 0, function () {
2434
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_13, token, _a, custodies_14, custody, _b, _c, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2435
+ var _d;
2436
+ return __generator(this, function (_e) {
2437
+ switch (_e.label) {
2453
2438
  case 0:
2454
2439
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2455
2440
  custodies = POOL_CONFIG.custodies;
2456
2441
  custodyMetas = [];
2457
2442
  marketMetas = [];
2458
- for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
2459
- token = custodies_13[_a];
2443
+ for (_i = 0, custodies_13 = custodies; _i < custodies_13.length; _i++) {
2444
+ token = custodies_13[_i];
2460
2445
  custodyMetas.push({
2461
2446
  isSigner: false,
2462
2447
  isWritable: false,
2463
2448
  pubkey: token.custodyAccount,
2464
2449
  });
2465
2450
  }
2466
- for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
2467
- custody = custodies_14[_b];
2451
+ for (_a = 0, custodies_14 = custodies; _a < custodies_14.length; _a++) {
2452
+ custody = custodies_14[_a];
2468
2453
  custodyMetas.push({
2469
2454
  isSigner: false,
2470
2455
  isWritable: false,
2471
2456
  pubkey: custody.intOracleAccount,
2472
2457
  });
2473
2458
  }
2474
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2475
- market = _d[_c];
2459
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2460
+ market = _c[_b];
2476
2461
  marketMetas.push({
2477
2462
  pubkey: market.marketAccount,
2478
2463
  isSigner: false,
@@ -2483,7 +2468,7 @@ var PerpetualsClient = (function () {
2483
2468
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2484
2469
  return [4, backUpOracleInstructionPromise];
2485
2470
  case 1:
2486
- backUpOracleInstruction = _f.sent();
2471
+ backUpOracleInstruction = _e.sent();
2487
2472
  return [4, this.program.methods
2488
2473
  .getRemoveCompoundingLiquidityAmountAndFee({
2489
2474
  compoundingAmountIn: amount,
@@ -2502,11 +2487,11 @@ var PerpetualsClient = (function () {
2502
2487
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2503
2488
  .transaction()];
2504
2489
  case 2:
2505
- transaction = _f.sent();
2506
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2490
+ transaction = _e.sent();
2491
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2507
2492
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2508
2493
  case 3:
2509
- result = _f.sent();
2494
+ result = _e.sent();
2510
2495
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2511
2496
  if (result.value.err) {
2512
2497
  return [2, {
@@ -2645,18 +2630,14 @@ var PerpetualsClient = (function () {
2645
2630
  }
2646
2631
  });
2647
2632
  }); };
2648
- this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
2649
- var args_1 = [];
2650
- for (var _i = 8; _i < arguments.length; _i++) {
2651
- args_1[_i - 8] = arguments[_i];
2652
- }
2653
- 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) {
2633
+ this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2634
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2635
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2636
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2637
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2638
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2639
+ return __awaiter(_this, void 0, void 0, function () {
2654
2640
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
2655
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2656
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2657
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2658
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2659
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2660
2641
  return __generator(this, function (_c) {
2661
2642
  switch (_c.label) {
2662
2643
  case 0:
@@ -2760,19 +2741,15 @@ var PerpetualsClient = (function () {
2760
2741
  });
2761
2742
  });
2762
2743
  };
2763
- this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
2764
- var args_1 = [];
2765
- for (var _i = 6; _i < arguments.length; _i++) {
2766
- args_1[_i - 6] = arguments[_i];
2767
- }
2768
- 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) {
2744
+ this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2745
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2746
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2747
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2748
+ if (createUserATA === void 0) { createUserATA = true; }
2749
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2750
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2751
+ return __awaiter(_this, void 0, void 0, function () {
2769
2752
  var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_2;
2770
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2771
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2772
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2773
- if (createUserATA === void 0) { createUserATA = true; }
2774
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2775
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2776
2753
  return __generator(this, function (_b) {
2777
2754
  switch (_b.label) {
2778
2755
  case 0:
@@ -2869,18 +2846,14 @@ var PerpetualsClient = (function () {
2869
2846
  });
2870
2847
  });
2871
2848
  };
2872
- this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
2873
- var args_1 = [];
2874
- for (var _i = 10; _i < arguments.length; _i++) {
2875
- args_1[_i - 10] = arguments[_i];
2876
- }
2877
- 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) {
2849
+ this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2850
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2851
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2852
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2853
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2854
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2855
+ return __awaiter(_this, void 0, void 0, function () {
2878
2856
  var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_2;
2879
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2880
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2881
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2882
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2883
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2884
2857
  return __generator(this, function (_c) {
2885
2858
  switch (_c.label) {
2886
2859
  case 0:
@@ -3020,17 +2993,13 @@ var PerpetualsClient = (function () {
3020
2993
  });
3021
2994
  });
3022
2995
  };
3023
- this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
3024
- var args_1 = [];
3025
- for (var _i = 8; _i < arguments.length; _i++) {
3026
- args_1[_i - 8] = arguments[_i];
3027
- }
3028
- 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) {
2996
+ this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
2997
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2998
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2999
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3000
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3001
+ return __awaiter(_this, void 0, void 0, function () {
3029
3002
  var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_3;
3030
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3031
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3032
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3033
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3034
3003
  return __generator(this, function (_a) {
3035
3004
  switch (_a.label) {
3036
3005
  case 0:
@@ -3144,20 +3113,16 @@ var PerpetualsClient = (function () {
3144
3113
  });
3145
3114
  });
3146
3115
  };
3147
- this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
3148
- var args_1 = [];
3149
- for (var _i = 5; _i < arguments.length; _i++) {
3150
- args_1[_i - 5] = arguments[_i];
3151
- }
3152
- 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) {
3153
- 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;
3154
- if (useFeesPool === void 0) { useFeesPool = false; }
3155
- if (createUserATA === void 0) { createUserATA = true; }
3156
- if (unWrapSol === void 0) { unWrapSol = false; }
3157
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3158
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3159
- return __generator(this, function (_g) {
3160
- switch (_g.label) {
3116
+ this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
3117
+ if (useFeesPool === void 0) { useFeesPool = false; }
3118
+ if (createUserATA === void 0) { createUserATA = true; }
3119
+ if (unWrapSol === void 0) { unWrapSol = false; }
3120
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3121
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3122
+ return __awaiter(_this, void 0, void 0, function () {
3123
+ 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;
3124
+ return __generator(this, function (_f) {
3125
+ switch (_f.label) {
3161
3126
  case 0:
3162
3127
  userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
3163
3128
  if (!userInputCustodyConfig) {
@@ -3175,10 +3140,10 @@ var PerpetualsClient = (function () {
3175
3140
  if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
3176
3141
  return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
3177
3142
  case 1:
3178
- wsolAssociatedTokenAccount = _g.sent();
3143
+ wsolAssociatedTokenAccount = _f.sent();
3179
3144
  return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
3180
3145
  case 2:
3181
- wsolATAExist = _g.sent();
3146
+ wsolATAExist = _f.sent();
3182
3147
  if (!wsolATAExist) {
3183
3148
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
3184
3149
  }
@@ -3186,11 +3151,11 @@ var PerpetualsClient = (function () {
3186
3151
  _a = anchor_1.BN.bind;
3187
3152
  return [4, this.provider.connection.getBalance(publicKey)];
3188
3153
  case 3:
3189
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
3154
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
3190
3155
  if (unWrappedSolBalance.lt(amountIn)) {
3191
3156
  throw "Insufficient SOL Funds";
3192
3157
  }
3193
- _g.label = 4;
3158
+ _f.label = 4;
3194
3159
  case 4:
3195
3160
  instructions.push(web3_js_1.SystemProgram.transfer({
3196
3161
  fromPubkey: publicKey,
@@ -3212,20 +3177,20 @@ var PerpetualsClient = (function () {
3212
3177
  additionalSigners: additionalSigners
3213
3178
  }];
3214
3179
  }
3215
- _g.label = 6;
3180
+ _f.label = 6;
3216
3181
  case 6:
3217
- _g.trys.push([6, 19, , 20]);
3182
+ _f.trys.push([6, 19, , 20]);
3218
3183
  if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
3219
3184
  console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
3220
3185
  return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
3221
3186
  case 7:
3222
- accCreationLamports = (_g.sent());
3187
+ accCreationLamports = (_f.sent());
3223
3188
  console.log("accCreationLamports:", accCreationLamports);
3224
3189
  lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
3225
3190
  _b = anchor_1.BN.bind;
3226
3191
  return [4, this.provider.connection.getBalance(publicKey)];
3227
3192
  case 8:
3228
- unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
3193
+ unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _f.sent()]))();
3229
3194
  if (unWrappedSolBalance.lt(amountIn)) {
3230
3195
  throw "Insufficient SOL Funds";
3231
3196
  }
@@ -3252,18 +3217,18 @@ var PerpetualsClient = (function () {
3252
3217
  userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
3253
3218
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
3254
3219
  case 10:
3255
- if (!(_g.sent())) {
3220
+ if (!(_f.sent())) {
3256
3221
  throw "Insufficient Funds , Token Account doesn't exist";
3257
3222
  }
3258
3223
  if (!!skipBalanceChecks) return [3, 12];
3259
3224
  _c = anchor_1.BN.bind;
3260
3225
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
3261
3226
  case 11:
3262
- tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3227
+ tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
3263
3228
  if (tokenAccountBalance.lt(amountIn)) {
3264
3229
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
3265
3230
  }
3266
- _g.label = 12;
3231
+ _f.label = 12;
3267
3232
  case 12:
3268
3233
  if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
3269
3234
  lamports = (this.minimumBalanceForRentExemptAccountLamports);
@@ -3288,23 +3253,23 @@ var PerpetualsClient = (function () {
3288
3253
  return [3, 17];
3289
3254
  case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
3290
3255
  case 14:
3291
- userOutputTokenAccount = _g.sent();
3256
+ userOutputTokenAccount = _f.sent();
3292
3257
  _d = createUserATA;
3293
3258
  if (!_d) return [3, 16];
3294
3259
  return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
3295
3260
  case 15:
3296
- _d = !(_g.sent());
3297
- _g.label = 16;
3261
+ _d = !(_f.sent());
3262
+ _f.label = 16;
3298
3263
  case 16:
3299
3264
  if (_d) {
3300
3265
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
3301
3266
  }
3302
- _g.label = 17;
3267
+ _f.label = 17;
3303
3268
  case 17:
3304
3269
  custodyAccountMetas = [];
3305
3270
  custodyOracleAccountMetas = [];
3306
- for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
3307
- custody = _f[_e];
3271
+ for (_i = 0, _e = poolConfig.custodies; _i < _e.length; _i++) {
3272
+ custody = _e[_i];
3308
3273
  custodyAccountMetas.push({
3309
3274
  pubkey: custody.custodyAccount,
3310
3275
  isSigner: false,
@@ -3344,7 +3309,7 @@ var PerpetualsClient = (function () {
3344
3309
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
3345
3310
  .instruction()];
3346
3311
  case 18:
3347
- inx = _g.sent();
3312
+ inx = _f.sent();
3348
3313
  instructions.push(inx);
3349
3314
  if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
3350
3315
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
@@ -3352,7 +3317,7 @@ var PerpetualsClient = (function () {
3352
3317
  }
3353
3318
  return [3, 20];
3354
3319
  case 19:
3355
- err_4 = _g.sent();
3320
+ err_4 = _f.sent();
3356
3321
  console.error("perpClient Swap error:: ", err_4);
3357
3322
  throw err_4;
3358
3323
  case 20: return [2, {
@@ -3434,15 +3399,11 @@ var PerpetualsClient = (function () {
3434
3399
  }
3435
3400
  });
3436
3401
  }); };
3437
- this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3438
- var args_1 = [];
3439
- for (var _i = 6; _i < arguments.length; _i++) {
3440
- args_1[_i - 6] = arguments[_i];
3441
- }
3442
- 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) {
3402
+ this.addCollateral = function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3403
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3404
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3405
+ return __awaiter(_this, void 0, void 0, function () {
3443
3406
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
3444
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3445
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3446
3407
  return __generator(this, function (_c) {
3447
3408
  switch (_c.label) {
3448
3409
  case 0:
@@ -3536,15 +3497,11 @@ var PerpetualsClient = (function () {
3536
3497
  });
3537
3498
  });
3538
3499
  };
3539
- this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
3540
- var args_1 = [];
3541
- for (var _i = 8; _i < arguments.length; _i++) {
3542
- args_1[_i - 8] = arguments[_i];
3543
- }
3544
- 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) {
3500
+ this.swapAndAddCollateral = function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3501
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3502
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3503
+ return __awaiter(_this, void 0, void 0, function () {
3545
3504
  var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
3546
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3547
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3548
3505
  return __generator(this, function (_c) {
3549
3506
  switch (_c.label) {
3550
3507
  case 0:
@@ -3655,16 +3612,12 @@ var PerpetualsClient = (function () {
3655
3612
  });
3656
3613
  });
3657
3614
  };
3658
- this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3659
- var args_1 = [];
3660
- for (var _i = 6; _i < arguments.length; _i++) {
3661
- args_1[_i - 6] = arguments[_i];
3662
- }
3663
- 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) {
3615
+ this.removeCollateral = function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3616
+ if (createUserATA === void 0) { createUserATA = true; }
3617
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3618
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3619
+ return __awaiter(_this, void 0, void 0, function () {
3664
3620
  var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_3;
3665
- if (createUserATA === void 0) { createUserATA = true; }
3666
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3667
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3668
3621
  return __generator(this, function (_b) {
3669
3622
  switch (_b.label) {
3670
3623
  case 0:
@@ -3765,14 +3718,10 @@ var PerpetualsClient = (function () {
3765
3718
  });
3766
3719
  });
3767
3720
  };
3768
- this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
3769
- var args_1 = [];
3770
- for (var _i = 7; _i < arguments.length; _i++) {
3771
- args_1[_i - 7] = arguments[_i];
3772
- }
3773
- 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) {
3721
+ this.removeCollateralAndSwap = function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
3722
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3723
+ return __awaiter(_this, void 0, void 0, function () {
3774
3724
  var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
3775
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3776
3725
  return __generator(this, function (_a) {
3777
3726
  switch (_a.label) {
3778
3727
  case 0:
@@ -3865,16 +3814,12 @@ var PerpetualsClient = (function () {
3865
3814
  });
3866
3815
  });
3867
3816
  };
3868
- this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3869
- var args_1 = [];
3870
- for (var _i = 8; _i < arguments.length; _i++) {
3871
- args_1[_i - 8] = arguments[_i];
3872
- }
3873
- 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) {
3817
+ this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3818
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3819
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3820
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3821
+ return __awaiter(_this, void 0, void 0, function () {
3874
3822
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3875
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3876
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3877
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3878
3823
  return __generator(this, function (_a) {
3879
3824
  switch (_a.label) {
3880
3825
  case 0:
@@ -3929,16 +3874,12 @@ var PerpetualsClient = (function () {
3929
3874
  });
3930
3875
  });
3931
3876
  };
3932
- this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3933
- var args_1 = [];
3934
- for (var _i = 8; _i < arguments.length; _i++) {
3935
- args_1[_i - 8] = arguments[_i];
3936
- }
3937
- 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) {
3877
+ this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3878
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3879
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3880
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3881
+ return __awaiter(_this, void 0, void 0, function () {
3938
3882
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3939
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3940
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3941
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3942
3883
  return __generator(this, function (_a) {
3943
3884
  switch (_a.label) {
3944
3885
  case 0:
@@ -3993,17 +3934,13 @@ var PerpetualsClient = (function () {
3993
3934
  });
3994
3935
  });
3995
3936
  };
3996
- this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
3997
- var args_1 = [];
3998
- for (var _i = 4; _i < arguments.length; _i++) {
3999
- args_1[_i - 4] = arguments[_i];
4000
- }
4001
- return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
4002
- 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;
4003
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4004
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4005
- return __generator(this, function (_g) {
4006
- switch (_g.label) {
3937
+ this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3938
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3939
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3940
+ return __awaiter(_this, void 0, void 0, function () {
3941
+ 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;
3942
+ return __generator(this, function (_f) {
3943
+ switch (_f.label) {
4007
3944
  case 0:
4008
3945
  publicKey = this.provider.wallet.publicKey;
4009
3946
  payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
@@ -4014,16 +3951,16 @@ var PerpetualsClient = (function () {
4014
3951
  instructions = [];
4015
3952
  postInstructions = [];
4016
3953
  additionalSigners = [];
4017
- _g.label = 1;
3954
+ _f.label = 1;
4018
3955
  case 1:
4019
- _g.trys.push([1, 10, , 11]);
3956
+ _f.trys.push([1, 10, , 11]);
4020
3957
  userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
4021
3958
  lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4022
3959
  custodyAccountMetas = [];
4023
3960
  custodyOracleAccountMetas = [];
4024
3961
  markets = [];
4025
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4026
- custody = _b[_a];
3962
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
3963
+ custody = _a[_i];
4027
3964
  custodyAccountMetas.push({
4028
3965
  pubkey: custody.custodyAccount,
4029
3966
  isSigner: false,
@@ -4035,8 +3972,8 @@ var PerpetualsClient = (function () {
4035
3972
  isWritable: false,
4036
3973
  });
4037
3974
  }
4038
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4039
- market = _d[_c];
3975
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
3976
+ market = _c[_b];
4040
3977
  markets.push({
4041
3978
  pubkey: market.marketAccount,
4042
3979
  isSigner: false,
@@ -4045,21 +3982,21 @@ var PerpetualsClient = (function () {
4045
3982
  }
4046
3983
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4047
3984
  case 2:
4048
- if (!(_g.sent())) {
3985
+ if (!(_f.sent())) {
4049
3986
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4050
3987
  }
4051
3988
  if (!(payTokenSymbol == 'SOL')) return [3, 5];
4052
3989
  console.log("payTokenSymbol === SOL", payTokenSymbol);
4053
3990
  lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
4054
3991
  if (!!skipBalanceChecks) return [3, 4];
4055
- _e = anchor_1.BN.bind;
3992
+ _d = anchor_1.BN.bind;
4056
3993
  return [4, this.provider.connection.getBalance(publicKey)];
4057
3994
  case 3:
4058
- unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
3995
+ unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _f.sent()]))();
4059
3996
  if (unWrappedSolBalance.lt(lamports)) {
4060
3997
  throw "Insufficient SOL Funds";
4061
3998
  }
4062
- _g.label = 4;
3999
+ _f.label = 4;
4063
4000
  case 4:
4064
4001
  if (!ephemeralSignerPubkey) {
4065
4002
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -4083,17 +4020,17 @@ var PerpetualsClient = (function () {
4083
4020
  if (!!skipBalanceChecks) return [3, 8];
4084
4021
  return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
4085
4022
  case 6:
4086
- if (!(_g.sent())) {
4023
+ if (!(_f.sent())) {
4087
4024
  throw "Insufficient Funds , token Account doesn't exist";
4088
4025
  }
4089
- _f = anchor_1.BN.bind;
4026
+ _e = anchor_1.BN.bind;
4090
4027
  return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
4091
4028
  case 7:
4092
- tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4029
+ tokenAccountBalance = new (_e.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4093
4030
  if (tokenAccountBalance.lt(tokenAmountIn)) {
4094
4031
  throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
4095
4032
  }
4096
- _g.label = 8;
4033
+ _f.label = 8;
4097
4034
  case 8: return [4, this.program.methods
4098
4035
  .addLiquidity({
4099
4036
  amountIn: tokenAmountIn,
@@ -4118,11 +4055,11 @@ var PerpetualsClient = (function () {
4118
4055
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4119
4056
  .instruction()];
4120
4057
  case 9:
4121
- instruction = _g.sent();
4058
+ instruction = _f.sent();
4122
4059
  instructions.push(instruction);
4123
4060
  return [3, 11];
4124
4061
  case 10:
4125
- err_6 = _g.sent();
4062
+ err_6 = _f.sent();
4126
4063
  console.error("perpClient addLiquidity error:: ", err_6);
4127
4064
  throw err_6;
4128
4065
  case 11: return [2, {
@@ -4133,18 +4070,14 @@ var PerpetualsClient = (function () {
4133
4070
  });
4134
4071
  });
4135
4072
  };
4136
- this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
4137
- var args_1 = [];
4138
- for (var _i = 4; _i < arguments.length; _i++) {
4139
- args_1[_i - 4] = arguments[_i];
4140
- }
4141
- return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
4142
- 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;
4143
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4144
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4145
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4146
- return __generator(this, function (_g) {
4147
- switch (_g.label) {
4073
+ this.addLiquidityAndStake = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
4074
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4075
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4076
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4077
+ return __awaiter(_this, void 0, void 0, function () {
4078
+ 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;
4079
+ return __generator(this, function (_f) {
4080
+ switch (_f.label) {
4148
4081
  case 0:
4149
4082
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4150
4083
  preInstructions = [];
@@ -4164,14 +4097,14 @@ var PerpetualsClient = (function () {
4164
4097
  _a = anchor_1.BN.bind;
4165
4098
  return [4, this.provider.connection.getBalance(publicKey)];
4166
4099
  case 1:
4167
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
4100
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
4168
4101
  if (unWrappedSolBalance.lt(lamports)) {
4169
4102
  throw "Insufficient SOL Funds";
4170
4103
  }
4171
- _g.label = 2;
4104
+ _f.label = 2;
4172
4105
  case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4173
4106
  case 3:
4174
- if (!(_g.sent())) {
4107
+ if (!(_f.sent())) {
4175
4108
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4176
4109
  }
4177
4110
  if (!ephemeralSignerPubkey) {
@@ -4197,23 +4130,23 @@ var PerpetualsClient = (function () {
4197
4130
  if (!!skipBalanceChecks) return [3, 7];
4198
4131
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
4199
4132
  case 5:
4200
- if (!(_g.sent())) {
4133
+ if (!(_f.sent())) {
4201
4134
  throw "Insufficient Funds , token Account doesn't exist";
4202
4135
  }
4203
4136
  _b = anchor_1.BN.bind;
4204
4137
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
4205
4138
  case 6:
4206
- tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4139
+ tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4207
4140
  if (tokenAccountBalance.lt(amountIn)) {
4208
4141
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
4209
4142
  }
4210
- _g.label = 7;
4143
+ _f.label = 7;
4211
4144
  case 7:
4212
4145
  custodyAccountMetas = [];
4213
4146
  custodyOracleAccountMetas = [];
4214
4147
  markets = [];
4215
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
4216
- custody = _d[_c];
4148
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
4149
+ custody = _c[_i];
4217
4150
  custodyAccountMetas.push({
4218
4151
  pubkey: custody.custodyAccount,
4219
4152
  isSigner: false,
@@ -4225,8 +4158,8 @@ var PerpetualsClient = (function () {
4225
4158
  isWritable: false,
4226
4159
  });
4227
4160
  }
4228
- for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
4229
- market = _f[_e];
4161
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
4162
+ market = _e[_d];
4230
4163
  markets.push({
4231
4164
  pubkey: market.marketAccount,
4232
4165
  isSigner: false,
@@ -4258,7 +4191,7 @@ var PerpetualsClient = (function () {
4258
4191
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4259
4192
  .instruction()];
4260
4193
  case 8:
4261
- instruction = _g.sent();
4194
+ instruction = _f.sent();
4262
4195
  instructions.push(instruction);
4263
4196
  return [2, {
4264
4197
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4268,20 +4201,16 @@ var PerpetualsClient = (function () {
4268
4201
  });
4269
4202
  });
4270
4203
  };
4271
- this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
4272
- var args_1 = [];
4273
- for (var _i = 4; _i < arguments.length; _i++) {
4274
- args_1[_i - 4] = arguments[_i];
4275
- }
4276
- 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, userPublicKey) {
4277
- 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;
4278
- if (closeLpATA === void 0) { closeLpATA = false; }
4279
- if (createUserATA === void 0) { createUserATA = true; }
4280
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4281
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4282
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4283
- return __generator(this, function (_f) {
4284
- switch (_f.label) {
4204
+ this.removeLiquidity = function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
4205
+ if (closeLpATA === void 0) { closeLpATA = false; }
4206
+ if (createUserATA === void 0) { createUserATA = true; }
4207
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4208
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4209
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4210
+ return __awaiter(_this, void 0, void 0, function () {
4211
+ 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;
4212
+ return __generator(this, function (_e) {
4213
+ switch (_e.label) {
4285
4214
  case 0:
4286
4215
  recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
4287
4216
  if (!recieveTokenCustodyConfig) {
@@ -4292,15 +4221,15 @@ var PerpetualsClient = (function () {
4292
4221
  instructions = [];
4293
4222
  postInstructions = [];
4294
4223
  additionalSigners = [];
4295
- _f.label = 1;
4224
+ _e.label = 1;
4296
4225
  case 1:
4297
- _f.trys.push([1, 7, , 8]);
4226
+ _e.trys.push([1, 7, , 8]);
4298
4227
  stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4299
4228
  custodyAccountMetas = [];
4300
4229
  custodyOracleAccountMetas = [];
4301
4230
  markets = [];
4302
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4303
- custody = _b[_a];
4231
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4232
+ custody = _a[_i];
4304
4233
  custodyAccountMetas.push({
4305
4234
  pubkey: custody.custodyAccount,
4306
4235
  isSigner: false,
@@ -4312,8 +4241,8 @@ var PerpetualsClient = (function () {
4312
4241
  isWritable: false,
4313
4242
  });
4314
4243
  }
4315
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4316
- market = _d[_c];
4244
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4245
+ market = _c[_b];
4317
4246
  markets.push({
4318
4247
  pubkey: market.marketAccount,
4319
4248
  isSigner: false,
@@ -4342,17 +4271,17 @@ var PerpetualsClient = (function () {
4342
4271
  return [3, 5];
4343
4272
  case 2:
4344
4273
  userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
4345
- _e = createUserATA;
4346
- if (!_e) return [3, 4];
4274
+ _d = createUserATA;
4275
+ if (!_d) return [3, 4];
4347
4276
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
4348
4277
  case 3:
4349
- _e = !(_f.sent());
4350
- _f.label = 4;
4278
+ _d = !(_e.sent());
4279
+ _e.label = 4;
4351
4280
  case 4:
4352
- if (_e) {
4281
+ if (_d) {
4353
4282
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
4354
4283
  }
4355
- _f.label = 5;
4284
+ _e.label = 5;
4356
4285
  case 5: return [4, this.program.methods
4357
4286
  .removeLiquidity({
4358
4287
  lpAmountIn: liquidityAmountIn,
@@ -4377,7 +4306,7 @@ var PerpetualsClient = (function () {
4377
4306
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4378
4307
  .instruction()];
4379
4308
  case 6:
4380
- removeLiquidityTx = _f.sent();
4309
+ removeLiquidityTx = _e.sent();
4381
4310
  instructions.push(removeLiquidityTx);
4382
4311
  if (closeLpATA) {
4383
4312
  closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
@@ -4389,7 +4318,7 @@ var PerpetualsClient = (function () {
4389
4318
  }
4390
4319
  return [3, 8];
4391
4320
  case 7:
4392
- err_7 = _f.sent();
4321
+ err_7 = _e.sent();
4393
4322
  console.log("perpClient removeLiquidity error:: ", err_7);
4394
4323
  throw err_7;
4395
4324
  case 8: return [2, {
@@ -4807,26 +4736,22 @@ var PerpetualsClient = (function () {
4807
4736
  }
4808
4737
  });
4809
4738
  }); };
4810
- this.refreshStakeWithTokenStake = function (rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1) {
4811
- var args_1 = [];
4812
- for (var _i = 3; _i < arguments.length; _i++) {
4813
- args_1[_i - 3] = arguments[_i];
4814
- }
4815
- return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4816
- var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
4817
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4818
- return __generator(this, function (_c) {
4819
- switch (_c.label) {
4739
+ this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4740
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4741
+ return __awaiter(_this, void 0, void 0, function () {
4742
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
4743
+ return __generator(this, function (_b) {
4744
+ switch (_b.label) {
4820
4745
  case 0:
4821
- _c.trys.push([0, 2, , 3]);
4746
+ _b.trys.push([0, 2, , 3]);
4822
4747
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4823
4748
  rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4824
4749
  rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4825
4750
  pool = poolConfig.poolAddress;
4826
4751
  feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4827
4752
  custodyAccountMetas = [];
4828
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4829
- custody = _b[_a];
4753
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4754
+ custody = _a[_i];
4830
4755
  custodyAccountMetas.push({
4831
4756
  pubkey: custody.custodyAccount,
4832
4757
  isSigner: false,
@@ -4858,10 +4783,10 @@ var PerpetualsClient = (function () {
4858
4783
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
4859
4784
  .instruction()];
4860
4785
  case 1:
4861
- refreshStakeInstruction = _c.sent();
4786
+ refreshStakeInstruction = _b.sent();
4862
4787
  return [2, refreshStakeInstruction];
4863
4788
  case 2:
4864
- err_16 = _c.sent();
4789
+ err_16 = _b.sent();
4865
4790
  console.log("perpClient refreshStaking error:: ", err_16);
4866
4791
  throw err_16;
4867
4792
  case 3: return [2];
@@ -4869,75 +4794,68 @@ var PerpetualsClient = (function () {
4869
4794
  });
4870
4795
  });
4871
4796
  };
4872
- this.unstakeInstant = function (rewardSymbol_1, unstakeAmount_1, poolConfig_1) {
4873
- var args_1 = [];
4874
- for (var _i = 3; _i < arguments.length; _i++) {
4875
- args_1[_i - 3] = arguments[_i];
4876
- }
4877
- return __awaiter(_this, __spreadArray([rewardSymbol_1, unstakeAmount_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
4878
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
4879
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4880
- return __generator(this, function (_b) {
4881
- switch (_b.label) {
4882
- case 0:
4883
- publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4884
- preInstructions = [];
4885
- instructions = [];
4886
- postInstructions = [];
4887
- additionalSigners = [];
4888
- _b.label = 1;
4889
- case 1:
4890
- _b.trys.push([1, 5, , 6]);
4891
- rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4892
- pool = poolConfig.poolAddress;
4893
- flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.programId)[0];
4894
- tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
4895
- tokenStakeAccounts = [];
4896
- _a = tokenStakeAccount;
4897
- if (!_a) return [3, 3];
4898
- return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
4899
- case 2:
4900
- _a = (_b.sent());
4901
- _b.label = 3;
4902
- case 3:
4903
- if (_a) {
4904
- tokenStakeAccounts.push({
4905
- pubkey: tokenStakeAccount,
4906
- isSigner: false,
4907
- isWritable: false,
4908
- });
4909
- }
4910
- return [4, this.program.methods
4911
- .unstakeInstant({
4912
- unstakeAmount: unstakeAmount
4913
- })
4914
- .accounts({
4915
- owner: publicKey,
4916
- perpetuals: this.perpetuals.publicKey,
4917
- pool: pool,
4918
- flpStakeAccount: flpStakeAccount,
4919
- rewardCustody: rewardCustodyConfig.custodyAccount,
4920
- eventAuthority: this.eventAuthority.publicKey,
4921
- program: this.program.programId,
4922
- })
4923
- .remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
4924
- .instruction()];
4925
- case 4:
4926
- unstakeInstantInstruction = _b.sent();
4927
- instructions.push(unstakeInstantInstruction);
4928
- return [3, 6];
4929
- case 5:
4930
- err_17 = _b.sent();
4931
- console.log("perpClient unstakeInstant error:: ", err_17);
4932
- throw err_17;
4933
- case 6: return [2, {
4934
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4935
- additionalSigners: additionalSigners
4936
- }];
4937
- }
4938
- });
4797
+ this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4798
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
4799
+ return __generator(this, function (_b) {
4800
+ switch (_b.label) {
4801
+ case 0:
4802
+ publicKey = this.provider.wallet.publicKey;
4803
+ preInstructions = [];
4804
+ instructions = [];
4805
+ postInstructions = [];
4806
+ additionalSigners = [];
4807
+ _b.label = 1;
4808
+ case 1:
4809
+ _b.trys.push([1, 5, , 6]);
4810
+ rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4811
+ pool = poolConfig.poolAddress;
4812
+ flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.programId)[0];
4813
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
4814
+ tokenStakeAccounts = [];
4815
+ _a = tokenStakeAccount;
4816
+ if (!_a) return [3, 3];
4817
+ return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
4818
+ case 2:
4819
+ _a = (_b.sent());
4820
+ _b.label = 3;
4821
+ case 3:
4822
+ if (_a) {
4823
+ tokenStakeAccounts.push({
4824
+ pubkey: tokenStakeAccount,
4825
+ isSigner: false,
4826
+ isWritable: false,
4827
+ });
4828
+ }
4829
+ return [4, this.program.methods
4830
+ .unstakeInstant({
4831
+ unstakeAmount: unstakeAmount
4832
+ })
4833
+ .accounts({
4834
+ owner: publicKey,
4835
+ perpetuals: this.perpetuals.publicKey,
4836
+ pool: pool,
4837
+ flpStakeAccount: flpStakeAccount,
4838
+ rewardCustody: rewardCustodyConfig.custodyAccount,
4839
+ eventAuthority: this.eventAuthority.publicKey,
4840
+ program: this.program.programId,
4841
+ })
4842
+ .remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
4843
+ .instruction()];
4844
+ case 4:
4845
+ unstakeInstantInstruction = _b.sent();
4846
+ instructions.push(unstakeInstantInstruction);
4847
+ return [3, 6];
4848
+ case 5:
4849
+ err_17 = _b.sent();
4850
+ console.log("perpClient unstakeInstant error:: ", err_17);
4851
+ throw err_17;
4852
+ case 6: return [2, {
4853
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4854
+ additionalSigners: additionalSigners
4855
+ }];
4856
+ }
4939
4857
  });
4940
- };
4858
+ }); };
4941
4859
  this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4942
4860
  var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_18;
4943
4861
  return __generator(this, function (_c) {
@@ -5035,21 +4953,16 @@ var PerpetualsClient = (function () {
5035
4953
  }
5036
4954
  });
5037
4955
  }); };
5038
- this.withdrawStake = function (poolConfig_1) {
5039
- var args_1 = [];
5040
- for (var _i = 1; _i < arguments.length; _i++) {
5041
- args_1[_i - 1] = arguments[_i];
5042
- }
5043
- return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
4956
+ this.withdrawStake = function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
4957
+ if (pendingActivation === void 0) { pendingActivation = true; }
4958
+ if (deactivated === void 0) { deactivated = true; }
4959
+ if (createUserLPTA === void 0) { createUserLPTA = true; }
4960
+ return __awaiter(_this, void 0, void 0, function () {
5044
4961
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_20;
5045
- if (pendingActivation === void 0) { pendingActivation = true; }
5046
- if (deactivated === void 0) { deactivated = true; }
5047
- if (createUserLPTA === void 0) { createUserLPTA = true; }
5048
- if (userPublicKey === void 0) { userPublicKey = undefined; }
5049
4962
  return __generator(this, function (_b) {
5050
4963
  switch (_b.label) {
5051
4964
  case 0:
5052
- publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4965
+ publicKey = this.provider.wallet.publicKey;
5053
4966
  preInstructions = [];
5054
4967
  instructions = [];
5055
4968
  postInstructions = [];
@@ -5107,14 +5020,10 @@ var PerpetualsClient = (function () {
5107
5020
  });
5108
5021
  });
5109
5022
  };
5110
- this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
5111
- var args_1 = [];
5112
- for (var _i = 3; _i < arguments.length; _i++) {
5113
- args_1[_i - 3] = arguments[_i];
5114
- }
5115
- return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
5023
+ this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
5024
+ if (createUserATA === void 0) { createUserATA = true; }
5025
+ return __awaiter(_this, void 0, void 0, function () {
5116
5026
  var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
5117
- if (createUserATA === void 0) { createUserATA = true; }
5118
5027
  return __generator(this, function (_b) {
5119
5028
  switch (_b.label) {
5120
5029
  case 0:
@@ -5838,14 +5747,10 @@ var PerpetualsClient = (function () {
5838
5747
  }
5839
5748
  });
5840
5749
  }); };
5841
- this.collectTokenReward = function (owner_1, poolConfig_1) {
5842
- var args_1 = [];
5843
- for (var _i = 2; _i < arguments.length; _i++) {
5844
- args_1[_i - 2] = arguments[_i];
5845
- }
5846
- return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5750
+ this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5751
+ if (createUserATA === void 0) { createUserATA = true; }
5752
+ return __awaiter(_this, void 0, void 0, function () {
5847
5753
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_35;
5848
- if (createUserATA === void 0) { createUserATA = true; }
5849
5754
  return __generator(this, function (_b) {
5850
5755
  switch (_b.label) {
5851
5756
  case 0:
@@ -5900,14 +5805,10 @@ var PerpetualsClient = (function () {
5900
5805
  });
5901
5806
  });
5902
5807
  };
5903
- this.collectRevenue = function (owner_1, rewardSymbol_1, poolConfig_1) {
5904
- var args_1 = [];
5905
- for (var _i = 3; _i < arguments.length; _i++) {
5906
- args_1[_i - 3] = arguments[_i];
5907
- }
5908
- return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
5808
+ this.collectRevenue = function (owner, rewardSymbol, poolConfig, createUserATA) {
5809
+ if (createUserATA === void 0) { createUserATA = true; }
5810
+ return __awaiter(_this, void 0, void 0, function () {
5909
5811
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_36;
5910
- if (createUserATA === void 0) { createUserATA = true; }
5911
5812
  return __generator(this, function (_b) {
5912
5813
  switch (_b.label) {
5913
5814
  case 0:
@@ -6092,14 +5993,10 @@ var PerpetualsClient = (function () {
6092
5993
  }
6093
5994
  });
6094
5995
  }); };
6095
- this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
6096
- var args_1 = [];
6097
- for (var _i = 3; _i < arguments.length; _i++) {
6098
- args_1[_i - 3] = arguments[_i];
6099
- }
6100
- return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5996
+ this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5997
+ if (createUserATA === void 0) { createUserATA = true; }
5998
+ return __awaiter(_this, void 0, void 0, function () {
6101
5999
  var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_40;
6102
- if (createUserATA === void 0) { createUserATA = true; }
6103
6000
  return __generator(this, function (_b) {
6104
6001
  switch (_b.label) {
6105
6002
  case 0:
@@ -6159,14 +6056,10 @@ var PerpetualsClient = (function () {
6159
6056
  });
6160
6057
  });
6161
6058
  };
6162
- this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
6163
- var args_1 = [];
6164
- for (var _i = 2; _i < arguments.length; _i++) {
6165
- args_1[_i - 2] = arguments[_i];
6166
- }
6167
- return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6059
+ this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6060
+ if (createUserATA === void 0) { createUserATA = true; }
6061
+ return __awaiter(_this, void 0, void 0, function () {
6168
6062
  var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_41;
6169
- if (createUserATA === void 0) { createUserATA = true; }
6170
6063
  return __generator(this, function (_b) {
6171
6064
  switch (_b.label) {
6172
6065
  case 0:
@@ -6291,16 +6184,12 @@ var PerpetualsClient = (function () {
6291
6184
  }
6292
6185
  });
6293
6186
  }); };
6294
- this.forceClosePosition = function (positionAccount_1, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
6295
- var args_1 = [];
6296
- for (var _i = 6; _i < arguments.length; _i++) {
6297
- args_1[_i - 6] = arguments[_i];
6298
- }
6299
- 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) {
6187
+ this.forceClosePosition = function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6188
+ if (createUserATA === void 0) { createUserATA = true; }
6189
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6190
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6191
+ return __awaiter(_this, void 0, void 0, function () {
6300
6192
  var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_43;
6301
- if (createUserATA === void 0) { createUserATA = true; }
6302
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6303
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6304
6193
  return __generator(this, function (_b) {
6305
6194
  switch (_b.label) {
6306
6195
  case 0:
@@ -6372,15 +6261,11 @@ var PerpetualsClient = (function () {
6372
6261
  });
6373
6262
  });
6374
6263
  };
6375
- 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) {
6376
- var args_1 = [];
6377
- for (var _i = 11; _i < arguments.length; _i++) {
6378
- args_1[_i - 11] = arguments[_i];
6379
- }
6380
- 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) {
6264
+ this.placeLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6265
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6266
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6267
+ return __awaiter(_this, void 0, void 0, function () {
6381
6268
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_44;
6382
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6383
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6384
6269
  return __generator(this, function (_c) {
6385
6270
  switch (_c.label) {
6386
6271
  case 0:
@@ -6496,15 +6381,11 @@ var PerpetualsClient = (function () {
6496
6381
  });
6497
6382
  });
6498
6383
  };
6499
- 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) {
6500
- var args_1 = [];
6501
- for (var _i = 11; _i < arguments.length; _i++) {
6502
- args_1[_i - 11] = arguments[_i];
6503
- }
6504
- 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) {
6384
+ this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6385
+ if (createUserATA === void 0) { createUserATA = true; }
6386
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6387
+ return __awaiter(_this, void 0, void 0, function () {
6505
6388
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_45;
6506
- if (createUserATA === void 0) { createUserATA = true; }
6507
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6508
6389
  return __generator(this, function (_b) {
6509
6390
  switch (_b.label) {
6510
6391
  case 0:
@@ -6603,16 +6484,12 @@ var PerpetualsClient = (function () {
6603
6484
  });
6604
6485
  });
6605
6486
  };
6606
- this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6607
- var args_1 = [];
6608
- for (var _i = 7; _i < arguments.length; _i++) {
6609
- args_1[_i - 7] = arguments[_i];
6610
- }
6611
- 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) {
6487
+ this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6488
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6489
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6490
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6491
+ return __awaiter(_this, void 0, void 0, function () {
6612
6492
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_46;
6613
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6614
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6615
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6616
6493
  return __generator(this, function (_a) {
6617
6494
  switch (_a.label) {
6618
6495
  case 0:
@@ -6672,16 +6549,12 @@ var PerpetualsClient = (function () {
6672
6549
  });
6673
6550
  });
6674
6551
  };
6675
- this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6676
- var args_1 = [];
6677
- for (var _i = 8; _i < arguments.length; _i++) {
6678
- args_1[_i - 8] = arguments[_i];
6679
- }
6680
- 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) {
6552
+ this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6553
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6554
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6555
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6556
+ return __awaiter(_this, void 0, void 0, function () {
6681
6557
  var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_47;
6682
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6683
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6684
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6685
6558
  return __generator(this, function (_a) {
6686
6559
  switch (_a.label) {
6687
6560
  case 0:
@@ -6947,20 +6820,16 @@ var PerpetualsClient = (function () {
6947
6820
  }
6948
6821
  });
6949
6822
  }); };
6950
- this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
6951
- var args_1 = [];
6952
- for (var _i = 9; _i < arguments.length; _i++) {
6953
- args_1[_i - 9] = arguments[_i];
6954
- }
6955
- 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) {
6956
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_52;
6957
- if (createUserATA === void 0) { createUserATA = true; }
6958
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6959
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6960
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6961
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6962
- return __generator(this, function (_e) {
6963
- switch (_e.label) {
6823
+ this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6824
+ if (createUserATA === void 0) { createUserATA = true; }
6825
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6826
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6827
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6828
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6829
+ return __awaiter(_this, void 0, void 0, function () {
6830
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_52;
6831
+ return __generator(this, function (_d) {
6832
+ switch (_d.label) {
6964
6833
  case 0:
6965
6834
  payerPubkey = this.provider.wallet.publicKey;
6966
6835
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
@@ -6971,9 +6840,9 @@ var PerpetualsClient = (function () {
6971
6840
  instructions = [];
6972
6841
  postInstructions = [];
6973
6842
  additionalSigners = [];
6974
- _e.label = 1;
6843
+ _d.label = 1;
6975
6844
  case 1:
6976
- _e.trys.push([1, 9, , 10]);
6845
+ _d.trys.push([1, 9, , 10]);
6977
6846
  if (!false) return [3, 2];
6978
6847
  return [3, 7];
6979
6848
  case 2:
@@ -6982,8 +6851,8 @@ var PerpetualsClient = (function () {
6982
6851
  if (!_a) return [3, 4];
6983
6852
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6984
6853
  case 3:
6985
- _a = !(_e.sent());
6986
- _e.label = 4;
6854
+ _a = !(_d.sent());
6855
+ _d.label = 4;
6987
6856
  case 4:
6988
6857
  if (_a) {
6989
6858
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
@@ -6993,20 +6862,20 @@ var PerpetualsClient = (function () {
6993
6862
  if (!_b) return [3, 6];
6994
6863
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
6995
6864
  case 5:
6996
- _b = !(_e.sent());
6997
- _e.label = 6;
6865
+ _b = !(_d.sent());
6866
+ _d.label = 6;
6998
6867
  case 6:
6999
6868
  if (_b) {
7000
6869
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
7001
6870
  }
7002
- _e.label = 7;
6871
+ _d.label = 7;
7003
6872
  case 7:
7004
6873
  positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
7005
6874
  orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
7006
6875
  custodyAccountMetas = [];
7007
6876
  custodyOracleAccountMetas = [];
7008
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7009
- custody = _d[_c];
6877
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
6878
+ custody = _c[_i];
7010
6879
  custodyAccountMetas.push({
7011
6880
  pubkey: custody.custodyAccount,
7012
6881
  isSigner: false,
@@ -7051,11 +6920,11 @@ var PerpetualsClient = (function () {
7051
6920
  .remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
7052
6921
  .instruction()];
7053
6922
  case 8:
7054
- executeTriggerWithSwap = _e.sent();
6923
+ executeTriggerWithSwap = _d.sent();
7055
6924
  instructions.push(executeTriggerWithSwap);
7056
6925
  return [3, 10];
7057
6926
  case 9:
7058
- err_52 = _e.sent();
6927
+ err_52 = _d.sent();
7059
6928
  console.log("perpClient executeTriggerWithSwap error:: ", err_52);
7060
6929
  throw err_52;
7061
6930
  case 10: return [2, {
@@ -7066,18 +6935,14 @@ var PerpetualsClient = (function () {
7066
6935
  });
7067
6936
  });
7068
6937
  };
7069
- this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
7070
- var args_1 = [];
7071
- for (var _i = 8; _i < arguments.length; _i++) {
7072
- args_1[_i - 8] = arguments[_i];
7073
- }
7074
- 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) {
6938
+ this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6939
+ if (createUserATA === void 0) { createUserATA = true; }
6940
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6941
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6942
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6943
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6944
+ return __awaiter(_this, void 0, void 0, function () {
7075
6945
  var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_53;
7076
- if (createUserATA === void 0) { createUserATA = true; }
7077
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7078
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
7079
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
7080
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
7081
6946
  return __generator(this, function (_b) {
7082
6947
  switch (_b.label) {
7083
6948
  case 0:
@@ -7500,18 +7365,75 @@ var PerpetualsClient = (function () {
7500
7365
  }
7501
7366
  });
7502
7367
  }); };
7503
- this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
7504
- var args_1 = [];
7505
- for (var _i = 5; _i < arguments.length; _i++) {
7506
- args_1[_i - 5] = arguments[_i];
7507
- }
7508
- 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, userPublicKey) {
7509
- 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_62;
7510
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7511
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7512
- if (userPublicKey === void 0) { userPublicKey = undefined; }
7513
- return __generator(this, function (_f) {
7514
- switch (_f.label) {
7368
+ this.setInternalOraclePriceBatch = function (tokenMintList, tokenInternalPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7369
+ var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_62;
7370
+ return __generator(this, function (_a) {
7371
+ switch (_a.label) {
7372
+ case 0:
7373
+ if (tokenMintList.length !== tokenInternalPrices.length) {
7374
+ throw new Error("tokenMintList and tokenInternalPrices length mismatch");
7375
+ }
7376
+ ALL_CUSTODY_CONFIGS = POOL_CONFIGS.map(function (f) { return f.custodies; }).flat();
7377
+ accountMetas = [];
7378
+ _loop_1 = function (tokenMint) {
7379
+ var custody = ALL_CUSTODY_CONFIGS.find(function (i) { return i.mintKey.equals(tokenMint); });
7380
+ accountMetas.push({
7381
+ pubkey: custody.custodyAccount,
7382
+ isSigner: false,
7383
+ isWritable: false,
7384
+ });
7385
+ accountMetas.push({
7386
+ pubkey: custody.intOracleAccount,
7387
+ isSigner: false,
7388
+ isWritable: true,
7389
+ });
7390
+ accountMetas.push({
7391
+ pubkey: custody.extOracleAccount,
7392
+ isSigner: false,
7393
+ isWritable: false,
7394
+ });
7395
+ };
7396
+ for (_i = 0, tokenMintList_1 = tokenMintList; _i < tokenMintList_1.length; _i++) {
7397
+ tokenMint = tokenMintList_1[_i];
7398
+ _loop_1(tokenMint);
7399
+ }
7400
+ instructions = [];
7401
+ additionalSigners = [];
7402
+ _a.label = 1;
7403
+ case 1:
7404
+ _a.trys.push([1, 3, , 4]);
7405
+ return [4, this.program.methods
7406
+ .setInternalCurrentPrice({
7407
+ prices: tokenInternalPrices
7408
+ })
7409
+ .accounts({
7410
+ authority: POOL_CONFIGS[0].backupOracle,
7411
+ })
7412
+ .remainingAccounts(__spreadArray([], accountMetas, true))
7413
+ .instruction()];
7414
+ case 2:
7415
+ setInternalOraclePrice = _a.sent();
7416
+ instructions.push(setInternalOraclePrice);
7417
+ return [3, 4];
7418
+ case 3:
7419
+ err_62 = _a.sent();
7420
+ console.log("perpClient setInternalOracleAccount error:: ", err_62);
7421
+ throw err_62;
7422
+ case 4: return [2, {
7423
+ instructions: __spreadArray([], instructions, true),
7424
+ additionalSigners: additionalSigners
7425
+ }];
7426
+ }
7427
+ });
7428
+ }); };
7429
+ this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
7430
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7431
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7432
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7433
+ return __awaiter(_this, void 0, void 0, function () {
7434
+ 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_63;
7435
+ return __generator(this, function (_e) {
7436
+ switch (_e.label) {
7515
7437
  case 0:
7516
7438
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7517
7439
  preInstructions = [];
@@ -7528,8 +7450,8 @@ var PerpetualsClient = (function () {
7528
7450
  custodyAccountMetas = [];
7529
7451
  custodyOracleAccountMetas = [];
7530
7452
  markets = [];
7531
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7532
- custody = _b[_a];
7453
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7454
+ custody = _a[_i];
7533
7455
  custodyAccountMetas.push({
7534
7456
  pubkey: custody.custodyAccount,
7535
7457
  isSigner: false,
@@ -7541,8 +7463,8 @@ var PerpetualsClient = (function () {
7541
7463
  isWritable: false,
7542
7464
  });
7543
7465
  }
7544
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7545
- market = _d[_c];
7466
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7467
+ market = _c[_b];
7546
7468
  markets.push({
7547
7469
  pubkey: market.marketAccount,
7548
7470
  isSigner: false,
@@ -7551,26 +7473,26 @@ var PerpetualsClient = (function () {
7551
7473
  }
7552
7474
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
7553
7475
  case 1:
7554
- if (!(_f.sent())) {
7476
+ if (!(_e.sent())) {
7555
7477
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
7556
7478
  }
7557
7479
  return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
7558
7480
  case 2:
7559
- if (!(_f.sent())) {
7481
+ if (!(_e.sent())) {
7560
7482
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
7561
7483
  }
7562
7484
  if (!(inTokenSymbol == 'SOL')) return [3, 5];
7563
7485
  console.log("inTokenSymbol === SOL", inTokenSymbol);
7564
7486
  lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
7565
7487
  if (!!skipBalanceChecks) return [3, 4];
7566
- _e = anchor_1.BN.bind;
7488
+ _d = anchor_1.BN.bind;
7567
7489
  return [4, this.provider.connection.getBalance(publicKey)];
7568
7490
  case 3:
7569
- unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
7491
+ unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _e.sent()]))();
7570
7492
  if (unWrappedSolBalance.lt(lamports)) {
7571
7493
  throw "Insufficient SOL Funds";
7572
7494
  }
7573
- _f.label = 4;
7495
+ _e.label = 4;
7574
7496
  case 4:
7575
7497
  if (!ephemeralSignerPubkey) {
7576
7498
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -7594,12 +7516,12 @@ var PerpetualsClient = (function () {
7594
7516
  if (!!skipBalanceChecks) return [3, 7];
7595
7517
  return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
7596
7518
  case 6:
7597
- if (!(_f.sent())) {
7519
+ if (!(_e.sent())) {
7598
7520
  throw "Insufficient Funds , token Account doesn't exist";
7599
7521
  }
7600
- _f.label = 7;
7522
+ _e.label = 7;
7601
7523
  case 7:
7602
- _f.trys.push([7, 9, , 10]);
7524
+ _e.trys.push([7, 9, , 10]);
7603
7525
  return [4, this.program.methods
7604
7526
  .addCompoundingLiquidity({
7605
7527
  amountIn: amountIn,
@@ -7628,12 +7550,12 @@ var PerpetualsClient = (function () {
7628
7550
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7629
7551
  .instruction()];
7630
7552
  case 8:
7631
- addCompoundingLiquidity = _f.sent();
7553
+ addCompoundingLiquidity = _e.sent();
7632
7554
  instructions.push(addCompoundingLiquidity);
7633
7555
  return [3, 10];
7634
7556
  case 9:
7635
- err_62 = _f.sent();
7636
- console.log("perpClient addCompoundingLiquidity error:: ", err_62);
7557
+ err_63 = _e.sent();
7558
+ console.log("perpClient addCompoundingLiquidity error:: ", err_63);
7637
7559
  return [3, 10];
7638
7560
  case 10: return [2, {
7639
7561
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7643,18 +7565,14 @@ var PerpetualsClient = (function () {
7643
7565
  });
7644
7566
  });
7645
7567
  };
7646
- this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
7647
- var args_1 = [];
7648
- for (var _i = 5; _i < arguments.length; _i++) {
7649
- args_1[_i - 5] = arguments[_i];
7650
- }
7651
- 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, userPublicKey) {
7652
- 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_63;
7653
- if (createUserATA === void 0) { createUserATA = true; }
7654
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7655
- if (userPublicKey === void 0) { userPublicKey = undefined; }
7656
- return __generator(this, function (_f) {
7657
- switch (_f.label) {
7568
+ this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey) {
7569
+ if (createUserATA === void 0) { createUserATA = true; }
7570
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7571
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7572
+ return __awaiter(_this, void 0, void 0, function () {
7573
+ 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_64;
7574
+ return __generator(this, function (_e) {
7575
+ switch (_e.label) {
7658
7576
  case 0:
7659
7577
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7660
7578
  preInstructions = [];
@@ -7691,19 +7609,19 @@ var PerpetualsClient = (function () {
7691
7609
  if (!_a) return [3, 3];
7692
7610
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
7693
7611
  case 2:
7694
- _a = !(_f.sent());
7695
- _f.label = 3;
7612
+ _a = !(_e.sent());
7613
+ _e.label = 3;
7696
7614
  case 3:
7697
7615
  if (_a) {
7698
7616
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
7699
7617
  }
7700
- _f.label = 4;
7618
+ _e.label = 4;
7701
7619
  case 4:
7702
7620
  custodyAccountMetas = [];
7703
7621
  custodyOracleAccountMetas = [];
7704
7622
  markets = [];
7705
- for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
7706
- custody = _c[_b];
7623
+ for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
7624
+ custody = _b[_i];
7707
7625
  custodyAccountMetas.push({
7708
7626
  pubkey: custody.custodyAccount,
7709
7627
  isSigner: false,
@@ -7715,8 +7633,8 @@ var PerpetualsClient = (function () {
7715
7633
  isWritable: false,
7716
7634
  });
7717
7635
  }
7718
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7719
- market = _e[_d];
7636
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7637
+ market = _d[_c];
7720
7638
  markets.push({
7721
7639
  pubkey: market.marketAccount,
7722
7640
  isSigner: false,
@@ -7724,9 +7642,9 @@ var PerpetualsClient = (function () {
7724
7642
  });
7725
7643
  }
7726
7644
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
7727
- _f.label = 5;
7645
+ _e.label = 5;
7728
7646
  case 5:
7729
- _f.trys.push([5, 7, , 8]);
7647
+ _e.trys.push([5, 7, , 8]);
7730
7648
  return [4, this.program.methods
7731
7649
  .removeCompoundingLiquidity({
7732
7650
  compoundingAmountIn: compoundingAmountIn,
@@ -7755,12 +7673,12 @@ var PerpetualsClient = (function () {
7755
7673
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7756
7674
  .instruction()];
7757
7675
  case 6:
7758
- removeCompoundingLiquidity = _f.sent();
7676
+ removeCompoundingLiquidity = _e.sent();
7759
7677
  instructions.push(removeCompoundingLiquidity);
7760
7678
  return [3, 8];
7761
7679
  case 7:
7762
- err_63 = _f.sent();
7763
- console.log("perpClient removeCompoundingLiquidity error:: ", err_63);
7680
+ err_64 = _e.sent();
7681
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_64);
7764
7682
  return [3, 8];
7765
7683
  case 8: return [2, {
7766
7684
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7770,16 +7688,12 @@ var PerpetualsClient = (function () {
7770
7688
  });
7771
7689
  });
7772
7690
  };
7773
- this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
7774
- var args_1 = [];
7775
- for (var _i = 3; _i < arguments.length; _i++) {
7776
- args_1[_i - 3] = arguments[_i];
7777
- }
7778
- return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
7779
- 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_64;
7780
- if (createUserATA === void 0) { createUserATA = true; }
7781
- return __generator(this, function (_g) {
7782
- switch (_g.label) {
7691
+ this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7692
+ if (createUserATA === void 0) { createUserATA = true; }
7693
+ return __awaiter(_this, void 0, void 0, function () {
7694
+ 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_65;
7695
+ return __generator(this, function (_f) {
7696
+ switch (_f.label) {
7783
7697
  case 0:
7784
7698
  publicKey = this.provider.wallet.publicKey;
7785
7699
  preInstructions = [];
@@ -7794,8 +7708,8 @@ var PerpetualsClient = (function () {
7794
7708
  if (!_a) return [3, 2];
7795
7709
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
7796
7710
  case 1:
7797
- _a = !(_g.sent());
7798
- _g.label = 2;
7711
+ _a = !(_f.sent());
7712
+ _f.label = 2;
7799
7713
  case 2:
7800
7714
  if (_a) {
7801
7715
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
@@ -7807,8 +7721,8 @@ var PerpetualsClient = (function () {
7807
7721
  if (!_b) return [3, 4];
7808
7722
  return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
7809
7723
  case 3:
7810
- _b = (_g.sent());
7811
- _g.label = 4;
7724
+ _b = (_f.sent());
7725
+ _f.label = 4;
7812
7726
  case 4:
7813
7727
  if (_b) {
7814
7728
  tokenStakeAccounts.push({
@@ -7821,8 +7735,8 @@ var PerpetualsClient = (function () {
7821
7735
  custodyAccountMetas = [];
7822
7736
  custodyOracleAccountMetas = [];
7823
7737
  markets = [];
7824
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7825
- custody = _d[_c];
7738
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
7739
+ custody = _c[_i];
7826
7740
  custodyAccountMetas.push({
7827
7741
  pubkey: custody.custodyAccount,
7828
7742
  isSigner: false,
@@ -7834,17 +7748,17 @@ var PerpetualsClient = (function () {
7834
7748
  isWritable: false,
7835
7749
  });
7836
7750
  }
7837
- for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
7838
- market = _f[_e];
7751
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7752
+ market = _e[_d];
7839
7753
  markets.push({
7840
7754
  pubkey: market.marketAccount,
7841
7755
  isSigner: false,
7842
7756
  isWritable: false,
7843
7757
  });
7844
7758
  }
7845
- _g.label = 5;
7759
+ _f.label = 5;
7846
7760
  case 5:
7847
- _g.trys.push([5, 7, , 8]);
7761
+ _f.trys.push([5, 7, , 8]);
7848
7762
  return [4, this.program.methods
7849
7763
  .migrateStake({
7850
7764
  amount: amount
@@ -7870,12 +7784,12 @@ var PerpetualsClient = (function () {
7870
7784
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
7871
7785
  .instruction()];
7872
7786
  case 6:
7873
- migrateStake = _g.sent();
7787
+ migrateStake = _f.sent();
7874
7788
  instructions.push(migrateStake);
7875
7789
  return [3, 8];
7876
7790
  case 7:
7877
- err_64 = _g.sent();
7878
- console.log("perpClient migrateStake error:: ", err_64);
7791
+ err_65 = _f.sent();
7792
+ console.log("perpClient migrateStake error:: ", err_65);
7879
7793
  return [3, 8];
7880
7794
  case 8: return [2, {
7881
7795
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7886,7 +7800,7 @@ var PerpetualsClient = (function () {
7886
7800
  });
7887
7801
  };
7888
7802
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7889
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_65;
7803
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_66;
7890
7804
  return __generator(this, function (_d) {
7891
7805
  switch (_d.label) {
7892
7806
  case 0:
@@ -7958,8 +7872,8 @@ var PerpetualsClient = (function () {
7958
7872
  instructions.push(migrateFlp);
7959
7873
  return [3, 4];
7960
7874
  case 3:
7961
- err_65 = _d.sent();
7962
- console.log("perpClient migrateFlp error:: ", err_65);
7875
+ err_66 = _d.sent();
7876
+ console.log("perpClient migrateFlp error:: ", err_66);
7963
7877
  return [3, 4];
7964
7878
  case 4: return [2, {
7965
7879
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7968,16 +7882,12 @@ var PerpetualsClient = (function () {
7968
7882
  }
7969
7883
  });
7970
7884
  }); };
7971
- this.compoundingFee = function (poolConfig_1) {
7972
- var args_1 = [];
7973
- for (var _i = 1; _i < arguments.length; _i++) {
7974
- args_1[_i - 1] = arguments[_i];
7975
- }
7976
- return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
7977
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_66;
7978
- if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7979
- return __generator(this, function (_e) {
7980
- switch (_e.label) {
7885
+ this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7886
+ if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7887
+ return __awaiter(_this, void 0, void 0, function () {
7888
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_67;
7889
+ return __generator(this, function (_d) {
7890
+ switch (_d.label) {
7981
7891
  case 0:
7982
7892
  instructions = [];
7983
7893
  additionalSigners = [];
@@ -7986,8 +7896,8 @@ var PerpetualsClient = (function () {
7986
7896
  custodyAccountMetas = [];
7987
7897
  custodyOracleAccountMetas = [];
7988
7898
  markets = [];
7989
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7990
- custody = _b[_a];
7899
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7900
+ custody = _a[_i];
7991
7901
  custodyAccountMetas.push({
7992
7902
  pubkey: custody.custodyAccount,
7993
7903
  isSigner: false,
@@ -7999,17 +7909,17 @@ var PerpetualsClient = (function () {
7999
7909
  isWritable: false,
8000
7910
  });
8001
7911
  }
8002
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
8003
- market = _d[_c];
7912
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7913
+ market = _c[_b];
8004
7914
  markets.push({
8005
7915
  pubkey: market.marketAccount,
8006
7916
  isSigner: false,
8007
7917
  isWritable: false,
8008
7918
  });
8009
7919
  }
8010
- _e.label = 1;
7920
+ _d.label = 1;
8011
7921
  case 1:
8012
- _e.trys.push([1, 3, , 4]);
7922
+ _d.trys.push([1, 3, , 4]);
8013
7923
  return [4, this.program.methods
8014
7924
  .compoundFees({})
8015
7925
  .accounts({
@@ -8028,12 +7938,12 @@ var PerpetualsClient = (function () {
8028
7938
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
8029
7939
  .instruction()];
8030
7940
  case 2:
8031
- compoundingFee = _e.sent();
7941
+ compoundingFee = _d.sent();
8032
7942
  instructions.push(compoundingFee);
8033
7943
  return [3, 4];
8034
7944
  case 3:
8035
- err_66 = _e.sent();
8036
- console.log("perpClient compoundingFee error:: ", err_66);
7945
+ err_67 = _d.sent();
7946
+ console.log("perpClient compoundingFee error:: ", err_67);
8037
7947
  return [3, 4];
8038
7948
  case 4: return [2, {
8039
7949
  instructions: __spreadArray([], instructions, true),
@@ -8044,7 +7954,7 @@ var PerpetualsClient = (function () {
8044
7954
  });
8045
7955
  };
8046
7956
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8047
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_67;
7957
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_68;
8048
7958
  return __generator(this, function (_a) {
8049
7959
  switch (_a.label) {
8050
7960
  case 0:
@@ -8082,8 +7992,8 @@ var PerpetualsClient = (function () {
8082
7992
  instructions.push(renameFlp);
8083
7993
  return [3, 4];
8084
7994
  case 3:
8085
- err_67 = _a.sent();
8086
- console.log("perpClient renameFlp error:: ", err_67);
7995
+ err_68 = _a.sent();
7996
+ console.log("perpClient renameFlp error:: ", err_68);
8087
7997
  return [3, 4];
8088
7998
  case 4: return [2, {
8089
7999
  instructions: __spreadArray([], instructions, true),
@@ -8193,9 +8103,9 @@ var PerpetualsClient = (function () {
8193
8103
  }
8194
8104
  }
8195
8105
  };
8196
- PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
8197
- return __awaiter(this, arguments, void 0, function (ixs, opts) {
8198
- if (opts === void 0) { opts = {}; }
8106
+ PerpetualsClient.prototype.sendTransaction = function (ixs, opts) {
8107
+ if (opts === void 0) { opts = {}; }
8108
+ return __awaiter(this, void 0, void 0, function () {
8199
8109
  return __generator(this, function (_a) {
8200
8110
  switch (_a.label) {
8201
8111
  case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
@@ -8204,9 +8114,9 @@ var PerpetualsClient = (function () {
8204
8114
  });
8205
8115
  });
8206
8116
  };
8207
- PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
8208
- return __awaiter(this, arguments, void 0, function (ixs, opts) {
8209
- if (opts === void 0) { opts = {}; }
8117
+ PerpetualsClient.prototype.sendTransactionV3 = function (ixs, opts) {
8118
+ if (opts === void 0) { opts = {}; }
8119
+ return __awaiter(this, void 0, void 0, function () {
8210
8120
  return __generator(this, function (_a) {
8211
8121
  switch (_a.label) {
8212
8122
  case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];