flash-sdk 2.50.1 → 2.50.2

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.
@@ -2148,40 +2148,36 @@ var PerpetualsClient = (function () {
2148
2148
  }
2149
2149
  });
2150
2150
  }); };
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) {
2151
+ this.getAddLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2152
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2153
+ return __awaiter(_this, void 0, void 0, function () {
2154
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_5, token, _a, custodies_6, custody, _b, _c, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2155
+ var _d;
2156
+ return __generator(this, function (_e) {
2157
+ switch (_e.label) {
2162
2158
  case 0:
2163
2159
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2164
2160
  custodies = POOL_CONFIG.custodies;
2165
2161
  custodyMetas = [];
2166
2162
  marketMetas = [];
2167
- for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
2168
- token = custodies_5[_a];
2163
+ for (_i = 0, custodies_5 = custodies; _i < custodies_5.length; _i++) {
2164
+ token = custodies_5[_i];
2169
2165
  custodyMetas.push({
2170
2166
  isSigner: false,
2171
2167
  isWritable: false,
2172
2168
  pubkey: token.custodyAccount,
2173
2169
  });
2174
2170
  }
2175
- for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
2176
- custody = custodies_6[_b];
2171
+ for (_a = 0, custodies_6 = custodies; _a < custodies_6.length; _a++) {
2172
+ custody = custodies_6[_a];
2177
2173
  custodyMetas.push({
2178
2174
  isSigner: false,
2179
2175
  isWritable: false,
2180
2176
  pubkey: custody.intOracleAccount,
2181
2177
  });
2182
2178
  }
2183
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2184
- market = _d[_c];
2179
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2180
+ market = _c[_b];
2185
2181
  marketMetas.push({
2186
2182
  pubkey: market.marketAccount,
2187
2183
  isSigner: false,
@@ -2204,14 +2200,14 @@ var PerpetualsClient = (function () {
2204
2200
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2205
2201
  .transaction()];
2206
2202
  case 1:
2207
- transaction = _f.sent();
2203
+ transaction = _e.sent();
2208
2204
  return [4, backUpOracleInstructionPromise];
2209
2205
  case 2:
2210
- backUpOracleInstruction = _f.sent();
2211
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2206
+ backUpOracleInstruction = _e.sent();
2207
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2212
2208
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2213
2209
  case 3:
2214
- result = _f.sent();
2210
+ result = _e.sent();
2215
2211
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
2216
2212
  res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
2217
2213
  return [2, {
@@ -2222,40 +2218,36 @@ var PerpetualsClient = (function () {
2222
2218
  });
2223
2219
  });
2224
2220
  };
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) {
2221
+ this.getRemoveLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2222
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2223
+ return __awaiter(_this, void 0, void 0, function () {
2224
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_7, token, _a, custodies_8, custody, _b, _c, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2225
+ var _d;
2226
+ return __generator(this, function (_e) {
2227
+ switch (_e.label) {
2236
2228
  case 0:
2237
2229
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2238
2230
  custodies = POOL_CONFIG.custodies;
2239
2231
  custodyMetas = [];
2240
2232
  marketMetas = [];
2241
- for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
2242
- token = custodies_7[_a];
2233
+ for (_i = 0, custodies_7 = custodies; _i < custodies_7.length; _i++) {
2234
+ token = custodies_7[_i];
2243
2235
  custodyMetas.push({
2244
2236
  isSigner: false,
2245
2237
  isWritable: false,
2246
2238
  pubkey: token.custodyAccount,
2247
2239
  });
2248
2240
  }
2249
- for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
2250
- custody = custodies_8[_b];
2241
+ for (_a = 0, custodies_8 = custodies; _a < custodies_8.length; _a++) {
2242
+ custody = custodies_8[_a];
2251
2243
  custodyMetas.push({
2252
2244
  isSigner: false,
2253
2245
  isWritable: false,
2254
2246
  pubkey: custody.intOracleAccount,
2255
2247
  });
2256
2248
  }
2257
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2258
- market = _d[_c];
2249
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2250
+ market = _c[_b];
2259
2251
  marketMetas.push({
2260
2252
  pubkey: market.marketAccount,
2261
2253
  isSigner: false,
@@ -2278,14 +2270,14 @@ var PerpetualsClient = (function () {
2278
2270
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2279
2271
  .transaction()];
2280
2272
  case 1:
2281
- transaction = _f.sent();
2273
+ transaction = _e.sent();
2282
2274
  return [4, backUpOracleInstructionPromise];
2283
2275
  case 2:
2284
- backUpOracleInstruction = _f.sent();
2285
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2276
+ backUpOracleInstruction = _e.sent();
2277
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2286
2278
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2287
2279
  case 3:
2288
- result = _f.sent();
2280
+ result = _e.sent();
2289
2281
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2290
2282
  if (result.value.err) {
2291
2283
  return [2, {
@@ -2361,40 +2353,36 @@ var PerpetualsClient = (function () {
2361
2353
  }
2362
2354
  });
2363
2355
  }); };
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) {
2356
+ this.getAddCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2357
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2358
+ return __awaiter(_this, void 0, void 0, function () {
2359
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_11, token, _a, custodies_12, custody, _b, _c, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2360
+ var _d;
2361
+ return __generator(this, function (_e) {
2362
+ switch (_e.label) {
2375
2363
  case 0:
2376
2364
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2377
2365
  custodies = POOL_CONFIG.custodies;
2378
2366
  custodyMetas = [];
2379
2367
  marketMetas = [];
2380
- for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
2381
- token = custodies_11[_a];
2368
+ for (_i = 0, custodies_11 = custodies; _i < custodies_11.length; _i++) {
2369
+ token = custodies_11[_i];
2382
2370
  custodyMetas.push({
2383
2371
  isSigner: false,
2384
2372
  isWritable: false,
2385
2373
  pubkey: token.custodyAccount,
2386
2374
  });
2387
2375
  }
2388
- for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
2389
- custody = custodies_12[_b];
2376
+ for (_a = 0, custodies_12 = custodies; _a < custodies_12.length; _a++) {
2377
+ custody = custodies_12[_a];
2390
2378
  custodyMetas.push({
2391
2379
  isSigner: false,
2392
2380
  isWritable: false,
2393
2381
  pubkey: custody.intOracleAccount,
2394
2382
  });
2395
2383
  }
2396
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2397
- market = _d[_c];
2384
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2385
+ market = _c[_b];
2398
2386
  marketMetas.push({
2399
2387
  pubkey: market.marketAccount,
2400
2388
  isSigner: false,
@@ -2405,7 +2393,7 @@ var PerpetualsClient = (function () {
2405
2393
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2406
2394
  return [4, backUpOracleInstructionPromise];
2407
2395
  case 1:
2408
- backUpOracleInstruction = _f.sent();
2396
+ backUpOracleInstruction = _e.sent();
2409
2397
  return [4, this.program.methods
2410
2398
  .getAddCompoundingLiquidityAmountAndFee({
2411
2399
  amountIn: amount,
@@ -2424,11 +2412,11 @@ var PerpetualsClient = (function () {
2424
2412
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2425
2413
  .transaction()];
2426
2414
  case 2:
2427
- transaction = _f.sent();
2428
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2415
+ transaction = _e.sent();
2416
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2429
2417
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2430
2418
  case 3:
2431
- result = _f.sent();
2419
+ result = _e.sent();
2432
2420
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2433
2421
  res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
2434
2422
  return [2, {
@@ -2439,40 +2427,36 @@ var PerpetualsClient = (function () {
2439
2427
  });
2440
2428
  });
2441
2429
  };
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) {
2430
+ this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2431
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2432
+ return __awaiter(_this, void 0, void 0, function () {
2433
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_13, token, _a, custodies_14, custody, _b, _c, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2434
+ var _d;
2435
+ return __generator(this, function (_e) {
2436
+ switch (_e.label) {
2453
2437
  case 0:
2454
2438
  backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2455
2439
  custodies = POOL_CONFIG.custodies;
2456
2440
  custodyMetas = [];
2457
2441
  marketMetas = [];
2458
- for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
2459
- token = custodies_13[_a];
2442
+ for (_i = 0, custodies_13 = custodies; _i < custodies_13.length; _i++) {
2443
+ token = custodies_13[_i];
2460
2444
  custodyMetas.push({
2461
2445
  isSigner: false,
2462
2446
  isWritable: false,
2463
2447
  pubkey: token.custodyAccount,
2464
2448
  });
2465
2449
  }
2466
- for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
2467
- custody = custodies_14[_b];
2450
+ for (_a = 0, custodies_14 = custodies; _a < custodies_14.length; _a++) {
2451
+ custody = custodies_14[_a];
2468
2452
  custodyMetas.push({
2469
2453
  isSigner: false,
2470
2454
  isWritable: false,
2471
2455
  pubkey: custody.intOracleAccount,
2472
2456
  });
2473
2457
  }
2474
- for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2475
- market = _d[_c];
2458
+ for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2459
+ market = _c[_b];
2476
2460
  marketMetas.push({
2477
2461
  pubkey: market.marketAccount,
2478
2462
  isSigner: false,
@@ -2483,7 +2467,7 @@ var PerpetualsClient = (function () {
2483
2467
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2484
2468
  return [4, backUpOracleInstructionPromise];
2485
2469
  case 1:
2486
- backUpOracleInstruction = _f.sent();
2470
+ backUpOracleInstruction = _e.sent();
2487
2471
  return [4, this.program.methods
2488
2472
  .getRemoveCompoundingLiquidityAmountAndFee({
2489
2473
  compoundingAmountIn: amount,
@@ -2502,11 +2486,11 @@ var PerpetualsClient = (function () {
2502
2486
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2503
2487
  .transaction()];
2504
2488
  case 2:
2505
- transaction = _f.sent();
2506
- (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2489
+ transaction = _e.sent();
2490
+ (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2507
2491
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2508
2492
  case 3:
2509
- result = _f.sent();
2493
+ result = _e.sent();
2510
2494
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2511
2495
  if (result.value.err) {
2512
2496
  return [2, {
@@ -2523,6 +2507,47 @@ var PerpetualsClient = (function () {
2523
2507
  });
2524
2508
  });
2525
2509
  };
2510
+ this.getLiquidationPriceView = function (positionAccountKey, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
2511
+ var positionAccount_1, marketConfig_1, targetCustodyConfig, collateralCustodyConfig, err_2;
2512
+ return __generator(this, function (_a) {
2513
+ switch (_a.label) {
2514
+ case 0:
2515
+ _a.trys.push([0, 3, , 4]);
2516
+ return [4, this.getPosition(positionAccountKey)];
2517
+ case 1:
2518
+ positionAccount_1 = _a.sent();
2519
+ marketConfig_1 = poolConfig.markets.find(function (m) { return m.marketAccount.equals(positionAccount_1.market); });
2520
+ if (!marketConfig_1) {
2521
+ throw new Error("Market config not found for position account: ".concat(positionAccountKey.toBase58()));
2522
+ }
2523
+ targetCustodyConfig = poolConfig.custodies.find(function (f) { return f.custodyAccount.equals(marketConfig_1.targetCustody); });
2524
+ collateralCustodyConfig = poolConfig.custodies.find(function (f) { return f.custodyAccount.equals(marketConfig_1.collateralCustody); });
2525
+ return [4, this.program.methods
2526
+ .getLiquidationPrice({})
2527
+ .accounts({
2528
+ perpetuals: this.perpetuals.publicKey,
2529
+ pool: poolConfig.poolAddress,
2530
+ position: positionAccountKey,
2531
+ targetCustody: targetCustodyConfig.custodyAccount,
2532
+ targetOracleAccount: targetCustodyConfig.intOracleAccount,
2533
+ collateralCustody: collateralCustodyConfig.custodyAccount,
2534
+ collateralOracleAccount: collateralCustodyConfig.intOracleAccount,
2535
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2536
+ })
2537
+ .view()
2538
+ .catch(function (err) {
2539
+ console.error(err);
2540
+ throw err;
2541
+ })];
2542
+ case 2: return [2, _a.sent()];
2543
+ case 3:
2544
+ err_2 = _a.sent();
2545
+ console.error("Error in getLiquidationPriceView:", err_2);
2546
+ throw err_2;
2547
+ case 4: return [2];
2548
+ }
2549
+ });
2550
+ }); };
2526
2551
  this.getLiquidationStateView = function (positionAccount, poolName, tokenMint, collateralMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
2527
2552
  var targetCustodyConfig, collateralCustodyConfig;
2528
2553
  return __generator(this, function (_a) {
@@ -2645,18 +2670,14 @@ var PerpetualsClient = (function () {
2645
2670
  }
2646
2671
  });
2647
2672
  }); };
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) {
2673
+ this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2674
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2675
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2676
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2677
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2678
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2679
+ return __awaiter(_this, void 0, void 0, function () {
2654
2680
  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
2681
  return __generator(this, function (_c) {
2661
2682
  switch (_c.label) {
2662
2683
  case 0:
@@ -2760,19 +2781,15 @@ var PerpetualsClient = (function () {
2760
2781
  });
2761
2782
  });
2762
2783
  };
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) {
2784
+ this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2785
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2786
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2787
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2788
+ if (createUserATA === void 0) { createUserATA = true; }
2789
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2790
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2791
+ return __awaiter(_this, void 0, void 0, function () {
2769
2792
  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
2793
  return __generator(this, function (_b) {
2777
2794
  switch (_b.label) {
2778
2795
  case 0:
@@ -2869,18 +2886,14 @@ var PerpetualsClient = (function () {
2869
2886
  });
2870
2887
  });
2871
2888
  };
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) {
2878
- 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; }
2889
+ this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2890
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2891
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2892
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2893
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2894
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2895
+ return __awaiter(_this, void 0, void 0, function () {
2896
+ var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_3;
2884
2897
  return __generator(this, function (_c) {
2885
2898
  switch (_c.label) {
2886
2899
  case 0:
@@ -3009,9 +3022,9 @@ var PerpetualsClient = (function () {
3009
3022
  instructions.push(inx);
3010
3023
  return [3, 13];
3011
3024
  case 12:
3012
- err_2 = _c.sent();
3013
- console.error("perpClient SwapAndOpen error:: ", err_2);
3014
- throw err_2;
3025
+ err_3 = _c.sent();
3026
+ console.error("perpClient SwapAndOpen error:: ", err_3);
3027
+ throw err_3;
3015
3028
  case 13: return [2, {
3016
3029
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3017
3030
  additionalSigners: additionalSigners
@@ -3020,17 +3033,13 @@ var PerpetualsClient = (function () {
3020
3033
  });
3021
3034
  });
3022
3035
  };
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) {
3029
- 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; }
3036
+ this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
3037
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3038
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3039
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3040
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3041
+ return __awaiter(_this, void 0, void 0, function () {
3042
+ var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_4;
3034
3043
  return __generator(this, function (_a) {
3035
3044
  switch (_a.label) {
3036
3045
  case 0:
@@ -3133,9 +3142,9 @@ var PerpetualsClient = (function () {
3133
3142
  instructions.push(inx);
3134
3143
  return [3, 9];
3135
3144
  case 8:
3136
- err_3 = _a.sent();
3137
- console.error("perpClient CloseAndSwap error:: ", err_3);
3138
- throw err_3;
3145
+ err_4 = _a.sent();
3146
+ console.error("perpClient CloseAndSwap error:: ", err_4);
3147
+ throw err_4;
3139
3148
  case 9: return [2, {
3140
3149
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3141
3150
  additionalSigners: additionalSigners
@@ -3144,20 +3153,16 @@ var PerpetualsClient = (function () {
3144
3153
  });
3145
3154
  });
3146
3155
  };
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) {
3156
+ this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
3157
+ if (useFeesPool === void 0) { useFeesPool = false; }
3158
+ if (createUserATA === void 0) { createUserATA = true; }
3159
+ if (unWrapSol === void 0) { unWrapSol = false; }
3160
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3161
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3162
+ return __awaiter(_this, void 0, void 0, function () {
3163
+ 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_5;
3164
+ return __generator(this, function (_f) {
3165
+ switch (_f.label) {
3161
3166
  case 0:
3162
3167
  userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
3163
3168
  if (!userInputCustodyConfig) {
@@ -3175,10 +3180,10 @@ var PerpetualsClient = (function () {
3175
3180
  if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
3176
3181
  return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
3177
3182
  case 1:
3178
- wsolAssociatedTokenAccount = _g.sent();
3183
+ wsolAssociatedTokenAccount = _f.sent();
3179
3184
  return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
3180
3185
  case 2:
3181
- wsolATAExist = _g.sent();
3186
+ wsolATAExist = _f.sent();
3182
3187
  if (!wsolATAExist) {
3183
3188
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
3184
3189
  }
@@ -3186,11 +3191,11 @@ var PerpetualsClient = (function () {
3186
3191
  _a = anchor_1.BN.bind;
3187
3192
  return [4, this.provider.connection.getBalance(publicKey)];
3188
3193
  case 3:
3189
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
3194
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
3190
3195
  if (unWrappedSolBalance.lt(amountIn)) {
3191
3196
  throw "Insufficient SOL Funds";
3192
3197
  }
3193
- _g.label = 4;
3198
+ _f.label = 4;
3194
3199
  case 4:
3195
3200
  instructions.push(web3_js_1.SystemProgram.transfer({
3196
3201
  fromPubkey: publicKey,
@@ -3212,20 +3217,20 @@ var PerpetualsClient = (function () {
3212
3217
  additionalSigners: additionalSigners
3213
3218
  }];
3214
3219
  }
3215
- _g.label = 6;
3220
+ _f.label = 6;
3216
3221
  case 6:
3217
- _g.trys.push([6, 19, , 20]);
3222
+ _f.trys.push([6, 19, , 20]);
3218
3223
  if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
3219
3224
  console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
3220
3225
  return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
3221
3226
  case 7:
3222
- accCreationLamports = (_g.sent());
3227
+ accCreationLamports = (_f.sent());
3223
3228
  console.log("accCreationLamports:", accCreationLamports);
3224
3229
  lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
3225
3230
  _b = anchor_1.BN.bind;
3226
3231
  return [4, this.provider.connection.getBalance(publicKey)];
3227
3232
  case 8:
3228
- unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
3233
+ unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _f.sent()]))();
3229
3234
  if (unWrappedSolBalance.lt(amountIn)) {
3230
3235
  throw "Insufficient SOL Funds";
3231
3236
  }
@@ -3252,18 +3257,18 @@ var PerpetualsClient = (function () {
3252
3257
  userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
3253
3258
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
3254
3259
  case 10:
3255
- if (!(_g.sent())) {
3260
+ if (!(_f.sent())) {
3256
3261
  throw "Insufficient Funds , Token Account doesn't exist";
3257
3262
  }
3258
3263
  if (!!skipBalanceChecks) return [3, 12];
3259
3264
  _c = anchor_1.BN.bind;
3260
3265
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
3261
3266
  case 11:
3262
- tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3267
+ tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
3263
3268
  if (tokenAccountBalance.lt(amountIn)) {
3264
3269
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
3265
3270
  }
3266
- _g.label = 12;
3271
+ _f.label = 12;
3267
3272
  case 12:
3268
3273
  if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
3269
3274
  lamports = (this.minimumBalanceForRentExemptAccountLamports);
@@ -3288,23 +3293,23 @@ var PerpetualsClient = (function () {
3288
3293
  return [3, 17];
3289
3294
  case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
3290
3295
  case 14:
3291
- userOutputTokenAccount = _g.sent();
3296
+ userOutputTokenAccount = _f.sent();
3292
3297
  _d = createUserATA;
3293
3298
  if (!_d) return [3, 16];
3294
3299
  return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
3295
3300
  case 15:
3296
- _d = !(_g.sent());
3297
- _g.label = 16;
3301
+ _d = !(_f.sent());
3302
+ _f.label = 16;
3298
3303
  case 16:
3299
3304
  if (_d) {
3300
3305
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
3301
3306
  }
3302
- _g.label = 17;
3307
+ _f.label = 17;
3303
3308
  case 17:
3304
3309
  custodyAccountMetas = [];
3305
3310
  custodyOracleAccountMetas = [];
3306
- for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
3307
- custody = _f[_e];
3311
+ for (_i = 0, _e = poolConfig.custodies; _i < _e.length; _i++) {
3312
+ custody = _e[_i];
3308
3313
  custodyAccountMetas.push({
3309
3314
  pubkey: custody.custodyAccount,
3310
3315
  isSigner: false,
@@ -3344,7 +3349,7 @@ var PerpetualsClient = (function () {
3344
3349
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
3345
3350
  .instruction()];
3346
3351
  case 18:
3347
- inx = _g.sent();
3352
+ inx = _f.sent();
3348
3353
  instructions.push(inx);
3349
3354
  if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
3350
3355
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
@@ -3352,9 +3357,9 @@ var PerpetualsClient = (function () {
3352
3357
  }
3353
3358
  return [3, 20];
3354
3359
  case 19:
3355
- err_4 = _g.sent();
3356
- console.error("perpClient Swap error:: ", err_4);
3357
- throw err_4;
3360
+ err_5 = _f.sent();
3361
+ console.error("perpClient Swap error:: ", err_5);
3362
+ throw err_5;
3358
3363
  case 20: return [2, {
3359
3364
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3360
3365
  additionalSigners: additionalSigners
@@ -3364,7 +3369,7 @@ var PerpetualsClient = (function () {
3364
3369
  });
3365
3370
  };
3366
3371
  this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
3367
- var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_5;
3372
+ var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_6;
3368
3373
  return __generator(this, function (_b) {
3369
3374
  switch (_b.label) {
3370
3375
  case 0:
@@ -3424,9 +3429,9 @@ var PerpetualsClient = (function () {
3424
3429
  instructions.push(inx);
3425
3430
  return [3, 4];
3426
3431
  case 3:
3427
- err_5 = _b.sent();
3428
- console.error("perpClient Swap error:: ", err_5);
3429
- throw err_5;
3432
+ err_6 = _b.sent();
3433
+ console.error("perpClient Swap error:: ", err_6);
3434
+ throw err_6;
3430
3435
  case 4: return [2, {
3431
3436
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3432
3437
  additionalSigners: additionalSigners
@@ -3434,15 +3439,11 @@ var PerpetualsClient = (function () {
3434
3439
  }
3435
3440
  });
3436
3441
  }); };
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) {
3442
+ this.addCollateral = function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3443
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3444
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3445
+ return __awaiter(_this, void 0, void 0, function () {
3443
3446
  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
3447
  return __generator(this, function (_c) {
3447
3448
  switch (_c.label) {
3448
3449
  case 0:
@@ -3536,15 +3537,11 @@ var PerpetualsClient = (function () {
3536
3537
  });
3537
3538
  });
3538
3539
  };
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) {
3540
+ this.swapAndAddCollateral = function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3541
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3542
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3543
+ return __awaiter(_this, void 0, void 0, function () {
3545
3544
  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
3545
  return __generator(this, function (_c) {
3549
3546
  switch (_c.label) {
3550
3547
  case 0:
@@ -3655,16 +3652,12 @@ var PerpetualsClient = (function () {
3655
3652
  });
3656
3653
  });
3657
3654
  };
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) {
3655
+ this.removeCollateral = function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3656
+ if (createUserATA === void 0) { createUserATA = true; }
3657
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3658
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3659
+ return __awaiter(_this, void 0, void 0, function () {
3664
3660
  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
3661
  return __generator(this, function (_b) {
3669
3662
  switch (_b.label) {
3670
3663
  case 0:
@@ -3765,14 +3758,10 @@ var PerpetualsClient = (function () {
3765
3758
  });
3766
3759
  });
3767
3760
  };
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) {
3761
+ this.removeCollateralAndSwap = function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
3762
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3763
+ return __awaiter(_this, void 0, void 0, function () {
3774
3764
  var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
3775
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3776
3765
  return __generator(this, function (_a) {
3777
3766
  switch (_a.label) {
3778
3767
  case 0:
@@ -3865,16 +3854,12 @@ var PerpetualsClient = (function () {
3865
3854
  });
3866
3855
  });
3867
3856
  };
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) {
3857
+ this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3858
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3859
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3860
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3861
+ return __awaiter(_this, void 0, void 0, function () {
3874
3862
  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
3863
  return __generator(this, function (_a) {
3879
3864
  switch (_a.label) {
3880
3865
  case 0:
@@ -3929,16 +3914,12 @@ var PerpetualsClient = (function () {
3929
3914
  });
3930
3915
  });
3931
3916
  };
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) {
3917
+ this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3918
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3919
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3920
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3921
+ return __awaiter(_this, void 0, void 0, function () {
3938
3922
  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
3923
  return __generator(this, function (_a) {
3943
3924
  switch (_a.label) {
3944
3925
  case 0:
@@ -3993,17 +3974,13 @@ var PerpetualsClient = (function () {
3993
3974
  });
3994
3975
  });
3995
3976
  };
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) {
3977
+ this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3978
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3979
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3980
+ return __awaiter(_this, void 0, void 0, function () {
3981
+ 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_7;
3982
+ return __generator(this, function (_f) {
3983
+ switch (_f.label) {
4007
3984
  case 0:
4008
3985
  publicKey = this.provider.wallet.publicKey;
4009
3986
  payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
@@ -4014,16 +3991,16 @@ var PerpetualsClient = (function () {
4014
3991
  instructions = [];
4015
3992
  postInstructions = [];
4016
3993
  additionalSigners = [];
4017
- _g.label = 1;
3994
+ _f.label = 1;
4018
3995
  case 1:
4019
- _g.trys.push([1, 10, , 11]);
3996
+ _f.trys.push([1, 10, , 11]);
4020
3997
  userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
4021
3998
  lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4022
3999
  custodyAccountMetas = [];
4023
4000
  custodyOracleAccountMetas = [];
4024
4001
  markets = [];
4025
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4026
- custody = _b[_a];
4002
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4003
+ custody = _a[_i];
4027
4004
  custodyAccountMetas.push({
4028
4005
  pubkey: custody.custodyAccount,
4029
4006
  isSigner: false,
@@ -4035,8 +4012,8 @@ var PerpetualsClient = (function () {
4035
4012
  isWritable: false,
4036
4013
  });
4037
4014
  }
4038
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4039
- market = _d[_c];
4015
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4016
+ market = _c[_b];
4040
4017
  markets.push({
4041
4018
  pubkey: market.marketAccount,
4042
4019
  isSigner: false,
@@ -4045,21 +4022,21 @@ var PerpetualsClient = (function () {
4045
4022
  }
4046
4023
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4047
4024
  case 2:
4048
- if (!(_g.sent())) {
4025
+ if (!(_f.sent())) {
4049
4026
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4050
4027
  }
4051
4028
  if (!(payTokenSymbol == 'SOL')) return [3, 5];
4052
4029
  console.log("payTokenSymbol === SOL", payTokenSymbol);
4053
4030
  lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
4054
4031
  if (!!skipBalanceChecks) return [3, 4];
4055
- _e = anchor_1.BN.bind;
4032
+ _d = anchor_1.BN.bind;
4056
4033
  return [4, this.provider.connection.getBalance(publicKey)];
4057
4034
  case 3:
4058
- unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
4035
+ unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _f.sent()]))();
4059
4036
  if (unWrappedSolBalance.lt(lamports)) {
4060
4037
  throw "Insufficient SOL Funds";
4061
4038
  }
4062
- _g.label = 4;
4039
+ _f.label = 4;
4063
4040
  case 4:
4064
4041
  if (!ephemeralSignerPubkey) {
4065
4042
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -4083,17 +4060,17 @@ var PerpetualsClient = (function () {
4083
4060
  if (!!skipBalanceChecks) return [3, 8];
4084
4061
  return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
4085
4062
  case 6:
4086
- if (!(_g.sent())) {
4063
+ if (!(_f.sent())) {
4087
4064
  throw "Insufficient Funds , token Account doesn't exist";
4088
4065
  }
4089
- _f = anchor_1.BN.bind;
4066
+ _e = anchor_1.BN.bind;
4090
4067
  return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
4091
4068
  case 7:
4092
- tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4069
+ tokenAccountBalance = new (_e.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4093
4070
  if (tokenAccountBalance.lt(tokenAmountIn)) {
4094
4071
  throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
4095
4072
  }
4096
- _g.label = 8;
4073
+ _f.label = 8;
4097
4074
  case 8: return [4, this.program.methods
4098
4075
  .addLiquidity({
4099
4076
  amountIn: tokenAmountIn,
@@ -4118,13 +4095,13 @@ var PerpetualsClient = (function () {
4118
4095
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4119
4096
  .instruction()];
4120
4097
  case 9:
4121
- instruction = _g.sent();
4098
+ instruction = _f.sent();
4122
4099
  instructions.push(instruction);
4123
4100
  return [3, 11];
4124
4101
  case 10:
4125
- err_6 = _g.sent();
4126
- console.error("perpClient addLiquidity error:: ", err_6);
4127
- throw err_6;
4102
+ err_7 = _f.sent();
4103
+ console.error("perpClient addLiquidity error:: ", err_7);
4104
+ throw err_7;
4128
4105
  case 11: return [2, {
4129
4106
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4130
4107
  additionalSigners: additionalSigners
@@ -4133,18 +4110,14 @@ var PerpetualsClient = (function () {
4133
4110
  });
4134
4111
  });
4135
4112
  };
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) {
4113
+ this.addLiquidityAndStake = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
4114
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4115
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4116
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4117
+ return __awaiter(_this, void 0, void 0, function () {
4118
+ 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;
4119
+ return __generator(this, function (_f) {
4120
+ switch (_f.label) {
4148
4121
  case 0:
4149
4122
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4150
4123
  preInstructions = [];
@@ -4164,14 +4137,14 @@ var PerpetualsClient = (function () {
4164
4137
  _a = anchor_1.BN.bind;
4165
4138
  return [4, this.provider.connection.getBalance(publicKey)];
4166
4139
  case 1:
4167
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
4140
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
4168
4141
  if (unWrappedSolBalance.lt(lamports)) {
4169
4142
  throw "Insufficient SOL Funds";
4170
4143
  }
4171
- _g.label = 2;
4144
+ _f.label = 2;
4172
4145
  case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4173
4146
  case 3:
4174
- if (!(_g.sent())) {
4147
+ if (!(_f.sent())) {
4175
4148
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4176
4149
  }
4177
4150
  if (!ephemeralSignerPubkey) {
@@ -4197,23 +4170,23 @@ var PerpetualsClient = (function () {
4197
4170
  if (!!skipBalanceChecks) return [3, 7];
4198
4171
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
4199
4172
  case 5:
4200
- if (!(_g.sent())) {
4173
+ if (!(_f.sent())) {
4201
4174
  throw "Insufficient Funds , token Account doesn't exist";
4202
4175
  }
4203
4176
  _b = anchor_1.BN.bind;
4204
4177
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
4205
4178
  case 6:
4206
- tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
4179
+ tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4207
4180
  if (tokenAccountBalance.lt(amountIn)) {
4208
4181
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
4209
4182
  }
4210
- _g.label = 7;
4183
+ _f.label = 7;
4211
4184
  case 7:
4212
4185
  custodyAccountMetas = [];
4213
4186
  custodyOracleAccountMetas = [];
4214
4187
  markets = [];
4215
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
4216
- custody = _d[_c];
4188
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
4189
+ custody = _c[_i];
4217
4190
  custodyAccountMetas.push({
4218
4191
  pubkey: custody.custodyAccount,
4219
4192
  isSigner: false,
@@ -4225,8 +4198,8 @@ var PerpetualsClient = (function () {
4225
4198
  isWritable: false,
4226
4199
  });
4227
4200
  }
4228
- for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
4229
- market = _f[_e];
4201
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
4202
+ market = _e[_d];
4230
4203
  markets.push({
4231
4204
  pubkey: market.marketAccount,
4232
4205
  isSigner: false,
@@ -4258,7 +4231,7 @@ var PerpetualsClient = (function () {
4258
4231
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4259
4232
  .instruction()];
4260
4233
  case 8:
4261
- instruction = _g.sent();
4234
+ instruction = _f.sent();
4262
4235
  instructions.push(instruction);
4263
4236
  return [2, {
4264
4237
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4268,20 +4241,16 @@ var PerpetualsClient = (function () {
4268
4241
  });
4269
4242
  });
4270
4243
  };
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) {
4244
+ this.removeLiquidity = function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
4245
+ if (closeLpATA === void 0) { closeLpATA = false; }
4246
+ if (createUserATA === void 0) { createUserATA = true; }
4247
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4248
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4249
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4250
+ return __awaiter(_this, void 0, void 0, function () {
4251
+ 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_8;
4252
+ return __generator(this, function (_e) {
4253
+ switch (_e.label) {
4285
4254
  case 0:
4286
4255
  recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
4287
4256
  if (!recieveTokenCustodyConfig) {
@@ -4292,15 +4261,15 @@ var PerpetualsClient = (function () {
4292
4261
  instructions = [];
4293
4262
  postInstructions = [];
4294
4263
  additionalSigners = [];
4295
- _f.label = 1;
4264
+ _e.label = 1;
4296
4265
  case 1:
4297
- _f.trys.push([1, 7, , 8]);
4266
+ _e.trys.push([1, 7, , 8]);
4298
4267
  stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4299
4268
  custodyAccountMetas = [];
4300
4269
  custodyOracleAccountMetas = [];
4301
4270
  markets = [];
4302
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4303
- custody = _b[_a];
4271
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4272
+ custody = _a[_i];
4304
4273
  custodyAccountMetas.push({
4305
4274
  pubkey: custody.custodyAccount,
4306
4275
  isSigner: false,
@@ -4312,8 +4281,8 @@ var PerpetualsClient = (function () {
4312
4281
  isWritable: false,
4313
4282
  });
4314
4283
  }
4315
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4316
- market = _d[_c];
4284
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4285
+ market = _c[_b];
4317
4286
  markets.push({
4318
4287
  pubkey: market.marketAccount,
4319
4288
  isSigner: false,
@@ -4342,17 +4311,17 @@ var PerpetualsClient = (function () {
4342
4311
  return [3, 5];
4343
4312
  case 2:
4344
4313
  userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
4345
- _e = createUserATA;
4346
- if (!_e) return [3, 4];
4314
+ _d = createUserATA;
4315
+ if (!_d) return [3, 4];
4347
4316
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
4348
4317
  case 3:
4349
- _e = !(_f.sent());
4350
- _f.label = 4;
4318
+ _d = !(_e.sent());
4319
+ _e.label = 4;
4351
4320
  case 4:
4352
- if (_e) {
4321
+ if (_d) {
4353
4322
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
4354
4323
  }
4355
- _f.label = 5;
4324
+ _e.label = 5;
4356
4325
  case 5: return [4, this.program.methods
4357
4326
  .removeLiquidity({
4358
4327
  lpAmountIn: liquidityAmountIn,
@@ -4377,7 +4346,7 @@ var PerpetualsClient = (function () {
4377
4346
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4378
4347
  .instruction()];
4379
4348
  case 6:
4380
- removeLiquidityTx = _f.sent();
4349
+ removeLiquidityTx = _e.sent();
4381
4350
  instructions.push(removeLiquidityTx);
4382
4351
  if (closeLpATA) {
4383
4352
  closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
@@ -4389,9 +4358,9 @@ var PerpetualsClient = (function () {
4389
4358
  }
4390
4359
  return [3, 8];
4391
4360
  case 7:
4392
- err_7 = _f.sent();
4393
- console.log("perpClient removeLiquidity error:: ", err_7);
4394
- throw err_7;
4361
+ err_8 = _e.sent();
4362
+ console.log("perpClient removeLiquidity error:: ", err_8);
4363
+ throw err_8;
4395
4364
  case 8: return [2, {
4396
4365
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4397
4366
  additionalSigners: additionalSigners
@@ -4401,7 +4370,7 @@ var PerpetualsClient = (function () {
4401
4370
  });
4402
4371
  };
4403
4372
  this.addReferral = function (tokenStakeAccount, nftReferralAccount) { return __awaiter(_this, void 0, void 0, function () {
4404
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction, err_8;
4373
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction, err_9;
4405
4374
  return __generator(this, function (_a) {
4406
4375
  switch (_a.label) {
4407
4376
  case 0:
@@ -4428,9 +4397,9 @@ var PerpetualsClient = (function () {
4428
4397
  instructions.push(addReferralInstruction);
4429
4398
  return [3, 4];
4430
4399
  case 3:
4431
- err_8 = _a.sent();
4432
- console.log("perpClient addReferral error:: ", err_8);
4433
- throw err_8;
4400
+ err_9 = _a.sent();
4401
+ console.log("perpClient addReferral error:: ", err_9);
4402
+ throw err_9;
4434
4403
  case 4: return [2, {
4435
4404
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4436
4405
  additionalSigners: additionalSigners
@@ -4439,7 +4408,7 @@ var PerpetualsClient = (function () {
4439
4408
  });
4440
4409
  }); };
4441
4410
  this.createNftTradingAccount = function (nftMint, owner, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4442
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, createNftTradingAccountInstruction, err_9;
4411
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, createNftTradingAccountInstruction, err_10;
4443
4412
  return __generator(this, function (_a) {
4444
4413
  switch (_a.label) {
4445
4414
  case 0:
@@ -4474,9 +4443,9 @@ var PerpetualsClient = (function () {
4474
4443
  instructions.push(createNftTradingAccountInstruction);
4475
4444
  return [3, 4];
4476
4445
  case 3:
4477
- err_9 = _a.sent();
4478
- console.log("perpClient createNftAccount error:: ", err_9);
4479
- throw err_9;
4446
+ err_10 = _a.sent();
4447
+ console.log("perpClient createNftAccount error:: ", err_10);
4448
+ throw err_10;
4480
4449
  case 4: return [2, {
4481
4450
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4482
4451
  additionalSigners: additionalSigners
@@ -4485,7 +4454,7 @@ var PerpetualsClient = (function () {
4485
4454
  });
4486
4455
  }); };
4487
4456
  this.updateNftAccount = function (nftMint, updateReferer, updateBooster, flpStakeAccounts) { return __awaiter(_this, void 0, void 0, function () {
4488
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction, err_10;
4457
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction, err_11;
4489
4458
  return __generator(this, function (_a) {
4490
4459
  switch (_a.label) {
4491
4460
  case 0:
@@ -4535,9 +4504,9 @@ var PerpetualsClient = (function () {
4535
4504
  instructions.push(updateNftTradingAccountInstruction);
4536
4505
  return [3, 5];
4537
4506
  case 4:
4538
- err_10 = _a.sent();
4539
- console.log("perpClient updateNftAccount error:: ", err_10);
4540
- throw err_10;
4507
+ err_11 = _a.sent();
4508
+ console.log("perpClient updateNftAccount error:: ", err_11);
4509
+ throw err_11;
4541
4510
  case 5: return [2, {
4542
4511
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4543
4512
  additionalSigners: additionalSigners
@@ -4546,7 +4515,7 @@ var PerpetualsClient = (function () {
4546
4515
  });
4547
4516
  }); };
4548
4517
  this.levelUp = function (poolConfig, nftMint, authorizationRulesAccount) { return __awaiter(_this, void 0, void 0, function () {
4549
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction, err_11;
4518
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction, err_12;
4550
4519
  return __generator(this, function (_a) {
4551
4520
  switch (_a.label) {
4552
4521
  case 0:
@@ -4585,9 +4554,9 @@ var PerpetualsClient = (function () {
4585
4554
  instructions.push(levelUpInstruction);
4586
4555
  return [3, 4];
4587
4556
  case 3:
4588
- err_11 = _a.sent();
4589
- console.log("perpClient levelUp error:: ", err_11);
4590
- throw err_11;
4557
+ err_12 = _a.sent();
4558
+ console.log("perpClient levelUp error:: ", err_12);
4559
+ throw err_12;
4591
4560
  case 4: return [2, {
4592
4561
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4593
4562
  additionalSigners: additionalSigners
@@ -4596,7 +4565,7 @@ var PerpetualsClient = (function () {
4596
4565
  });
4597
4566
  }); };
4598
4567
  this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4599
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_12;
4568
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_13;
4600
4569
  return __generator(this, function (_a) {
4601
4570
  switch (_a.label) {
4602
4571
  case 0:
@@ -4634,9 +4603,9 @@ var PerpetualsClient = (function () {
4634
4603
  instructions.push(initStakeInstruction);
4635
4604
  return [3, 4];
4636
4605
  case 3:
4637
- err_12 = _a.sent();
4638
- console.log("perpClient InitStaking error:: ", err_12);
4639
- throw err_12;
4606
+ err_13 = _a.sent();
4607
+ console.log("perpClient InitStaking error:: ", err_13);
4608
+ throw err_13;
4640
4609
  case 4: return [2, {
4641
4610
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4642
4611
  additionalSigners: additionalSigners
@@ -4645,7 +4614,7 @@ var PerpetualsClient = (function () {
4645
4614
  });
4646
4615
  }); };
4647
4616
  this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4648
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_13;
4617
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_14;
4649
4618
  return __generator(this, function (_a) {
4650
4619
  switch (_a.label) {
4651
4620
  case 0:
@@ -4690,9 +4659,9 @@ var PerpetualsClient = (function () {
4690
4659
  instructions.push(initCompoundingInstruction);
4691
4660
  return [3, 4];
4692
4661
  case 3:
4693
- err_13 = _a.sent();
4694
- console.log("perpClient initCompounding error:: ", err_13);
4695
- throw err_13;
4662
+ err_14 = _a.sent();
4663
+ console.log("perpClient initCompounding error:: ", err_14);
4664
+ throw err_14;
4696
4665
  case 4: return [2, {
4697
4666
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4698
4667
  additionalSigners: additionalSigners
@@ -4701,7 +4670,7 @@ var PerpetualsClient = (function () {
4701
4670
  });
4702
4671
  }); };
4703
4672
  this.depositStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4704
- var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_14;
4673
+ var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_15;
4705
4674
  return __generator(this, function (_a) {
4706
4675
  switch (_a.label) {
4707
4676
  case 0:
@@ -4742,9 +4711,9 @@ var PerpetualsClient = (function () {
4742
4711
  instructions.push(depositStakeInstruction);
4743
4712
  return [3, 5];
4744
4713
  case 4:
4745
- err_14 = _a.sent();
4746
- console.log("perpClient depositStaking error:: ", err_14);
4747
- throw err_14;
4714
+ err_15 = _a.sent();
4715
+ console.log("perpClient depositStaking error:: ", err_15);
4716
+ throw err_15;
4748
4717
  case 5: return [2, {
4749
4718
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4750
4719
  additionalSigners: additionalSigners
@@ -4753,7 +4722,7 @@ var PerpetualsClient = (function () {
4753
4722
  });
4754
4723
  }); };
4755
4724
  this.refreshStakeWithAllFlpStakeAccounts = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4756
- var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_15;
4725
+ var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_16;
4757
4726
  return __generator(this, function (_c) {
4758
4727
  switch (_c.label) {
4759
4728
  case 0:
@@ -4800,33 +4769,29 @@ var PerpetualsClient = (function () {
4800
4769
  refreshStakeInstruction = _c.sent();
4801
4770
  return [2, refreshStakeInstruction];
4802
4771
  case 2:
4803
- err_15 = _c.sent();
4804
- console.log("perpClient refreshStaking error:: ", err_15);
4805
- throw err_15;
4772
+ err_16 = _c.sent();
4773
+ console.log("perpClient refreshStaking error:: ", err_16);
4774
+ throw err_16;
4806
4775
  case 3: return [2];
4807
4776
  }
4808
4777
  });
4809
4778
  }); };
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) {
4779
+ this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4780
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4781
+ return __awaiter(_this, void 0, void 0, function () {
4782
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_17;
4783
+ return __generator(this, function (_b) {
4784
+ switch (_b.label) {
4820
4785
  case 0:
4821
- _c.trys.push([0, 2, , 3]);
4786
+ _b.trys.push([0, 2, , 3]);
4822
4787
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4823
4788
  rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4824
4789
  rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4825
4790
  pool = poolConfig.poolAddress;
4826
4791
  feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4827
4792
  custodyAccountMetas = [];
4828
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4829
- custody = _b[_a];
4793
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4794
+ custody = _a[_i];
4830
4795
  custodyAccountMetas.push({
4831
4796
  pubkey: custody.custodyAccount,
4832
4797
  isSigner: false,
@@ -4858,25 +4823,21 @@ var PerpetualsClient = (function () {
4858
4823
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
4859
4824
  .instruction()];
4860
4825
  case 1:
4861
- refreshStakeInstruction = _c.sent();
4826
+ refreshStakeInstruction = _b.sent();
4862
4827
  return [2, refreshStakeInstruction];
4863
4828
  case 2:
4864
- err_16 = _c.sent();
4865
- console.log("perpClient refreshStaking error:: ", err_16);
4866
- throw err_16;
4829
+ err_17 = _b.sent();
4830
+ console.log("perpClient refreshStaking error:: ", err_17);
4831
+ throw err_17;
4867
4832
  case 3: return [2];
4868
4833
  }
4869
4834
  });
4870
4835
  });
4871
4836
  };
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; }
4837
+ this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
4838
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4839
+ return __awaiter(_this, void 0, void 0, function () {
4840
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_18;
4880
4841
  return __generator(this, function (_b) {
4881
4842
  switch (_b.label) {
4882
4843
  case 0:
@@ -4927,9 +4888,9 @@ var PerpetualsClient = (function () {
4927
4888
  instructions.push(unstakeInstantInstruction);
4928
4889
  return [3, 6];
4929
4890
  case 5:
4930
- err_17 = _b.sent();
4931
- console.log("perpClient unstakeInstant error:: ", err_17);
4932
- throw err_17;
4891
+ err_18 = _b.sent();
4892
+ console.log("perpClient unstakeInstant error:: ", err_18);
4893
+ throw err_18;
4933
4894
  case 6: return [2, {
4934
4895
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4935
4896
  additionalSigners: additionalSigners
@@ -4939,7 +4900,7 @@ var PerpetualsClient = (function () {
4939
4900
  });
4940
4901
  };
4941
4902
  this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4942
- var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_18;
4903
+ var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_19;
4943
4904
  return __generator(this, function (_c) {
4944
4905
  switch (_c.label) {
4945
4906
  case 0:
@@ -4983,15 +4944,15 @@ var PerpetualsClient = (function () {
4983
4944
  refreshStakeInstruction = _c.sent();
4984
4945
  return [2, refreshStakeInstruction];
4985
4946
  case 2:
4986
- err_18 = _c.sent();
4987
- console.log("perpClient refreshStaking error:: ", err_18);
4988
- throw err_18;
4947
+ err_19 = _c.sent();
4948
+ console.log("perpClient refreshStaking error:: ", err_19);
4949
+ throw err_19;
4989
4950
  case 3: return [2];
4990
4951
  }
4991
4952
  });
4992
4953
  }); };
4993
4954
  this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4994
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_19;
4955
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_20;
4995
4956
  return __generator(this, function (_a) {
4996
4957
  switch (_a.label) {
4997
4958
  case 0:
@@ -5025,9 +4986,9 @@ var PerpetualsClient = (function () {
5025
4986
  instructions.push(unstakeRequestInstruction);
5026
4987
  return [3, 4];
5027
4988
  case 3:
5028
- err_19 = _a.sent();
5029
- console.log("perpClient unstakeRequest error:: ", err_19);
5030
- throw err_19;
4989
+ err_20 = _a.sent();
4990
+ console.log("perpClient unstakeRequest error:: ", err_20);
4991
+ throw err_20;
5031
4992
  case 4: return [2, {
5032
4993
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5033
4994
  additionalSigners: additionalSigners
@@ -5035,17 +4996,13 @@ var PerpetualsClient = (function () {
5035
4996
  }
5036
4997
  });
5037
4998
  }); };
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) {
5044
- 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; }
4999
+ this.withdrawStake = function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
5000
+ if (pendingActivation === void 0) { pendingActivation = true; }
5001
+ if (deactivated === void 0) { deactivated = true; }
5002
+ if (createUserLPTA === void 0) { createUserLPTA = true; }
5003
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
5004
+ return __awaiter(_this, void 0, void 0, function () {
5005
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_21;
5049
5006
  return __generator(this, function (_b) {
5050
5007
  switch (_b.label) {
5051
5008
  case 0:
@@ -5096,9 +5053,9 @@ var PerpetualsClient = (function () {
5096
5053
  instructions.push(withdrawStakeInstruction);
5097
5054
  return [3, 6];
5098
5055
  case 5:
5099
- err_20 = _b.sent();
5100
- console.log("perpClient withdrawStake error:: ", err_20);
5101
- throw err_20;
5056
+ err_21 = _b.sent();
5057
+ console.log("perpClient withdrawStake error:: ", err_21);
5058
+ throw err_21;
5102
5059
  case 6: return [2, {
5103
5060
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5104
5061
  additionalSigners: additionalSigners
@@ -5107,14 +5064,10 @@ var PerpetualsClient = (function () {
5107
5064
  });
5108
5065
  });
5109
5066
  };
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) {
5116
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
5117
- if (createUserATA === void 0) { createUserATA = true; }
5067
+ this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
5068
+ if (createUserATA === void 0) { createUserATA = true; }
5069
+ return __awaiter(_this, void 0, void 0, function () {
5070
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_22;
5118
5071
  return __generator(this, function (_b) {
5119
5072
  switch (_b.label) {
5120
5073
  case 0:
@@ -5173,9 +5126,9 @@ var PerpetualsClient = (function () {
5173
5126
  instructions.push(withdrawStakeInstruction);
5174
5127
  return [3, 6];
5175
5128
  case 5:
5176
- err_21 = _b.sent();
5177
- console.log("perpClient withdrawStake error:: ", err_21);
5178
- throw err_21;
5129
+ err_22 = _b.sent();
5130
+ console.log("perpClient withdrawStake error:: ", err_22);
5131
+ throw err_22;
5179
5132
  case 6: return [2, {
5180
5133
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5181
5134
  additionalSigners: additionalSigners
@@ -5185,7 +5138,7 @@ var PerpetualsClient = (function () {
5185
5138
  });
5186
5139
  };
5187
5140
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5188
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_22;
5141
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_23;
5189
5142
  return __generator(this, function (_a) {
5190
5143
  switch (_a.label) {
5191
5144
  case 0:
@@ -5226,9 +5179,9 @@ var PerpetualsClient = (function () {
5226
5179
  instructions.push(initTokenVaultInstruction);
5227
5180
  return [3, 4];
5228
5181
  case 3:
5229
- err_22 = _a.sent();
5230
- console.log("perpClient InitTokenVaultInstruction error:: ", err_22);
5231
- throw err_22;
5182
+ err_23 = _a.sent();
5183
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_23);
5184
+ throw err_23;
5232
5185
  case 4: return [2, {
5233
5186
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5234
5187
  additionalSigners: additionalSigners
@@ -5237,7 +5190,7 @@ var PerpetualsClient = (function () {
5237
5190
  });
5238
5191
  }); };
5239
5192
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5240
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_23;
5193
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_24;
5241
5194
  return __generator(this, function (_a) {
5242
5195
  switch (_a.label) {
5243
5196
  case 0:
@@ -5268,9 +5221,9 @@ var PerpetualsClient = (function () {
5268
5221
  instructions.push(setTokenVaultConfigInstruction);
5269
5222
  return [3, 4];
5270
5223
  case 3:
5271
- err_23 = _a.sent();
5272
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_23);
5273
- throw err_23;
5224
+ err_24 = _a.sent();
5225
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_24);
5226
+ throw err_24;
5274
5227
  case 4: return [2, {
5275
5228
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5276
5229
  additionalSigners: additionalSigners
@@ -5279,7 +5232,7 @@ var PerpetualsClient = (function () {
5279
5232
  });
5280
5233
  }); };
5281
5234
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5282
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_24;
5235
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_25;
5283
5236
  return __generator(this, function (_a) {
5284
5237
  switch (_a.label) {
5285
5238
  case 0:
@@ -5317,9 +5270,9 @@ var PerpetualsClient = (function () {
5317
5270
  instructions.push(withdrawInstantFeeInstruction);
5318
5271
  return [3, 6];
5319
5272
  case 5:
5320
- err_24 = _a.sent();
5321
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_24);
5322
- throw err_24;
5273
+ err_25 = _a.sent();
5274
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_25);
5275
+ throw err_25;
5323
5276
  case 6: return [2, {
5324
5277
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5325
5278
  additionalSigners: additionalSigners
@@ -5328,7 +5281,7 @@ var PerpetualsClient = (function () {
5328
5281
  });
5329
5282
  }); };
5330
5283
  this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5331
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_25;
5284
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_26;
5332
5285
  return __generator(this, function (_a) {
5333
5286
  switch (_a.label) {
5334
5287
  case 0:
@@ -5365,9 +5318,9 @@ var PerpetualsClient = (function () {
5365
5318
  instructions.push(initRevenueTokenAccountInstruction);
5366
5319
  return [3, 4];
5367
5320
  case 3:
5368
- err_25 = _a.sent();
5369
- console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_25);
5370
- throw err_25;
5321
+ err_26 = _a.sent();
5322
+ console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_26);
5323
+ throw err_26;
5371
5324
  case 4: return [2, {
5372
5325
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5373
5326
  additionalSigners: additionalSigners
@@ -5376,7 +5329,7 @@ var PerpetualsClient = (function () {
5376
5329
  });
5377
5330
  }); };
5378
5331
  this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
5379
- var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_26;
5332
+ var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_27;
5380
5333
  return __generator(this, function (_b) {
5381
5334
  switch (_b.label) {
5382
5335
  case 0:
@@ -5440,9 +5393,9 @@ var PerpetualsClient = (function () {
5440
5393
  instructions.push(burnAndClaimInstruction);
5441
5394
  return [3, 8];
5442
5395
  case 7:
5443
- err_26 = _b.sent();
5444
- console.log("perpClient burnAndClaimInstruction error:: ", err_26);
5445
- throw err_26;
5396
+ err_27 = _b.sent();
5397
+ console.log("perpClient burnAndClaimInstruction error:: ", err_27);
5398
+ throw err_27;
5446
5399
  case 8: return [2, {
5447
5400
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5448
5401
  additionalSigners: additionalSigners
@@ -5451,7 +5404,7 @@ var PerpetualsClient = (function () {
5451
5404
  });
5452
5405
  }); };
5453
5406
  this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5454
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_27;
5407
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_28;
5455
5408
  return __generator(this, function (_a) {
5456
5409
  switch (_a.label) {
5457
5410
  case 0:
@@ -5502,9 +5455,9 @@ var PerpetualsClient = (function () {
5502
5455
  instructions.push(burnAndStakeInstruction);
5503
5456
  return [3, 4];
5504
5457
  case 3:
5505
- err_27 = _a.sent();
5506
- console.log("perpClient burnAndStakeInstruction error:: ", err_27);
5507
- throw err_27;
5458
+ err_28 = _a.sent();
5459
+ console.log("perpClient burnAndStakeInstruction error:: ", err_28);
5460
+ throw err_28;
5508
5461
  case 4: return [2, {
5509
5462
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5510
5463
  additionalSigners: additionalSigners
@@ -5513,7 +5466,7 @@ var PerpetualsClient = (function () {
5513
5466
  });
5514
5467
  }); };
5515
5468
  this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5516
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_28;
5469
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_29;
5517
5470
  return __generator(this, function (_a) {
5518
5471
  switch (_a.label) {
5519
5472
  case 0:
@@ -5554,9 +5507,9 @@ var PerpetualsClient = (function () {
5554
5507
  instructions.push(depositTokenStakeInstruction);
5555
5508
  return [3, 5];
5556
5509
  case 4:
5557
- err_28 = _a.sent();
5558
- console.log("perpClient depositStakingInstruction error:: ", err_28);
5559
- throw err_28;
5510
+ err_29 = _a.sent();
5511
+ console.log("perpClient depositStakingInstruction error:: ", err_29);
5512
+ throw err_29;
5560
5513
  case 5: return [2, {
5561
5514
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5562
5515
  additionalSigners: additionalSigners
@@ -5565,7 +5518,7 @@ var PerpetualsClient = (function () {
5565
5518
  });
5566
5519
  }); };
5567
5520
  this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5568
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_29;
5521
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_30;
5569
5522
  return __generator(this, function (_a) {
5570
5523
  switch (_a.label) {
5571
5524
  case 0:
@@ -5594,9 +5547,9 @@ var PerpetualsClient = (function () {
5594
5547
  instructions.push(unstakeTokenRequestInstruction);
5595
5548
  return [3, 4];
5596
5549
  case 3:
5597
- err_29 = _a.sent();
5598
- console.log("perpClient unstakeTokenRequestInstruction error:: ", err_29);
5599
- throw err_29;
5550
+ err_30 = _a.sent();
5551
+ console.log("perpClient unstakeTokenRequestInstruction error:: ", err_30);
5552
+ throw err_30;
5600
5553
  case 4: return [2, {
5601
5554
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5602
5555
  additionalSigners: additionalSigners
@@ -5605,7 +5558,7 @@ var PerpetualsClient = (function () {
5605
5558
  });
5606
5559
  }); };
5607
5560
  this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5608
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_30;
5561
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_31;
5609
5562
  return __generator(this, function (_a) {
5610
5563
  switch (_a.label) {
5611
5564
  case 0:
@@ -5645,9 +5598,9 @@ var PerpetualsClient = (function () {
5645
5598
  instructions.push(unstakeTokenInstantInstruction);
5646
5599
  return [3, 5];
5647
5600
  case 4:
5648
- err_30 = _a.sent();
5649
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_30);
5650
- throw err_30;
5601
+ err_31 = _a.sent();
5602
+ console.log("perpClient unstakeTokenInstantInstruction error:: ", err_31);
5603
+ throw err_31;
5651
5604
  case 5: return [2, {
5652
5605
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5653
5606
  additionalSigners: additionalSigners
@@ -5656,7 +5609,7 @@ var PerpetualsClient = (function () {
5656
5609
  });
5657
5610
  }); };
5658
5611
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5659
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_31;
5612
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_32;
5660
5613
  return __generator(this, function (_a) {
5661
5614
  switch (_a.label) {
5662
5615
  case 0:
@@ -5696,9 +5649,9 @@ var PerpetualsClient = (function () {
5696
5649
  instructions.push(withdrawTokenInstruction);
5697
5650
  return [3, 5];
5698
5651
  case 4:
5699
- err_31 = _a.sent();
5700
- console.log("perpClient withdrawTokenInstruction error:: ", err_31);
5701
- throw err_31;
5652
+ err_32 = _a.sent();
5653
+ console.log("perpClient withdrawTokenInstruction error:: ", err_32);
5654
+ throw err_32;
5702
5655
  case 5: return [2, {
5703
5656
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5704
5657
  additionalSigners: additionalSigners
@@ -5707,7 +5660,7 @@ var PerpetualsClient = (function () {
5707
5660
  });
5708
5661
  }); };
5709
5662
  this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5710
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_32;
5663
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_33;
5711
5664
  return __generator(this, function (_a) {
5712
5665
  switch (_a.label) {
5713
5666
  case 0:
@@ -5736,9 +5689,9 @@ var PerpetualsClient = (function () {
5736
5689
  instructions.push(cancelUnstakeRequestInstruction);
5737
5690
  return [3, 4];
5738
5691
  case 3:
5739
- err_32 = _a.sent();
5740
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_32);
5741
- throw err_32;
5692
+ err_33 = _a.sent();
5693
+ console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_33);
5694
+ throw err_33;
5742
5695
  case 4: return [2, {
5743
5696
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5744
5697
  additionalSigners: additionalSigners
@@ -5747,7 +5700,7 @@ var PerpetualsClient = (function () {
5747
5700
  });
5748
5701
  }); };
5749
5702
  this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5750
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_33;
5703
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_34;
5751
5704
  return __generator(this, function (_a) {
5752
5705
  switch (_a.label) {
5753
5706
  case 0:
@@ -5785,9 +5738,9 @@ var PerpetualsClient = (function () {
5785
5738
  instructions.push(distributeTokenRewardInstruction);
5786
5739
  return [3, 4];
5787
5740
  case 3:
5788
- err_33 = _a.sent();
5789
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_33);
5790
- throw err_33;
5741
+ err_34 = _a.sent();
5742
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_34);
5743
+ throw err_34;
5791
5744
  case 4: return [2, {
5792
5745
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5793
5746
  additionalSigners: additionalSigners
@@ -5796,7 +5749,7 @@ var PerpetualsClient = (function () {
5796
5749
  });
5797
5750
  }); };
5798
5751
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5799
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_34;
5752
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_35;
5800
5753
  return __generator(this, function (_a) {
5801
5754
  switch (_a.label) {
5802
5755
  case 0:
@@ -5828,9 +5781,9 @@ var PerpetualsClient = (function () {
5828
5781
  instructions.push(setTokenRewardInstruction);
5829
5782
  return [3, 4];
5830
5783
  case 3:
5831
- err_34 = _a.sent();
5832
- console.log("perpClient setTokenRewardInstruction error:: ", err_34);
5833
- throw err_34;
5784
+ err_35 = _a.sent();
5785
+ console.log("perpClient setTokenRewardInstruction error:: ", err_35);
5786
+ throw err_35;
5834
5787
  case 4: return [2, {
5835
5788
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5836
5789
  additionalSigners: additionalSigners
@@ -5838,14 +5791,10 @@ var PerpetualsClient = (function () {
5838
5791
  }
5839
5792
  });
5840
5793
  }); };
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) {
5847
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_35;
5848
- if (createUserATA === void 0) { createUserATA = true; }
5794
+ this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5795
+ if (createUserATA === void 0) { createUserATA = true; }
5796
+ return __awaiter(_this, void 0, void 0, function () {
5797
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_36;
5849
5798
  return __generator(this, function (_b) {
5850
5799
  switch (_b.label) {
5851
5800
  case 0:
@@ -5889,9 +5838,9 @@ var PerpetualsClient = (function () {
5889
5838
  instructions.push(collectTokenRewardInstruction);
5890
5839
  return [3, 6];
5891
5840
  case 5:
5892
- err_35 = _b.sent();
5893
- console.log("perpClient collectTokenRewardInstruction error:: ", err_35);
5894
- throw err_35;
5841
+ err_36 = _b.sent();
5842
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_36);
5843
+ throw err_36;
5895
5844
  case 6: return [2, {
5896
5845
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5897
5846
  additionalSigners: additionalSigners
@@ -5900,14 +5849,10 @@ var PerpetualsClient = (function () {
5900
5849
  });
5901
5850
  });
5902
5851
  };
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) {
5909
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_36;
5910
- if (createUserATA === void 0) { createUserATA = true; }
5852
+ this.collectRevenue = function (owner, rewardSymbol, poolConfig, createUserATA) {
5853
+ if (createUserATA === void 0) { createUserATA = true; }
5854
+ return __awaiter(_this, void 0, void 0, function () {
5855
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_37;
5911
5856
  return __generator(this, function (_b) {
5912
5857
  switch (_b.label) {
5913
5858
  case 0:
@@ -5952,9 +5897,9 @@ var PerpetualsClient = (function () {
5952
5897
  instructions.push(collectRevenueInstruction);
5953
5898
  return [3, 6];
5954
5899
  case 5:
5955
- err_36 = _b.sent();
5956
- console.log("perpClient collectRevenueInstruction error:: ", err_36);
5957
- throw err_36;
5900
+ err_37 = _b.sent();
5901
+ console.log("perpClient collectRevenueInstruction error:: ", err_37);
5902
+ throw err_37;
5958
5903
  case 6: return [2, {
5959
5904
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5960
5905
  additionalSigners: additionalSigners
@@ -5964,7 +5909,7 @@ var PerpetualsClient = (function () {
5964
5909
  });
5965
5910
  };
5966
5911
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
5967
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_37;
5912
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_38;
5968
5913
  return __generator(this, function (_a) {
5969
5914
  switch (_a.label) {
5970
5915
  case 0:
@@ -5992,9 +5937,9 @@ var PerpetualsClient = (function () {
5992
5937
  instructions.push(setTokenStakeLevelInstruction);
5993
5938
  return [3, 4];
5994
5939
  case 3:
5995
- err_37 = _a.sent();
5996
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_37);
5997
- throw err_37;
5940
+ err_38 = _a.sent();
5941
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_38);
5942
+ throw err_38;
5998
5943
  case 4: return [2, {
5999
5944
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6000
5945
  additionalSigners: additionalSigners
@@ -6003,7 +5948,7 @@ var PerpetualsClient = (function () {
6003
5948
  });
6004
5949
  }); };
6005
5950
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6006
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_38;
5951
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_39;
6007
5952
  return __generator(this, function (_a) {
6008
5953
  switch (_a.label) {
6009
5954
  case 0:
@@ -6040,9 +5985,9 @@ var PerpetualsClient = (function () {
6040
5985
  instructions.push(initRewardVault);
6041
5986
  return [3, 4];
6042
5987
  case 3:
6043
- err_38 = _a.sent();
6044
- console.log("perpClient InitRewardVault error:: ", err_38);
6045
- throw err_38;
5988
+ err_39 = _a.sent();
5989
+ console.log("perpClient InitRewardVault error:: ", err_39);
5990
+ throw err_39;
6046
5991
  case 4: return [2, {
6047
5992
  instructions: __spreadArray([], instructions, true),
6048
5993
  additionalSigners: additionalSigners
@@ -6051,7 +5996,7 @@ var PerpetualsClient = (function () {
6051
5996
  });
6052
5997
  }); };
6053
5998
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6054
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_39;
5999
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_40;
6055
6000
  return __generator(this, function (_a) {
6056
6001
  switch (_a.label) {
6057
6002
  case 0:
@@ -6082,9 +6027,9 @@ var PerpetualsClient = (function () {
6082
6027
  instructions.push(distributeReward);
6083
6028
  return [3, 4];
6084
6029
  case 3:
6085
- err_39 = _a.sent();
6086
- console.log("perpClient distributeReward error:: ", err_39);
6087
- throw err_39;
6030
+ err_40 = _a.sent();
6031
+ console.log("perpClient distributeReward error:: ", err_40);
6032
+ throw err_40;
6088
6033
  case 4: return [2, {
6089
6034
  instructions: __spreadArray([], instructions, true),
6090
6035
  additionalSigners: additionalSigners
@@ -6092,14 +6037,10 @@ var PerpetualsClient = (function () {
6092
6037
  }
6093
6038
  });
6094
6039
  }); };
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) {
6101
- var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_40;
6102
- if (createUserATA === void 0) { createUserATA = true; }
6040
+ this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
6041
+ if (createUserATA === void 0) { createUserATA = true; }
6042
+ return __awaiter(_this, void 0, void 0, function () {
6043
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_41;
6103
6044
  return __generator(this, function (_b) {
6104
6045
  switch (_b.label) {
6105
6046
  case 0:
@@ -6149,8 +6090,8 @@ var PerpetualsClient = (function () {
6149
6090
  instructions.push(collectNftReward);
6150
6091
  return [3, 6];
6151
6092
  case 5:
6152
- err_40 = _b.sent();
6153
- throw err_40;
6093
+ err_41 = _b.sent();
6094
+ throw err_41;
6154
6095
  case 6: return [2, {
6155
6096
  instructions: __spreadArray([], instructions, true),
6156
6097
  additionalSigners: additionalSigners
@@ -6159,14 +6100,10 @@ var PerpetualsClient = (function () {
6159
6100
  });
6160
6101
  });
6161
6102
  };
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) {
6168
- 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; }
6103
+ this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6104
+ if (createUserATA === void 0) { createUserATA = true; }
6105
+ return __awaiter(_this, void 0, void 0, function () {
6106
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_42;
6170
6107
  return __generator(this, function (_b) {
6171
6108
  switch (_b.label) {
6172
6109
  case 0:
@@ -6230,9 +6167,9 @@ var PerpetualsClient = (function () {
6230
6167
  instructions.push(withdrawStakeInstruction);
6231
6168
  return [3, 6];
6232
6169
  case 5:
6233
- err_41 = _b.sent();
6234
- console.log("perpClient withdrawStake error:: ", err_41);
6235
- throw err_41;
6170
+ err_42 = _b.sent();
6171
+ console.log("perpClient withdrawStake error:: ", err_42);
6172
+ throw err_42;
6236
6173
  case 6: return [2, {
6237
6174
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6238
6175
  additionalSigners: additionalSigners
@@ -6242,7 +6179,7 @@ var PerpetualsClient = (function () {
6242
6179
  });
6243
6180
  };
6244
6181
  this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6245
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_42;
6182
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_43;
6246
6183
  return __generator(this, function (_a) {
6247
6184
  switch (_a.label) {
6248
6185
  case 0:
@@ -6281,9 +6218,9 @@ var PerpetualsClient = (function () {
6281
6218
  instructions.push(setTriggerPrice);
6282
6219
  return [3, 4];
6283
6220
  case 3:
6284
- err_42 = _a.sent();
6285
- console.log("perpClient setTriggerPrice error:: ", err_42);
6286
- throw err_42;
6221
+ err_43 = _a.sent();
6222
+ console.log("perpClient setTriggerPrice error:: ", err_43);
6223
+ throw err_43;
6287
6224
  case 4: return [2, {
6288
6225
  instructions: __spreadArray([], instructions, true),
6289
6226
  additionalSigners: additionalSigners
@@ -6291,16 +6228,12 @@ var PerpetualsClient = (function () {
6291
6228
  }
6292
6229
  });
6293
6230
  }); };
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) {
6300
- 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; }
6231
+ this.forceClosePosition = function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6232
+ if (createUserATA === void 0) { createUserATA = true; }
6233
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6234
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6235
+ return __awaiter(_this, void 0, void 0, function () {
6236
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_44;
6304
6237
  return __generator(this, function (_b) {
6305
6238
  switch (_b.label) {
6306
6239
  case 0:
@@ -6361,9 +6294,9 @@ var PerpetualsClient = (function () {
6361
6294
  }
6362
6295
  return [3, 7];
6363
6296
  case 6:
6364
- err_43 = _b.sent();
6365
- console.log("perpClient forceClosePosition error:: ", err_43);
6366
- throw err_43;
6297
+ err_44 = _b.sent();
6298
+ console.log("perpClient forceClosePosition error:: ", err_44);
6299
+ throw err_44;
6367
6300
  case 7: return [2, {
6368
6301
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6369
6302
  additionalSigners: additionalSigners
@@ -6372,15 +6305,11 @@ var PerpetualsClient = (function () {
6372
6305
  });
6373
6306
  });
6374
6307
  };
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) {
6381
- 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; }
6308
+ this.placeLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6309
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6310
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6311
+ return __awaiter(_this, void 0, void 0, function () {
6312
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_45;
6384
6313
  return __generator(this, function (_c) {
6385
6314
  switch (_c.label) {
6386
6315
  case 0:
@@ -6485,9 +6414,9 @@ var PerpetualsClient = (function () {
6485
6414
  instructions.push(placeLimitOrder);
6486
6415
  return [3, 11];
6487
6416
  case 10:
6488
- err_44 = _c.sent();
6489
- console.log("perpClient placeLimitOrder error:: ", err_44);
6490
- throw err_44;
6417
+ err_45 = _c.sent();
6418
+ console.log("perpClient placeLimitOrder error:: ", err_45);
6419
+ throw err_45;
6491
6420
  case 11: return [2, {
6492
6421
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6493
6422
  additionalSigners: additionalSigners
@@ -6496,15 +6425,11 @@ var PerpetualsClient = (function () {
6496
6425
  });
6497
6426
  });
6498
6427
  };
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) {
6505
- 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; }
6428
+ this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6429
+ if (createUserATA === void 0) { createUserATA = true; }
6430
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6431
+ return __awaiter(_this, void 0, void 0, function () {
6432
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_46;
6508
6433
  return __generator(this, function (_b) {
6509
6434
  switch (_b.label) {
6510
6435
  case 0:
@@ -6592,9 +6517,9 @@ var PerpetualsClient = (function () {
6592
6517
  instructions.push(editLimitOrder);
6593
6518
  return [3, 8];
6594
6519
  case 7:
6595
- err_45 = _b.sent();
6596
- console.log("perpClient editLimitOrder error:: ", err_45);
6597
- throw err_45;
6520
+ err_46 = _b.sent();
6521
+ console.log("perpClient editLimitOrder error:: ", err_46);
6522
+ throw err_46;
6598
6523
  case 8: return [2, {
6599
6524
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6600
6525
  additionalSigners: additionalSigners
@@ -6603,16 +6528,12 @@ var PerpetualsClient = (function () {
6603
6528
  });
6604
6529
  });
6605
6530
  };
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) {
6612
- 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; }
6531
+ this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6532
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6533
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6534
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6535
+ return __awaiter(_this, void 0, void 0, function () {
6536
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_47;
6616
6537
  return __generator(this, function (_a) {
6617
6538
  switch (_a.label) {
6618
6539
  case 0:
@@ -6661,9 +6582,9 @@ var PerpetualsClient = (function () {
6661
6582
  instructions.push(executeLimitOrder);
6662
6583
  return [3, 4];
6663
6584
  case 3:
6664
- err_46 = _a.sent();
6665
- console.log("perpClient executeLimitOrder error:: ", err_46);
6666
- throw err_46;
6585
+ err_47 = _a.sent();
6586
+ console.log("perpClient executeLimitOrder error:: ", err_47);
6587
+ throw err_47;
6667
6588
  case 4: return [2, {
6668
6589
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6669
6590
  additionalSigners: additionalSigners
@@ -6672,16 +6593,12 @@ var PerpetualsClient = (function () {
6672
6593
  });
6673
6594
  });
6674
6595
  };
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) {
6681
- 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; }
6596
+ this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6597
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6598
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6599
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6600
+ return __awaiter(_this, void 0, void 0, function () {
6601
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_48;
6685
6602
  return __generator(this, function (_a) {
6686
6603
  switch (_a.label) {
6687
6604
  case 0:
@@ -6733,9 +6650,9 @@ var PerpetualsClient = (function () {
6733
6650
  instructions.push(executeLimitWithSwap);
6734
6651
  return [3, 4];
6735
6652
  case 3:
6736
- err_47 = _a.sent();
6737
- console.log("perpClient executeLimitWithSwap error:: ", err_47);
6738
- throw err_47;
6653
+ err_48 = _a.sent();
6654
+ console.log("perpClient executeLimitWithSwap error:: ", err_48);
6655
+ throw err_48;
6739
6656
  case 4: return [2, {
6740
6657
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6741
6658
  additionalSigners: additionalSigners
@@ -6745,7 +6662,7 @@ var PerpetualsClient = (function () {
6745
6662
  });
6746
6663
  };
6747
6664
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6748
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_48;
6665
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_49;
6749
6666
  return __generator(this, function (_a) {
6750
6667
  switch (_a.label) {
6751
6668
  case 0:
@@ -6793,9 +6710,9 @@ var PerpetualsClient = (function () {
6793
6710
  instructions.push(placeTriggerOrder);
6794
6711
  return [3, 4];
6795
6712
  case 3:
6796
- err_48 = _a.sent();
6797
- console.log("perpClient placeTriggerOrder error:: ", err_48);
6798
- throw err_48;
6713
+ err_49 = _a.sent();
6714
+ console.log("perpClient placeTriggerOrder error:: ", err_49);
6715
+ throw err_49;
6799
6716
  case 4: return [2, {
6800
6717
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6801
6718
  additionalSigners: additionalSigners
@@ -6804,7 +6721,7 @@ var PerpetualsClient = (function () {
6804
6721
  });
6805
6722
  }); };
6806
6723
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6807
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_49;
6724
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_50;
6808
6725
  return __generator(this, function (_a) {
6809
6726
  switch (_a.label) {
6810
6727
  case 0:
@@ -6851,9 +6768,9 @@ var PerpetualsClient = (function () {
6851
6768
  instructions.push(editTriggerOrder);
6852
6769
  return [3, 4];
6853
6770
  case 3:
6854
- err_49 = _a.sent();
6855
- console.log("perpClient editTriggerOrder error:: ", err_49);
6856
- throw err_49;
6771
+ err_50 = _a.sent();
6772
+ console.log("perpClient editTriggerOrder error:: ", err_50);
6773
+ throw err_50;
6857
6774
  case 4: return [2, {
6858
6775
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6859
6776
  additionalSigners: additionalSigners
@@ -6862,7 +6779,7 @@ var PerpetualsClient = (function () {
6862
6779
  });
6863
6780
  }); };
6864
6781
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6865
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_50;
6782
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_51;
6866
6783
  return __generator(this, function (_a) {
6867
6784
  switch (_a.label) {
6868
6785
  case 0:
@@ -6895,9 +6812,9 @@ var PerpetualsClient = (function () {
6895
6812
  instructions.push(cancelTriggerOrder);
6896
6813
  return [3, 4];
6897
6814
  case 3:
6898
- err_50 = _a.sent();
6899
- console.log("perpClient cancelTriggerOrder error:: ", err_50);
6900
- throw err_50;
6815
+ err_51 = _a.sent();
6816
+ console.log("perpClient cancelTriggerOrder error:: ", err_51);
6817
+ throw err_51;
6901
6818
  case 4: return [2, {
6902
6819
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6903
6820
  additionalSigners: additionalSigners
@@ -6906,7 +6823,7 @@ var PerpetualsClient = (function () {
6906
6823
  });
6907
6824
  }); };
6908
6825
  this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6909
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_51;
6826
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_52;
6910
6827
  return __generator(this, function (_a) {
6911
6828
  switch (_a.label) {
6912
6829
  case 0:
@@ -6937,9 +6854,9 @@ var PerpetualsClient = (function () {
6937
6854
  instructions.push(cancelAllTriggerOrders);
6938
6855
  return [3, 4];
6939
6856
  case 3:
6940
- err_51 = _a.sent();
6941
- console.log("perpClient cancelAllTriggerOrders error:: ", err_51);
6942
- throw err_51;
6857
+ err_52 = _a.sent();
6858
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_52);
6859
+ throw err_52;
6943
6860
  case 4: return [2, {
6944
6861
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6945
6862
  additionalSigners: additionalSigners
@@ -6947,20 +6864,16 @@ var PerpetualsClient = (function () {
6947
6864
  }
6948
6865
  });
6949
6866
  }); };
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) {
6867
+ this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6868
+ if (createUserATA === void 0) { createUserATA = true; }
6869
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6870
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6871
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6872
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6873
+ return __awaiter(_this, void 0, void 0, function () {
6874
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_53;
6875
+ return __generator(this, function (_d) {
6876
+ switch (_d.label) {
6964
6877
  case 0:
6965
6878
  payerPubkey = this.provider.wallet.publicKey;
6966
6879
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
@@ -6971,9 +6884,9 @@ var PerpetualsClient = (function () {
6971
6884
  instructions = [];
6972
6885
  postInstructions = [];
6973
6886
  additionalSigners = [];
6974
- _e.label = 1;
6887
+ _d.label = 1;
6975
6888
  case 1:
6976
- _e.trys.push([1, 9, , 10]);
6889
+ _d.trys.push([1, 9, , 10]);
6977
6890
  if (!false) return [3, 2];
6978
6891
  return [3, 7];
6979
6892
  case 2:
@@ -6982,8 +6895,8 @@ var PerpetualsClient = (function () {
6982
6895
  if (!_a) return [3, 4];
6983
6896
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6984
6897
  case 3:
6985
- _a = !(_e.sent());
6986
- _e.label = 4;
6898
+ _a = !(_d.sent());
6899
+ _d.label = 4;
6987
6900
  case 4:
6988
6901
  if (_a) {
6989
6902
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
@@ -6993,20 +6906,20 @@ var PerpetualsClient = (function () {
6993
6906
  if (!_b) return [3, 6];
6994
6907
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
6995
6908
  case 5:
6996
- _b = !(_e.sent());
6997
- _e.label = 6;
6909
+ _b = !(_d.sent());
6910
+ _d.label = 6;
6998
6911
  case 6:
6999
6912
  if (_b) {
7000
6913
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
7001
6914
  }
7002
- _e.label = 7;
6915
+ _d.label = 7;
7003
6916
  case 7:
7004
6917
  positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
7005
6918
  orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
7006
6919
  custodyAccountMetas = [];
7007
6920
  custodyOracleAccountMetas = [];
7008
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7009
- custody = _d[_c];
6921
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
6922
+ custody = _c[_i];
7010
6923
  custodyAccountMetas.push({
7011
6924
  pubkey: custody.custodyAccount,
7012
6925
  isSigner: false,
@@ -7051,13 +6964,13 @@ var PerpetualsClient = (function () {
7051
6964
  .remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
7052
6965
  .instruction()];
7053
6966
  case 8:
7054
- executeTriggerWithSwap = _e.sent();
6967
+ executeTriggerWithSwap = _d.sent();
7055
6968
  instructions.push(executeTriggerWithSwap);
7056
6969
  return [3, 10];
7057
6970
  case 9:
7058
- err_52 = _e.sent();
7059
- console.log("perpClient executeTriggerWithSwap error:: ", err_52);
7060
- throw err_52;
6971
+ err_53 = _d.sent();
6972
+ console.log("perpClient executeTriggerWithSwap error:: ", err_53);
6973
+ throw err_53;
7061
6974
  case 10: return [2, {
7062
6975
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7063
6976
  additionalSigners: additionalSigners
@@ -7066,18 +6979,14 @@ var PerpetualsClient = (function () {
7066
6979
  });
7067
6980
  });
7068
6981
  };
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) {
7075
- 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; }
6982
+ this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6983
+ if (createUserATA === void 0) { createUserATA = true; }
6984
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6985
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6986
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6987
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6988
+ return __awaiter(_this, void 0, void 0, function () {
6989
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_54;
7081
6990
  return __generator(this, function (_b) {
7082
6991
  switch (_b.label) {
7083
6992
  case 0:
@@ -7143,9 +7052,9 @@ var PerpetualsClient = (function () {
7143
7052
  instructions.push(executeTriggerOrder);
7144
7053
  return [3, 8];
7145
7054
  case 7:
7146
- err_53 = _b.sent();
7147
- console.log("perpClient executeTriggerOrder error:: ", err_53);
7148
- throw err_53;
7055
+ err_54 = _b.sent();
7056
+ console.log("perpClient executeTriggerOrder error:: ", err_54);
7057
+ throw err_54;
7149
7058
  case 8: return [2, {
7150
7059
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7151
7060
  additionalSigners: additionalSigners
@@ -7155,7 +7064,7 @@ var PerpetualsClient = (function () {
7155
7064
  });
7156
7065
  };
7157
7066
  this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7158
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_54;
7067
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_55;
7159
7068
  return __generator(this, function (_a) {
7160
7069
  switch (_a.label) {
7161
7070
  case 0:
@@ -7185,9 +7094,9 @@ var PerpetualsClient = (function () {
7185
7094
  instructions.push(migrateTriggerOrder);
7186
7095
  return [3, 4];
7187
7096
  case 3:
7188
- err_54 = _a.sent();
7189
- console.log("perpClient migrateTriggerOrder error:: ", err_54);
7190
- throw err_54;
7097
+ err_55 = _a.sent();
7098
+ console.log("perpClient migrateTriggerOrder error:: ", err_55);
7099
+ throw err_55;
7191
7100
  case 4: return [2, {
7192
7101
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7193
7102
  additionalSigners: additionalSigners
@@ -7196,7 +7105,7 @@ var PerpetualsClient = (function () {
7196
7105
  });
7197
7106
  }); };
7198
7107
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7199
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_55;
7108
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_56;
7200
7109
  return __generator(this, function (_a) {
7201
7110
  switch (_a.label) {
7202
7111
  case 0:
@@ -7225,15 +7134,15 @@ var PerpetualsClient = (function () {
7225
7134
  console.log(getPositionData);
7226
7135
  return [2, getPositionData];
7227
7136
  case 3:
7228
- err_55 = _a.sent();
7229
- console.log("perpClient setPool error:: ", err_55);
7230
- throw err_55;
7137
+ err_56 = _a.sent();
7138
+ console.log("perpClient setPool error:: ", err_56);
7139
+ throw err_56;
7231
7140
  case 4: return [2];
7232
7141
  }
7233
7142
  });
7234
7143
  }); };
7235
7144
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7236
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_56;
7145
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_57;
7237
7146
  return __generator(this, function (_a) {
7238
7147
  switch (_a.label) {
7239
7148
  case 0:
@@ -7265,9 +7174,9 @@ var PerpetualsClient = (function () {
7265
7174
  instructions.push(withdrawFeesIx);
7266
7175
  return [3, 5];
7267
7176
  case 4:
7268
- err_56 = _a.sent();
7269
- console.log("perpClient setPool error:: ", err_56);
7270
- throw err_56;
7177
+ err_57 = _a.sent();
7178
+ console.log("perpClient setPool error:: ", err_57);
7179
+ throw err_57;
7271
7180
  case 5: return [2, {
7272
7181
  instructions: __spreadArray([], instructions, true),
7273
7182
  additionalSigners: additionalSigners
@@ -7276,7 +7185,7 @@ var PerpetualsClient = (function () {
7276
7185
  });
7277
7186
  }); };
7278
7187
  this.moveProtocolFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7279
- var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_57;
7188
+ var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_58;
7280
7189
  return __generator(this, function (_a) {
7281
7190
  switch (_a.label) {
7282
7191
  case 0:
@@ -7309,9 +7218,9 @@ var PerpetualsClient = (function () {
7309
7218
  instructions.push(moveProtocolFeesIx);
7310
7219
  return [3, 4];
7311
7220
  case 3:
7312
- err_57 = _a.sent();
7313
- console.log("perpClient setPool error:: ", err_57);
7314
- throw err_57;
7221
+ err_58 = _a.sent();
7222
+ console.log("perpClient setPool error:: ", err_58);
7223
+ throw err_58;
7315
7224
  case 4: return [2, {
7316
7225
  instructions: __spreadArray([], instructions, true),
7317
7226
  additionalSigners: additionalSigners
@@ -7320,7 +7229,7 @@ var PerpetualsClient = (function () {
7320
7229
  });
7321
7230
  }); };
7322
7231
  this.setProtocolFeeShareBps = function (feeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7323
- var publicKey, setProtocolFeeShareBpsIx, err_58;
7232
+ var publicKey, setProtocolFeeShareBpsIx, err_59;
7324
7233
  return __generator(this, function (_a) {
7325
7234
  switch (_a.label) {
7326
7235
  case 0:
@@ -7340,15 +7249,15 @@ var PerpetualsClient = (function () {
7340
7249
  setProtocolFeeShareBpsIx = _a.sent();
7341
7250
  return [2, setProtocolFeeShareBpsIx];
7342
7251
  case 2:
7343
- err_58 = _a.sent();
7344
- console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_58);
7345
- throw err_58;
7252
+ err_59 = _a.sent();
7253
+ console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_59);
7254
+ throw err_59;
7346
7255
  case 3: return [2];
7347
7256
  }
7348
7257
  });
7349
7258
  }); };
7350
7259
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
7351
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_59;
7260
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_60;
7352
7261
  return __generator(this, function (_a) {
7353
7262
  switch (_a.label) {
7354
7263
  case 0:
@@ -7375,9 +7284,9 @@ var PerpetualsClient = (function () {
7375
7284
  instructions.push(setPermissionsInstruction);
7376
7285
  return [3, 4];
7377
7286
  case 3:
7378
- err_59 = _a.sent();
7379
- console.log("perpClient setPool error:: ", err_59);
7380
- throw err_59;
7287
+ err_60 = _a.sent();
7288
+ console.log("perpClient setPool error:: ", err_60);
7289
+ throw err_60;
7381
7290
  case 4: return [2, {
7382
7291
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7383
7292
  additionalSigners: additionalSigners
@@ -7386,7 +7295,7 @@ var PerpetualsClient = (function () {
7386
7295
  });
7387
7296
  }); };
7388
7297
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7389
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_60;
7298
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_61;
7390
7299
  var _f;
7391
7300
  return __generator(this, function (_g) {
7392
7301
  switch (_g.label) {
@@ -7446,9 +7355,9 @@ var PerpetualsClient = (function () {
7446
7355
  instructions.push(reimburse);
7447
7356
  return [3, 5];
7448
7357
  case 4:
7449
- err_60 = _g.sent();
7450
- console.log("perpClient setPool error:: ", err_60);
7451
- throw err_60;
7358
+ err_61 = _g.sent();
7359
+ console.log("perpClient setPool error:: ", err_61);
7360
+ throw err_61;
7452
7361
  case 5: return [2, {
7453
7362
  instructions: __spreadArray([], instructions, true),
7454
7363
  additionalSigners: additionalSigners
@@ -7457,7 +7366,7 @@ var PerpetualsClient = (function () {
7457
7366
  });
7458
7367
  }); };
7459
7368
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7460
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_61;
7369
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_62;
7461
7370
  return __generator(this, function (_a) {
7462
7371
  switch (_a.label) {
7463
7372
  case 0:
@@ -7490,9 +7399,9 @@ var PerpetualsClient = (function () {
7490
7399
  instructions.push(setInternalOraclePrice);
7491
7400
  return [3, 4];
7492
7401
  case 3:
7493
- err_61 = _a.sent();
7494
- console.log("perpClient setInternalOracleAccount error:: ", err_61);
7495
- throw err_61;
7402
+ err_62 = _a.sent();
7403
+ console.log("perpClient setInternalOracleAccount error:: ", err_62);
7404
+ throw err_62;
7496
7405
  case 4: return [2, {
7497
7406
  instructions: __spreadArray([], instructions, true),
7498
7407
  additionalSigners: additionalSigners
@@ -7500,18 +7409,14 @@ var PerpetualsClient = (function () {
7500
7409
  }
7501
7410
  });
7502
7411
  }); };
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) {
7412
+ this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
7413
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7414
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7415
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7416
+ return __awaiter(_this, void 0, void 0, function () {
7417
+ 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;
7418
+ return __generator(this, function (_e) {
7419
+ switch (_e.label) {
7515
7420
  case 0:
7516
7421
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7517
7422
  preInstructions = [];
@@ -7528,8 +7433,8 @@ var PerpetualsClient = (function () {
7528
7433
  custodyAccountMetas = [];
7529
7434
  custodyOracleAccountMetas = [];
7530
7435
  markets = [];
7531
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7532
- custody = _b[_a];
7436
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7437
+ custody = _a[_i];
7533
7438
  custodyAccountMetas.push({
7534
7439
  pubkey: custody.custodyAccount,
7535
7440
  isSigner: false,
@@ -7541,8 +7446,8 @@ var PerpetualsClient = (function () {
7541
7446
  isWritable: false,
7542
7447
  });
7543
7448
  }
7544
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7545
- market = _d[_c];
7449
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7450
+ market = _c[_b];
7546
7451
  markets.push({
7547
7452
  pubkey: market.marketAccount,
7548
7453
  isSigner: false,
@@ -7551,26 +7456,26 @@ var PerpetualsClient = (function () {
7551
7456
  }
7552
7457
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
7553
7458
  case 1:
7554
- if (!(_f.sent())) {
7459
+ if (!(_e.sent())) {
7555
7460
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
7556
7461
  }
7557
7462
  return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
7558
7463
  case 2:
7559
- if (!(_f.sent())) {
7464
+ if (!(_e.sent())) {
7560
7465
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
7561
7466
  }
7562
7467
  if (!(inTokenSymbol == 'SOL')) return [3, 5];
7563
7468
  console.log("inTokenSymbol === SOL", inTokenSymbol);
7564
7469
  lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
7565
7470
  if (!!skipBalanceChecks) return [3, 4];
7566
- _e = anchor_1.BN.bind;
7471
+ _d = anchor_1.BN.bind;
7567
7472
  return [4, this.provider.connection.getBalance(publicKey)];
7568
7473
  case 3:
7569
- unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
7474
+ unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _e.sent()]))();
7570
7475
  if (unWrappedSolBalance.lt(lamports)) {
7571
7476
  throw "Insufficient SOL Funds";
7572
7477
  }
7573
- _f.label = 4;
7478
+ _e.label = 4;
7574
7479
  case 4:
7575
7480
  if (!ephemeralSignerPubkey) {
7576
7481
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -7594,12 +7499,12 @@ var PerpetualsClient = (function () {
7594
7499
  if (!!skipBalanceChecks) return [3, 7];
7595
7500
  return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
7596
7501
  case 6:
7597
- if (!(_f.sent())) {
7502
+ if (!(_e.sent())) {
7598
7503
  throw "Insufficient Funds , token Account doesn't exist";
7599
7504
  }
7600
- _f.label = 7;
7505
+ _e.label = 7;
7601
7506
  case 7:
7602
- _f.trys.push([7, 9, , 10]);
7507
+ _e.trys.push([7, 9, , 10]);
7603
7508
  return [4, this.program.methods
7604
7509
  .addCompoundingLiquidity({
7605
7510
  amountIn: amountIn,
@@ -7628,12 +7533,12 @@ var PerpetualsClient = (function () {
7628
7533
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7629
7534
  .instruction()];
7630
7535
  case 8:
7631
- addCompoundingLiquidity = _f.sent();
7536
+ addCompoundingLiquidity = _e.sent();
7632
7537
  instructions.push(addCompoundingLiquidity);
7633
7538
  return [3, 10];
7634
7539
  case 9:
7635
- err_62 = _f.sent();
7636
- console.log("perpClient addCompoundingLiquidity error:: ", err_62);
7540
+ err_63 = _e.sent();
7541
+ console.log("perpClient addCompoundingLiquidity error:: ", err_63);
7637
7542
  return [3, 10];
7638
7543
  case 10: return [2, {
7639
7544
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7643,18 +7548,14 @@ var PerpetualsClient = (function () {
7643
7548
  });
7644
7549
  });
7645
7550
  };
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) {
7551
+ this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey) {
7552
+ if (createUserATA === void 0) { createUserATA = true; }
7553
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7554
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7555
+ return __awaiter(_this, void 0, void 0, function () {
7556
+ 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;
7557
+ return __generator(this, function (_e) {
7558
+ switch (_e.label) {
7658
7559
  case 0:
7659
7560
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7660
7561
  preInstructions = [];
@@ -7691,19 +7592,19 @@ var PerpetualsClient = (function () {
7691
7592
  if (!_a) return [3, 3];
7692
7593
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
7693
7594
  case 2:
7694
- _a = !(_f.sent());
7695
- _f.label = 3;
7595
+ _a = !(_e.sent());
7596
+ _e.label = 3;
7696
7597
  case 3:
7697
7598
  if (_a) {
7698
7599
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
7699
7600
  }
7700
- _f.label = 4;
7601
+ _e.label = 4;
7701
7602
  case 4:
7702
7603
  custodyAccountMetas = [];
7703
7604
  custodyOracleAccountMetas = [];
7704
7605
  markets = [];
7705
- for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
7706
- custody = _c[_b];
7606
+ for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
7607
+ custody = _b[_i];
7707
7608
  custodyAccountMetas.push({
7708
7609
  pubkey: custody.custodyAccount,
7709
7610
  isSigner: false,
@@ -7715,8 +7616,8 @@ var PerpetualsClient = (function () {
7715
7616
  isWritable: false,
7716
7617
  });
7717
7618
  }
7718
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7719
- market = _e[_d];
7619
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7620
+ market = _d[_c];
7720
7621
  markets.push({
7721
7622
  pubkey: market.marketAccount,
7722
7623
  isSigner: false,
@@ -7724,9 +7625,9 @@ var PerpetualsClient = (function () {
7724
7625
  });
7725
7626
  }
7726
7627
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
7727
- _f.label = 5;
7628
+ _e.label = 5;
7728
7629
  case 5:
7729
- _f.trys.push([5, 7, , 8]);
7630
+ _e.trys.push([5, 7, , 8]);
7730
7631
  return [4, this.program.methods
7731
7632
  .removeCompoundingLiquidity({
7732
7633
  compoundingAmountIn: compoundingAmountIn,
@@ -7755,12 +7656,12 @@ var PerpetualsClient = (function () {
7755
7656
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7756
7657
  .instruction()];
7757
7658
  case 6:
7758
- removeCompoundingLiquidity = _f.sent();
7659
+ removeCompoundingLiquidity = _e.sent();
7759
7660
  instructions.push(removeCompoundingLiquidity);
7760
7661
  return [3, 8];
7761
7662
  case 7:
7762
- err_63 = _f.sent();
7763
- console.log("perpClient removeCompoundingLiquidity error:: ", err_63);
7663
+ err_64 = _e.sent();
7664
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_64);
7764
7665
  return [3, 8];
7765
7666
  case 8: return [2, {
7766
7667
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7770,16 +7671,12 @@ var PerpetualsClient = (function () {
7770
7671
  });
7771
7672
  });
7772
7673
  };
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) {
7674
+ this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7675
+ if (createUserATA === void 0) { createUserATA = true; }
7676
+ return __awaiter(_this, void 0, void 0, function () {
7677
+ 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;
7678
+ return __generator(this, function (_f) {
7679
+ switch (_f.label) {
7783
7680
  case 0:
7784
7681
  publicKey = this.provider.wallet.publicKey;
7785
7682
  preInstructions = [];
@@ -7794,8 +7691,8 @@ var PerpetualsClient = (function () {
7794
7691
  if (!_a) return [3, 2];
7795
7692
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
7796
7693
  case 1:
7797
- _a = !(_g.sent());
7798
- _g.label = 2;
7694
+ _a = !(_f.sent());
7695
+ _f.label = 2;
7799
7696
  case 2:
7800
7697
  if (_a) {
7801
7698
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
@@ -7807,8 +7704,8 @@ var PerpetualsClient = (function () {
7807
7704
  if (!_b) return [3, 4];
7808
7705
  return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
7809
7706
  case 3:
7810
- _b = (_g.sent());
7811
- _g.label = 4;
7707
+ _b = (_f.sent());
7708
+ _f.label = 4;
7812
7709
  case 4:
7813
7710
  if (_b) {
7814
7711
  tokenStakeAccounts.push({
@@ -7821,8 +7718,8 @@ var PerpetualsClient = (function () {
7821
7718
  custodyAccountMetas = [];
7822
7719
  custodyOracleAccountMetas = [];
7823
7720
  markets = [];
7824
- for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
7825
- custody = _d[_c];
7721
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
7722
+ custody = _c[_i];
7826
7723
  custodyAccountMetas.push({
7827
7724
  pubkey: custody.custodyAccount,
7828
7725
  isSigner: false,
@@ -7834,17 +7731,17 @@ var PerpetualsClient = (function () {
7834
7731
  isWritable: false,
7835
7732
  });
7836
7733
  }
7837
- for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
7838
- market = _f[_e];
7734
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7735
+ market = _e[_d];
7839
7736
  markets.push({
7840
7737
  pubkey: market.marketAccount,
7841
7738
  isSigner: false,
7842
7739
  isWritable: false,
7843
7740
  });
7844
7741
  }
7845
- _g.label = 5;
7742
+ _f.label = 5;
7846
7743
  case 5:
7847
- _g.trys.push([5, 7, , 8]);
7744
+ _f.trys.push([5, 7, , 8]);
7848
7745
  return [4, this.program.methods
7849
7746
  .migrateStake({
7850
7747
  amount: amount
@@ -7870,12 +7767,12 @@ var PerpetualsClient = (function () {
7870
7767
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
7871
7768
  .instruction()];
7872
7769
  case 6:
7873
- migrateStake = _g.sent();
7770
+ migrateStake = _f.sent();
7874
7771
  instructions.push(migrateStake);
7875
7772
  return [3, 8];
7876
7773
  case 7:
7877
- err_64 = _g.sent();
7878
- console.log("perpClient migrateStake error:: ", err_64);
7774
+ err_65 = _f.sent();
7775
+ console.log("perpClient migrateStake error:: ", err_65);
7879
7776
  return [3, 8];
7880
7777
  case 8: return [2, {
7881
7778
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7886,7 +7783,7 @@ var PerpetualsClient = (function () {
7886
7783
  });
7887
7784
  };
7888
7785
  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;
7786
+ 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
7787
  return __generator(this, function (_d) {
7891
7788
  switch (_d.label) {
7892
7789
  case 0:
@@ -7958,8 +7855,8 @@ var PerpetualsClient = (function () {
7958
7855
  instructions.push(migrateFlp);
7959
7856
  return [3, 4];
7960
7857
  case 3:
7961
- err_65 = _d.sent();
7962
- console.log("perpClient migrateFlp error:: ", err_65);
7858
+ err_66 = _d.sent();
7859
+ console.log("perpClient migrateFlp error:: ", err_66);
7963
7860
  return [3, 4];
7964
7861
  case 4: return [2, {
7965
7862
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7968,16 +7865,12 @@ var PerpetualsClient = (function () {
7968
7865
  }
7969
7866
  });
7970
7867
  }); };
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) {
7868
+ this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7869
+ if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7870
+ return __awaiter(_this, void 0, void 0, function () {
7871
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_67;
7872
+ return __generator(this, function (_d) {
7873
+ switch (_d.label) {
7981
7874
  case 0:
7982
7875
  instructions = [];
7983
7876
  additionalSigners = [];
@@ -7986,8 +7879,8 @@ var PerpetualsClient = (function () {
7986
7879
  custodyAccountMetas = [];
7987
7880
  custodyOracleAccountMetas = [];
7988
7881
  markets = [];
7989
- for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
7990
- custody = _b[_a];
7882
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
7883
+ custody = _a[_i];
7991
7884
  custodyAccountMetas.push({
7992
7885
  pubkey: custody.custodyAccount,
7993
7886
  isSigner: false,
@@ -7999,17 +7892,17 @@ var PerpetualsClient = (function () {
7999
7892
  isWritable: false,
8000
7893
  });
8001
7894
  }
8002
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
8003
- market = _d[_c];
7895
+ for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
7896
+ market = _c[_b];
8004
7897
  markets.push({
8005
7898
  pubkey: market.marketAccount,
8006
7899
  isSigner: false,
8007
7900
  isWritable: false,
8008
7901
  });
8009
7902
  }
8010
- _e.label = 1;
7903
+ _d.label = 1;
8011
7904
  case 1:
8012
- _e.trys.push([1, 3, , 4]);
7905
+ _d.trys.push([1, 3, , 4]);
8013
7906
  return [4, this.program.methods
8014
7907
  .compoundFees({})
8015
7908
  .accounts({
@@ -8028,12 +7921,12 @@ var PerpetualsClient = (function () {
8028
7921
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
8029
7922
  .instruction()];
8030
7923
  case 2:
8031
- compoundingFee = _e.sent();
7924
+ compoundingFee = _d.sent();
8032
7925
  instructions.push(compoundingFee);
8033
7926
  return [3, 4];
8034
7927
  case 3:
8035
- err_66 = _e.sent();
8036
- console.log("perpClient compoundingFee error:: ", err_66);
7928
+ err_67 = _d.sent();
7929
+ console.log("perpClient compoundingFee error:: ", err_67);
8037
7930
  return [3, 4];
8038
7931
  case 4: return [2, {
8039
7932
  instructions: __spreadArray([], instructions, true),
@@ -8044,7 +7937,7 @@ var PerpetualsClient = (function () {
8044
7937
  });
8045
7938
  };
8046
7939
  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;
7940
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_68;
8048
7941
  return __generator(this, function (_a) {
8049
7942
  switch (_a.label) {
8050
7943
  case 0:
@@ -8082,8 +7975,8 @@ var PerpetualsClient = (function () {
8082
7975
  instructions.push(renameFlp);
8083
7976
  return [3, 4];
8084
7977
  case 3:
8085
- err_67 = _a.sent();
8086
- console.log("perpClient renameFlp error:: ", err_67);
7978
+ err_68 = _a.sent();
7979
+ console.log("perpClient renameFlp error:: ", err_68);
8087
7980
  return [3, 4];
8088
7981
  case 4: return [2, {
8089
7982
  instructions: __spreadArray([], instructions, true),
@@ -8193,9 +8086,9 @@ var PerpetualsClient = (function () {
8193
8086
  }
8194
8087
  }
8195
8088
  };
8196
- PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
8197
- return __awaiter(this, arguments, void 0, function (ixs, opts) {
8198
- if (opts === void 0) { opts = {}; }
8089
+ PerpetualsClient.prototype.sendTransaction = function (ixs, opts) {
8090
+ if (opts === void 0) { opts = {}; }
8091
+ return __awaiter(this, void 0, void 0, function () {
8199
8092
  return __generator(this, function (_a) {
8200
8093
  switch (_a.label) {
8201
8094
  case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
@@ -8204,9 +8097,9 @@ var PerpetualsClient = (function () {
8204
8097
  });
8205
8098
  });
8206
8099
  };
8207
- PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
8208
- return __awaiter(this, arguments, void 0, function (ixs, opts) {
8209
- if (opts === void 0) { opts = {}; }
8100
+ PerpetualsClient.prototype.sendTransactionV3 = function (ixs, opts) {
8101
+ if (opts === void 0) { opts = {}; }
8102
+ return __awaiter(this, void 0, void 0, function () {
8210
8103
  return __generator(this, function (_a) {
8211
8104
  switch (_a.label) {
8212
8105
  case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];