flash-sdk 2.50.1 → 2.50.3

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