flash-sdk 11.1.1 → 11.1.2
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/OraclePrice.d.ts +0 -1
- package/dist/OrderAccount.d.ts +0 -1
- package/dist/PerpetualsClient.d.ts +72 -27
- package/dist/PerpetualsClient.js +254 -95
- package/dist/PoolAccount.d.ts +0 -1
- package/dist/PoolDataClient.d.ts +0 -1
- package/dist/PositionAccount.d.ts +0 -1
- package/dist/TokenStakeAccount.d.ts +0 -1
- package/dist/TokenVaultAccount.d.ts +0 -1
- package/dist/ViewHelper.js +2 -2
- package/dist/backupOracle.js +4 -4
- package/dist/constants/index.d.ts +0 -1
- package/dist/idl/perpetuals.d.ts +177 -4
- package/dist/idl/perpetuals.js +177 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +3 -3
- package/dist/utils/IdlCoder.js +17 -7
- package/dist/utils/alt.js +5 -6
- package/dist/utils/anchorCpiEvents.d.ts +0 -1
- package/dist/utils/anchorCpiEvents.js +4 -4
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +9 -9
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -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,
|
|
@@ -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();
|
|
@@ -3626,10 +3661,11 @@ var PerpetualsClient = (function () {
|
|
|
3626
3661
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3627
3662
|
args_1[_i - 4] = arguments[_i];
|
|
3628
3663
|
}
|
|
3629
|
-
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, instruction, err_5;
|
|
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;
|
|
3631
3666
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3632
3667
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3668
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3633
3669
|
return __generator(this, function (_g) {
|
|
3634
3670
|
switch (_g.label) {
|
|
3635
3671
|
case 0:
|
|
@@ -3723,31 +3759,38 @@ var PerpetualsClient = (function () {
|
|
|
3723
3759
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
|
3724
3760
|
}
|
|
3725
3761
|
_g.label = 8;
|
|
3726
|
-
case 8:
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3762
|
+
case 8:
|
|
3763
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3764
|
+
whitelistMeta = {
|
|
3765
|
+
pubkey: whitelistPda,
|
|
3766
|
+
isSigner: false,
|
|
3767
|
+
isWritable: false,
|
|
3768
|
+
};
|
|
3769
|
+
return [4, this.program.methods
|
|
3770
|
+
.addLiquidity({
|
|
3771
|
+
amountIn: tokenAmountIn,
|
|
3772
|
+
minLpAmountOut: minLpAmountOut
|
|
3773
|
+
})
|
|
3774
|
+
.accounts({
|
|
3775
|
+
owner: publicKey,
|
|
3776
|
+
fundingAccount: payTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userPayingTokenAccount,
|
|
3777
|
+
lpTokenAccount: lpTokenAccount,
|
|
3778
|
+
transferAuthority: poolConfig.transferAuthority,
|
|
3779
|
+
perpetuals: poolConfig.perpetuals,
|
|
3780
|
+
pool: poolConfig.poolAddress,
|
|
3781
|
+
custody: payTokenCustodyConfig.custodyAccount,
|
|
3782
|
+
custodyOracleAccount: this.useExtOracleAccount ? payTokenCustodyConfig.extOracleAccount : payTokenCustodyConfig.intOracleAccount,
|
|
3783
|
+
custodyTokenAccount: payTokenCustodyConfig.tokenAccount,
|
|
3784
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
3785
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3786
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3787
|
+
program: this.programId,
|
|
3788
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3789
|
+
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3790
|
+
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3791
|
+
})
|
|
3792
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3793
|
+
.instruction()];
|
|
3751
3794
|
case 9:
|
|
3752
3795
|
instruction = _g.sent();
|
|
3753
3796
|
instructions.push(instruction);
|
|
@@ -3769,11 +3812,12 @@ var PerpetualsClient = (function () {
|
|
|
3769
3812
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3770
3813
|
args_1[_i - 4] = arguments[_i];
|
|
3771
3814
|
}
|
|
3772
|
-
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) {
|
|
3773
|
-
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, instruction;
|
|
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;
|
|
3774
3817
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3775
3818
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3776
3819
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
3820
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3777
3821
|
return __generator(this, function (_g) {
|
|
3778
3822
|
switch (_g.label) {
|
|
3779
3823
|
case 0:
|
|
@@ -3865,6 +3909,12 @@ var PerpetualsClient = (function () {
|
|
|
3865
3909
|
isWritable: false,
|
|
3866
3910
|
});
|
|
3867
3911
|
}
|
|
3912
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3913
|
+
whitelistMeta = {
|
|
3914
|
+
pubkey: whitelistPda,
|
|
3915
|
+
isSigner: false,
|
|
3916
|
+
isWritable: false,
|
|
3917
|
+
};
|
|
3868
3918
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
3869
3919
|
amountIn: amountIn,
|
|
3870
3920
|
minLpAmountOut: minLpAmountOut,
|
|
@@ -3887,9 +3937,9 @@ var PerpetualsClient = (function () {
|
|
|
3887
3937
|
program: this.programId,
|
|
3888
3938
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3889
3939
|
fundingMint: inputCustodyConfig.mintKey,
|
|
3890
|
-
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3940
|
+
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3891
3941
|
})
|
|
3892
|
-
.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))
|
|
3893
3943
|
.instruction()];
|
|
3894
3944
|
case 8:
|
|
3895
3945
|
instruction = _g.sent();
|
|
@@ -3907,13 +3957,14 @@ var PerpetualsClient = (function () {
|
|
|
3907
3957
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3908
3958
|
args_1[_i - 4] = arguments[_i];
|
|
3909
3959
|
}
|
|
3910
|
-
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) {
|
|
3911
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
|
|
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;
|
|
3912
3962
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
3913
3963
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3914
3964
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
3915
3965
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3916
3966
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
3967
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3917
3968
|
return __generator(this, function (_f) {
|
|
3918
3969
|
switch (_f.label) {
|
|
3919
3970
|
case 0:
|
|
@@ -3988,31 +4039,38 @@ var PerpetualsClient = (function () {
|
|
|
3988
4039
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, recieveToken.mintKey, recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3989
4040
|
}
|
|
3990
4041
|
_f.label = 5;
|
|
3991
|
-
case 5:
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4042
|
+
case 5:
|
|
4043
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4044
|
+
whitelistMeta = {
|
|
4045
|
+
pubkey: whitelistPda,
|
|
4046
|
+
isSigner: false,
|
|
4047
|
+
isWritable: false,
|
|
4048
|
+
};
|
|
4049
|
+
return [4, this.program.methods
|
|
4050
|
+
.removeLiquidity({
|
|
4051
|
+
lpAmountIn: liquidityAmountIn,
|
|
4052
|
+
minAmountOut: minTokenAmountOut
|
|
4053
|
+
})
|
|
4054
|
+
.accounts({
|
|
4055
|
+
owner: publicKey,
|
|
4056
|
+
receivingAccount: recieveTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
4057
|
+
lpTokenAccount: stakedLpTokenAccount,
|
|
4058
|
+
transferAuthority: poolConfig.transferAuthority,
|
|
4059
|
+
perpetuals: poolConfig.perpetuals,
|
|
4060
|
+
pool: poolConfig.poolAddress,
|
|
4061
|
+
custody: recieveTokenCustodyConfig.custodyAccount,
|
|
4062
|
+
custodyOracleAccount: this.useExtOracleAccount ? recieveTokenCustodyConfig.extOracleAccount : recieveTokenCustodyConfig.intOracleAccount,
|
|
4063
|
+
custodyTokenAccount: recieveTokenCustodyConfig.tokenAccount,
|
|
4064
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
4065
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4066
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4067
|
+
program: this.programId,
|
|
4068
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4069
|
+
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4070
|
+
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4071
|
+
})
|
|
4072
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4073
|
+
.instruction()];
|
|
4016
4074
|
case 6:
|
|
4017
4075
|
removeLiquidityTx = _f.sent();
|
|
4018
4076
|
instructions.push(removeLiquidityTx);
|
|
@@ -4567,13 +4625,13 @@ var PerpetualsClient = (function () {
|
|
|
4567
4625
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4568
4626
|
args_1[_i - 5] = arguments[_i];
|
|
4569
4627
|
}
|
|
4570
|
-
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,
|
|
4571
|
-
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, addCompoundingLiquidity, err_16;
|
|
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;
|
|
4572
4630
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4573
4631
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4574
4632
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4575
4633
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4576
|
-
if (
|
|
4634
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4577
4635
|
return __generator(this, function (_f) {
|
|
4578
4636
|
switch (_f.label) {
|
|
4579
4637
|
case 0:
|
|
@@ -4668,11 +4726,14 @@ var PerpetualsClient = (function () {
|
|
|
4668
4726
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4669
4727
|
bytes: 64 * 1024,
|
|
4670
4728
|
});
|
|
4671
|
-
if (enableDebugLogs) {
|
|
4672
|
-
console.log("SDK: adding 64 liq Data heapSizeIx for addCompoundingLiquidity");
|
|
4673
|
-
}
|
|
4674
4729
|
preInstructions.push(heapSizeIx);
|
|
4675
4730
|
}
|
|
4731
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4732
|
+
whitelistMeta = {
|
|
4733
|
+
pubkey: whitelistPda,
|
|
4734
|
+
isSigner: false,
|
|
4735
|
+
isWritable: false,
|
|
4736
|
+
};
|
|
4676
4737
|
return [4, this.program.methods
|
|
4677
4738
|
.addCompoundingLiquidity({
|
|
4678
4739
|
amountIn: amountIn,
|
|
@@ -4700,7 +4761,7 @@ var PerpetualsClient = (function () {
|
|
|
4700
4761
|
fundingMint: inCustodyConfig.mintKey,
|
|
4701
4762
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4702
4763
|
})
|
|
4703
|
-
.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))
|
|
4704
4765
|
.instruction()];
|
|
4705
4766
|
case 8:
|
|
4706
4767
|
addCompoundingLiquidity = _f.sent();
|
|
@@ -4723,13 +4784,13 @@ var PerpetualsClient = (function () {
|
|
|
4723
4784
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4724
4785
|
args_1[_i - 5] = arguments[_i];
|
|
4725
4786
|
}
|
|
4726
|
-
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,
|
|
4727
|
-
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, removeCompoundingLiquidity, err_17;
|
|
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;
|
|
4728
4789
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4729
4790
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4730
4791
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4731
4792
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4732
|
-
if (
|
|
4793
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4733
4794
|
return __generator(this, function (_f) {
|
|
4734
4795
|
switch (_f.label) {
|
|
4735
4796
|
case 0:
|
|
@@ -4808,11 +4869,14 @@ var PerpetualsClient = (function () {
|
|
|
4808
4869
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4809
4870
|
bytes: 64 * 1024,
|
|
4810
4871
|
});
|
|
4811
|
-
if (enableDebugLogs) {
|
|
4812
|
-
console.log("SDK: adding 64 liq Data heapSizeIx for addCompoundingLiquidity");
|
|
4813
|
-
}
|
|
4814
4872
|
preInstructions.push(heapSizeIx);
|
|
4815
4873
|
}
|
|
4874
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
4875
|
+
whitelistMeta = {
|
|
4876
|
+
pubkey: whitelistPda,
|
|
4877
|
+
isSigner: false,
|
|
4878
|
+
isWritable: false,
|
|
4879
|
+
};
|
|
4816
4880
|
return [4, this.program.methods
|
|
4817
4881
|
.removeCompoundingLiquidity({
|
|
4818
4882
|
compoundingAmountIn: compoundingAmountIn,
|
|
@@ -4838,9 +4902,9 @@ var PerpetualsClient = (function () {
|
|
|
4838
4902
|
program: this.program.programId,
|
|
4839
4903
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4840
4904
|
receivingMint: outCustodyConfig.mintKey,
|
|
4841
|
-
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
4905
|
+
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4842
4906
|
})
|
|
4843
|
-
.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))
|
|
4844
4908
|
.instruction()];
|
|
4845
4909
|
case 6:
|
|
4846
4910
|
removeCompoundingLiquidity = _f.sent();
|
|
@@ -6397,13 +6461,14 @@ var PerpetualsClient = (function () {
|
|
|
6397
6461
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
6398
6462
|
args_1[_i - 5] = arguments[_i];
|
|
6399
6463
|
}
|
|
6400
|
-
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) {
|
|
6401
|
-
var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_40;
|
|
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;
|
|
6402
6466
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6403
6467
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6404
6468
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
6405
6469
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
6406
6470
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
6471
|
+
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
6407
6472
|
return __generator(this, function (_g) {
|
|
6408
6473
|
switch (_g.label) {
|
|
6409
6474
|
case 0:
|
|
@@ -6564,6 +6629,12 @@ var PerpetualsClient = (function () {
|
|
|
6564
6629
|
isWritable: false,
|
|
6565
6630
|
});
|
|
6566
6631
|
}
|
|
6632
|
+
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
6633
|
+
whitelistMeta = {
|
|
6634
|
+
pubkey: whitelistPda,
|
|
6635
|
+
isSigner: false,
|
|
6636
|
+
isWritable: false,
|
|
6637
|
+
};
|
|
6567
6638
|
params = {
|
|
6568
6639
|
amountIn: amountIn,
|
|
6569
6640
|
minAmountOut: minAmountOut,
|
|
@@ -6592,7 +6663,7 @@ var PerpetualsClient = (function () {
|
|
|
6592
6663
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
6593
6664
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6594
6665
|
})
|
|
6595
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
6666
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
6596
6667
|
.instruction()];
|
|
6597
6668
|
case 18:
|
|
6598
6669
|
inx = _g.sent();
|
|
@@ -8002,6 +8073,94 @@ var PerpetualsClient = (function () {
|
|
|
8002
8073
|
}
|
|
8003
8074
|
});
|
|
8004
8075
|
}); };
|
|
8076
|
+
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8077
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_65;
|
|
8078
|
+
return __generator(this, function (_a) {
|
|
8079
|
+
switch (_a.label) {
|
|
8080
|
+
case 0:
|
|
8081
|
+
publicKey = this.provider.wallet.publicKey;
|
|
8082
|
+
preInstructions = [];
|
|
8083
|
+
instructions = [];
|
|
8084
|
+
postInstructions = [];
|
|
8085
|
+
additionalSigners = [];
|
|
8086
|
+
_a.label = 1;
|
|
8087
|
+
case 1:
|
|
8088
|
+
_a.trys.push([1, 3, , 4]);
|
|
8089
|
+
whitelist = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("whitelist"), owner.toBuffer()], this.programId)[0];
|
|
8090
|
+
return [4, this.program.methods
|
|
8091
|
+
.createWhitelist({
|
|
8092
|
+
isSwapFeeExempt: isSwapFeeExempt,
|
|
8093
|
+
isDepositFeeExempt: isDepositFeeExempt,
|
|
8094
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8095
|
+
poolAddress: poolAddress,
|
|
8096
|
+
})
|
|
8097
|
+
.accounts({
|
|
8098
|
+
admin: publicKey,
|
|
8099
|
+
multisig: this.multisig.publicKey,
|
|
8100
|
+
owner: owner,
|
|
8101
|
+
whitelist: whitelist,
|
|
8102
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
8103
|
+
})
|
|
8104
|
+
.instruction()];
|
|
8105
|
+
case 2:
|
|
8106
|
+
createWhitelistInstruction = _a.sent();
|
|
8107
|
+
instructions.push(createWhitelistInstruction);
|
|
8108
|
+
return [3, 4];
|
|
8109
|
+
case 3:
|
|
8110
|
+
err_65 = _a.sent();
|
|
8111
|
+
console.log("perpClient createWhitelistInstruction error:: ", err_65);
|
|
8112
|
+
throw err_65;
|
|
8113
|
+
case 4: return [2, {
|
|
8114
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8115
|
+
additionalSigners: additionalSigners
|
|
8116
|
+
}];
|
|
8117
|
+
}
|
|
8118
|
+
});
|
|
8119
|
+
}); };
|
|
8120
|
+
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8121
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_66;
|
|
8122
|
+
return __generator(this, function (_a) {
|
|
8123
|
+
switch (_a.label) {
|
|
8124
|
+
case 0:
|
|
8125
|
+
publicKey = this.provider.wallet.publicKey;
|
|
8126
|
+
preInstructions = [];
|
|
8127
|
+
instructions = [];
|
|
8128
|
+
postInstructions = [];
|
|
8129
|
+
additionalSigners = [];
|
|
8130
|
+
_a.label = 1;
|
|
8131
|
+
case 1:
|
|
8132
|
+
_a.trys.push([1, 3, , 4]);
|
|
8133
|
+
whitelist = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("whitelist"), owner.toBuffer()], this.programId)[0];
|
|
8134
|
+
return [4, this.program.methods
|
|
8135
|
+
.setWhitelistConfig({
|
|
8136
|
+
isSwapFeeExempt: isSwapFeeExempt,
|
|
8137
|
+
isDepositFeeExempt: isDepositFeeExempt,
|
|
8138
|
+
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8139
|
+
poolAddress: poolAddress
|
|
8140
|
+
})
|
|
8141
|
+
.accounts({
|
|
8142
|
+
admin: publicKey,
|
|
8143
|
+
multisig: this.multisig.publicKey,
|
|
8144
|
+
owner: owner,
|
|
8145
|
+
whitelist: whitelist,
|
|
8146
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
8147
|
+
})
|
|
8148
|
+
.instruction()];
|
|
8149
|
+
case 2:
|
|
8150
|
+
setWhitelistConfigInstruction = _a.sent();
|
|
8151
|
+
instructions.push(setWhitelistConfigInstruction);
|
|
8152
|
+
return [3, 4];
|
|
8153
|
+
case 3:
|
|
8154
|
+
err_66 = _a.sent();
|
|
8155
|
+
console.log("perpClient setWhitelistConfigInstruction error:: ", err_66);
|
|
8156
|
+
throw err_66;
|
|
8157
|
+
case 4: return [2, {
|
|
8158
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8159
|
+
additionalSigners: additionalSigners
|
|
8160
|
+
}];
|
|
8161
|
+
}
|
|
8162
|
+
});
|
|
8163
|
+
}); };
|
|
8005
8164
|
this.provider = provider;
|
|
8006
8165
|
(0, anchor_1.setProvider)(provider);
|
|
8007
8166
|
this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
|