flash-sdk 11.1.1-alpha.1 → 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.
- package/dist/PerpetualsClient.d.ts +20 -20
- package/dist/PerpetualsClient.js +129 -94
- package/dist/idl/perpetuals.d.ts +10 -73
- package/dist/idl/perpetuals.js +10 -73
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
|
@@ -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 =
|
|
1727
|
-
|
|
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 =
|
|
1748
|
-
|
|
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,
|
|
@@ -1994,7 +2005,7 @@ var PerpetualsClient = (function () {
|
|
|
1994
2005
|
args_1[_i - 4] = arguments[_i];
|
|
1995
2006
|
}
|
|
1996
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) {
|
|
1997
|
-
var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
|
|
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; }
|
|
@@ -2029,6 +2040,11 @@ var PerpetualsClient = (function () {
|
|
|
2029
2040
|
isWritable: false,
|
|
2030
2041
|
});
|
|
2031
2042
|
}
|
|
2043
|
+
whitelistMeta = {
|
|
2044
|
+
pubkey: whitelist,
|
|
2045
|
+
isSigner: false,
|
|
2046
|
+
isWritable: false,
|
|
2047
|
+
};
|
|
2032
2048
|
depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
|
|
2033
2049
|
return [4, this.program.methods
|
|
2034
2050
|
.getAddLiquidityAmountAndFee({
|
|
@@ -2041,9 +2057,8 @@ var PerpetualsClient = (function () {
|
|
|
2041
2057
|
custodyOracleAccount: depositCustodyConfig.intOracleAccount,
|
|
2042
2058
|
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2043
2059
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2044
|
-
whitelist: whitelist
|
|
2045
2060
|
})
|
|
2046
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
|
2061
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
|
|
2047
2062
|
.transaction()];
|
|
2048
2063
|
case 1:
|
|
2049
2064
|
transaction = _f.sent();
|
|
@@ -2082,11 +2097,11 @@ var PerpetualsClient = (function () {
|
|
|
2082
2097
|
args_1[_i - 4] = arguments[_i];
|
|
2083
2098
|
}
|
|
2084
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) {
|
|
2085
|
-
var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
|
|
2100
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
|
|
2086
2101
|
var _e;
|
|
2087
2102
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
2088
2103
|
if (enableBackupOracle === void 0) { enableBackupOracle = false; }
|
|
2089
|
-
if (whitelist === void 0) { whitelist =
|
|
2104
|
+
if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
|
|
2090
2105
|
return __generator(this, function (_f) {
|
|
2091
2106
|
switch (_f.label) {
|
|
2092
2107
|
case 0:
|
|
@@ -2117,6 +2132,11 @@ var PerpetualsClient = (function () {
|
|
|
2117
2132
|
isWritable: false,
|
|
2118
2133
|
});
|
|
2119
2134
|
}
|
|
2135
|
+
whitelistMeta = {
|
|
2136
|
+
pubkey: whitelist,
|
|
2137
|
+
isSigner: false,
|
|
2138
|
+
isWritable: false,
|
|
2139
|
+
};
|
|
2120
2140
|
removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
|
|
2121
2141
|
return [4, this.program.methods
|
|
2122
2142
|
.getRemoveLiquidityAmountAndFee({
|
|
@@ -2129,9 +2149,8 @@ var PerpetualsClient = (function () {
|
|
|
2129
2149
|
custodyOracleAccount: removeCustodyConfig.intOracleAccount,
|
|
2130
2150
|
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2131
2151
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2132
|
-
whitelist: whitelist
|
|
2133
2152
|
})
|
|
2134
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
|
2153
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
|
|
2135
2154
|
.transaction()];
|
|
2136
2155
|
case 1:
|
|
2137
2156
|
transaction = _f.sent();
|
|
@@ -2231,11 +2250,11 @@ var PerpetualsClient = (function () {
|
|
|
2231
2250
|
args_1[_i - 4] = arguments[_i];
|
|
2232
2251
|
}
|
|
2233
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) {
|
|
2234
|
-
var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
|
|
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;
|
|
2235
2254
|
var _e;
|
|
2236
2255
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
2237
2256
|
if (enableBackupOracle === void 0) { enableBackupOracle = false; }
|
|
2238
|
-
if (whitelist === void 0) { whitelist =
|
|
2257
|
+
if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
|
|
2239
2258
|
return __generator(this, function (_f) {
|
|
2240
2259
|
switch (_f.label) {
|
|
2241
2260
|
case 0:
|
|
@@ -2266,6 +2285,11 @@ var PerpetualsClient = (function () {
|
|
|
2266
2285
|
isWritable: false,
|
|
2267
2286
|
});
|
|
2268
2287
|
}
|
|
2288
|
+
whitelistMeta = {
|
|
2289
|
+
pubkey: whitelist,
|
|
2290
|
+
isSigner: false,
|
|
2291
|
+
isWritable: false,
|
|
2292
|
+
};
|
|
2269
2293
|
depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
|
|
2270
2294
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
|
2271
2295
|
return [4, this.program.methods
|
|
@@ -2282,9 +2306,8 @@ var PerpetualsClient = (function () {
|
|
|
2282
2306
|
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2283
2307
|
compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
|
|
2284
2308
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2285
|
-
whitelist: whitelist
|
|
2286
2309
|
})
|
|
2287
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
|
2310
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
|
|
2288
2311
|
.transaction()];
|
|
2289
2312
|
case 1:
|
|
2290
2313
|
transaction = _f.sent();
|
|
@@ -2315,11 +2338,11 @@ var PerpetualsClient = (function () {
|
|
|
2315
2338
|
args_1[_i - 4] = arguments[_i];
|
|
2316
2339
|
}
|
|
2317
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) {
|
|
2318
|
-
var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
|
|
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;
|
|
2319
2342
|
var _e;
|
|
2320
2343
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
2321
2344
|
if (enableBackupOracle === void 0) { enableBackupOracle = false; }
|
|
2322
|
-
if (whitelist === void 0) { whitelist =
|
|
2345
|
+
if (whitelist === void 0) { whitelist = web3_js_1.PublicKey.default; }
|
|
2323
2346
|
return __generator(this, function (_f) {
|
|
2324
2347
|
switch (_f.label) {
|
|
2325
2348
|
case 0:
|
|
@@ -2350,6 +2373,11 @@ var PerpetualsClient = (function () {
|
|
|
2350
2373
|
isWritable: false,
|
|
2351
2374
|
});
|
|
2352
2375
|
}
|
|
2376
|
+
whitelistMeta = {
|
|
2377
|
+
pubkey: whitelist,
|
|
2378
|
+
isSigner: false,
|
|
2379
|
+
isWritable: false,
|
|
2380
|
+
};
|
|
2353
2381
|
removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
|
|
2354
2382
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
|
2355
2383
|
return [4, this.program.methods
|
|
@@ -2366,9 +2394,8 @@ var PerpetualsClient = (function () {
|
|
|
2366
2394
|
compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
|
|
2367
2395
|
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2368
2396
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2369
|
-
whitelist: whitelist
|
|
2370
2397
|
})
|
|
2371
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
|
2398
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true), (whitelist ? [whitelistMeta] : []), true))
|
|
2372
2399
|
.transaction()];
|
|
2373
2400
|
case 1:
|
|
2374
2401
|
transaction = _f.sent();
|
|
@@ -3635,7 +3662,7 @@ var PerpetualsClient = (function () {
|
|
|
3635
3662
|
args_1[_i - 4] = arguments[_i];
|
|
3636
3663
|
}
|
|
3637
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) {
|
|
3638
|
-
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,
|
|
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;
|
|
3639
3666
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3640
3667
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3641
3668
|
return __generator(this, function (_g) {
|
|
@@ -3653,7 +3680,7 @@ var PerpetualsClient = (function () {
|
|
|
3653
3680
|
payToken = poolConfig.getTokenFromSymbol(payTokenSymbol);
|
|
3654
3681
|
_g.label = 1;
|
|
3655
3682
|
case 1:
|
|
3656
|
-
_g.trys.push([1,
|
|
3683
|
+
_g.trys.push([1, 10, , 11]);
|
|
3657
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);
|
|
3658
3685
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3659
3686
|
custodyAccountMetas = [];
|
|
@@ -3732,10 +3759,12 @@ var PerpetualsClient = (function () {
|
|
|
3732
3759
|
}
|
|
3733
3760
|
_g.label = 8;
|
|
3734
3761
|
case 8:
|
|
3735
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3762
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3763
|
+
whitelistMeta = {
|
|
3764
|
+
pubkey: whitelistPda,
|
|
3765
|
+
isSigner: false,
|
|
3766
|
+
isWritable: false,
|
|
3767
|
+
};
|
|
3739
3768
|
return [4, this.program.methods
|
|
3740
3769
|
.addLiquidity({
|
|
3741
3770
|
amountIn: tokenAmountIn,
|
|
@@ -3758,19 +3787,18 @@ var PerpetualsClient = (function () {
|
|
|
3758
3787
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3759
3788
|
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3760
3789
|
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3761
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3762
3790
|
})
|
|
3763
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3791
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
|
|
3764
3792
|
.instruction()];
|
|
3765
|
-
case
|
|
3793
|
+
case 9:
|
|
3766
3794
|
instruction = _g.sent();
|
|
3767
3795
|
instructions.push(instruction);
|
|
3768
|
-
return [3,
|
|
3769
|
-
case
|
|
3796
|
+
return [3, 11];
|
|
3797
|
+
case 10:
|
|
3770
3798
|
err_5 = _g.sent();
|
|
3771
3799
|
console.error("perpClient addLiquidity error:: ", err_5);
|
|
3772
3800
|
throw err_5;
|
|
3773
|
-
case
|
|
3801
|
+
case 11: return [2, {
|
|
3774
3802
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3775
3803
|
additionalSigners: additionalSigners
|
|
3776
3804
|
}];
|
|
@@ -3784,7 +3812,7 @@ var PerpetualsClient = (function () {
|
|
|
3784
3812
|
args_1[_i - 4] = arguments[_i];
|
|
3785
3813
|
}
|
|
3786
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) {
|
|
3787
|
-
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,
|
|
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;
|
|
3788
3816
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3789
3817
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3790
3818
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -3879,10 +3907,12 @@ var PerpetualsClient = (function () {
|
|
|
3879
3907
|
isWritable: false,
|
|
3880
3908
|
});
|
|
3881
3909
|
}
|
|
3882
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3910
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3911
|
+
whitelistMeta = {
|
|
3912
|
+
pubkey: whitelistPda,
|
|
3913
|
+
isSigner: false,
|
|
3914
|
+
isWritable: false,
|
|
3915
|
+
};
|
|
3886
3916
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
3887
3917
|
amountIn: amountIn,
|
|
3888
3918
|
minLpAmountOut: minLpAmountOut,
|
|
@@ -3906,11 +3936,10 @@ var PerpetualsClient = (function () {
|
|
|
3906
3936
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3907
3937
|
fundingMint: inputCustodyConfig.mintKey,
|
|
3908
3938
|
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3909
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3910
3939
|
})
|
|
3911
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3940
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
|
|
3912
3941
|
.instruction()];
|
|
3913
|
-
case
|
|
3942
|
+
case 8:
|
|
3914
3943
|
instruction = _g.sent();
|
|
3915
3944
|
instructions.push(instruction);
|
|
3916
3945
|
return [2, {
|
|
@@ -3927,7 +3956,7 @@ var PerpetualsClient = (function () {
|
|
|
3927
3956
|
args_1[_i - 4] = arguments[_i];
|
|
3928
3957
|
}
|
|
3929
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) {
|
|
3930
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, whitelistPda,
|
|
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;
|
|
3931
3960
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
3932
3961
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3933
3962
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
@@ -3948,7 +3977,7 @@ var PerpetualsClient = (function () {
|
|
|
3948
3977
|
recieveToken = poolConfig.getTokenFromSymbol(recieveTokenSymbol);
|
|
3949
3978
|
_f.label = 1;
|
|
3950
3979
|
case 1:
|
|
3951
|
-
_f.trys.push([1,
|
|
3980
|
+
_f.trys.push([1, 7, , 8]);
|
|
3952
3981
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3953
3982
|
custodyAccountMetas = [];
|
|
3954
3983
|
custodyOracleAccountMetas = [];
|
|
@@ -4008,10 +4037,12 @@ var PerpetualsClient = (function () {
|
|
|
4008
4037
|
}
|
|
4009
4038
|
_f.label = 5;
|
|
4010
4039
|
case 5:
|
|
4011
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4040
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4041
|
+
whitelistMeta = {
|
|
4042
|
+
pubkey: whitelistPda,
|
|
4043
|
+
isSigner: false,
|
|
4044
|
+
isWritable: false,
|
|
4045
|
+
};
|
|
4015
4046
|
return [4, this.program.methods
|
|
4016
4047
|
.removeLiquidity({
|
|
4017
4048
|
lpAmountIn: liquidityAmountIn,
|
|
@@ -4034,11 +4065,10 @@ var PerpetualsClient = (function () {
|
|
|
4034
4065
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4035
4066
|
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4036
4067
|
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4037
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4038
4068
|
})
|
|
4039
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4069
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
|
|
4040
4070
|
.instruction()];
|
|
4041
|
-
case
|
|
4071
|
+
case 6:
|
|
4042
4072
|
removeLiquidityTx = _f.sent();
|
|
4043
4073
|
instructions.push(removeLiquidityTx);
|
|
4044
4074
|
if (closeLpATA) {
|
|
@@ -4049,12 +4079,12 @@ var PerpetualsClient = (function () {
|
|
|
4049
4079
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
4050
4080
|
postInstructions.push(closeWsolATAIns);
|
|
4051
4081
|
}
|
|
4052
|
-
return [3,
|
|
4053
|
-
case
|
|
4082
|
+
return [3, 8];
|
|
4083
|
+
case 7:
|
|
4054
4084
|
err_6 = _f.sent();
|
|
4055
4085
|
console.log("perpClient removeLiquidity error:: ", err_6);
|
|
4056
4086
|
throw err_6;
|
|
4057
|
-
case
|
|
4087
|
+
case 8: return [2, {
|
|
4058
4088
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4059
4089
|
additionalSigners: additionalSigners
|
|
4060
4090
|
}];
|
|
@@ -4593,7 +4623,7 @@ var PerpetualsClient = (function () {
|
|
|
4593
4623
|
args_1[_i - 5] = arguments[_i];
|
|
4594
4624
|
}
|
|
4595
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) {
|
|
4596
|
-
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,
|
|
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;
|
|
4597
4627
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4598
4628
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4599
4629
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4688,7 +4718,7 @@ var PerpetualsClient = (function () {
|
|
|
4688
4718
|
}
|
|
4689
4719
|
_f.label = 7;
|
|
4690
4720
|
case 7:
|
|
4691
|
-
_f.trys.push([7,
|
|
4721
|
+
_f.trys.push([7, 9, , 10]);
|
|
4692
4722
|
if (enableHeapSizeIx) {
|
|
4693
4723
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4694
4724
|
bytes: 64 * 1024,
|
|
@@ -4698,10 +4728,12 @@ var PerpetualsClient = (function () {
|
|
|
4698
4728
|
}
|
|
4699
4729
|
preInstructions.push(heapSizeIx);
|
|
4700
4730
|
}
|
|
4701
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4731
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4732
|
+
whitelistMeta = {
|
|
4733
|
+
pubkey: whitelistPda,
|
|
4734
|
+
isSigner: false,
|
|
4735
|
+
isWritable: false,
|
|
4736
|
+
};
|
|
4705
4737
|
return [4, this.program.methods
|
|
4706
4738
|
.addCompoundingLiquidity({
|
|
4707
4739
|
amountIn: amountIn,
|
|
@@ -4728,19 +4760,18 @@ var PerpetualsClient = (function () {
|
|
|
4728
4760
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4729
4761
|
fundingMint: inCustodyConfig.mintKey,
|
|
4730
4762
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4731
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4732
4763
|
})
|
|
4733
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4764
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
|
|
4734
4765
|
.instruction()];
|
|
4735
|
-
case
|
|
4766
|
+
case 8:
|
|
4736
4767
|
addCompoundingLiquidity = _f.sent();
|
|
4737
4768
|
instructions.push(addCompoundingLiquidity);
|
|
4738
|
-
return [3,
|
|
4739
|
-
case
|
|
4769
|
+
return [3, 10];
|
|
4770
|
+
case 9:
|
|
4740
4771
|
err_16 = _f.sent();
|
|
4741
4772
|
console.log("perpClient addCompoundingLiquidity error:: ", err_16);
|
|
4742
|
-
return [3,
|
|
4743
|
-
case
|
|
4773
|
+
return [3, 10];
|
|
4774
|
+
case 10: return [2, {
|
|
4744
4775
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4745
4776
|
additionalSigners: additionalSigners
|
|
4746
4777
|
}];
|
|
@@ -4754,7 +4785,7 @@ var PerpetualsClient = (function () {
|
|
|
4754
4785
|
args_1[_i - 5] = arguments[_i];
|
|
4755
4786
|
}
|
|
4756
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) {
|
|
4757
|
-
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,
|
|
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;
|
|
4758
4789
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4759
4790
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4760
4791
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4833,7 +4864,7 @@ var PerpetualsClient = (function () {
|
|
|
4833
4864
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
|
4834
4865
|
_f.label = 5;
|
|
4835
4866
|
case 5:
|
|
4836
|
-
_f.trys.push([5,
|
|
4867
|
+
_f.trys.push([5, 7, , 8]);
|
|
4837
4868
|
if (enableHeapSizeIx) {
|
|
4838
4869
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4839
4870
|
bytes: 64 * 1024,
|
|
@@ -4843,10 +4874,12 @@ var PerpetualsClient = (function () {
|
|
|
4843
4874
|
}
|
|
4844
4875
|
preInstructions.push(heapSizeIx);
|
|
4845
4876
|
}
|
|
4846
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4877
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4878
|
+
whitelistMeta = {
|
|
4879
|
+
pubkey: whitelistPda,
|
|
4880
|
+
isSigner: false,
|
|
4881
|
+
isWritable: false,
|
|
4882
|
+
};
|
|
4850
4883
|
return [4, this.program.methods
|
|
4851
4884
|
.removeCompoundingLiquidity({
|
|
4852
4885
|
compoundingAmountIn: compoundingAmountIn,
|
|
@@ -4873,19 +4906,18 @@ var PerpetualsClient = (function () {
|
|
|
4873
4906
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4874
4907
|
receivingMint: outCustodyConfig.mintKey,
|
|
4875
4908
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4876
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4877
4909
|
})
|
|
4878
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4910
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), [whitelistMeta], false))
|
|
4879
4911
|
.instruction()];
|
|
4880
|
-
case
|
|
4912
|
+
case 6:
|
|
4881
4913
|
removeCompoundingLiquidity = _f.sent();
|
|
4882
4914
|
instructions.push(removeCompoundingLiquidity);
|
|
4883
|
-
return [3,
|
|
4884
|
-
case
|
|
4915
|
+
return [3, 8];
|
|
4916
|
+
case 7:
|
|
4885
4917
|
err_17 = _f.sent();
|
|
4886
4918
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
|
|
4887
|
-
return [3,
|
|
4888
|
-
case
|
|
4919
|
+
return [3, 8];
|
|
4920
|
+
case 8: return [2, {
|
|
4889
4921
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4890
4922
|
additionalSigners: additionalSigners
|
|
4891
4923
|
}];
|
|
@@ -6433,7 +6465,7 @@ var PerpetualsClient = (function () {
|
|
|
6433
6465
|
args_1[_i - 5] = arguments[_i];
|
|
6434
6466
|
}
|
|
6435
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) {
|
|
6436
|
-
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,
|
|
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;
|
|
6437
6469
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6438
6470
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6439
6471
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
@@ -6497,7 +6529,7 @@ var PerpetualsClient = (function () {
|
|
|
6497
6529
|
}
|
|
6498
6530
|
_g.label = 6;
|
|
6499
6531
|
case 6:
|
|
6500
|
-
_g.trys.push([6,
|
|
6532
|
+
_g.trys.push([6, 19, , 20]);
|
|
6501
6533
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
|
6502
6534
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
|
6503
6535
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
|
@@ -6599,10 +6631,12 @@ var PerpetualsClient = (function () {
|
|
|
6599
6631
|
isWritable: false,
|
|
6600
6632
|
});
|
|
6601
6633
|
}
|
|
6602
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6634
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
6635
|
+
whitelistMeta = {
|
|
6636
|
+
pubkey: whitelistPda,
|
|
6637
|
+
isSigner: false,
|
|
6638
|
+
isWritable: false,
|
|
6639
|
+
};
|
|
6606
6640
|
params = {
|
|
6607
6641
|
amountIn: amountIn,
|
|
6608
6642
|
minAmountOut: minAmountOut,
|
|
@@ -6630,23 +6664,22 @@ var PerpetualsClient = (function () {
|
|
|
6630
6664
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6631
6665
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
6632
6666
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6633
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
6634
6667
|
})
|
|
6635
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
6668
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), [whitelistMeta], false))
|
|
6636
6669
|
.instruction()];
|
|
6637
|
-
case
|
|
6670
|
+
case 18:
|
|
6638
6671
|
inx = _g.sent();
|
|
6639
6672
|
instructions.push(inx);
|
|
6640
6673
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
|
6641
6674
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
|
6642
6675
|
instructions.push(closeWsolATAIns);
|
|
6643
6676
|
}
|
|
6644
|
-
return [3,
|
|
6645
|
-
case
|
|
6677
|
+
return [3, 20];
|
|
6678
|
+
case 19:
|
|
6646
6679
|
err_40 = _g.sent();
|
|
6647
6680
|
console.error("perpClient Swap error:: ", err_40);
|
|
6648
6681
|
throw err_40;
|
|
6649
|
-
case
|
|
6682
|
+
case 20: return [2, {
|
|
6650
6683
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6651
6684
|
additionalSigners: additionalSigners
|
|
6652
6685
|
}];
|
|
@@ -8042,7 +8075,7 @@ var PerpetualsClient = (function () {
|
|
|
8042
8075
|
}
|
|
8043
8076
|
});
|
|
8044
8077
|
}); };
|
|
8045
|
-
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8078
|
+
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8046
8079
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_65;
|
|
8047
8080
|
return __generator(this, function (_a) {
|
|
8048
8081
|
switch (_a.label) {
|
|
@@ -8060,7 +8093,8 @@ var PerpetualsClient = (function () {
|
|
|
8060
8093
|
.createWhitelist({
|
|
8061
8094
|
isSwapFeeExempt: isSwapFeeExempt,
|
|
8062
8095
|
isDepositFeeExempt: isDepositFeeExempt,
|
|
8063
|
-
isWithdrawalFeeExempt: isWithdrawalFeeExempt
|
|
8096
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8097
|
+
poolAddress: poolAddress,
|
|
8064
8098
|
})
|
|
8065
8099
|
.accounts({
|
|
8066
8100
|
admin: publicKey,
|
|
@@ -8085,7 +8119,7 @@ var PerpetualsClient = (function () {
|
|
|
8085
8119
|
}
|
|
8086
8120
|
});
|
|
8087
8121
|
}); };
|
|
8088
|
-
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8122
|
+
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8089
8123
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_66;
|
|
8090
8124
|
return __generator(this, function (_a) {
|
|
8091
8125
|
switch (_a.label) {
|
|
@@ -8103,7 +8137,8 @@ var PerpetualsClient = (function () {
|
|
|
8103
8137
|
.setWhitelistConfig({
|
|
8104
8138
|
isSwapFeeExempt: isSwapFeeExempt,
|
|
8105
8139
|
isDepositFeeExempt: isDepositFeeExempt,
|
|
8106
|
-
isWithdrawalFeeExempt: isWithdrawalFeeExempt
|
|
8140
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8141
|
+
poolAddress: poolAddress
|
|
8107
8142
|
})
|
|
8108
8143
|
.accounts({
|
|
8109
8144
|
admin: publicKey,
|