flash-sdk 11.1.1-alpha.1 → 11.1.1-alpha.11
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 +26 -26
- package/dist/PerpetualsClient.js +141 -108
- 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.isSwapFeeExempt) {
|
|
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();
|
|
@@ -3634,10 +3661,11 @@ var PerpetualsClient = (function () {
|
|
|
3634
3661
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3635
3662
|
args_1[_i - 4] = arguments[_i];
|
|
3636
3663
|
}
|
|
3637
|
-
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,
|
|
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, isWhitelistedUser) {
|
|
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; }
|
|
3668
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3641
3669
|
return __generator(this, function (_g) {
|
|
3642
3670
|
switch (_g.label) {
|
|
3643
3671
|
case 0:
|
|
@@ -3653,7 +3681,7 @@ var PerpetualsClient = (function () {
|
|
|
3653
3681
|
payToken = poolConfig.getTokenFromSymbol(payTokenSymbol);
|
|
3654
3682
|
_g.label = 1;
|
|
3655
3683
|
case 1:
|
|
3656
|
-
_g.trys.push([1,
|
|
3684
|
+
_g.trys.push([1, 10, , 11]);
|
|
3657
3685
|
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
3686
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3659
3687
|
custodyAccountMetas = [];
|
|
@@ -3732,10 +3760,12 @@ var PerpetualsClient = (function () {
|
|
|
3732
3760
|
}
|
|
3733
3761
|
_g.label = 8;
|
|
3734
3762
|
case 8:
|
|
3735
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3763
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3764
|
+
whitelistMeta = {
|
|
3765
|
+
pubkey: whitelistPda,
|
|
3766
|
+
isSigner: false,
|
|
3767
|
+
isWritable: false,
|
|
3768
|
+
};
|
|
3739
3769
|
return [4, this.program.methods
|
|
3740
3770
|
.addLiquidity({
|
|
3741
3771
|
amountIn: tokenAmountIn,
|
|
@@ -3758,19 +3788,18 @@ var PerpetualsClient = (function () {
|
|
|
3758
3788
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3759
3789
|
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3760
3790
|
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3761
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3762
3791
|
})
|
|
3763
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3792
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3764
3793
|
.instruction()];
|
|
3765
|
-
case
|
|
3794
|
+
case 9:
|
|
3766
3795
|
instruction = _g.sent();
|
|
3767
3796
|
instructions.push(instruction);
|
|
3768
|
-
return [3,
|
|
3769
|
-
case
|
|
3797
|
+
return [3, 11];
|
|
3798
|
+
case 10:
|
|
3770
3799
|
err_5 = _g.sent();
|
|
3771
3800
|
console.error("perpClient addLiquidity error:: ", err_5);
|
|
3772
3801
|
throw err_5;
|
|
3773
|
-
case
|
|
3802
|
+
case 11: return [2, {
|
|
3774
3803
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3775
3804
|
additionalSigners: additionalSigners
|
|
3776
3805
|
}];
|
|
@@ -3783,11 +3812,12 @@ var PerpetualsClient = (function () {
|
|
|
3783
3812
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3784
3813
|
args_1[_i - 4] = arguments[_i];
|
|
3785
3814
|
}
|
|
3786
|
-
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
|
+
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, isWhitelistedUser) {
|
|
3816
|
+
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
3817
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3789
3818
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3790
3819
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
3820
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3791
3821
|
return __generator(this, function (_g) {
|
|
3792
3822
|
switch (_g.label) {
|
|
3793
3823
|
case 0:
|
|
@@ -3879,10 +3909,12 @@ var PerpetualsClient = (function () {
|
|
|
3879
3909
|
isWritable: false,
|
|
3880
3910
|
});
|
|
3881
3911
|
}
|
|
3882
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3912
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3913
|
+
whitelistMeta = {
|
|
3914
|
+
pubkey: whitelistPda,
|
|
3915
|
+
isSigner: false,
|
|
3916
|
+
isWritable: false,
|
|
3917
|
+
};
|
|
3886
3918
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
3887
3919
|
amountIn: amountIn,
|
|
3888
3920
|
minLpAmountOut: minLpAmountOut,
|
|
@@ -3906,11 +3938,10 @@ var PerpetualsClient = (function () {
|
|
|
3906
3938
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3907
3939
|
fundingMint: inputCustodyConfig.mintKey,
|
|
3908
3940
|
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3909
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3910
3941
|
})
|
|
3911
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3942
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3912
3943
|
.instruction()];
|
|
3913
|
-
case
|
|
3944
|
+
case 8:
|
|
3914
3945
|
instruction = _g.sent();
|
|
3915
3946
|
instructions.push(instruction);
|
|
3916
3947
|
return [2, {
|
|
@@ -3926,13 +3957,14 @@ var PerpetualsClient = (function () {
|
|
|
3926
3957
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3927
3958
|
args_1[_i - 4] = arguments[_i];
|
|
3928
3959
|
}
|
|
3929
|
-
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,
|
|
3960
|
+
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, isWhitelistedUser) {
|
|
3961
|
+
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
3962
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
3932
3963
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3933
3964
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
3934
3965
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3935
3966
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
3967
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3936
3968
|
return __generator(this, function (_f) {
|
|
3937
3969
|
switch (_f.label) {
|
|
3938
3970
|
case 0:
|
|
@@ -3948,7 +3980,7 @@ var PerpetualsClient = (function () {
|
|
|
3948
3980
|
recieveToken = poolConfig.getTokenFromSymbol(recieveTokenSymbol);
|
|
3949
3981
|
_f.label = 1;
|
|
3950
3982
|
case 1:
|
|
3951
|
-
_f.trys.push([1,
|
|
3983
|
+
_f.trys.push([1, 7, , 8]);
|
|
3952
3984
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3953
3985
|
custodyAccountMetas = [];
|
|
3954
3986
|
custodyOracleAccountMetas = [];
|
|
@@ -4008,10 +4040,12 @@ var PerpetualsClient = (function () {
|
|
|
4008
4040
|
}
|
|
4009
4041
|
_f.label = 5;
|
|
4010
4042
|
case 5:
|
|
4011
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4043
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4044
|
+
whitelistMeta = {
|
|
4045
|
+
pubkey: whitelistPda,
|
|
4046
|
+
isSigner: false,
|
|
4047
|
+
isWritable: false,
|
|
4048
|
+
};
|
|
4015
4049
|
return [4, this.program.methods
|
|
4016
4050
|
.removeLiquidity({
|
|
4017
4051
|
lpAmountIn: liquidityAmountIn,
|
|
@@ -4034,11 +4068,10 @@ var PerpetualsClient = (function () {
|
|
|
4034
4068
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4035
4069
|
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4036
4070
|
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4037
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4038
4071
|
})
|
|
4039
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4072
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4040
4073
|
.instruction()];
|
|
4041
|
-
case
|
|
4074
|
+
case 6:
|
|
4042
4075
|
removeLiquidityTx = _f.sent();
|
|
4043
4076
|
instructions.push(removeLiquidityTx);
|
|
4044
4077
|
if (closeLpATA) {
|
|
@@ -4049,12 +4082,12 @@ var PerpetualsClient = (function () {
|
|
|
4049
4082
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
4050
4083
|
postInstructions.push(closeWsolATAIns);
|
|
4051
4084
|
}
|
|
4052
|
-
return [3,
|
|
4053
|
-
case
|
|
4085
|
+
return [3, 8];
|
|
4086
|
+
case 7:
|
|
4054
4087
|
err_6 = _f.sent();
|
|
4055
4088
|
console.log("perpClient removeLiquidity error:: ", err_6);
|
|
4056
4089
|
throw err_6;
|
|
4057
|
-
case
|
|
4090
|
+
case 8: return [2, {
|
|
4058
4091
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4059
4092
|
additionalSigners: additionalSigners
|
|
4060
4093
|
}];
|
|
@@ -4592,13 +4625,13 @@ var PerpetualsClient = (function () {
|
|
|
4592
4625
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4593
4626
|
args_1[_i - 5] = arguments[_i];
|
|
4594
4627
|
}
|
|
4595
|
-
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,
|
|
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,
|
|
4628
|
+
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, isWhitelistedUser) {
|
|
4629
|
+
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
4630
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4598
4631
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4599
4632
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4600
4633
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4601
|
-
if (
|
|
4634
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4602
4635
|
return __generator(this, function (_f) {
|
|
4603
4636
|
switch (_f.label) {
|
|
4604
4637
|
case 0:
|
|
@@ -4688,20 +4721,19 @@ var PerpetualsClient = (function () {
|
|
|
4688
4721
|
}
|
|
4689
4722
|
_f.label = 7;
|
|
4690
4723
|
case 7:
|
|
4691
|
-
_f.trys.push([7,
|
|
4724
|
+
_f.trys.push([7, 9, , 10]);
|
|
4692
4725
|
if (enableHeapSizeIx) {
|
|
4693
4726
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4694
4727
|
bytes: 64 * 1024,
|
|
4695
4728
|
});
|
|
4696
|
-
if (enableDebugLogs) {
|
|
4697
|
-
console.log("SDK: adding 64 liq Data heapSizeIx for addCompoundingLiquidity");
|
|
4698
|
-
}
|
|
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), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
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
|
}];
|
|
@@ -4753,13 +4784,13 @@ var PerpetualsClient = (function () {
|
|
|
4753
4784
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4754
4785
|
args_1[_i - 5] = arguments[_i];
|
|
4755
4786
|
}
|
|
4756
|
-
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,
|
|
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,
|
|
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, isWhitelistedUser) {
|
|
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; }
|
|
4761
4792
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4762
|
-
if (
|
|
4793
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4763
4794
|
return __generator(this, function (_f) {
|
|
4764
4795
|
switch (_f.label) {
|
|
4765
4796
|
case 0:
|
|
@@ -4833,20 +4864,19 @@ 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,
|
|
4840
4871
|
});
|
|
4841
|
-
if (enableDebugLogs) {
|
|
4842
|
-
console.log("SDK: adding 64 liq Data heapSizeIx for addCompoundingLiquidity");
|
|
4843
|
-
}
|
|
4844
4872
|
preInstructions.push(heapSizeIx);
|
|
4845
4873
|
}
|
|
4846
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4874
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4875
|
+
whitelistMeta = {
|
|
4876
|
+
pubkey: whitelistPda,
|
|
4877
|
+
isSigner: false,
|
|
4878
|
+
isWritable: false,
|
|
4879
|
+
};
|
|
4850
4880
|
return [4, this.program.methods
|
|
4851
4881
|
.removeCompoundingLiquidity({
|
|
4852
4882
|
compoundingAmountIn: compoundingAmountIn,
|
|
@@ -4873,19 +4903,18 @@ var PerpetualsClient = (function () {
|
|
|
4873
4903
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4874
4904
|
receivingMint: outCustodyConfig.mintKey,
|
|
4875
4905
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4876
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4877
4906
|
})
|
|
4878
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4907
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4879
4908
|
.instruction()];
|
|
4880
|
-
case
|
|
4909
|
+
case 6:
|
|
4881
4910
|
removeCompoundingLiquidity = _f.sent();
|
|
4882
4911
|
instructions.push(removeCompoundingLiquidity);
|
|
4883
|
-
return [3,
|
|
4884
|
-
case
|
|
4912
|
+
return [3, 8];
|
|
4913
|
+
case 7:
|
|
4885
4914
|
err_17 = _f.sent();
|
|
4886
4915
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
|
|
4887
|
-
return [3,
|
|
4888
|
-
case
|
|
4916
|
+
return [3, 8];
|
|
4917
|
+
case 8: return [2, {
|
|
4889
4918
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4890
4919
|
additionalSigners: additionalSigners
|
|
4891
4920
|
}];
|
|
@@ -6432,13 +6461,14 @@ var PerpetualsClient = (function () {
|
|
|
6432
6461
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
6433
6462
|
args_1[_i - 5] = arguments[_i];
|
|
6434
6463
|
}
|
|
6435
|
-
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,
|
|
6464
|
+
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, isWhitelistedUser) {
|
|
6465
|
+
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
6466
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6438
6467
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6439
6468
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
6440
6469
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
6441
6470
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
6471
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
6442
6472
|
return __generator(this, function (_g) {
|
|
6443
6473
|
switch (_g.label) {
|
|
6444
6474
|
case 0:
|
|
@@ -6497,7 +6527,7 @@ var PerpetualsClient = (function () {
|
|
|
6497
6527
|
}
|
|
6498
6528
|
_g.label = 6;
|
|
6499
6529
|
case 6:
|
|
6500
|
-
_g.trys.push([6,
|
|
6530
|
+
_g.trys.push([6, 19, , 20]);
|
|
6501
6531
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
|
6502
6532
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
|
6503
6533
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
|
@@ -6599,10 +6629,12 @@ var PerpetualsClient = (function () {
|
|
|
6599
6629
|
isWritable: false,
|
|
6600
6630
|
});
|
|
6601
6631
|
}
|
|
6602
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6632
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
6633
|
+
whitelistMeta = {
|
|
6634
|
+
pubkey: whitelistPda,
|
|
6635
|
+
isSigner: false,
|
|
6636
|
+
isWritable: false,
|
|
6637
|
+
};
|
|
6606
6638
|
params = {
|
|
6607
6639
|
amountIn: amountIn,
|
|
6608
6640
|
minAmountOut: minAmountOut,
|
|
@@ -6630,23 +6662,22 @@ var PerpetualsClient = (function () {
|
|
|
6630
6662
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6631
6663
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
6632
6664
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6633
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
6634
6665
|
})
|
|
6635
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
6666
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
6636
6667
|
.instruction()];
|
|
6637
|
-
case
|
|
6668
|
+
case 18:
|
|
6638
6669
|
inx = _g.sent();
|
|
6639
6670
|
instructions.push(inx);
|
|
6640
6671
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
|
6641
6672
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
|
6642
6673
|
instructions.push(closeWsolATAIns);
|
|
6643
6674
|
}
|
|
6644
|
-
return [3,
|
|
6645
|
-
case
|
|
6675
|
+
return [3, 20];
|
|
6676
|
+
case 19:
|
|
6646
6677
|
err_40 = _g.sent();
|
|
6647
6678
|
console.error("perpClient Swap error:: ", err_40);
|
|
6648
6679
|
throw err_40;
|
|
6649
|
-
case
|
|
6680
|
+
case 20: return [2, {
|
|
6650
6681
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6651
6682
|
additionalSigners: additionalSigners
|
|
6652
6683
|
}];
|
|
@@ -8042,7 +8073,7 @@ var PerpetualsClient = (function () {
|
|
|
8042
8073
|
}
|
|
8043
8074
|
});
|
|
8044
8075
|
}); };
|
|
8045
|
-
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8076
|
+
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8046
8077
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_65;
|
|
8047
8078
|
return __generator(this, function (_a) {
|
|
8048
8079
|
switch (_a.label) {
|
|
@@ -8060,7 +8091,8 @@ var PerpetualsClient = (function () {
|
|
|
8060
8091
|
.createWhitelist({
|
|
8061
8092
|
isSwapFeeExempt: isSwapFeeExempt,
|
|
8062
8093
|
isDepositFeeExempt: isDepositFeeExempt,
|
|
8063
|
-
isWithdrawalFeeExempt: isWithdrawalFeeExempt
|
|
8094
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8095
|
+
poolAddress: poolAddress,
|
|
8064
8096
|
})
|
|
8065
8097
|
.accounts({
|
|
8066
8098
|
admin: publicKey,
|
|
@@ -8085,7 +8117,7 @@ var PerpetualsClient = (function () {
|
|
|
8085
8117
|
}
|
|
8086
8118
|
});
|
|
8087
8119
|
}); };
|
|
8088
|
-
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8120
|
+
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8089
8121
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_66;
|
|
8090
8122
|
return __generator(this, function (_a) {
|
|
8091
8123
|
switch (_a.label) {
|
|
@@ -8103,7 +8135,8 @@ var PerpetualsClient = (function () {
|
|
|
8103
8135
|
.setWhitelistConfig({
|
|
8104
8136
|
isSwapFeeExempt: isSwapFeeExempt,
|
|
8105
8137
|
isDepositFeeExempt: isDepositFeeExempt,
|
|
8106
|
-
isWithdrawalFeeExempt: isWithdrawalFeeExempt
|
|
8138
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8139
|
+
poolAddress: poolAddress
|
|
8107
8140
|
})
|
|
8108
8141
|
.accounts({
|
|
8109
8142
|
admin: publicKey,
|