flash-sdk 2.52.0 → 2.52.1

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.
@@ -1816,11 +1816,15 @@ var PerpetualsClient = (function () {
1816
1816
  }
1817
1817
  return finalIndexPriceAtT1.toString();
1818
1818
  };
1819
- this.getUserClaimableRevenueAmount = function (POOL_CONFIG, userPublicKey, enableDebuglogs) {
1820
- if (enableDebuglogs === void 0) { enableDebuglogs = false; }
1821
- return __awaiter(_this, void 0, void 0, function () {
1819
+ this.getUserClaimableRevenueAmount = function (POOL_CONFIG_1, userPublicKey_1) {
1820
+ var args_1 = [];
1821
+ for (var _i = 2; _i < arguments.length; _i++) {
1822
+ args_1[_i - 2] = arguments[_i];
1823
+ }
1824
+ return __awaiter(_this, __spreadArray([POOL_CONFIG_1, userPublicKey_1], args_1, true), void 0, function (POOL_CONFIG, userPublicKey, enableDebuglogs) {
1822
1825
  var fafTokenVaultPk, fafTokenVaultAccountInfo, fafTokenVaultAccount, fafTokenVault, tokenStakeAccount, accountInfo, fafStakeData, tokenStakeFafAccount, activeStakeAmount, revenuePerFafStaked, revenueWatermark, revenueSnapshot, unclaimedRevenue, revenueAmount;
1823
1826
  var _a, _b, _c, _d;
1827
+ if (enableDebuglogs === void 0) { enableDebuglogs = false; }
1824
1828
  return __generator(this, function (_e) {
1825
1829
  switch (_e.label) {
1826
1830
  case 0:
@@ -1977,34 +1981,38 @@ var PerpetualsClient = (function () {
1977
1981
  }
1978
1982
  });
1979
1983
  }); };
1980
- this.getAddLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
1981
- if (userPublicKey === void 0) { userPublicKey = undefined; }
1982
- return __awaiter(_this, void 0, void 0, function () {
1983
- var custodies, custodyMetas, marketMetas, _i, custodies_5, token, _a, custodies_6, custody, _b, _c, market, depositCustodyConfig, transaction, result, index, res;
1984
- return __generator(this, function (_d) {
1985
- switch (_d.label) {
1984
+ this.getAddLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
1985
+ var args_1 = [];
1986
+ for (var _i = 4; _i < arguments.length; _i++) {
1987
+ args_1[_i - 4] = arguments[_i];
1988
+ }
1989
+ 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) {
1990
+ var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, result, index, res;
1991
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
1992
+ return __generator(this, function (_e) {
1993
+ switch (_e.label) {
1986
1994
  case 0:
1987
1995
  custodies = POOL_CONFIG.custodies;
1988
1996
  custodyMetas = [];
1989
1997
  marketMetas = [];
1990
- for (_i = 0, custodies_5 = custodies; _i < custodies_5.length; _i++) {
1991
- token = custodies_5[_i];
1998
+ for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
1999
+ token = custodies_5[_a];
1992
2000
  custodyMetas.push({
1993
2001
  isSigner: false,
1994
2002
  isWritable: false,
1995
2003
  pubkey: token.custodyAccount,
1996
2004
  });
1997
2005
  }
1998
- for (_a = 0, custodies_6 = custodies; _a < custodies_6.length; _a++) {
1999
- custody = custodies_6[_a];
2006
+ for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
2007
+ custody = custodies_6[_b];
2000
2008
  custodyMetas.push({
2001
2009
  isSigner: false,
2002
2010
  isWritable: false,
2003
2011
  pubkey: custody.intOracleAccount,
2004
2012
  });
2005
2013
  }
2006
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2007
- market = _c[_b];
2014
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2015
+ market = _d[_c];
2008
2016
  marketMetas.push({
2009
2017
  pubkey: market.marketAccount,
2010
2018
  isSigner: false,
@@ -2027,10 +2035,10 @@ var PerpetualsClient = (function () {
2027
2035
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2028
2036
  .transaction()];
2029
2037
  case 1:
2030
- transaction = _d.sent();
2038
+ transaction = _e.sent();
2031
2039
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2032
2040
  case 2:
2033
- result = _d.sent();
2041
+ result = _e.sent();
2034
2042
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
2035
2043
  res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
2036
2044
  return [2, {
@@ -2041,34 +2049,38 @@ var PerpetualsClient = (function () {
2041
2049
  });
2042
2050
  });
2043
2051
  };
2044
- this.getRemoveLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2045
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2046
- return __awaiter(_this, void 0, void 0, function () {
2047
- var custodies, custodyMetas, marketMetas, _i, custodies_7, token, _a, custodies_8, custody, _b, _c, market, removeCustodyConfig, transaction, result, index, res;
2048
- return __generator(this, function (_d) {
2049
- switch (_d.label) {
2052
+ this.getRemoveLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2053
+ var args_1 = [];
2054
+ for (var _i = 4; _i < arguments.length; _i++) {
2055
+ args_1[_i - 4] = arguments[_i];
2056
+ }
2057
+ 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) {
2058
+ var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, result, index, res;
2059
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2060
+ return __generator(this, function (_e) {
2061
+ switch (_e.label) {
2050
2062
  case 0:
2051
2063
  custodies = POOL_CONFIG.custodies;
2052
2064
  custodyMetas = [];
2053
2065
  marketMetas = [];
2054
- for (_i = 0, custodies_7 = custodies; _i < custodies_7.length; _i++) {
2055
- token = custodies_7[_i];
2066
+ for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
2067
+ token = custodies_7[_a];
2056
2068
  custodyMetas.push({
2057
2069
  isSigner: false,
2058
2070
  isWritable: false,
2059
2071
  pubkey: token.custodyAccount,
2060
2072
  });
2061
2073
  }
2062
- for (_a = 0, custodies_8 = custodies; _a < custodies_8.length; _a++) {
2063
- custody = custodies_8[_a];
2074
+ for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
2075
+ custody = custodies_8[_b];
2064
2076
  custodyMetas.push({
2065
2077
  isSigner: false,
2066
2078
  isWritable: false,
2067
2079
  pubkey: custody.intOracleAccount,
2068
2080
  });
2069
2081
  }
2070
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2071
- market = _c[_b];
2082
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2083
+ market = _d[_c];
2072
2084
  marketMetas.push({
2073
2085
  pubkey: market.marketAccount,
2074
2086
  isSigner: false,
@@ -2091,10 +2103,10 @@ var PerpetualsClient = (function () {
2091
2103
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2092
2104
  .transaction()];
2093
2105
  case 1:
2094
- transaction = _d.sent();
2106
+ transaction = _e.sent();
2095
2107
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2096
2108
  case 2:
2097
- result = _d.sent();
2109
+ result = _e.sent();
2098
2110
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2099
2111
  if (result.value.err) {
2100
2112
  return [2, {
@@ -2170,34 +2182,38 @@ var PerpetualsClient = (function () {
2170
2182
  }
2171
2183
  });
2172
2184
  }); };
2173
- this.getAddCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey) {
2174
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2175
- return __awaiter(_this, void 0, void 0, function () {
2176
- var custodies, custodyMetas, marketMetas, _i, custodies_11, token, _a, custodies_12, custody, _b, _c, market, depositCustodyConfig, rewardCustody, transaction, result, index, res;
2177
- return __generator(this, function (_d) {
2178
- switch (_d.label) {
2185
+ this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
2186
+ var args_1 = [];
2187
+ for (var _i = 4; _i < arguments.length; _i++) {
2188
+ args_1[_i - 4] = arguments[_i];
2189
+ }
2190
+ 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) {
2191
+ var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, result, index, res;
2192
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2193
+ return __generator(this, function (_e) {
2194
+ switch (_e.label) {
2179
2195
  case 0:
2180
2196
  custodies = POOL_CONFIG.custodies;
2181
2197
  custodyMetas = [];
2182
2198
  marketMetas = [];
2183
- for (_i = 0, custodies_11 = custodies; _i < custodies_11.length; _i++) {
2184
- token = custodies_11[_i];
2199
+ for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
2200
+ token = custodies_11[_a];
2185
2201
  custodyMetas.push({
2186
2202
  isSigner: false,
2187
2203
  isWritable: false,
2188
2204
  pubkey: token.custodyAccount,
2189
2205
  });
2190
2206
  }
2191
- for (_a = 0, custodies_12 = custodies; _a < custodies_12.length; _a++) {
2192
- custody = custodies_12[_a];
2207
+ for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
2208
+ custody = custodies_12[_b];
2193
2209
  custodyMetas.push({
2194
2210
  isSigner: false,
2195
2211
  isWritable: false,
2196
2212
  pubkey: custody.intOracleAccount,
2197
2213
  });
2198
2214
  }
2199
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2200
- market = _c[_b];
2215
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2216
+ market = _d[_c];
2201
2217
  marketMetas.push({
2202
2218
  pubkey: market.marketAccount,
2203
2219
  isSigner: false,
@@ -2224,10 +2240,10 @@ var PerpetualsClient = (function () {
2224
2240
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2225
2241
  .transaction()];
2226
2242
  case 1:
2227
- transaction = _d.sent();
2243
+ transaction = _e.sent();
2228
2244
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2229
2245
  case 2:
2230
- result = _d.sent();
2246
+ result = _e.sent();
2231
2247
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2232
2248
  res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
2233
2249
  return [2, {
@@ -2238,34 +2254,38 @@ var PerpetualsClient = (function () {
2238
2254
  });
2239
2255
  });
2240
2256
  };
2241
- this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey) {
2242
- if (userPublicKey === void 0) { userPublicKey = undefined; }
2243
- return __awaiter(_this, void 0, void 0, function () {
2244
- var custodies, custodyMetas, marketMetas, _i, custodies_13, token, _a, custodies_14, custody, _b, _c, market, removeCustodyConfig, rewardCustody, transaction, result, index, res;
2245
- return __generator(this, function (_d) {
2246
- switch (_d.label) {
2257
+ this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2258
+ var args_1 = [];
2259
+ for (var _i = 4; _i < arguments.length; _i++) {
2260
+ args_1[_i - 4] = arguments[_i];
2261
+ }
2262
+ 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) {
2263
+ var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, result, index, res;
2264
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2265
+ return __generator(this, function (_e) {
2266
+ switch (_e.label) {
2247
2267
  case 0:
2248
2268
  custodies = POOL_CONFIG.custodies;
2249
2269
  custodyMetas = [];
2250
2270
  marketMetas = [];
2251
- for (_i = 0, custodies_13 = custodies; _i < custodies_13.length; _i++) {
2252
- token = custodies_13[_i];
2271
+ for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
2272
+ token = custodies_13[_a];
2253
2273
  custodyMetas.push({
2254
2274
  isSigner: false,
2255
2275
  isWritable: false,
2256
2276
  pubkey: token.custodyAccount,
2257
2277
  });
2258
2278
  }
2259
- for (_a = 0, custodies_14 = custodies; _a < custodies_14.length; _a++) {
2260
- custody = custodies_14[_a];
2279
+ for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
2280
+ custody = custodies_14[_b];
2261
2281
  custodyMetas.push({
2262
2282
  isSigner: false,
2263
2283
  isWritable: false,
2264
2284
  pubkey: custody.intOracleAccount,
2265
2285
  });
2266
2286
  }
2267
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2268
- market = _c[_b];
2287
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2288
+ market = _d[_c];
2269
2289
  marketMetas.push({
2270
2290
  pubkey: market.marketAccount,
2271
2291
  isSigner: false,
@@ -2292,10 +2312,10 @@ var PerpetualsClient = (function () {
2292
2312
  .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2293
2313
  .transaction()];
2294
2314
  case 1:
2295
- transaction = _d.sent();
2315
+ transaction = _e.sent();
2296
2316
  return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2297
2317
  case 2:
2298
- result = _d.sent();
2318
+ result = _e.sent();
2299
2319
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2300
2320
  if (result.value.err) {
2301
2321
  return [2, {
@@ -2476,14 +2496,18 @@ var PerpetualsClient = (function () {
2476
2496
  }
2477
2497
  });
2478
2498
  }); };
2479
- this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2480
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2481
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2482
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2483
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2484
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2485
- return __awaiter(_this, void 0, void 0, function () {
2499
+ this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
2500
+ var args_1 = [];
2501
+ for (var _i = 8; _i < arguments.length; _i++) {
2502
+ args_1[_i - 8] = arguments[_i];
2503
+ }
2504
+ 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) {
2486
2505
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
2506
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2507
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2508
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2509
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2510
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2487
2511
  return __generator(this, function (_c) {
2488
2512
  switch (_c.label) {
2489
2513
  case 0:
@@ -2587,15 +2611,19 @@ var PerpetualsClient = (function () {
2587
2611
  });
2588
2612
  });
2589
2613
  };
2590
- this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2591
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2592
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2593
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2594
- if (createUserATA === void 0) { createUserATA = true; }
2595
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2596
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2597
- return __awaiter(_this, void 0, void 0, function () {
2614
+ this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
2615
+ var args_1 = [];
2616
+ for (var _i = 6; _i < arguments.length; _i++) {
2617
+ args_1[_i - 6] = arguments[_i];
2618
+ }
2619
+ 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) {
2598
2620
  var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_1;
2621
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2622
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2623
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2624
+ if (createUserATA === void 0) { createUserATA = true; }
2625
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
2626
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2599
2627
  return __generator(this, function (_b) {
2600
2628
  switch (_b.label) {
2601
2629
  case 0:
@@ -2692,14 +2720,18 @@ var PerpetualsClient = (function () {
2692
2720
  });
2693
2721
  });
2694
2722
  };
2695
- this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2696
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2697
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2698
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2699
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2700
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2701
- return __awaiter(_this, void 0, void 0, function () {
2723
+ this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
2724
+ var args_1 = [];
2725
+ for (var _i = 10; _i < arguments.length; _i++) {
2726
+ args_1[_i - 10] = arguments[_i];
2727
+ }
2728
+ 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) {
2702
2729
  var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_3;
2730
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2731
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2732
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2733
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2734
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2703
2735
  return __generator(this, function (_c) {
2704
2736
  switch (_c.label) {
2705
2737
  case 0:
@@ -2839,13 +2871,17 @@ var PerpetualsClient = (function () {
2839
2871
  });
2840
2872
  });
2841
2873
  };
2842
- this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
2843
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2844
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2845
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2846
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2847
- return __awaiter(_this, void 0, void 0, function () {
2874
+ this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
2875
+ var args_1 = [];
2876
+ for (var _i = 8; _i < arguments.length; _i++) {
2877
+ args_1[_i - 8] = arguments[_i];
2878
+ }
2879
+ 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) {
2848
2880
  var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_4;
2881
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2882
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
2883
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
2884
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2849
2885
  return __generator(this, function (_a) {
2850
2886
  switch (_a.label) {
2851
2887
  case 0:
@@ -2959,16 +2995,20 @@ var PerpetualsClient = (function () {
2959
2995
  });
2960
2996
  });
2961
2997
  };
2962
- this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
2963
- if (useFeesPool === void 0) { useFeesPool = false; }
2964
- if (createUserATA === void 0) { createUserATA = true; }
2965
- if (unWrapSol === void 0) { unWrapSol = false; }
2966
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
2967
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
2968
- return __awaiter(_this, void 0, void 0, function () {
2969
- 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;
2970
- return __generator(this, function (_f) {
2971
- switch (_f.label) {
2998
+ this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
2999
+ var args_1 = [];
3000
+ for (var _i = 5; _i < arguments.length; _i++) {
3001
+ args_1[_i - 5] = arguments[_i];
3002
+ }
3003
+ 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) {
3004
+ 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_5;
3005
+ if (useFeesPool === void 0) { useFeesPool = false; }
3006
+ if (createUserATA === void 0) { createUserATA = true; }
3007
+ if (unWrapSol === void 0) { unWrapSol = false; }
3008
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3009
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3010
+ return __generator(this, function (_g) {
3011
+ switch (_g.label) {
2972
3012
  case 0:
2973
3013
  userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
2974
3014
  if (!userInputCustodyConfig) {
@@ -2986,10 +3026,10 @@ var PerpetualsClient = (function () {
2986
3026
  if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
2987
3027
  return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
2988
3028
  case 1:
2989
- wsolAssociatedTokenAccount = _f.sent();
3029
+ wsolAssociatedTokenAccount = _g.sent();
2990
3030
  return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
2991
3031
  case 2:
2992
- wsolATAExist = _f.sent();
3032
+ wsolATAExist = _g.sent();
2993
3033
  if (!wsolATAExist) {
2994
3034
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
2995
3035
  }
@@ -2997,11 +3037,11 @@ var PerpetualsClient = (function () {
2997
3037
  _a = anchor_1.BN.bind;
2998
3038
  return [4, this.provider.connection.getBalance(publicKey)];
2999
3039
  case 3:
3000
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
3040
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
3001
3041
  if (unWrappedSolBalance.lt(amountIn)) {
3002
3042
  throw "Insufficient SOL Funds";
3003
3043
  }
3004
- _f.label = 4;
3044
+ _g.label = 4;
3005
3045
  case 4:
3006
3046
  instructions.push(web3_js_1.SystemProgram.transfer({
3007
3047
  fromPubkey: publicKey,
@@ -3023,20 +3063,20 @@ var PerpetualsClient = (function () {
3023
3063
  additionalSigners: additionalSigners
3024
3064
  }];
3025
3065
  }
3026
- _f.label = 6;
3066
+ _g.label = 6;
3027
3067
  case 6:
3028
- _f.trys.push([6, 19, , 20]);
3068
+ _g.trys.push([6, 19, , 20]);
3029
3069
  if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
3030
3070
  console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
3031
3071
  return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
3032
3072
  case 7:
3033
- accCreationLamports = (_f.sent());
3073
+ accCreationLamports = (_g.sent());
3034
3074
  console.log("accCreationLamports:", accCreationLamports);
3035
3075
  lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
3036
3076
  _b = anchor_1.BN.bind;
3037
3077
  return [4, this.provider.connection.getBalance(publicKey)];
3038
3078
  case 8:
3039
- unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _f.sent()]))();
3079
+ unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
3040
3080
  if (unWrappedSolBalance.lt(amountIn)) {
3041
3081
  throw "Insufficient SOL Funds";
3042
3082
  }
@@ -3063,18 +3103,18 @@ var PerpetualsClient = (function () {
3063
3103
  userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
3064
3104
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
3065
3105
  case 10:
3066
- if (!(_f.sent())) {
3106
+ if (!(_g.sent())) {
3067
3107
  throw "Insufficient Funds , Token Account doesn't exist";
3068
3108
  }
3069
3109
  if (!!skipBalanceChecks) return [3, 12];
3070
3110
  _c = anchor_1.BN.bind;
3071
3111
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
3072
3112
  case 11:
3073
- tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
3113
+ tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3074
3114
  if (tokenAccountBalance.lt(amountIn)) {
3075
3115
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
3076
3116
  }
3077
- _f.label = 12;
3117
+ _g.label = 12;
3078
3118
  case 12:
3079
3119
  if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
3080
3120
  lamports = (this.minimumBalanceForRentExemptAccountLamports);
@@ -3099,23 +3139,23 @@ var PerpetualsClient = (function () {
3099
3139
  return [3, 17];
3100
3140
  case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
3101
3141
  case 14:
3102
- userOutputTokenAccount = _f.sent();
3142
+ userOutputTokenAccount = _g.sent();
3103
3143
  _d = createUserATA;
3104
3144
  if (!_d) return [3, 16];
3105
3145
  return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
3106
3146
  case 15:
3107
- _d = !(_f.sent());
3108
- _f.label = 16;
3147
+ _d = !(_g.sent());
3148
+ _g.label = 16;
3109
3149
  case 16:
3110
3150
  if (_d) {
3111
3151
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
3112
3152
  }
3113
- _f.label = 17;
3153
+ _g.label = 17;
3114
3154
  case 17:
3115
3155
  custodyAccountMetas = [];
3116
3156
  custodyOracleAccountMetas = [];
3117
- for (_i = 0, _e = poolConfig.custodies; _i < _e.length; _i++) {
3118
- custody = _e[_i];
3157
+ for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
3158
+ custody = _f[_e];
3119
3159
  custodyAccountMetas.push({
3120
3160
  pubkey: custody.custodyAccount,
3121
3161
  isSigner: false,
@@ -3155,7 +3195,7 @@ var PerpetualsClient = (function () {
3155
3195
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
3156
3196
  .instruction()];
3157
3197
  case 18:
3158
- inx = _f.sent();
3198
+ inx = _g.sent();
3159
3199
  instructions.push(inx);
3160
3200
  if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
3161
3201
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
@@ -3163,7 +3203,7 @@ var PerpetualsClient = (function () {
3163
3203
  }
3164
3204
  return [3, 20];
3165
3205
  case 19:
3166
- err_5 = _f.sent();
3206
+ err_5 = _g.sent();
3167
3207
  console.error("perpClient Swap error:: ", err_5);
3168
3208
  throw err_5;
3169
3209
  case 20: return [2, {
@@ -3245,11 +3285,15 @@ var PerpetualsClient = (function () {
3245
3285
  }
3246
3286
  });
3247
3287
  }); };
3248
- this.addCollateral = function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3249
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3250
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3251
- return __awaiter(_this, void 0, void 0, function () {
3288
+ this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3289
+ var args_1 = [];
3290
+ for (var _i = 6; _i < arguments.length; _i++) {
3291
+ args_1[_i - 6] = arguments[_i];
3292
+ }
3293
+ 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) {
3252
3294
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
3295
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3296
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3253
3297
  return __generator(this, function (_c) {
3254
3298
  switch (_c.label) {
3255
3299
  case 0:
@@ -3343,11 +3387,15 @@ var PerpetualsClient = (function () {
3343
3387
  });
3344
3388
  });
3345
3389
  };
3346
- this.swapAndAddCollateral = function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3347
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3348
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3349
- return __awaiter(_this, void 0, void 0, function () {
3390
+ this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
3391
+ var args_1 = [];
3392
+ for (var _i = 8; _i < arguments.length; _i++) {
3393
+ args_1[_i - 8] = arguments[_i];
3394
+ }
3395
+ 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) {
3350
3396
  var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
3397
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3398
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3351
3399
  return __generator(this, function (_c) {
3352
3400
  switch (_c.label) {
3353
3401
  case 0:
@@ -3458,12 +3506,16 @@ var PerpetualsClient = (function () {
3458
3506
  });
3459
3507
  });
3460
3508
  };
3461
- this.removeCollateral = function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3462
- if (createUserATA === void 0) { createUserATA = true; }
3463
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3464
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3465
- return __awaiter(_this, void 0, void 0, function () {
3509
+ this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
3510
+ var args_1 = [];
3511
+ for (var _i = 6; _i < arguments.length; _i++) {
3512
+ args_1[_i - 6] = arguments[_i];
3513
+ }
3514
+ 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) {
3466
3515
  var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_2;
3516
+ if (createUserATA === void 0) { createUserATA = true; }
3517
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
3518
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3467
3519
  return __generator(this, function (_b) {
3468
3520
  switch (_b.label) {
3469
3521
  case 0:
@@ -3564,10 +3616,14 @@ var PerpetualsClient = (function () {
3564
3616
  });
3565
3617
  });
3566
3618
  };
3567
- this.removeCollateralAndSwap = function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
3568
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3569
- return __awaiter(_this, void 0, void 0, function () {
3619
+ this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
3620
+ var args_1 = [];
3621
+ for (var _i = 7; _i < arguments.length; _i++) {
3622
+ args_1[_i - 7] = arguments[_i];
3623
+ }
3624
+ 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) {
3570
3625
  var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
3626
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3571
3627
  return __generator(this, function (_a) {
3572
3628
  switch (_a.label) {
3573
3629
  case 0:
@@ -3660,12 +3716,16 @@ var PerpetualsClient = (function () {
3660
3716
  });
3661
3717
  });
3662
3718
  };
3663
- this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3664
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3665
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3666
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3667
- return __awaiter(_this, void 0, void 0, function () {
3719
+ this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3720
+ var args_1 = [];
3721
+ for (var _i = 8; _i < arguments.length; _i++) {
3722
+ args_1[_i - 8] = arguments[_i];
3723
+ }
3724
+ 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) {
3668
3725
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3726
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3727
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3728
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3669
3729
  return __generator(this, function (_a) {
3670
3730
  switch (_a.label) {
3671
3731
  case 0:
@@ -3720,12 +3780,16 @@ var PerpetualsClient = (function () {
3720
3780
  });
3721
3781
  });
3722
3782
  };
3723
- this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
3724
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3725
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3726
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3727
- return __awaiter(_this, void 0, void 0, function () {
3783
+ this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
3784
+ var args_1 = [];
3785
+ for (var _i = 8; _i < arguments.length; _i++) {
3786
+ args_1[_i - 8] = arguments[_i];
3787
+ }
3788
+ 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) {
3728
3789
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3790
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3791
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3792
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
3729
3793
  return __generator(this, function (_a) {
3730
3794
  switch (_a.label) {
3731
3795
  case 0:
@@ -3780,13 +3844,17 @@ var PerpetualsClient = (function () {
3780
3844
  });
3781
3845
  });
3782
3846
  };
3783
- this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3784
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3785
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3786
- return __awaiter(_this, void 0, void 0, function () {
3787
- 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;
3788
- return __generator(this, function (_f) {
3789
- switch (_f.label) {
3847
+ this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
3848
+ var args_1 = [];
3849
+ for (var _i = 4; _i < arguments.length; _i++) {
3850
+ args_1[_i - 4] = arguments[_i];
3851
+ }
3852
+ return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3853
+ 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_7;
3854
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3855
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3856
+ return __generator(this, function (_g) {
3857
+ switch (_g.label) {
3790
3858
  case 0:
3791
3859
  publicKey = this.provider.wallet.publicKey;
3792
3860
  payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
@@ -3797,16 +3865,16 @@ var PerpetualsClient = (function () {
3797
3865
  instructions = [];
3798
3866
  postInstructions = [];
3799
3867
  additionalSigners = [];
3800
- _f.label = 1;
3868
+ _g.label = 1;
3801
3869
  case 1:
3802
- _f.trys.push([1, 10, , 11]);
3870
+ _g.trys.push([1, 10, , 11]);
3803
3871
  userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
3804
3872
  lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
3805
3873
  custodyAccountMetas = [];
3806
3874
  custodyOracleAccountMetas = [];
3807
3875
  markets = [];
3808
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
3809
- custody = _a[_i];
3876
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
3877
+ custody = _b[_a];
3810
3878
  custodyAccountMetas.push({
3811
3879
  pubkey: custody.custodyAccount,
3812
3880
  isSigner: false,
@@ -3818,8 +3886,8 @@ var PerpetualsClient = (function () {
3818
3886
  isWritable: false,
3819
3887
  });
3820
3888
  }
3821
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
3822
- market = _c[_b];
3889
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
3890
+ market = _d[_c];
3823
3891
  markets.push({
3824
3892
  pubkey: market.marketAccount,
3825
3893
  isSigner: false,
@@ -3828,21 +3896,21 @@ var PerpetualsClient = (function () {
3828
3896
  }
3829
3897
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
3830
3898
  case 2:
3831
- if (!(_f.sent())) {
3899
+ if (!(_g.sent())) {
3832
3900
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
3833
3901
  }
3834
3902
  if (!(payTokenSymbol == 'SOL')) return [3, 5];
3835
3903
  console.log("payTokenSymbol === SOL", payTokenSymbol);
3836
3904
  lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
3837
3905
  if (!!skipBalanceChecks) return [3, 4];
3838
- _d = anchor_1.BN.bind;
3906
+ _e = anchor_1.BN.bind;
3839
3907
  return [4, this.provider.connection.getBalance(publicKey)];
3840
3908
  case 3:
3841
- unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _f.sent()]))();
3909
+ unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
3842
3910
  if (unWrappedSolBalance.lt(lamports)) {
3843
3911
  throw "Insufficient SOL Funds";
3844
3912
  }
3845
- _f.label = 4;
3913
+ _g.label = 4;
3846
3914
  case 4:
3847
3915
  if (!ephemeralSignerPubkey) {
3848
3916
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -3866,17 +3934,17 @@ var PerpetualsClient = (function () {
3866
3934
  if (!!skipBalanceChecks) return [3, 8];
3867
3935
  return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
3868
3936
  case 6:
3869
- if (!(_f.sent())) {
3937
+ if (!(_g.sent())) {
3870
3938
  throw "Insufficient Funds , token Account doesn't exist";
3871
3939
  }
3872
- _e = anchor_1.BN.bind;
3940
+ _f = anchor_1.BN.bind;
3873
3941
  return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
3874
3942
  case 7:
3875
- tokenAccountBalance = new (_e.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
3943
+ tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3876
3944
  if (tokenAccountBalance.lt(tokenAmountIn)) {
3877
3945
  throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
3878
3946
  }
3879
- _f.label = 8;
3947
+ _g.label = 8;
3880
3948
  case 8: return [4, this.program.methods
3881
3949
  .addLiquidity({
3882
3950
  amountIn: tokenAmountIn,
@@ -3901,11 +3969,11 @@ var PerpetualsClient = (function () {
3901
3969
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
3902
3970
  .instruction()];
3903
3971
  case 9:
3904
- instruction = _f.sent();
3972
+ instruction = _g.sent();
3905
3973
  instructions.push(instruction);
3906
3974
  return [3, 11];
3907
3975
  case 10:
3908
- err_7 = _f.sent();
3976
+ err_7 = _g.sent();
3909
3977
  console.error("perpClient addLiquidity error:: ", err_7);
3910
3978
  throw err_7;
3911
3979
  case 11: return [2, {
@@ -3916,14 +3984,18 @@ var PerpetualsClient = (function () {
3916
3984
  });
3917
3985
  });
3918
3986
  };
3919
- this.addLiquidityAndStake = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
3920
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3921
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3922
- if (userPublicKey === void 0) { userPublicKey = undefined; }
3923
- return __awaiter(_this, void 0, void 0, function () {
3924
- 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;
3925
- return __generator(this, function (_f) {
3926
- switch (_f.label) {
3987
+ this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
3988
+ var args_1 = [];
3989
+ for (var _i = 4; _i < arguments.length; _i++) {
3990
+ args_1[_i - 4] = arguments[_i];
3991
+ }
3992
+ 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) {
3993
+ 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;
3994
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3995
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3996
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
3997
+ return __generator(this, function (_g) {
3998
+ switch (_g.label) {
3927
3999
  case 0:
3928
4000
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3929
4001
  preInstructions = [];
@@ -3943,14 +4015,14 @@ var PerpetualsClient = (function () {
3943
4015
  _a = anchor_1.BN.bind;
3944
4016
  return [4, this.provider.connection.getBalance(publicKey)];
3945
4017
  case 1:
3946
- unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _f.sent()]))();
4018
+ unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
3947
4019
  if (unWrappedSolBalance.lt(lamports)) {
3948
4020
  throw "Insufficient SOL Funds";
3949
4021
  }
3950
- _f.label = 2;
4022
+ _g.label = 2;
3951
4023
  case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
3952
4024
  case 3:
3953
- if (!(_f.sent())) {
4025
+ if (!(_g.sent())) {
3954
4026
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
3955
4027
  }
3956
4028
  if (!ephemeralSignerPubkey) {
@@ -3976,23 +4048,23 @@ var PerpetualsClient = (function () {
3976
4048
  if (!!skipBalanceChecks) return [3, 7];
3977
4049
  return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
3978
4050
  case 5:
3979
- if (!(_f.sent())) {
4051
+ if (!(_g.sent())) {
3980
4052
  throw "Insufficient Funds , token Account doesn't exist";
3981
4053
  }
3982
4054
  _b = anchor_1.BN.bind;
3983
4055
  return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
3984
4056
  case 6:
3985
- tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_f.sent()).value.amount]))();
4057
+ tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
3986
4058
  if (tokenAccountBalance.lt(amountIn)) {
3987
4059
  throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
3988
4060
  }
3989
- _f.label = 7;
4061
+ _g.label = 7;
3990
4062
  case 7:
3991
4063
  custodyAccountMetas = [];
3992
4064
  custodyOracleAccountMetas = [];
3993
4065
  markets = [];
3994
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
3995
- custody = _c[_i];
4066
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
4067
+ custody = _d[_c];
3996
4068
  custodyAccountMetas.push({
3997
4069
  pubkey: custody.custodyAccount,
3998
4070
  isSigner: false,
@@ -4004,8 +4076,8 @@ var PerpetualsClient = (function () {
4004
4076
  isWritable: false,
4005
4077
  });
4006
4078
  }
4007
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
4008
- market = _e[_d];
4079
+ for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
4080
+ market = _f[_e];
4009
4081
  markets.push({
4010
4082
  pubkey: market.marketAccount,
4011
4083
  isSigner: false,
@@ -4037,7 +4109,7 @@ var PerpetualsClient = (function () {
4037
4109
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4038
4110
  .instruction()];
4039
4111
  case 8:
4040
- instruction = _f.sent();
4112
+ instruction = _g.sent();
4041
4113
  instructions.push(instruction);
4042
4114
  return [2, {
4043
4115
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4047,16 +4119,20 @@ var PerpetualsClient = (function () {
4047
4119
  });
4048
4120
  });
4049
4121
  };
4050
- this.removeLiquidity = function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
4051
- if (closeLpATA === void 0) { closeLpATA = false; }
4052
- if (createUserATA === void 0) { createUserATA = true; }
4053
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4054
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4055
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4056
- return __awaiter(_this, void 0, void 0, function () {
4057
- 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;
4058
- return __generator(this, function (_e) {
4059
- switch (_e.label) {
4122
+ this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
4123
+ var args_1 = [];
4124
+ for (var _i = 4; _i < arguments.length; _i++) {
4125
+ args_1[_i - 4] = arguments[_i];
4126
+ }
4127
+ 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) {
4128
+ 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_8;
4129
+ if (closeLpATA === void 0) { closeLpATA = false; }
4130
+ if (createUserATA === void 0) { createUserATA = true; }
4131
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4132
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4133
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4134
+ return __generator(this, function (_f) {
4135
+ switch (_f.label) {
4060
4136
  case 0:
4061
4137
  recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
4062
4138
  if (!recieveTokenCustodyConfig) {
@@ -4067,15 +4143,15 @@ var PerpetualsClient = (function () {
4067
4143
  instructions = [];
4068
4144
  postInstructions = [];
4069
4145
  additionalSigners = [];
4070
- _e.label = 1;
4146
+ _f.label = 1;
4071
4147
  case 1:
4072
- _e.trys.push([1, 7, , 8]);
4148
+ _f.trys.push([1, 7, , 8]);
4073
4149
  stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
4074
4150
  custodyAccountMetas = [];
4075
4151
  custodyOracleAccountMetas = [];
4076
4152
  markets = [];
4077
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4078
- custody = _a[_i];
4153
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4154
+ custody = _b[_a];
4079
4155
  custodyAccountMetas.push({
4080
4156
  pubkey: custody.custodyAccount,
4081
4157
  isSigner: false,
@@ -4087,8 +4163,8 @@ var PerpetualsClient = (function () {
4087
4163
  isWritable: false,
4088
4164
  });
4089
4165
  }
4090
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4091
- market = _c[_b];
4166
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4167
+ market = _d[_c];
4092
4168
  markets.push({
4093
4169
  pubkey: market.marketAccount,
4094
4170
  isSigner: false,
@@ -4117,17 +4193,17 @@ var PerpetualsClient = (function () {
4117
4193
  return [3, 5];
4118
4194
  case 2:
4119
4195
  userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
4120
- _d = createUserATA;
4121
- if (!_d) return [3, 4];
4196
+ _e = createUserATA;
4197
+ if (!_e) return [3, 4];
4122
4198
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
4123
4199
  case 3:
4124
- _d = !(_e.sent());
4125
- _e.label = 4;
4200
+ _e = !(_f.sent());
4201
+ _f.label = 4;
4126
4202
  case 4:
4127
- if (_d) {
4203
+ if (_e) {
4128
4204
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
4129
4205
  }
4130
- _e.label = 5;
4206
+ _f.label = 5;
4131
4207
  case 5: return [4, this.program.methods
4132
4208
  .removeLiquidity({
4133
4209
  lpAmountIn: liquidityAmountIn,
@@ -4152,7 +4228,7 @@ var PerpetualsClient = (function () {
4152
4228
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4153
4229
  .instruction()];
4154
4230
  case 6:
4155
- removeLiquidityTx = _e.sent();
4231
+ removeLiquidityTx = _f.sent();
4156
4232
  instructions.push(removeLiquidityTx);
4157
4233
  if (closeLpATA) {
4158
4234
  closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
@@ -4164,7 +4240,7 @@ var PerpetualsClient = (function () {
4164
4240
  }
4165
4241
  return [3, 8];
4166
4242
  case 7:
4167
- err_8 = _e.sent();
4243
+ err_8 = _f.sent();
4168
4244
  console.log("perpClient removeLiquidity error:: ", err_8);
4169
4245
  throw err_8;
4170
4246
  case 8: return [2, {
@@ -4477,22 +4553,26 @@ var PerpetualsClient = (function () {
4477
4553
  }
4478
4554
  });
4479
4555
  }); };
4480
- this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4481
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4482
- return __awaiter(_this, void 0, void 0, function () {
4483
- var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_15;
4484
- return __generator(this, function (_b) {
4485
- switch (_b.label) {
4556
+ this.refreshStakeWithTokenStake = function (rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1) {
4557
+ var args_1 = [];
4558
+ for (var _i = 3; _i < arguments.length; _i++) {
4559
+ args_1[_i - 3] = arguments[_i];
4560
+ }
4561
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4562
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_15;
4563
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4564
+ return __generator(this, function (_c) {
4565
+ switch (_c.label) {
4486
4566
  case 0:
4487
- _b.trys.push([0, 2, , 3]);
4567
+ _c.trys.push([0, 2, , 3]);
4488
4568
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4489
4569
  rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4490
4570
  rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4491
4571
  pool = poolConfig.poolAddress;
4492
4572
  feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4493
4573
  custodyAccountMetas = [];
4494
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4495
- custody = _a[_i];
4574
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4575
+ custody = _b[_a];
4496
4576
  custodyAccountMetas.push({
4497
4577
  pubkey: custody.custodyAccount,
4498
4578
  isSigner: false,
@@ -4524,10 +4604,10 @@ var PerpetualsClient = (function () {
4524
4604
  .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
4525
4605
  .instruction()];
4526
4606
  case 1:
4527
- refreshStakeInstruction = _b.sent();
4607
+ refreshStakeInstruction = _c.sent();
4528
4608
  return [2, refreshStakeInstruction];
4529
4609
  case 2:
4530
- err_15 = _b.sent();
4610
+ err_15 = _c.sent();
4531
4611
  console.log("perpClient refreshStaking error:: ", err_15);
4532
4612
  throw err_15;
4533
4613
  case 3: return [2];
@@ -4535,10 +4615,14 @@ var PerpetualsClient = (function () {
4535
4615
  });
4536
4616
  });
4537
4617
  };
4538
- this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
4539
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4540
- return __awaiter(_this, void 0, void 0, function () {
4618
+ this.unstakeInstant = function (rewardSymbol_1, unstakeAmount_1, poolConfig_1) {
4619
+ var args_1 = [];
4620
+ for (var _i = 3; _i < arguments.length; _i++) {
4621
+ args_1[_i - 3] = arguments[_i];
4622
+ }
4623
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, unstakeAmount_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
4541
4624
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_16;
4625
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4542
4626
  return __generator(this, function (_b) {
4543
4627
  switch (_b.label) {
4544
4628
  case 0:
@@ -4697,13 +4781,17 @@ var PerpetualsClient = (function () {
4697
4781
  }
4698
4782
  });
4699
4783
  }); };
4700
- this.withdrawStake = function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
4701
- if (pendingActivation === void 0) { pendingActivation = true; }
4702
- if (deactivated === void 0) { deactivated = true; }
4703
- if (createUserLPTA === void 0) { createUserLPTA = true; }
4704
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4705
- return __awaiter(_this, void 0, void 0, function () {
4784
+ this.withdrawStake = function (poolConfig_1) {
4785
+ var args_1 = [];
4786
+ for (var _i = 1; _i < arguments.length; _i++) {
4787
+ args_1[_i - 1] = arguments[_i];
4788
+ }
4789
+ return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
4706
4790
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_19;
4791
+ if (pendingActivation === void 0) { pendingActivation = true; }
4792
+ if (deactivated === void 0) { deactivated = true; }
4793
+ if (createUserLPTA === void 0) { createUserLPTA = true; }
4794
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4707
4795
  return __generator(this, function (_b) {
4708
4796
  switch (_b.label) {
4709
4797
  case 0:
@@ -4765,10 +4853,14 @@ var PerpetualsClient = (function () {
4765
4853
  });
4766
4854
  });
4767
4855
  };
4768
- this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
4769
- if (createUserATA === void 0) { createUserATA = true; }
4770
- return __awaiter(_this, void 0, void 0, function () {
4856
+ this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
4857
+ var args_1 = [];
4858
+ for (var _i = 3; _i < arguments.length; _i++) {
4859
+ args_1[_i - 3] = arguments[_i];
4860
+ }
4861
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
4771
4862
  var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_20;
4863
+ if (createUserATA === void 0) { createUserATA = true; }
4772
4864
  return __generator(this, function (_b) {
4773
4865
  switch (_b.label) {
4774
4866
  case 0:
@@ -4838,14 +4930,18 @@ var PerpetualsClient = (function () {
4838
4930
  });
4839
4931
  });
4840
4932
  };
4841
- this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
4842
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4843
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4844
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4845
- return __awaiter(_this, void 0, void 0, function () {
4846
- 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_21;
4847
- return __generator(this, function (_e) {
4848
- switch (_e.label) {
4933
+ this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
4934
+ var args_1 = [];
4935
+ for (var _i = 5; _i < arguments.length; _i++) {
4936
+ args_1[_i - 5] = arguments[_i];
4937
+ }
4938
+ 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) {
4939
+ 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_21;
4940
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4941
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4942
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4943
+ return __generator(this, function (_f) {
4944
+ switch (_f.label) {
4849
4945
  case 0:
4850
4946
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4851
4947
  preInstructions = [];
@@ -4862,8 +4958,8 @@ var PerpetualsClient = (function () {
4862
4958
  custodyAccountMetas = [];
4863
4959
  custodyOracleAccountMetas = [];
4864
4960
  markets = [];
4865
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4866
- custody = _a[_i];
4961
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4962
+ custody = _b[_a];
4867
4963
  custodyAccountMetas.push({
4868
4964
  pubkey: custody.custodyAccount,
4869
4965
  isSigner: false,
@@ -4875,8 +4971,8 @@ var PerpetualsClient = (function () {
4875
4971
  isWritable: false,
4876
4972
  });
4877
4973
  }
4878
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
4879
- market = _c[_b];
4974
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
4975
+ market = _d[_c];
4880
4976
  markets.push({
4881
4977
  pubkey: market.marketAccount,
4882
4978
  isSigner: false,
@@ -4885,26 +4981,26 @@ var PerpetualsClient = (function () {
4885
4981
  }
4886
4982
  return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
4887
4983
  case 1:
4888
- if (!(_e.sent())) {
4984
+ if (!(_f.sent())) {
4889
4985
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
4890
4986
  }
4891
4987
  return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
4892
4988
  case 2:
4893
- if (!(_e.sent())) {
4989
+ if (!(_f.sent())) {
4894
4990
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
4895
4991
  }
4896
4992
  if (!(inTokenSymbol == 'SOL')) return [3, 5];
4897
4993
  console.log("inTokenSymbol === SOL", inTokenSymbol);
4898
4994
  lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
4899
4995
  if (!!skipBalanceChecks) return [3, 4];
4900
- _d = anchor_1.BN.bind;
4996
+ _e = anchor_1.BN.bind;
4901
4997
  return [4, this.provider.connection.getBalance(publicKey)];
4902
4998
  case 3:
4903
- unWrappedSolBalance = new (_d.apply(anchor_1.BN, [void 0, _e.sent()]))();
4999
+ unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
4904
5000
  if (unWrappedSolBalance.lt(lamports)) {
4905
5001
  throw "Insufficient SOL Funds";
4906
5002
  }
4907
- _e.label = 4;
5003
+ _f.label = 4;
4908
5004
  case 4:
4909
5005
  if (!ephemeralSignerPubkey) {
4910
5006
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -4928,12 +5024,12 @@ var PerpetualsClient = (function () {
4928
5024
  if (!!skipBalanceChecks) return [3, 7];
4929
5025
  return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
4930
5026
  case 6:
4931
- if (!(_e.sent())) {
5027
+ if (!(_f.sent())) {
4932
5028
  throw "Insufficient Funds , token Account doesn't exist";
4933
5029
  }
4934
- _e.label = 7;
5030
+ _f.label = 7;
4935
5031
  case 7:
4936
- _e.trys.push([7, 9, , 10]);
5032
+ _f.trys.push([7, 9, , 10]);
4937
5033
  return [4, this.program.methods
4938
5034
  .addCompoundingLiquidity({
4939
5035
  amountIn: amountIn,
@@ -4962,11 +5058,11 @@ var PerpetualsClient = (function () {
4962
5058
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4963
5059
  .instruction()];
4964
5060
  case 8:
4965
- addCompoundingLiquidity = _e.sent();
5061
+ addCompoundingLiquidity = _f.sent();
4966
5062
  instructions.push(addCompoundingLiquidity);
4967
5063
  return [3, 10];
4968
5064
  case 9:
4969
- err_21 = _e.sent();
5065
+ err_21 = _f.sent();
4970
5066
  console.log("perpClient addCompoundingLiquidity error:: ", err_21);
4971
5067
  return [3, 10];
4972
5068
  case 10: return [2, {
@@ -4977,14 +5073,18 @@ var PerpetualsClient = (function () {
4977
5073
  });
4978
5074
  });
4979
5075
  };
4980
- this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey) {
4981
- if (createUserATA === void 0) { createUserATA = true; }
4982
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4983
- if (userPublicKey === void 0) { userPublicKey = undefined; }
4984
- return __awaiter(_this, void 0, void 0, function () {
4985
- 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_22;
4986
- return __generator(this, function (_e) {
4987
- switch (_e.label) {
5076
+ this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
5077
+ var args_1 = [];
5078
+ for (var _i = 5; _i < arguments.length; _i++) {
5079
+ args_1[_i - 5] = arguments[_i];
5080
+ }
5081
+ 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) {
5082
+ 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_22;
5083
+ if (createUserATA === void 0) { createUserATA = true; }
5084
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5085
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
5086
+ return __generator(this, function (_f) {
5087
+ switch (_f.label) {
4988
5088
  case 0:
4989
5089
  publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4990
5090
  preInstructions = [];
@@ -5021,19 +5121,19 @@ var PerpetualsClient = (function () {
5021
5121
  if (!_a) return [3, 3];
5022
5122
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
5023
5123
  case 2:
5024
- _a = !(_e.sent());
5025
- _e.label = 3;
5124
+ _a = !(_f.sent());
5125
+ _f.label = 3;
5026
5126
  case 3:
5027
5127
  if (_a) {
5028
5128
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
5029
5129
  }
5030
- _e.label = 4;
5130
+ _f.label = 4;
5031
5131
  case 4:
5032
5132
  custodyAccountMetas = [];
5033
5133
  custodyOracleAccountMetas = [];
5034
5134
  markets = [];
5035
- for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
5036
- custody = _b[_i];
5135
+ for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
5136
+ custody = _c[_b];
5037
5137
  custodyAccountMetas.push({
5038
5138
  pubkey: custody.custodyAccount,
5039
5139
  isSigner: false,
@@ -5045,8 +5145,8 @@ var PerpetualsClient = (function () {
5045
5145
  isWritable: false,
5046
5146
  });
5047
5147
  }
5048
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
5049
- market = _d[_c];
5148
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
5149
+ market = _e[_d];
5050
5150
  markets.push({
5051
5151
  pubkey: market.marketAccount,
5052
5152
  isSigner: false,
@@ -5054,9 +5154,9 @@ var PerpetualsClient = (function () {
5054
5154
  });
5055
5155
  }
5056
5156
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
5057
- _e.label = 5;
5157
+ _f.label = 5;
5058
5158
  case 5:
5059
- _e.trys.push([5, 7, , 8]);
5159
+ _f.trys.push([5, 7, , 8]);
5060
5160
  return [4, this.program.methods
5061
5161
  .removeCompoundingLiquidity({
5062
5162
  compoundingAmountIn: compoundingAmountIn,
@@ -5085,11 +5185,11 @@ var PerpetualsClient = (function () {
5085
5185
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
5086
5186
  .instruction()];
5087
5187
  case 6:
5088
- removeCompoundingLiquidity = _e.sent();
5188
+ removeCompoundingLiquidity = _f.sent();
5089
5189
  instructions.push(removeCompoundingLiquidity);
5090
5190
  return [3, 8];
5091
5191
  case 7:
5092
- err_22 = _e.sent();
5192
+ err_22 = _f.sent();
5093
5193
  console.log("perpClient removeCompoundingLiquidity error:: ", err_22);
5094
5194
  return [3, 8];
5095
5195
  case 8: return [2, {
@@ -5100,12 +5200,16 @@ var PerpetualsClient = (function () {
5100
5200
  });
5101
5201
  });
5102
5202
  };
5103
- this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
5104
- if (createUserATA === void 0) { createUserATA = true; }
5105
- return __awaiter(_this, void 0, void 0, function () {
5106
- 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_23;
5107
- return __generator(this, function (_f) {
5108
- switch (_f.label) {
5203
+ this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
5204
+ var args_1 = [];
5205
+ for (var _i = 3; _i < arguments.length; _i++) {
5206
+ args_1[_i - 3] = arguments[_i];
5207
+ }
5208
+ return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
5209
+ 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_23;
5210
+ if (createUserATA === void 0) { createUserATA = true; }
5211
+ return __generator(this, function (_g) {
5212
+ switch (_g.label) {
5109
5213
  case 0:
5110
5214
  publicKey = this.provider.wallet.publicKey;
5111
5215
  preInstructions = [];
@@ -5120,8 +5224,8 @@ var PerpetualsClient = (function () {
5120
5224
  if (!_a) return [3, 2];
5121
5225
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
5122
5226
  case 1:
5123
- _a = !(_f.sent());
5124
- _f.label = 2;
5227
+ _a = !(_g.sent());
5228
+ _g.label = 2;
5125
5229
  case 2:
5126
5230
  if (_a) {
5127
5231
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
@@ -5133,8 +5237,8 @@ var PerpetualsClient = (function () {
5133
5237
  if (!_b) return [3, 4];
5134
5238
  return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
5135
5239
  case 3:
5136
- _b = (_f.sent());
5137
- _f.label = 4;
5240
+ _b = (_g.sent());
5241
+ _g.label = 4;
5138
5242
  case 4:
5139
5243
  if (_b) {
5140
5244
  tokenStakeAccounts.push({
@@ -5147,8 +5251,8 @@ var PerpetualsClient = (function () {
5147
5251
  custodyAccountMetas = [];
5148
5252
  custodyOracleAccountMetas = [];
5149
5253
  markets = [];
5150
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
5151
- custody = _c[_i];
5254
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
5255
+ custody = _d[_c];
5152
5256
  custodyAccountMetas.push({
5153
5257
  pubkey: custody.custodyAccount,
5154
5258
  isSigner: false,
@@ -5160,17 +5264,17 @@ var PerpetualsClient = (function () {
5160
5264
  isWritable: false,
5161
5265
  });
5162
5266
  }
5163
- for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
5164
- market = _e[_d];
5267
+ for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
5268
+ market = _f[_e];
5165
5269
  markets.push({
5166
5270
  pubkey: market.marketAccount,
5167
5271
  isSigner: false,
5168
5272
  isWritable: false,
5169
5273
  });
5170
5274
  }
5171
- _f.label = 5;
5275
+ _g.label = 5;
5172
5276
  case 5:
5173
- _f.trys.push([5, 7, , 8]);
5277
+ _g.trys.push([5, 7, , 8]);
5174
5278
  return [4, this.program.methods
5175
5279
  .migrateStake({
5176
5280
  amount: amount
@@ -5196,11 +5300,11 @@ var PerpetualsClient = (function () {
5196
5300
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
5197
5301
  .instruction()];
5198
5302
  case 6:
5199
- migrateStake = _f.sent();
5303
+ migrateStake = _g.sent();
5200
5304
  instructions.push(migrateStake);
5201
5305
  return [3, 8];
5202
5306
  case 7:
5203
- err_23 = _f.sent();
5307
+ err_23 = _g.sent();
5204
5308
  console.log("perpClient migrateStake error:: ", err_23);
5205
5309
  return [3, 8];
5206
5310
  case 8: return [2, {
@@ -5294,12 +5398,16 @@ var PerpetualsClient = (function () {
5294
5398
  }
5295
5399
  });
5296
5400
  }); };
5297
- this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
5298
- if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
5299
- return __awaiter(_this, void 0, void 0, function () {
5300
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_25;
5301
- return __generator(this, function (_d) {
5302
- switch (_d.label) {
5401
+ this.compoundingFee = function (poolConfig_1) {
5402
+ var args_1 = [];
5403
+ for (var _i = 1; _i < arguments.length; _i++) {
5404
+ args_1[_i - 1] = arguments[_i];
5405
+ }
5406
+ return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
5407
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_25;
5408
+ if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
5409
+ return __generator(this, function (_e) {
5410
+ switch (_e.label) {
5303
5411
  case 0:
5304
5412
  instructions = [];
5305
5413
  additionalSigners = [];
@@ -5308,8 +5416,8 @@ var PerpetualsClient = (function () {
5308
5416
  custodyAccountMetas = [];
5309
5417
  custodyOracleAccountMetas = [];
5310
5418
  markets = [];
5311
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
5312
- custody = _a[_i];
5419
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
5420
+ custody = _b[_a];
5313
5421
  custodyAccountMetas.push({
5314
5422
  pubkey: custody.custodyAccount,
5315
5423
  isSigner: false,
@@ -5321,17 +5429,17 @@ var PerpetualsClient = (function () {
5321
5429
  isWritable: false,
5322
5430
  });
5323
5431
  }
5324
- for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
5325
- market = _c[_b];
5432
+ for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
5433
+ market = _d[_c];
5326
5434
  markets.push({
5327
5435
  pubkey: market.marketAccount,
5328
5436
  isSigner: false,
5329
5437
  isWritable: false,
5330
5438
  });
5331
5439
  }
5332
- _d.label = 1;
5440
+ _e.label = 1;
5333
5441
  case 1:
5334
- _d.trys.push([1, 3, , 4]);
5442
+ _e.trys.push([1, 3, , 4]);
5335
5443
  return [4, this.program.methods
5336
5444
  .compoundFees({})
5337
5445
  .accounts({
@@ -5350,11 +5458,11 @@ var PerpetualsClient = (function () {
5350
5458
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
5351
5459
  .instruction()];
5352
5460
  case 2:
5353
- compoundingFee = _d.sent();
5461
+ compoundingFee = _e.sent();
5354
5462
  instructions.push(compoundingFee);
5355
5463
  return [3, 4];
5356
5464
  case 3:
5357
- err_25 = _d.sent();
5465
+ err_25 = _e.sent();
5358
5466
  console.log("perpClient compoundingFee error:: ", err_25);
5359
5467
  return [3, 4];
5360
5468
  case 4: return [2, {
@@ -5736,10 +5844,14 @@ var PerpetualsClient = (function () {
5736
5844
  }
5737
5845
  });
5738
5846
  }); };
5739
- this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5740
- if (createUserATA === void 0) { createUserATA = true; }
5741
- return __awaiter(_this, void 0, void 0, function () {
5847
+ this.collectTokenReward = function (owner_1, poolConfig_1) {
5848
+ var args_1 = [];
5849
+ for (var _i = 2; _i < arguments.length; _i++) {
5850
+ args_1[_i - 2] = arguments[_i];
5851
+ }
5852
+ return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5742
5853
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_33;
5854
+ if (createUserATA === void 0) { createUserATA = true; }
5743
5855
  return __generator(this, function (_b) {
5744
5856
  switch (_b.label) {
5745
5857
  case 0:
@@ -5794,10 +5906,14 @@ var PerpetualsClient = (function () {
5794
5906
  });
5795
5907
  });
5796
5908
  };
5797
- this.collectRevenue = function (owner, rewardSymbol, poolConfig, createUserATA) {
5798
- if (createUserATA === void 0) { createUserATA = true; }
5799
- return __awaiter(_this, void 0, void 0, function () {
5909
+ this.collectRevenue = function (owner_1, rewardSymbol_1, poolConfig_1) {
5910
+ var args_1 = [];
5911
+ for (var _i = 3; _i < arguments.length; _i++) {
5912
+ args_1[_i - 3] = arguments[_i];
5913
+ }
5914
+ return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
5800
5915
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_34;
5916
+ if (createUserATA === void 0) { createUserATA = true; }
5801
5917
  return __generator(this, function (_b) {
5802
5918
  switch (_b.label) {
5803
5919
  case 0:
@@ -5943,10 +6059,14 @@ var PerpetualsClient = (function () {
5943
6059
  }
5944
6060
  });
5945
6061
  }); };
5946
- this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5947
- if (createUserATA === void 0) { createUserATA = true; }
5948
- return __awaiter(_this, void 0, void 0, function () {
6062
+ this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
6063
+ var args_1 = [];
6064
+ for (var _i = 3; _i < arguments.length; _i++) {
6065
+ args_1[_i - 3] = arguments[_i];
6066
+ }
6067
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5949
6068
  var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_37;
6069
+ if (createUserATA === void 0) { createUserATA = true; }
5950
6070
  return __generator(this, function (_b) {
5951
6071
  switch (_b.label) {
5952
6072
  case 0:
@@ -6006,10 +6126,14 @@ var PerpetualsClient = (function () {
6006
6126
  });
6007
6127
  });
6008
6128
  };
6009
- this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6010
- if (createUserATA === void 0) { createUserATA = true; }
6011
- return __awaiter(_this, void 0, void 0, function () {
6129
+ this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
6130
+ var args_1 = [];
6131
+ for (var _i = 2; _i < arguments.length; _i++) {
6132
+ args_1[_i - 2] = arguments[_i];
6133
+ }
6134
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
6012
6135
  var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_38;
6136
+ if (createUserATA === void 0) { createUserATA = true; }
6013
6137
  return __generator(this, function (_b) {
6014
6138
  switch (_b.label) {
6015
6139
  case 0:
@@ -6134,12 +6258,16 @@ var PerpetualsClient = (function () {
6134
6258
  }
6135
6259
  });
6136
6260
  }); };
6137
- this.forceClosePosition = function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6138
- if (createUserATA === void 0) { createUserATA = true; }
6139
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6140
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6141
- return __awaiter(_this, void 0, void 0, function () {
6261
+ this.forceClosePosition = function (positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
6262
+ var args_1 = [];
6263
+ for (var _i = 6; _i < arguments.length; _i++) {
6264
+ args_1[_i - 6] = arguments[_i];
6265
+ }
6266
+ return __awaiter(_this, __spreadArray([positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1], args_1, true), void 0, function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6142
6267
  var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_40;
6268
+ if (createUserATA === void 0) { createUserATA = true; }
6269
+ if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6270
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6143
6271
  return __generator(this, function (_b) {
6144
6272
  switch (_b.label) {
6145
6273
  case 0:
@@ -6211,11 +6339,15 @@ var PerpetualsClient = (function () {
6211
6339
  });
6212
6340
  });
6213
6341
  };
6214
- this.placeLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
6215
- if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6216
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6217
- return __awaiter(_this, void 0, void 0, function () {
6342
+ 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) {
6343
+ var args_1 = [];
6344
+ for (var _i = 11; _i < arguments.length; _i++) {
6345
+ args_1[_i - 11] = arguments[_i];
6346
+ }
6347
+ 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) {
6218
6348
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_41;
6349
+ if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6350
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6219
6351
  return __generator(this, function (_c) {
6220
6352
  switch (_c.label) {
6221
6353
  case 0:
@@ -6331,11 +6463,15 @@ var PerpetualsClient = (function () {
6331
6463
  });
6332
6464
  });
6333
6465
  };
6334
- this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6335
- if (createUserATA === void 0) { createUserATA = true; }
6336
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6337
- return __awaiter(_this, void 0, void 0, function () {
6466
+ 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) {
6467
+ var args_1 = [];
6468
+ for (var _i = 11; _i < arguments.length; _i++) {
6469
+ args_1[_i - 11] = arguments[_i];
6470
+ }
6471
+ 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) {
6338
6472
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_42;
6473
+ if (createUserATA === void 0) { createUserATA = true; }
6474
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6339
6475
  return __generator(this, function (_b) {
6340
6476
  switch (_b.label) {
6341
6477
  case 0:
@@ -6434,12 +6570,16 @@ var PerpetualsClient = (function () {
6434
6570
  });
6435
6571
  });
6436
6572
  };
6437
- this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6438
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6439
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6440
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6441
- return __awaiter(_this, void 0, void 0, function () {
6573
+ this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6574
+ var args_1 = [];
6575
+ for (var _i = 7; _i < arguments.length; _i++) {
6576
+ args_1[_i - 7] = arguments[_i];
6577
+ }
6578
+ 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) {
6442
6579
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_43;
6580
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6581
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6582
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6443
6583
  return __generator(this, function (_a) {
6444
6584
  switch (_a.label) {
6445
6585
  case 0:
@@ -6499,12 +6639,16 @@ var PerpetualsClient = (function () {
6499
6639
  });
6500
6640
  });
6501
6641
  };
6502
- this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6503
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6504
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6505
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6506
- return __awaiter(_this, void 0, void 0, function () {
6642
+ this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
6643
+ var args_1 = [];
6644
+ for (var _i = 8; _i < arguments.length; _i++) {
6645
+ args_1[_i - 8] = arguments[_i];
6646
+ }
6647
+ 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) {
6507
6648
  var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_44;
6649
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6650
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6651
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6508
6652
  return __generator(this, function (_a) {
6509
6653
  switch (_a.label) {
6510
6654
  case 0:
@@ -6770,16 +6914,20 @@ var PerpetualsClient = (function () {
6770
6914
  }
6771
6915
  });
6772
6916
  }); };
6773
- this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6774
- if (createUserATA === void 0) { createUserATA = true; }
6775
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6776
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6777
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6778
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6779
- return __awaiter(_this, void 0, void 0, function () {
6780
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_49;
6781
- return __generator(this, function (_d) {
6782
- switch (_d.label) {
6917
+ this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
6918
+ var args_1 = [];
6919
+ for (var _i = 9; _i < arguments.length; _i++) {
6920
+ args_1[_i - 9] = arguments[_i];
6921
+ }
6922
+ 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) {
6923
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_49;
6924
+ if (createUserATA === void 0) { createUserATA = true; }
6925
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6926
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6927
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6928
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6929
+ return __generator(this, function (_e) {
6930
+ switch (_e.label) {
6783
6931
  case 0:
6784
6932
  payerPubkey = this.provider.wallet.publicKey;
6785
6933
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
@@ -6790,9 +6938,9 @@ var PerpetualsClient = (function () {
6790
6938
  instructions = [];
6791
6939
  postInstructions = [];
6792
6940
  additionalSigners = [];
6793
- _d.label = 1;
6941
+ _e.label = 1;
6794
6942
  case 1:
6795
- _d.trys.push([1, 9, , 10]);
6943
+ _e.trys.push([1, 9, , 10]);
6796
6944
  if (!false) return [3, 2];
6797
6945
  return [3, 7];
6798
6946
  case 2:
@@ -6801,8 +6949,8 @@ var PerpetualsClient = (function () {
6801
6949
  if (!_a) return [3, 4];
6802
6950
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6803
6951
  case 3:
6804
- _a = !(_d.sent());
6805
- _d.label = 4;
6952
+ _a = !(_e.sent());
6953
+ _e.label = 4;
6806
6954
  case 4:
6807
6955
  if (_a) {
6808
6956
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
@@ -6812,20 +6960,20 @@ var PerpetualsClient = (function () {
6812
6960
  if (!_b) return [3, 6];
6813
6961
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
6814
6962
  case 5:
6815
- _b = !(_d.sent());
6816
- _d.label = 6;
6963
+ _b = !(_e.sent());
6964
+ _e.label = 6;
6817
6965
  case 6:
6818
6966
  if (_b) {
6819
6967
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
6820
6968
  }
6821
- _d.label = 7;
6969
+ _e.label = 7;
6822
6970
  case 7:
6823
6971
  positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
6824
6972
  orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
6825
6973
  custodyAccountMetas = [];
6826
6974
  custodyOracleAccountMetas = [];
6827
- for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
6828
- custody = _c[_i];
6975
+ for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
6976
+ custody = _d[_c];
6829
6977
  custodyAccountMetas.push({
6830
6978
  pubkey: custody.custodyAccount,
6831
6979
  isSigner: false,
@@ -6870,11 +7018,11 @@ var PerpetualsClient = (function () {
6870
7018
  .remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
6871
7019
  .instruction()];
6872
7020
  case 8:
6873
- executeTriggerWithSwap = _d.sent();
7021
+ executeTriggerWithSwap = _e.sent();
6874
7022
  instructions.push(executeTriggerWithSwap);
6875
7023
  return [3, 10];
6876
7024
  case 9:
6877
- err_49 = _d.sent();
7025
+ err_49 = _e.sent();
6878
7026
  console.log("perpClient executeTriggerWithSwap error:: ", err_49);
6879
7027
  throw err_49;
6880
7028
  case 10: return [2, {
@@ -6885,14 +7033,18 @@ var PerpetualsClient = (function () {
6885
7033
  });
6886
7034
  });
6887
7035
  };
6888
- this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6889
- if (createUserATA === void 0) { createUserATA = true; }
6890
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6891
- if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6892
- if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6893
- if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6894
- return __awaiter(_this, void 0, void 0, function () {
7036
+ this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
7037
+ var args_1 = [];
7038
+ for (var _i = 8; _i < arguments.length; _i++) {
7039
+ args_1[_i - 8] = arguments[_i];
7040
+ }
7041
+ 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) {
6895
7042
  var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_50;
7043
+ if (createUserATA === void 0) { createUserATA = true; }
7044
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7045
+ if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
7046
+ if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
7047
+ if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6896
7048
  return __generator(this, function (_b) {
6897
7049
  switch (_b.label) {
6898
7050
  case 0:
@@ -8237,9 +8389,9 @@ var PerpetualsClient = (function () {
8237
8389
  }
8238
8390
  }
8239
8391
  };
8240
- PerpetualsClient.prototype.sendTransaction = function (ixs, opts) {
8241
- if (opts === void 0) { opts = {}; }
8242
- return __awaiter(this, void 0, void 0, function () {
8392
+ PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
8393
+ return __awaiter(this, arguments, void 0, function (ixs, opts) {
8394
+ if (opts === void 0) { opts = {}; }
8243
8395
  return __generator(this, function (_a) {
8244
8396
  switch (_a.label) {
8245
8397
  case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
@@ -8248,9 +8400,9 @@ var PerpetualsClient = (function () {
8248
8400
  });
8249
8401
  });
8250
8402
  };
8251
- PerpetualsClient.prototype.sendTransactionV3 = function (ixs, opts) {
8252
- if (opts === void 0) { opts = {}; }
8253
- return __awaiter(this, void 0, void 0, function () {
8403
+ PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
8404
+ return __awaiter(this, arguments, void 0, function (ixs, opts) {
8405
+ if (opts === void 0) { opts = {}; }
8254
8406
  return __generator(this, function (_a) {
8255
8407
  switch (_a.label) {
8256
8408
  case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];