flash-sdk 11.1.1-alpha.0 → 11.1.1-alpha.10

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.
@@ -1676,7 +1676,8 @@ var PerpetualsClient = (function () {
1676
1676
  };
1677
1677
  }
1678
1678
  };
1679
- this.getSwapAmountAndFeesSync = function (amountIn, amountOut, poolAccount, inputTokenPrice, inputTokenEmaPrice, inputTokenCustodyAccount, outputTokenPrice, outputTokenEmaPrice, outputTokenCustodyAccount, poolAumUsdMax, poolConfig) {
1679
+ this.getSwapAmountAndFeesSync = function (amountIn, amountOut, poolAccount, inputTokenPrice, inputTokenEmaPrice, inputTokenCustodyAccount, outputTokenPrice, outputTokenEmaPrice, outputTokenCustodyAccount, poolAumUsdMax, poolConfig, whitelistedUserAccount) {
1680
+ if (whitelistedUserAccount === void 0) { whitelistedUserAccount = null; }
1680
1681
  if (!amountIn.isZero() && !amountOut.isZero()) {
1681
1682
  throw new Error("both amountIn and amountOut cannot be non-zero");
1682
1683
  }
@@ -1688,6 +1689,12 @@ var PerpetualsClient = (function () {
1688
1689
  feeOut: constants_1.BN_ZERO,
1689
1690
  };
1690
1691
  }
1692
+ var isWhitelistedUser = false;
1693
+ if (whitelistedUserAccount && whitelistedUserAccount.isInitialized) {
1694
+ if (whitelistedUserAccount.pool.equals(poolAccount.publicKey) || whitelistedUserAccount.pool.equals(web3_js_1.PublicKey.default)) {
1695
+ isWhitelistedUser = true;
1696
+ }
1697
+ }
1691
1698
  var newInputTokenPrice, newInputTokenEmaPrice;
1692
1699
  var newOutputTokenPrice, newOutputTokenEmaPrice;
1693
1700
  if (inputTokenPrice.exponent.lte(outputTokenPrice.exponent)) {
@@ -1723,8 +1730,10 @@ var PerpetualsClient = (function () {
1723
1730
  }
1724
1731
  var swapPrice = pairPrice.sub(pairPrice.mul(outputTokenCustodyAccount.pricing.swapSpread).div(new anchor_1.BN(constants_1.BPS_POWER)));
1725
1732
  inputTokenAmount = (0, utils_1.checkedDecimalMul)(amountOut, new anchor_1.BN(-1 * outputTokenCustodyAccount.decimals), swapPrice, inputMinMaxPrice.min.exponent, new anchor_1.BN(-1 * inputTokenCustodyAccount.decimals));
1726
- feeIn = _this.getFeeHelper(types_1.FeesAction.SwapIn, inputTokenAmount, constants_1.BN_ZERO, inputTokenCustodyAccount, inputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1727
- feeOut = _this.getFeeHelper(types_1.FeesAction.SwapOut, constants_1.BN_ZERO, amountOut, outputTokenCustodyAccount, outputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1733
+ feeIn = isWhitelistedUser ? constants_1.BN_ZERO
1734
+ : _this.getFeeHelper(types_1.FeesAction.SwapIn, inputTokenAmount, constants_1.BN_ZERO, inputTokenCustodyAccount, inputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1735
+ feeOut = isWhitelistedUser ? constants_1.BN_ZERO
1736
+ : _this.getFeeHelper(types_1.FeesAction.SwapOut, constants_1.BN_ZERO, amountOut, outputTokenCustodyAccount, outputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1728
1737
  var swapAmount = (0, utils_1.checkedDecimalMul)(amountOut.add(feeOut), new anchor_1.BN(-1 * outputTokenCustodyAccount.decimals), swapPrice, inputMinMaxPrice.min.exponent, new anchor_1.BN(-1 * inputTokenCustodyAccount.decimals)).add(feeIn);
1729
1738
  return {
1730
1739
  minAmountIn: swapAmount,
@@ -1744,8 +1753,10 @@ var PerpetualsClient = (function () {
1744
1753
  }
1745
1754
  var swapPrice = pairPrice.sub(pairPrice.mul(inputTokenCustodyAccount.pricing.swapSpread).div(new anchor_1.BN(constants_1.BPS_POWER)));
1746
1755
  outputTokenAmount = (0, utils_1.checkedDecimalMul)(amountIn, new anchor_1.BN(-1 * inputTokenCustodyAccount.decimals), swapPrice, inputMinMaxPrice.min.exponent, new anchor_1.BN(-1 * outputTokenCustodyAccount.decimals));
1747
- feeIn = _this.getFeeHelper(types_1.FeesAction.SwapIn, amountIn, constants_1.BN_ZERO, inputTokenCustodyAccount, inputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1748
- feeOut = _this.getFeeHelper(types_1.FeesAction.SwapOut, constants_1.BN_ZERO, outputTokenAmount, outputTokenCustodyAccount, outputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1756
+ feeIn = isWhitelistedUser ? constants_1.BN_ZERO
1757
+ : _this.getFeeHelper(types_1.FeesAction.SwapIn, amountIn, constants_1.BN_ZERO, inputTokenCustodyAccount, inputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1758
+ feeOut = isWhitelistedUser ? constants_1.BN_ZERO
1759
+ : _this.getFeeHelper(types_1.FeesAction.SwapOut, constants_1.BN_ZERO, outputTokenAmount, outputTokenCustodyAccount, outputMinMaxPrice.max, poolAumUsdMax, poolAccount, poolConfig).feeAmount;
1749
1760
  var swapAmount = (0, utils_1.checkedDecimalMul)(amountIn.sub(feeIn), new anchor_1.BN(-1 * inputTokenCustodyAccount.decimals), swapPrice, inputMinMaxPrice.min.exponent, new anchor_1.BN(-1 * outputTokenCustodyAccount.decimals)).sub(feeOut);
1750
1761
  return {
1751
1762
  minAmountIn: constants_1.BN_ZERO,
@@ -1993,11 +2004,12 @@ var PerpetualsClient = (function () {
1993
2004
  for (var _i = 4; _i < arguments.length; _i++) {
1994
2005
  args_1[_i - 4] = arguments[_i];
1995
2006
  }
1996
- 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, enableBackupOracle) {
1997
- var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2007
+ 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, enableBackupOracle, whitelist) {
2008
+ var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
1998
2009
  var _e;
1999
2010
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2000
2011
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
2012
+ if (whitelist === void 0) { whitelist = undefined; }
2001
2013
  return __generator(this, function (_f) {
2002
2014
  switch (_f.label) {
2003
2015
  case 0:
@@ -2028,6 +2040,11 @@ var PerpetualsClient = (function () {
2028
2040
  isWritable: false,
2029
2041
  });
2030
2042
  }
2043
+ whitelistMeta = {
2044
+ pubkey: whitelist,
2045
+ isSigner: false,
2046
+ isWritable: false,
2047
+ };
2031
2048
  depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2032
2049
  return [4, this.program.methods
2033
2050
  .getAddLiquidityAmountAndFee({
@@ -2041,7 +2058,7 @@ var PerpetualsClient = (function () {
2041
2058
  lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2042
2059
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2043
2060
  })
2044
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2061
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
2045
2062
  .transaction()];
2046
2063
  case 1:
2047
2064
  transaction = _f.sent();
@@ -2079,11 +2096,12 @@ var PerpetualsClient = (function () {
2079
2096
  for (var _i = 4; _i < arguments.length; _i++) {
2080
2097
  args_1[_i - 4] = arguments[_i];
2081
2098
  }
2082
- 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, enableBackupOracle) {
2083
- var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2099
+ 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, enableBackupOracle, whitelist) {
2100
+ var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2084
2101
  var _e;
2085
2102
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2086
2103
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
2104
+ if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
2087
2105
  return __generator(this, function (_f) {
2088
2106
  switch (_f.label) {
2089
2107
  case 0:
@@ -2114,6 +2132,11 @@ var PerpetualsClient = (function () {
2114
2132
  isWritable: false,
2115
2133
  });
2116
2134
  }
2135
+ whitelistMeta = {
2136
+ pubkey: whitelist,
2137
+ isSigner: false,
2138
+ isWritable: false,
2139
+ };
2117
2140
  removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2118
2141
  return [4, this.program.methods
2119
2142
  .getRemoveLiquidityAmountAndFee({
@@ -2127,7 +2150,7 @@ var PerpetualsClient = (function () {
2127
2150
  lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2128
2151
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2129
2152
  })
2130
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2153
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
2131
2154
  .transaction()];
2132
2155
  case 1:
2133
2156
  transaction = _f.sent();
@@ -2226,11 +2249,12 @@ var PerpetualsClient = (function () {
2226
2249
  for (var _i = 4; _i < arguments.length; _i++) {
2227
2250
  args_1[_i - 4] = arguments[_i];
2228
2251
  }
2229
- 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, enableBackupOracle) {
2230
- var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2252
+ 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, enableBackupOracle, whitelist) {
2253
+ var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2231
2254
  var _e;
2232
2255
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2233
2256
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
2257
+ if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
2234
2258
  return __generator(this, function (_f) {
2235
2259
  switch (_f.label) {
2236
2260
  case 0:
@@ -2261,6 +2285,11 @@ var PerpetualsClient = (function () {
2261
2285
  isWritable: false,
2262
2286
  });
2263
2287
  }
2288
+ whitelistMeta = {
2289
+ pubkey: whitelist,
2290
+ isSigner: false,
2291
+ isWritable: false,
2292
+ };
2264
2293
  depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2265
2294
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2266
2295
  return [4, this.program.methods
@@ -2278,7 +2307,7 @@ var PerpetualsClient = (function () {
2278
2307
  compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
2279
2308
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2280
2309
  })
2281
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2310
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
2282
2311
  .transaction()];
2283
2312
  case 1:
2284
2313
  transaction = _f.sent();
@@ -2308,11 +2337,12 @@ var PerpetualsClient = (function () {
2308
2337
  for (var _i = 4; _i < arguments.length; _i++) {
2309
2338
  args_1[_i - 4] = arguments[_i];
2310
2339
  }
2311
- 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, enableBackupOracle) {
2312
- var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2340
+ 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, enableBackupOracle, whitelist) {
2341
+ var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2313
2342
  var _e;
2314
2343
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2315
2344
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
2345
+ if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
2316
2346
  return __generator(this, function (_f) {
2317
2347
  switch (_f.label) {
2318
2348
  case 0:
@@ -2343,6 +2373,11 @@ var PerpetualsClient = (function () {
2343
2373
  isWritable: false,
2344
2374
  });
2345
2375
  }
2376
+ whitelistMeta = {
2377
+ pubkey: whitelist,
2378
+ isSigner: false,
2379
+ isWritable: false,
2380
+ };
2346
2381
  removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2347
2382
  rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2348
2383
  return [4, this.program.methods
@@ -2360,7 +2395,7 @@ var PerpetualsClient = (function () {
2360
2395
  lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2361
2396
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2362
2397
  })
2363
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2398
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
2364
2399
  .transaction()];
2365
2400
  case 1:
2366
2401
  transaction = _f.sent();
@@ -3627,7 +3662,7 @@ var PerpetualsClient = (function () {
3627
3662
  args_1[_i - 4] = arguments[_i];
3628
3663
  }
3629
3664
  return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3630
- var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, whitelistPda, whitelistExists, instruction, err_5;
3665
+ var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, whitelistPda, whitelistMeta, instruction, err_5;
3631
3666
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3632
3667
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3633
3668
  return __generator(this, function (_g) {
@@ -3645,7 +3680,7 @@ var PerpetualsClient = (function () {
3645
3680
  payToken = poolConfig.getTokenFromSymbol(payTokenSymbol);
3646
3681
  _g.label = 1;
3647
3682
  case 1:
3648
- _g.trys.push([1, 11, , 12]);
3683
+ _g.trys.push([1, 10, , 11]);
3649
3684
  userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true, payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
3650
3685
  lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
3651
3686
  custodyAccountMetas = [];
@@ -3724,10 +3759,12 @@ var PerpetualsClient = (function () {
3724
3759
  }
3725
3760
  _g.label = 8;
3726
3761
  case 8:
3727
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
3728
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
3729
- case 9:
3730
- whitelistExists = _g.sent();
3762
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
3763
+ whitelistMeta = {
3764
+ pubkey: whitelistPda,
3765
+ isSigner: false,
3766
+ isWritable: false,
3767
+ };
3731
3768
  return [4, this.program.methods
3732
3769
  .addLiquidity({
3733
3770
  amountIn: tokenAmountIn,
@@ -3750,19 +3787,18 @@ var PerpetualsClient = (function () {
3750
3787
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
3751
3788
  fundingMint: payTokenCustodyConfig.mintKey,
3752
3789
  fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
3753
- whitelist: whitelistExists ? whitelistPda : undefined,
3754
3790
  })
3755
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
3791
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
3756
3792
  .instruction()];
3757
- case 10:
3793
+ case 9:
3758
3794
  instruction = _g.sent();
3759
3795
  instructions.push(instruction);
3760
- return [3, 12];
3761
- case 11:
3796
+ return [3, 11];
3797
+ case 10:
3762
3798
  err_5 = _g.sent();
3763
3799
  console.error("perpClient addLiquidity error:: ", err_5);
3764
3800
  throw err_5;
3765
- case 12: return [2, {
3801
+ case 11: return [2, {
3766
3802
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
3767
3803
  additionalSigners: additionalSigners
3768
3804
  }];
@@ -3776,7 +3812,7 @@ var PerpetualsClient = (function () {
3776
3812
  args_1[_i - 4] = arguments[_i];
3777
3813
  }
3778
3814
  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) {
3779
- var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, inputToken, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, whitelistPda, whitelistExists, instruction;
3815
+ var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, inputToken, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, whitelistPda, whitelistMeta, instruction;
3780
3816
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3781
3817
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3782
3818
  if (userPublicKey === void 0) { userPublicKey = undefined; }
@@ -3871,10 +3907,12 @@ var PerpetualsClient = (function () {
3871
3907
  isWritable: false,
3872
3908
  });
3873
3909
  }
3874
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
3875
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
3876
- case 8:
3877
- whitelistExists = _g.sent();
3910
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
3911
+ whitelistMeta = {
3912
+ pubkey: whitelistPda,
3913
+ isSigner: false,
3914
+ isWritable: false,
3915
+ };
3878
3916
  return [4, this.program.methods.addLiquidityAndStake({
3879
3917
  amountIn: amountIn,
3880
3918
  minLpAmountOut: minLpAmountOut,
@@ -3898,11 +3936,10 @@ var PerpetualsClient = (function () {
3898
3936
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
3899
3937
  fundingMint: inputCustodyConfig.mintKey,
3900
3938
  fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
3901
- whitelist: whitelistExists ? whitelistPda : undefined,
3902
3939
  })
3903
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
3940
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
3904
3941
  .instruction()];
3905
- case 9:
3942
+ case 8:
3906
3943
  instruction = _g.sent();
3907
3944
  instructions.push(instruction);
3908
3945
  return [2, {
@@ -3919,7 +3956,7 @@ var PerpetualsClient = (function () {
3919
3956
  args_1[_i - 4] = arguments[_i];
3920
3957
  }
3921
3958
  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) {
3922
- var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, whitelistPda, whitelistExists, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
3959
+ var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, whitelistPda, whitelistMeta, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
3923
3960
  if (closeLpATA === void 0) { closeLpATA = false; }
3924
3961
  if (createUserATA === void 0) { createUserATA = true; }
3925
3962
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
@@ -3940,7 +3977,7 @@ var PerpetualsClient = (function () {
3940
3977
  recieveToken = poolConfig.getTokenFromSymbol(recieveTokenSymbol);
3941
3978
  _f.label = 1;
3942
3979
  case 1:
3943
- _f.trys.push([1, 8, , 9]);
3980
+ _f.trys.push([1, 7, , 8]);
3944
3981
  stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
3945
3982
  custodyAccountMetas = [];
3946
3983
  custodyOracleAccountMetas = [];
@@ -4000,10 +4037,12 @@ var PerpetualsClient = (function () {
4000
4037
  }
4001
4038
  _f.label = 5;
4002
4039
  case 5:
4003
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
4004
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
4005
- case 6:
4006
- whitelistExists = _f.sent();
4040
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
4041
+ whitelistMeta = {
4042
+ pubkey: whitelistPda,
4043
+ isSigner: false,
4044
+ isWritable: false,
4045
+ };
4007
4046
  return [4, this.program.methods
4008
4047
  .removeLiquidity({
4009
4048
  lpAmountIn: liquidityAmountIn,
@@ -4026,11 +4065,10 @@ var PerpetualsClient = (function () {
4026
4065
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
4027
4066
  receivingMint: recieveTokenCustodyConfig.mintKey,
4028
4067
  receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
4029
- whitelist: whitelistExists ? whitelistPda : undefined,
4030
4068
  })
4031
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4069
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
4032
4070
  .instruction()];
4033
- case 7:
4071
+ case 6:
4034
4072
  removeLiquidityTx = _f.sent();
4035
4073
  instructions.push(removeLiquidityTx);
4036
4074
  if (closeLpATA) {
@@ -4041,12 +4079,12 @@ var PerpetualsClient = (function () {
4041
4079
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
4042
4080
  postInstructions.push(closeWsolATAIns);
4043
4081
  }
4044
- return [3, 9];
4045
- case 8:
4082
+ return [3, 8];
4083
+ case 7:
4046
4084
  err_6 = _f.sent();
4047
4085
  console.log("perpClient removeLiquidity error:: ", err_6);
4048
4086
  throw err_6;
4049
- case 9: return [2, {
4087
+ case 8: return [2, {
4050
4088
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4051
4089
  additionalSigners: additionalSigners
4052
4090
  }];
@@ -4585,7 +4623,7 @@ var PerpetualsClient = (function () {
4585
4623
  args_1[_i - 5] = arguments[_i];
4586
4624
  }
4587
4625
  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, enableHeapSizeIx, enableDebugLogs) {
4588
- 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, heapSizeIx, whitelistPda, whitelistExists, addCompoundingLiquidity, err_16;
4626
+ 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, heapSizeIx, whitelistPda, whitelistMeta, addCompoundingLiquidity, err_16;
4589
4627
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4590
4628
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4591
4629
  if (userPublicKey === void 0) { userPublicKey = undefined; }
@@ -4680,7 +4718,7 @@ var PerpetualsClient = (function () {
4680
4718
  }
4681
4719
  _f.label = 7;
4682
4720
  case 7:
4683
- _f.trys.push([7, 10, , 11]);
4721
+ _f.trys.push([7, 9, , 10]);
4684
4722
  if (enableHeapSizeIx) {
4685
4723
  heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
4686
4724
  bytes: 64 * 1024,
@@ -4690,10 +4728,12 @@ var PerpetualsClient = (function () {
4690
4728
  }
4691
4729
  preInstructions.push(heapSizeIx);
4692
4730
  }
4693
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
4694
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
4695
- case 8:
4696
- whitelistExists = _f.sent();
4731
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
4732
+ whitelistMeta = {
4733
+ pubkey: whitelistPda,
4734
+ isSigner: false,
4735
+ isWritable: false,
4736
+ };
4697
4737
  return [4, this.program.methods
4698
4738
  .addCompoundingLiquidity({
4699
4739
  amountIn: amountIn,
@@ -4720,19 +4760,18 @@ var PerpetualsClient = (function () {
4720
4760
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
4721
4761
  fundingMint: inCustodyConfig.mintKey,
4722
4762
  fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
4723
- whitelist: whitelistExists ? whitelistPda : undefined,
4724
4763
  })
4725
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4764
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
4726
4765
  .instruction()];
4727
- case 9:
4766
+ case 8:
4728
4767
  addCompoundingLiquidity = _f.sent();
4729
4768
  instructions.push(addCompoundingLiquidity);
4730
- return [3, 11];
4731
- case 10:
4769
+ return [3, 10];
4770
+ case 9:
4732
4771
  err_16 = _f.sent();
4733
4772
  console.log("perpClient addCompoundingLiquidity error:: ", err_16);
4734
- return [3, 11];
4735
- case 11: return [2, {
4773
+ return [3, 10];
4774
+ case 10: return [2, {
4736
4775
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4737
4776
  additionalSigners: additionalSigners
4738
4777
  }];
@@ -4746,7 +4785,7 @@ var PerpetualsClient = (function () {
4746
4785
  args_1[_i - 5] = arguments[_i];
4747
4786
  }
4748
4787
  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, enableHeapSizeIx, enableDebugLogs) {
4749
- var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, heapSizeIx, whitelistPda, whitelistExists, removeCompoundingLiquidity, err_17;
4788
+ var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, heapSizeIx, whitelistPda, whitelistMeta, removeCompoundingLiquidity, err_17;
4750
4789
  if (createUserATA === void 0) { createUserATA = true; }
4751
4790
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4752
4791
  if (userPublicKey === void 0) { userPublicKey = undefined; }
@@ -4825,7 +4864,7 @@ var PerpetualsClient = (function () {
4825
4864
  compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
4826
4865
  _f.label = 5;
4827
4866
  case 5:
4828
- _f.trys.push([5, 8, , 9]);
4867
+ _f.trys.push([5, 7, , 8]);
4829
4868
  if (enableHeapSizeIx) {
4830
4869
  heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
4831
4870
  bytes: 64 * 1024,
@@ -4835,10 +4874,12 @@ var PerpetualsClient = (function () {
4835
4874
  }
4836
4875
  preInstructions.push(heapSizeIx);
4837
4876
  }
4838
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
4839
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
4840
- case 6:
4841
- whitelistExists = _f.sent();
4877
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
4878
+ whitelistMeta = {
4879
+ pubkey: whitelistPda,
4880
+ isSigner: false,
4881
+ isWritable: false,
4882
+ };
4842
4883
  return [4, this.program.methods
4843
4884
  .removeCompoundingLiquidity({
4844
4885
  compoundingAmountIn: compoundingAmountIn,
@@ -4865,19 +4906,18 @@ var PerpetualsClient = (function () {
4865
4906
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
4866
4907
  receivingMint: outCustodyConfig.mintKey,
4867
4908
  receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
4868
- whitelist: whitelistExists ? whitelistPda : undefined,
4869
4909
  })
4870
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
4910
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
4871
4911
  .instruction()];
4872
- case 7:
4912
+ case 6:
4873
4913
  removeCompoundingLiquidity = _f.sent();
4874
4914
  instructions.push(removeCompoundingLiquidity);
4875
- return [3, 9];
4876
- case 8:
4915
+ return [3, 8];
4916
+ case 7:
4877
4917
  err_17 = _f.sent();
4878
4918
  console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
4879
- return [3, 9];
4880
- case 9: return [2, {
4919
+ return [3, 8];
4920
+ case 8: return [2, {
4881
4921
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4882
4922
  additionalSigners: additionalSigners
4883
4923
  }];
@@ -6425,7 +6465,7 @@ var PerpetualsClient = (function () {
6425
6465
  args_1[_i - 5] = arguments[_i];
6426
6466
  }
6427
6467
  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) {
6428
- 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, whitelistPda, whitelistExists, params, inx, closeWsolATAIns, err_40;
6468
+ 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, whitelistPda, whitelistMeta, params, inx, closeWsolATAIns, err_40;
6429
6469
  if (useFeesPool === void 0) { useFeesPool = false; }
6430
6470
  if (createUserATA === void 0) { createUserATA = true; }
6431
6471
  if (unWrapSol === void 0) { unWrapSol = false; }
@@ -6489,7 +6529,7 @@ var PerpetualsClient = (function () {
6489
6529
  }
6490
6530
  _g.label = 6;
6491
6531
  case 6:
6492
- _g.trys.push([6, 20, , 21]);
6532
+ _g.trys.push([6, 19, , 20]);
6493
6533
  if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
6494
6534
  console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
6495
6535
  return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
@@ -6591,10 +6631,12 @@ var PerpetualsClient = (function () {
6591
6631
  isWritable: false,
6592
6632
  });
6593
6633
  }
6594
- whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
6595
- return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
6596
- case 18:
6597
- whitelistExists = _g.sent();
6634
+ whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
6635
+ whitelistMeta = {
6636
+ pubkey: whitelistPda,
6637
+ isSigner: false,
6638
+ isWritable: false,
6639
+ };
6598
6640
  params = {
6599
6641
  amountIn: amountIn,
6600
6642
  minAmountOut: minAmountOut,
@@ -6622,23 +6664,22 @@ var PerpetualsClient = (function () {
6622
6664
  fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
6623
6665
  receivingMint: userOutputCustodyConfig.mintKey,
6624
6666
  receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
6625
- whitelist: whitelistExists ? whitelistPda : undefined,
6626
6667
  })
6627
- .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
6668
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), [whitelistMeta], false))
6628
6669
  .instruction()];
6629
- case 19:
6670
+ case 18:
6630
6671
  inx = _g.sent();
6631
6672
  instructions.push(inx);
6632
6673
  if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
6633
6674
  closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
6634
6675
  instructions.push(closeWsolATAIns);
6635
6676
  }
6636
- return [3, 21];
6637
- case 20:
6677
+ return [3, 20];
6678
+ case 19:
6638
6679
  err_40 = _g.sent();
6639
6680
  console.error("perpClient Swap error:: ", err_40);
6640
6681
  throw err_40;
6641
- case 21: return [2, {
6682
+ case 20: return [2, {
6642
6683
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6643
6684
  additionalSigners: additionalSigners
6644
6685
  }];
@@ -8034,6 +8075,94 @@ var PerpetualsClient = (function () {
8034
8075
  }
8035
8076
  });
8036
8077
  }); };
8078
+ this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
8079
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_65;
8080
+ return __generator(this, function (_a) {
8081
+ switch (_a.label) {
8082
+ case 0:
8083
+ publicKey = this.provider.wallet.publicKey;
8084
+ preInstructions = [];
8085
+ instructions = [];
8086
+ postInstructions = [];
8087
+ additionalSigners = [];
8088
+ _a.label = 1;
8089
+ case 1:
8090
+ _a.trys.push([1, 3, , 4]);
8091
+ whitelist = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("whitelist"), owner.toBuffer()], this.programId)[0];
8092
+ return [4, this.program.methods
8093
+ .createWhitelist({
8094
+ isSwapFeeExempt: isSwapFeeExempt,
8095
+ isDepositFeeExempt: isDepositFeeExempt,
8096
+ isWithdrawalFeeExempt: isWithdrawalFeeExempt,
8097
+ poolAddress: poolAddress,
8098
+ })
8099
+ .accounts({
8100
+ admin: publicKey,
8101
+ multisig: this.multisig.publicKey,
8102
+ owner: owner,
8103
+ whitelist: whitelist,
8104
+ systemProgram: web3_js_1.SystemProgram.programId,
8105
+ })
8106
+ .instruction()];
8107
+ case 2:
8108
+ createWhitelistInstruction = _a.sent();
8109
+ instructions.push(createWhitelistInstruction);
8110
+ return [3, 4];
8111
+ case 3:
8112
+ err_65 = _a.sent();
8113
+ console.log("perpClient createWhitelistInstruction error:: ", err_65);
8114
+ throw err_65;
8115
+ case 4: return [2, {
8116
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8117
+ additionalSigners: additionalSigners
8118
+ }];
8119
+ }
8120
+ });
8121
+ }); };
8122
+ this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
8123
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_66;
8124
+ return __generator(this, function (_a) {
8125
+ switch (_a.label) {
8126
+ case 0:
8127
+ publicKey = this.provider.wallet.publicKey;
8128
+ preInstructions = [];
8129
+ instructions = [];
8130
+ postInstructions = [];
8131
+ additionalSigners = [];
8132
+ _a.label = 1;
8133
+ case 1:
8134
+ _a.trys.push([1, 3, , 4]);
8135
+ whitelist = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("whitelist"), owner.toBuffer()], this.programId)[0];
8136
+ return [4, this.program.methods
8137
+ .setWhitelistConfig({
8138
+ isSwapFeeExempt: isSwapFeeExempt,
8139
+ isDepositFeeExempt: isDepositFeeExempt,
8140
+ isWithdrawalFeeExempt: isWithdrawalFeeExempt,
8141
+ poolAddress: poolAddress
8142
+ })
8143
+ .accounts({
8144
+ admin: publicKey,
8145
+ multisig: this.multisig.publicKey,
8146
+ owner: owner,
8147
+ whitelist: whitelist,
8148
+ systemProgram: web3_js_1.SystemProgram.programId,
8149
+ })
8150
+ .instruction()];
8151
+ case 2:
8152
+ setWhitelistConfigInstruction = _a.sent();
8153
+ instructions.push(setWhitelistConfigInstruction);
8154
+ return [3, 4];
8155
+ case 3:
8156
+ err_66 = _a.sent();
8157
+ console.log("perpClient setWhitelistConfigInstruction error:: ", err_66);
8158
+ throw err_66;
8159
+ case 4: return [2, {
8160
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8161
+ additionalSigners: additionalSigners
8162
+ }];
8163
+ }
8164
+ });
8165
+ }); };
8037
8166
  this.provider = provider;
8038
8167
  (0, anchor_1.setProvider)(provider);
8039
8168
  this.program = new anchor_1.Program(perpetuals_1.IDL, programId);