flash-sdk 2.51.3 → 2.51.5
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 +1 -1
- package/dist/PerpetualsClient.js +508 -384
- package/dist/ViewHelper.js +3 -3
- package/dist/backupOracle.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/alt.d.ts +0 -1
- package/dist/utils/rpc.js +50 -50
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
@@ -2148,36 +2148,38 @@ var PerpetualsClient = (function () {
|
|
2148
2148
|
}
|
2149
2149
|
});
|
2150
2150
|
}); };
|
2151
|
-
this.getAddLiquidityAmountAndFeeView = function (
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2151
|
+
this.getAddLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
|
2152
|
+
var args_1 = [];
|
2153
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2154
|
+
args_1[_i - 4] = arguments[_i];
|
2155
|
+
}
|
2156
|
+
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) {
|
2157
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, result, index, res;
|
2158
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2156
2159
|
return __generator(this, function (_e) {
|
2157
2160
|
switch (_e.label) {
|
2158
2161
|
case 0:
|
2159
|
-
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2160
2162
|
custodies = POOL_CONFIG.custodies;
|
2161
2163
|
custodyMetas = [];
|
2162
2164
|
marketMetas = [];
|
2163
|
-
for (
|
2164
|
-
token = custodies_5[
|
2165
|
+
for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
|
2166
|
+
token = custodies_5[_a];
|
2165
2167
|
custodyMetas.push({
|
2166
2168
|
isSigner: false,
|
2167
2169
|
isWritable: false,
|
2168
2170
|
pubkey: token.custodyAccount,
|
2169
2171
|
});
|
2170
2172
|
}
|
2171
|
-
for (
|
2172
|
-
custody = custodies_6[
|
2173
|
+
for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
|
2174
|
+
custody = custodies_6[_b];
|
2173
2175
|
custodyMetas.push({
|
2174
2176
|
isSigner: false,
|
2175
2177
|
isWritable: false,
|
2176
2178
|
pubkey: custody.intOracleAccount,
|
2177
2179
|
});
|
2178
2180
|
}
|
2179
|
-
for (
|
2180
|
-
market = _c
|
2181
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2182
|
+
market = _d[_c];
|
2181
2183
|
marketMetas.push({
|
2182
2184
|
pubkey: market.marketAccount,
|
2183
2185
|
isSigner: false,
|
@@ -2201,12 +2203,8 @@ var PerpetualsClient = (function () {
|
|
2201
2203
|
.transaction()];
|
2202
2204
|
case 1:
|
2203
2205
|
transaction = _e.sent();
|
2204
|
-
return [4, backUpOracleInstructionPromise];
|
2205
|
-
case 2:
|
2206
|
-
backUpOracleInstruction = _e.sent();
|
2207
|
-
(_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
|
2208
2206
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2209
|
-
case
|
2207
|
+
case 2:
|
2210
2208
|
result = _e.sent();
|
2211
2209
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
|
2212
2210
|
res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
|
@@ -2218,36 +2216,38 @@ var PerpetualsClient = (function () {
|
|
2218
2216
|
});
|
2219
2217
|
});
|
2220
2218
|
};
|
2221
|
-
this.getRemoveLiquidityAmountAndFeeView = function (
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2219
|
+
this.getRemoveLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
|
2220
|
+
var args_1 = [];
|
2221
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2222
|
+
args_1[_i - 4] = arguments[_i];
|
2223
|
+
}
|
2224
|
+
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) {
|
2225
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, result, index, res;
|
2226
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2226
2227
|
return __generator(this, function (_e) {
|
2227
2228
|
switch (_e.label) {
|
2228
2229
|
case 0:
|
2229
|
-
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2230
2230
|
custodies = POOL_CONFIG.custodies;
|
2231
2231
|
custodyMetas = [];
|
2232
2232
|
marketMetas = [];
|
2233
|
-
for (
|
2234
|
-
token = custodies_7[
|
2233
|
+
for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
|
2234
|
+
token = custodies_7[_a];
|
2235
2235
|
custodyMetas.push({
|
2236
2236
|
isSigner: false,
|
2237
2237
|
isWritable: false,
|
2238
2238
|
pubkey: token.custodyAccount,
|
2239
2239
|
});
|
2240
2240
|
}
|
2241
|
-
for (
|
2242
|
-
custody = custodies_8[
|
2241
|
+
for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
|
2242
|
+
custody = custodies_8[_b];
|
2243
2243
|
custodyMetas.push({
|
2244
2244
|
isSigner: false,
|
2245
2245
|
isWritable: false,
|
2246
2246
|
pubkey: custody.intOracleAccount,
|
2247
2247
|
});
|
2248
2248
|
}
|
2249
|
-
for (
|
2250
|
-
market = _c
|
2249
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2250
|
+
market = _d[_c];
|
2251
2251
|
marketMetas.push({
|
2252
2252
|
pubkey: market.marketAccount,
|
2253
2253
|
isSigner: false,
|
@@ -2271,12 +2271,8 @@ var PerpetualsClient = (function () {
|
|
2271
2271
|
.transaction()];
|
2272
2272
|
case 1:
|
2273
2273
|
transaction = _e.sent();
|
2274
|
-
return [4, backUpOracleInstructionPromise];
|
2275
|
-
case 2:
|
2276
|
-
backUpOracleInstruction = _e.sent();
|
2277
|
-
(_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
|
2278
2274
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2279
|
-
case
|
2275
|
+
case 2:
|
2280
2276
|
result = _e.sent();
|
2281
2277
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
|
2282
2278
|
if (result.value.err) {
|
@@ -2353,36 +2349,38 @@ var PerpetualsClient = (function () {
|
|
2353
2349
|
}
|
2354
2350
|
});
|
2355
2351
|
}); };
|
2356
|
-
this.getAddCompoundingLiquidityAmountAndFeeView = function (
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2352
|
+
this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
|
2353
|
+
var args_1 = [];
|
2354
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2355
|
+
args_1[_i - 4] = arguments[_i];
|
2356
|
+
}
|
2357
|
+
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) {
|
2358
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, result, index, res;
|
2359
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2361
2360
|
return __generator(this, function (_e) {
|
2362
2361
|
switch (_e.label) {
|
2363
2362
|
case 0:
|
2364
|
-
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2365
2363
|
custodies = POOL_CONFIG.custodies;
|
2366
2364
|
custodyMetas = [];
|
2367
2365
|
marketMetas = [];
|
2368
|
-
for (
|
2369
|
-
token = custodies_11[
|
2366
|
+
for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
|
2367
|
+
token = custodies_11[_a];
|
2370
2368
|
custodyMetas.push({
|
2371
2369
|
isSigner: false,
|
2372
2370
|
isWritable: false,
|
2373
2371
|
pubkey: token.custodyAccount,
|
2374
2372
|
});
|
2375
2373
|
}
|
2376
|
-
for (
|
2377
|
-
custody = custodies_12[
|
2374
|
+
for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
|
2375
|
+
custody = custodies_12[_b];
|
2378
2376
|
custodyMetas.push({
|
2379
2377
|
isSigner: false,
|
2380
2378
|
isWritable: false,
|
2381
2379
|
pubkey: custody.intOracleAccount,
|
2382
2380
|
});
|
2383
2381
|
}
|
2384
|
-
for (
|
2385
|
-
market = _c
|
2382
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2383
|
+
market = _d[_c];
|
2386
2384
|
marketMetas.push({
|
2387
2385
|
pubkey: market.marketAccount,
|
2388
2386
|
isSigner: false,
|
@@ -2391,9 +2389,6 @@ var PerpetualsClient = (function () {
|
|
2391
2389
|
}
|
2392
2390
|
depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
|
2393
2391
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
2394
|
-
return [4, backUpOracleInstructionPromise];
|
2395
|
-
case 1:
|
2396
|
-
backUpOracleInstruction = _e.sent();
|
2397
2392
|
return [4, this.program.methods
|
2398
2393
|
.getAddCompoundingLiquidityAmountAndFee({
|
2399
2394
|
amountIn: amount,
|
@@ -2411,11 +2406,10 @@ var PerpetualsClient = (function () {
|
|
2411
2406
|
})
|
2412
2407
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2413
2408
|
.transaction()];
|
2414
|
-
case
|
2409
|
+
case 1:
|
2415
2410
|
transaction = _e.sent();
|
2416
|
-
(_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
|
2417
2411
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2418
|
-
case
|
2412
|
+
case 2:
|
2419
2413
|
result = _e.sent();
|
2420
2414
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
|
2421
2415
|
res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
|
@@ -2427,36 +2421,38 @@ var PerpetualsClient = (function () {
|
|
2427
2421
|
});
|
2428
2422
|
});
|
2429
2423
|
};
|
2430
|
-
this.getRemoveCompoundingLiquidityAmountAndFeeView = function (
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2424
|
+
this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
|
2425
|
+
var args_1 = [];
|
2426
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2427
|
+
args_1[_i - 4] = arguments[_i];
|
2428
|
+
}
|
2429
|
+
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) {
|
2430
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, result, index, res;
|
2431
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2435
2432
|
return __generator(this, function (_e) {
|
2436
2433
|
switch (_e.label) {
|
2437
2434
|
case 0:
|
2438
|
-
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2439
2435
|
custodies = POOL_CONFIG.custodies;
|
2440
2436
|
custodyMetas = [];
|
2441
2437
|
marketMetas = [];
|
2442
|
-
for (
|
2443
|
-
token = custodies_13[
|
2438
|
+
for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
|
2439
|
+
token = custodies_13[_a];
|
2444
2440
|
custodyMetas.push({
|
2445
2441
|
isSigner: false,
|
2446
2442
|
isWritable: false,
|
2447
2443
|
pubkey: token.custodyAccount,
|
2448
2444
|
});
|
2449
2445
|
}
|
2450
|
-
for (
|
2451
|
-
custody = custodies_14[
|
2446
|
+
for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
|
2447
|
+
custody = custodies_14[_b];
|
2452
2448
|
custodyMetas.push({
|
2453
2449
|
isSigner: false,
|
2454
2450
|
isWritable: false,
|
2455
2451
|
pubkey: custody.intOracleAccount,
|
2456
2452
|
});
|
2457
2453
|
}
|
2458
|
-
for (
|
2459
|
-
market = _c
|
2454
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2455
|
+
market = _d[_c];
|
2460
2456
|
marketMetas.push({
|
2461
2457
|
pubkey: market.marketAccount,
|
2462
2458
|
isSigner: false,
|
@@ -2465,9 +2461,6 @@ var PerpetualsClient = (function () {
|
|
2465
2461
|
}
|
2466
2462
|
removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
|
2467
2463
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
2468
|
-
return [4, backUpOracleInstructionPromise];
|
2469
|
-
case 1:
|
2470
|
-
backUpOracleInstruction = _e.sent();
|
2471
2464
|
return [4, this.program.methods
|
2472
2465
|
.getRemoveCompoundingLiquidityAmountAndFee({
|
2473
2466
|
compoundingAmountIn: amount,
|
@@ -2485,11 +2478,10 @@ var PerpetualsClient = (function () {
|
|
2485
2478
|
})
|
2486
2479
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2487
2480
|
.transaction()];
|
2488
|
-
case
|
2481
|
+
case 1:
|
2489
2482
|
transaction = _e.sent();
|
2490
|
-
(_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
|
2491
2483
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2492
|
-
case
|
2484
|
+
case 2:
|
2493
2485
|
result = _e.sent();
|
2494
2486
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
|
2495
2487
|
if (result.value.err) {
|
@@ -2671,14 +2663,18 @@ var PerpetualsClient = (function () {
|
|
2671
2663
|
}
|
2672
2664
|
});
|
2673
2665
|
}); };
|
2674
|
-
this.openPosition = function (
|
2675
|
-
|
2676
|
-
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2666
|
+
this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
|
2667
|
+
var args_1 = [];
|
2668
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
2669
|
+
args_1[_i - 8] = arguments[_i];
|
2670
|
+
}
|
2671
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
2681
2672
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
|
2673
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2674
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2675
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2676
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2677
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2682
2678
|
return __generator(this, function (_c) {
|
2683
2679
|
switch (_c.label) {
|
2684
2680
|
case 0:
|
@@ -2782,15 +2778,19 @@ var PerpetualsClient = (function () {
|
|
2782
2778
|
});
|
2783
2779
|
});
|
2784
2780
|
};
|
2785
|
-
this.closePosition = function (
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2792
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2781
|
+
this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
2782
|
+
var args_1 = [];
|
2783
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
2784
|
+
args_1[_i - 6] = arguments[_i];
|
2785
|
+
}
|
2786
|
+
return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
2793
2787
|
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_2;
|
2788
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2789
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2790
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2791
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
2792
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
2793
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2794
2794
|
return __generator(this, function (_b) {
|
2795
2795
|
switch (_b.label) {
|
2796
2796
|
case 0:
|
@@ -2887,14 +2887,18 @@ var PerpetualsClient = (function () {
|
|
2887
2887
|
});
|
2888
2888
|
});
|
2889
2889
|
};
|
2890
|
-
this.swapAndOpen = function (
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2890
|
+
this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
|
2891
|
+
var args_1 = [];
|
2892
|
+
for (var _i = 10; _i < arguments.length; _i++) {
|
2893
|
+
args_1[_i - 10] = arguments[_i];
|
2894
|
+
}
|
2895
|
+
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
2897
2896
|
var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_3;
|
2897
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2898
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2899
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2900
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2901
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2898
2902
|
return __generator(this, function (_c) {
|
2899
2903
|
switch (_c.label) {
|
2900
2904
|
case 0:
|
@@ -3034,13 +3038,17 @@ var PerpetualsClient = (function () {
|
|
3034
3038
|
});
|
3035
3039
|
});
|
3036
3040
|
};
|
3037
|
-
this.closeAndSwap = function (
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
return __awaiter(_this,
|
3041
|
+
this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
3042
|
+
var args_1 = [];
|
3043
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3044
|
+
args_1[_i - 8] = arguments[_i];
|
3045
|
+
}
|
3046
|
+
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
|
3043
3047
|
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_4;
|
3048
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3049
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3050
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3051
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3044
3052
|
return __generator(this, function (_a) {
|
3045
3053
|
switch (_a.label) {
|
3046
3054
|
case 0:
|
@@ -3154,16 +3162,20 @@ var PerpetualsClient = (function () {
|
|
3154
3162
|
});
|
3155
3163
|
});
|
3156
3164
|
};
|
3157
|
-
this.swap = function (
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3165
|
+
this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
|
3166
|
+
var args_1 = [];
|
3167
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
3168
|
+
args_1[_i - 5] = arguments[_i];
|
3169
|
+
}
|
3170
|
+
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) {
|
3171
|
+
var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_5;
|
3172
|
+
if (useFeesPool === void 0) { useFeesPool = false; }
|
3173
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3174
|
+
if (unWrapSol === void 0) { unWrapSol = false; }
|
3175
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3176
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3177
|
+
return __generator(this, function (_g) {
|
3178
|
+
switch (_g.label) {
|
3167
3179
|
case 0:
|
3168
3180
|
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
3169
3181
|
if (!userInputCustodyConfig) {
|
@@ -3181,10 +3193,10 @@ var PerpetualsClient = (function () {
|
|
3181
3193
|
if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
|
3182
3194
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
|
3183
3195
|
case 1:
|
3184
|
-
wsolAssociatedTokenAccount =
|
3196
|
+
wsolAssociatedTokenAccount = _g.sent();
|
3185
3197
|
return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
|
3186
3198
|
case 2:
|
3187
|
-
wsolATAExist =
|
3199
|
+
wsolATAExist = _g.sent();
|
3188
3200
|
if (!wsolATAExist) {
|
3189
3201
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
|
3190
3202
|
}
|
@@ -3192,11 +3204,11 @@ var PerpetualsClient = (function () {
|
|
3192
3204
|
_a = anchor_1.BN.bind;
|
3193
3205
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3194
3206
|
case 3:
|
3195
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
3207
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3196
3208
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3197
3209
|
throw "Insufficient SOL Funds";
|
3198
3210
|
}
|
3199
|
-
|
3211
|
+
_g.label = 4;
|
3200
3212
|
case 4:
|
3201
3213
|
instructions.push(web3_js_1.SystemProgram.transfer({
|
3202
3214
|
fromPubkey: publicKey,
|
@@ -3218,20 +3230,20 @@ var PerpetualsClient = (function () {
|
|
3218
3230
|
additionalSigners: additionalSigners
|
3219
3231
|
}];
|
3220
3232
|
}
|
3221
|
-
|
3233
|
+
_g.label = 6;
|
3222
3234
|
case 6:
|
3223
|
-
|
3235
|
+
_g.trys.push([6, 19, , 20]);
|
3224
3236
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
3225
3237
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
3226
3238
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
3227
3239
|
case 7:
|
3228
|
-
accCreationLamports = (
|
3240
|
+
accCreationLamports = (_g.sent());
|
3229
3241
|
console.log("accCreationLamports:", accCreationLamports);
|
3230
3242
|
lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
|
3231
3243
|
_b = anchor_1.BN.bind;
|
3232
3244
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3233
3245
|
case 8:
|
3234
|
-
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0,
|
3246
|
+
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3235
3247
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3236
3248
|
throw "Insufficient SOL Funds";
|
3237
3249
|
}
|
@@ -3258,18 +3270,18 @@ var PerpetualsClient = (function () {
|
|
3258
3270
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
|
3259
3271
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
3260
3272
|
case 10:
|
3261
|
-
if (!(
|
3273
|
+
if (!(_g.sent())) {
|
3262
3274
|
throw "Insufficient Funds , Token Account doesn't exist";
|
3263
3275
|
}
|
3264
3276
|
if (!!skipBalanceChecks) return [3, 12];
|
3265
3277
|
_c = anchor_1.BN.bind;
|
3266
3278
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
3267
3279
|
case 11:
|
3268
|
-
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (
|
3280
|
+
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
3269
3281
|
if (tokenAccountBalance.lt(amountIn)) {
|
3270
3282
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
3271
3283
|
}
|
3272
|
-
|
3284
|
+
_g.label = 12;
|
3273
3285
|
case 12:
|
3274
3286
|
if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
|
3275
3287
|
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
@@ -3294,23 +3306,23 @@ var PerpetualsClient = (function () {
|
|
3294
3306
|
return [3, 17];
|
3295
3307
|
case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
|
3296
3308
|
case 14:
|
3297
|
-
userOutputTokenAccount =
|
3309
|
+
userOutputTokenAccount = _g.sent();
|
3298
3310
|
_d = createUserATA;
|
3299
3311
|
if (!_d) return [3, 16];
|
3300
3312
|
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
3301
3313
|
case 15:
|
3302
|
-
_d = !(
|
3303
|
-
|
3314
|
+
_d = !(_g.sent());
|
3315
|
+
_g.label = 16;
|
3304
3316
|
case 16:
|
3305
3317
|
if (_d) {
|
3306
3318
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
|
3307
3319
|
}
|
3308
|
-
|
3320
|
+
_g.label = 17;
|
3309
3321
|
case 17:
|
3310
3322
|
custodyAccountMetas = [];
|
3311
3323
|
custodyOracleAccountMetas = [];
|
3312
|
-
for (
|
3313
|
-
custody = _e
|
3324
|
+
for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
|
3325
|
+
custody = _f[_e];
|
3314
3326
|
custodyAccountMetas.push({
|
3315
3327
|
pubkey: custody.custodyAccount,
|
3316
3328
|
isSigner: false,
|
@@ -3350,7 +3362,7 @@ var PerpetualsClient = (function () {
|
|
3350
3362
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
3351
3363
|
.instruction()];
|
3352
3364
|
case 18:
|
3353
|
-
inx =
|
3365
|
+
inx = _g.sent();
|
3354
3366
|
instructions.push(inx);
|
3355
3367
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
3356
3368
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
@@ -3358,7 +3370,7 @@ var PerpetualsClient = (function () {
|
|
3358
3370
|
}
|
3359
3371
|
return [3, 20];
|
3360
3372
|
case 19:
|
3361
|
-
err_5 =
|
3373
|
+
err_5 = _g.sent();
|
3362
3374
|
console.error("perpClient Swap error:: ", err_5);
|
3363
3375
|
throw err_5;
|
3364
3376
|
case 20: return [2, {
|
@@ -3440,11 +3452,15 @@ var PerpetualsClient = (function () {
|
|
3440
3452
|
}
|
3441
3453
|
});
|
3442
3454
|
}); };
|
3443
|
-
this.addCollateral = function (
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3455
|
+
this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3456
|
+
var args_1 = [];
|
3457
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3458
|
+
args_1[_i - 6] = arguments[_i];
|
3459
|
+
}
|
3460
|
+
return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
3447
3461
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
|
3462
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3463
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3448
3464
|
return __generator(this, function (_c) {
|
3449
3465
|
switch (_c.label) {
|
3450
3466
|
case 0:
|
@@ -3538,11 +3554,15 @@ var PerpetualsClient = (function () {
|
|
3538
3554
|
});
|
3539
3555
|
});
|
3540
3556
|
};
|
3541
|
-
this.swapAndAddCollateral = function (
|
3542
|
-
|
3543
|
-
|
3544
|
-
|
3557
|
+
this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
|
3558
|
+
var args_1 = [];
|
3559
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3560
|
+
args_1[_i - 8] = arguments[_i];
|
3561
|
+
}
|
3562
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, minCollateralAmountOut, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
3545
3563
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
|
3564
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3565
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3546
3566
|
return __generator(this, function (_c) {
|
3547
3567
|
switch (_c.label) {
|
3548
3568
|
case 0:
|
@@ -3653,12 +3673,16 @@ var PerpetualsClient = (function () {
|
|
3653
3673
|
});
|
3654
3674
|
});
|
3655
3675
|
};
|
3656
|
-
this.removeCollateral = function (
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3676
|
+
this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3677
|
+
var args_1 = [];
|
3678
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3679
|
+
args_1[_i - 6] = arguments[_i];
|
3680
|
+
}
|
3681
|
+
return __awaiter(_this, __spreadArray([collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
3661
3682
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_3;
|
3683
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3684
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
3685
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3662
3686
|
return __generator(this, function (_b) {
|
3663
3687
|
switch (_b.label) {
|
3664
3688
|
case 0:
|
@@ -3759,10 +3783,14 @@ var PerpetualsClient = (function () {
|
|
3759
3783
|
});
|
3760
3784
|
});
|
3761
3785
|
};
|
3762
|
-
this.removeCollateralAndSwap = function (
|
3763
|
-
|
3764
|
-
|
3786
|
+
this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
|
3787
|
+
var args_1 = [];
|
3788
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
3789
|
+
args_1[_i - 7] = arguments[_i];
|
3790
|
+
}
|
3791
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, minSwapAmountOut, collateralDelta, side, poolConfig, ephemeralSignerPubkey) {
|
3765
3792
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
|
3793
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3766
3794
|
return __generator(this, function (_a) {
|
3767
3795
|
switch (_a.label) {
|
3768
3796
|
case 0:
|
@@ -3855,12 +3883,16 @@ var PerpetualsClient = (function () {
|
|
3855
3883
|
});
|
3856
3884
|
});
|
3857
3885
|
};
|
3858
|
-
this.increaseSize = function (
|
3859
|
-
|
3860
|
-
|
3861
|
-
|
3862
|
-
|
3886
|
+
this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3887
|
+
var args_1 = [];
|
3888
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3889
|
+
args_1[_i - 8] = arguments[_i];
|
3890
|
+
}
|
3891
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
3863
3892
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3893
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3894
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3895
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3864
3896
|
return __generator(this, function (_a) {
|
3865
3897
|
switch (_a.label) {
|
3866
3898
|
case 0:
|
@@ -3915,12 +3947,16 @@ var PerpetualsClient = (function () {
|
|
3915
3947
|
});
|
3916
3948
|
});
|
3917
3949
|
};
|
3918
|
-
this.decreaseSize = function (
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3950
|
+
this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3951
|
+
var args_1 = [];
|
3952
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3953
|
+
args_1[_i - 8] = arguments[_i];
|
3954
|
+
}
|
3955
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
3923
3956
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3957
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3958
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3959
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3924
3960
|
return __generator(this, function (_a) {
|
3925
3961
|
switch (_a.label) {
|
3926
3962
|
case 0:
|
@@ -3975,13 +4011,17 @@ var PerpetualsClient = (function () {
|
|
3975
4011
|
});
|
3976
4012
|
});
|
3977
4013
|
};
|
3978
|
-
this.addLiquidity = function (
|
3979
|
-
|
3980
|
-
|
3981
|
-
|
3982
|
-
|
3983
|
-
|
3984
|
-
|
4014
|
+
this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
|
4015
|
+
var args_1 = [];
|
4016
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4017
|
+
args_1[_i - 4] = arguments[_i];
|
4018
|
+
}
|
4019
|
+
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
4020
|
+
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, instruction, err_7;
|
4021
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
4022
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4023
|
+
return __generator(this, function (_g) {
|
4024
|
+
switch (_g.label) {
|
3985
4025
|
case 0:
|
3986
4026
|
publicKey = this.provider.wallet.publicKey;
|
3987
4027
|
payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
|
@@ -3992,16 +4032,16 @@ var PerpetualsClient = (function () {
|
|
3992
4032
|
instructions = [];
|
3993
4033
|
postInstructions = [];
|
3994
4034
|
additionalSigners = [];
|
3995
|
-
|
4035
|
+
_g.label = 1;
|
3996
4036
|
case 1:
|
3997
|
-
|
4037
|
+
_g.trys.push([1, 10, , 11]);
|
3998
4038
|
userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
|
3999
4039
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
4000
4040
|
custodyAccountMetas = [];
|
4001
4041
|
custodyOracleAccountMetas = [];
|
4002
4042
|
markets = [];
|
4003
|
-
for (
|
4004
|
-
custody = _a
|
4043
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4044
|
+
custody = _b[_a];
|
4005
4045
|
custodyAccountMetas.push({
|
4006
4046
|
pubkey: custody.custodyAccount,
|
4007
4047
|
isSigner: false,
|
@@ -4013,8 +4053,8 @@ var PerpetualsClient = (function () {
|
|
4013
4053
|
isWritable: false,
|
4014
4054
|
});
|
4015
4055
|
}
|
4016
|
-
for (
|
4017
|
-
market = _c
|
4056
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4057
|
+
market = _d[_c];
|
4018
4058
|
markets.push({
|
4019
4059
|
pubkey: market.marketAccount,
|
4020
4060
|
isSigner: false,
|
@@ -4023,21 +4063,21 @@ var PerpetualsClient = (function () {
|
|
4023
4063
|
}
|
4024
4064
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
4025
4065
|
case 2:
|
4026
|
-
if (!(
|
4066
|
+
if (!(_g.sent())) {
|
4027
4067
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
4028
4068
|
}
|
4029
4069
|
if (!(payTokenSymbol == 'SOL')) return [3, 5];
|
4030
4070
|
console.log("payTokenSymbol === SOL", payTokenSymbol);
|
4031
4071
|
lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
4032
4072
|
if (!!skipBalanceChecks) return [3, 4];
|
4033
|
-
|
4073
|
+
_e = anchor_1.BN.bind;
|
4034
4074
|
return [4, this.provider.connection.getBalance(publicKey)];
|
4035
4075
|
case 3:
|
4036
|
-
unWrappedSolBalance = new (
|
4076
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
4037
4077
|
if (unWrappedSolBalance.lt(lamports)) {
|
4038
4078
|
throw "Insufficient SOL Funds";
|
4039
4079
|
}
|
4040
|
-
|
4080
|
+
_g.label = 4;
|
4041
4081
|
case 4:
|
4042
4082
|
if (!ephemeralSignerPubkey) {
|
4043
4083
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -4061,17 +4101,17 @@ var PerpetualsClient = (function () {
|
|
4061
4101
|
if (!!skipBalanceChecks) return [3, 8];
|
4062
4102
|
return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
|
4063
4103
|
case 6:
|
4064
|
-
if (!(
|
4104
|
+
if (!(_g.sent())) {
|
4065
4105
|
throw "Insufficient Funds , token Account doesn't exist";
|
4066
4106
|
}
|
4067
|
-
|
4107
|
+
_f = anchor_1.BN.bind;
|
4068
4108
|
return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
|
4069
4109
|
case 7:
|
4070
|
-
tokenAccountBalance = new (
|
4110
|
+
tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4071
4111
|
if (tokenAccountBalance.lt(tokenAmountIn)) {
|
4072
4112
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
4073
4113
|
}
|
4074
|
-
|
4114
|
+
_g.label = 8;
|
4075
4115
|
case 8: return [4, this.program.methods
|
4076
4116
|
.addLiquidity({
|
4077
4117
|
amountIn: tokenAmountIn,
|
@@ -4096,11 +4136,11 @@ var PerpetualsClient = (function () {
|
|
4096
4136
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4097
4137
|
.instruction()];
|
4098
4138
|
case 9:
|
4099
|
-
instruction =
|
4139
|
+
instruction = _g.sent();
|
4100
4140
|
instructions.push(instruction);
|
4101
4141
|
return [3, 11];
|
4102
4142
|
case 10:
|
4103
|
-
err_7 =
|
4143
|
+
err_7 = _g.sent();
|
4104
4144
|
console.error("perpClient addLiquidity error:: ", err_7);
|
4105
4145
|
throw err_7;
|
4106
4146
|
case 11: return [2, {
|
@@ -4111,14 +4151,18 @@ var PerpetualsClient = (function () {
|
|
4111
4151
|
});
|
4112
4152
|
});
|
4113
4153
|
};
|
4114
|
-
this.addLiquidityAndStake = function (
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4120
|
-
|
4121
|
-
|
4154
|
+
this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
|
4155
|
+
var args_1 = [];
|
4156
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4157
|
+
args_1[_i - 4] = arguments[_i];
|
4158
|
+
}
|
4159
|
+
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) {
|
4160
|
+
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, instruction;
|
4161
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
4162
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4163
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4164
|
+
return __generator(this, function (_g) {
|
4165
|
+
switch (_g.label) {
|
4122
4166
|
case 0:
|
4123
4167
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
4124
4168
|
preInstructions = [];
|
@@ -4138,14 +4182,14 @@ var PerpetualsClient = (function () {
|
|
4138
4182
|
_a = anchor_1.BN.bind;
|
4139
4183
|
return [4, this.provider.connection.getBalance(publicKey)];
|
4140
4184
|
case 1:
|
4141
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
4185
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
4142
4186
|
if (unWrappedSolBalance.lt(lamports)) {
|
4143
4187
|
throw "Insufficient SOL Funds";
|
4144
4188
|
}
|
4145
|
-
|
4189
|
+
_g.label = 2;
|
4146
4190
|
case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
4147
4191
|
case 3:
|
4148
|
-
if (!(
|
4192
|
+
if (!(_g.sent())) {
|
4149
4193
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
4150
4194
|
}
|
4151
4195
|
if (!ephemeralSignerPubkey) {
|
@@ -4171,23 +4215,23 @@ var PerpetualsClient = (function () {
|
|
4171
4215
|
if (!!skipBalanceChecks) return [3, 7];
|
4172
4216
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
4173
4217
|
case 5:
|
4174
|
-
if (!(
|
4218
|
+
if (!(_g.sent())) {
|
4175
4219
|
throw "Insufficient Funds , token Account doesn't exist";
|
4176
4220
|
}
|
4177
4221
|
_b = anchor_1.BN.bind;
|
4178
4222
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
4179
4223
|
case 6:
|
4180
|
-
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (
|
4224
|
+
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4181
4225
|
if (tokenAccountBalance.lt(amountIn)) {
|
4182
4226
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
4183
4227
|
}
|
4184
|
-
|
4228
|
+
_g.label = 7;
|
4185
4229
|
case 7:
|
4186
4230
|
custodyAccountMetas = [];
|
4187
4231
|
custodyOracleAccountMetas = [];
|
4188
4232
|
markets = [];
|
4189
|
-
for (
|
4190
|
-
custody = _c
|
4233
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
4234
|
+
custody = _d[_c];
|
4191
4235
|
custodyAccountMetas.push({
|
4192
4236
|
pubkey: custody.custodyAccount,
|
4193
4237
|
isSigner: false,
|
@@ -4199,8 +4243,8 @@ var PerpetualsClient = (function () {
|
|
4199
4243
|
isWritable: false,
|
4200
4244
|
});
|
4201
4245
|
}
|
4202
|
-
for (
|
4203
|
-
market = _e
|
4246
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
4247
|
+
market = _f[_e];
|
4204
4248
|
markets.push({
|
4205
4249
|
pubkey: market.marketAccount,
|
4206
4250
|
isSigner: false,
|
@@ -4232,7 +4276,7 @@ var PerpetualsClient = (function () {
|
|
4232
4276
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4233
4277
|
.instruction()];
|
4234
4278
|
case 8:
|
4235
|
-
instruction =
|
4279
|
+
instruction = _g.sent();
|
4236
4280
|
instructions.push(instruction);
|
4237
4281
|
return [2, {
|
4238
4282
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -4242,16 +4286,20 @@ var PerpetualsClient = (function () {
|
|
4242
4286
|
});
|
4243
4287
|
});
|
4244
4288
|
};
|
4245
|
-
this.removeLiquidity = function (
|
4246
|
-
|
4247
|
-
|
4248
|
-
|
4249
|
-
|
4250
|
-
|
4251
|
-
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4289
|
+
this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
|
4290
|
+
var args_1 = [];
|
4291
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4292
|
+
args_1[_i - 4] = arguments[_i];
|
4293
|
+
}
|
4294
|
+
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) {
|
4295
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, removeLiquidityTx, closeInx, closeWsolATAIns, err_8;
|
4296
|
+
if (closeLpATA === void 0) { closeLpATA = false; }
|
4297
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
4298
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
4299
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4300
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4301
|
+
return __generator(this, function (_f) {
|
4302
|
+
switch (_f.label) {
|
4255
4303
|
case 0:
|
4256
4304
|
recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
|
4257
4305
|
if (!recieveTokenCustodyConfig) {
|
@@ -4262,15 +4310,15 @@ var PerpetualsClient = (function () {
|
|
4262
4310
|
instructions = [];
|
4263
4311
|
postInstructions = [];
|
4264
4312
|
additionalSigners = [];
|
4265
|
-
|
4313
|
+
_f.label = 1;
|
4266
4314
|
case 1:
|
4267
|
-
|
4315
|
+
_f.trys.push([1, 7, , 8]);
|
4268
4316
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
4269
4317
|
custodyAccountMetas = [];
|
4270
4318
|
custodyOracleAccountMetas = [];
|
4271
4319
|
markets = [];
|
4272
|
-
for (
|
4273
|
-
custody = _a
|
4320
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4321
|
+
custody = _b[_a];
|
4274
4322
|
custodyAccountMetas.push({
|
4275
4323
|
pubkey: custody.custodyAccount,
|
4276
4324
|
isSigner: false,
|
@@ -4282,8 +4330,8 @@ var PerpetualsClient = (function () {
|
|
4282
4330
|
isWritable: false,
|
4283
4331
|
});
|
4284
4332
|
}
|
4285
|
-
for (
|
4286
|
-
market = _c
|
4333
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4334
|
+
market = _d[_c];
|
4287
4335
|
markets.push({
|
4288
4336
|
pubkey: market.marketAccount,
|
4289
4337
|
isSigner: false,
|
@@ -4312,17 +4360,17 @@ var PerpetualsClient = (function () {
|
|
4312
4360
|
return [3, 5];
|
4313
4361
|
case 2:
|
4314
4362
|
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
|
4315
|
-
|
4316
|
-
if (!
|
4363
|
+
_e = createUserATA;
|
4364
|
+
if (!_e) return [3, 4];
|
4317
4365
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
4318
4366
|
case 3:
|
4319
|
-
|
4320
|
-
|
4367
|
+
_e = !(_f.sent());
|
4368
|
+
_f.label = 4;
|
4321
4369
|
case 4:
|
4322
|
-
if (
|
4370
|
+
if (_e) {
|
4323
4371
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
|
4324
4372
|
}
|
4325
|
-
|
4373
|
+
_f.label = 5;
|
4326
4374
|
case 5: return [4, this.program.methods
|
4327
4375
|
.removeLiquidity({
|
4328
4376
|
lpAmountIn: liquidityAmountIn,
|
@@ -4347,7 +4395,7 @@ var PerpetualsClient = (function () {
|
|
4347
4395
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4348
4396
|
.instruction()];
|
4349
4397
|
case 6:
|
4350
|
-
removeLiquidityTx =
|
4398
|
+
removeLiquidityTx = _f.sent();
|
4351
4399
|
instructions.push(removeLiquidityTx);
|
4352
4400
|
if (closeLpATA) {
|
4353
4401
|
closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
|
@@ -4359,7 +4407,7 @@ var PerpetualsClient = (function () {
|
|
4359
4407
|
}
|
4360
4408
|
return [3, 8];
|
4361
4409
|
case 7:
|
4362
|
-
err_8 =
|
4410
|
+
err_8 = _f.sent();
|
4363
4411
|
console.log("perpClient removeLiquidity error:: ", err_8);
|
4364
4412
|
throw err_8;
|
4365
4413
|
case 8: return [2, {
|
@@ -4777,22 +4825,26 @@ var PerpetualsClient = (function () {
|
|
4777
4825
|
}
|
4778
4826
|
});
|
4779
4827
|
}); };
|
4780
|
-
this.refreshStakeWithTokenStake = function (
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4828
|
+
this.refreshStakeWithTokenStake = function (rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1) {
|
4829
|
+
var args_1 = [];
|
4830
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
4831
|
+
args_1[_i - 3] = arguments[_i];
|
4832
|
+
}
|
4833
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
|
4834
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_17;
|
4835
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4836
|
+
return __generator(this, function (_c) {
|
4837
|
+
switch (_c.label) {
|
4786
4838
|
case 0:
|
4787
|
-
|
4839
|
+
_c.trys.push([0, 2, , 3]);
|
4788
4840
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
4789
4841
|
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
4790
4842
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
4791
4843
|
pool = poolConfig.poolAddress;
|
4792
4844
|
feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
|
4793
4845
|
custodyAccountMetas = [];
|
4794
|
-
for (
|
4795
|
-
custody = _a
|
4846
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4847
|
+
custody = _b[_a];
|
4796
4848
|
custodyAccountMetas.push({
|
4797
4849
|
pubkey: custody.custodyAccount,
|
4798
4850
|
isSigner: false,
|
@@ -4824,10 +4876,10 @@ var PerpetualsClient = (function () {
|
|
4824
4876
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
|
4825
4877
|
.instruction()];
|
4826
4878
|
case 1:
|
4827
|
-
refreshStakeInstruction =
|
4879
|
+
refreshStakeInstruction = _c.sent();
|
4828
4880
|
return [2, refreshStakeInstruction];
|
4829
4881
|
case 2:
|
4830
|
-
err_17 =
|
4882
|
+
err_17 = _c.sent();
|
4831
4883
|
console.log("perpClient refreshStaking error:: ", err_17);
|
4832
4884
|
throw err_17;
|
4833
4885
|
case 3: return [2];
|
@@ -4835,10 +4887,14 @@ var PerpetualsClient = (function () {
|
|
4835
4887
|
});
|
4836
4888
|
});
|
4837
4889
|
};
|
4838
|
-
this.unstakeInstant = function (
|
4839
|
-
|
4840
|
-
|
4890
|
+
this.unstakeInstant = function (rewardSymbol_1, unstakeAmount_1, poolConfig_1) {
|
4891
|
+
var args_1 = [];
|
4892
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
4893
|
+
args_1[_i - 3] = arguments[_i];
|
4894
|
+
}
|
4895
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, unstakeAmount_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
|
4841
4896
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_18;
|
4897
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4842
4898
|
return __generator(this, function (_b) {
|
4843
4899
|
switch (_b.label) {
|
4844
4900
|
case 0:
|
@@ -4997,13 +5053,17 @@ var PerpetualsClient = (function () {
|
|
4997
5053
|
}
|
4998
5054
|
});
|
4999
5055
|
}); };
|
5000
|
-
this.withdrawStake = function (
|
5001
|
-
|
5002
|
-
|
5003
|
-
|
5004
|
-
|
5005
|
-
return __awaiter(_this,
|
5056
|
+
this.withdrawStake = function (poolConfig_1) {
|
5057
|
+
var args_1 = [];
|
5058
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
5059
|
+
args_1[_i - 1] = arguments[_i];
|
5060
|
+
}
|
5061
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
|
5006
5062
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_21;
|
5063
|
+
if (pendingActivation === void 0) { pendingActivation = true; }
|
5064
|
+
if (deactivated === void 0) { deactivated = true; }
|
5065
|
+
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
5066
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
5007
5067
|
return __generator(this, function (_b) {
|
5008
5068
|
switch (_b.label) {
|
5009
5069
|
case 0:
|
@@ -5065,10 +5125,14 @@ var PerpetualsClient = (function () {
|
|
5065
5125
|
});
|
5066
5126
|
});
|
5067
5127
|
};
|
5068
|
-
this.collectStakeFees = function (
|
5069
|
-
|
5070
|
-
|
5128
|
+
this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
|
5129
|
+
var args_1 = [];
|
5130
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5131
|
+
args_1[_i - 3] = arguments[_i];
|
5132
|
+
}
|
5133
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
|
5071
5134
|
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_22;
|
5135
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5072
5136
|
return __generator(this, function (_b) {
|
5073
5137
|
switch (_b.label) {
|
5074
5138
|
case 0:
|
@@ -5792,10 +5856,14 @@ var PerpetualsClient = (function () {
|
|
5792
5856
|
}
|
5793
5857
|
});
|
5794
5858
|
}); };
|
5795
|
-
this.collectTokenReward = function (
|
5796
|
-
|
5797
|
-
|
5859
|
+
this.collectTokenReward = function (owner_1, poolConfig_1) {
|
5860
|
+
var args_1 = [];
|
5861
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
5862
|
+
args_1[_i - 2] = arguments[_i];
|
5863
|
+
}
|
5864
|
+
return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
|
5798
5865
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_36;
|
5866
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5799
5867
|
return __generator(this, function (_b) {
|
5800
5868
|
switch (_b.label) {
|
5801
5869
|
case 0:
|
@@ -5850,10 +5918,14 @@ var PerpetualsClient = (function () {
|
|
5850
5918
|
});
|
5851
5919
|
});
|
5852
5920
|
};
|
5853
|
-
this.collectRevenue = function (
|
5854
|
-
|
5855
|
-
|
5921
|
+
this.collectRevenue = function (owner_1, rewardSymbol_1, poolConfig_1) {
|
5922
|
+
var args_1 = [];
|
5923
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5924
|
+
args_1[_i - 3] = arguments[_i];
|
5925
|
+
}
|
5926
|
+
return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
|
5856
5927
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_37;
|
5928
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5857
5929
|
return __generator(this, function (_b) {
|
5858
5930
|
switch (_b.label) {
|
5859
5931
|
case 0:
|
@@ -6038,10 +6110,14 @@ var PerpetualsClient = (function () {
|
|
6038
6110
|
}
|
6039
6111
|
});
|
6040
6112
|
}); };
|
6041
|
-
this.collectNftReward = function (
|
6042
|
-
|
6043
|
-
|
6113
|
+
this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
|
6114
|
+
var args_1 = [];
|
6115
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
6116
|
+
args_1[_i - 3] = arguments[_i];
|
6117
|
+
}
|
6118
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
6044
6119
|
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_41;
|
6120
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6045
6121
|
return __generator(this, function (_b) {
|
6046
6122
|
switch (_b.label) {
|
6047
6123
|
case 0:
|
@@ -6101,10 +6177,14 @@ var PerpetualsClient = (function () {
|
|
6101
6177
|
});
|
6102
6178
|
});
|
6103
6179
|
};
|
6104
|
-
this.collectAndDistributeFee = function (
|
6105
|
-
|
6106
|
-
|
6180
|
+
this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
|
6181
|
+
var args_1 = [];
|
6182
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
6183
|
+
args_1[_i - 2] = arguments[_i];
|
6184
|
+
}
|
6185
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
6107
6186
|
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_42;
|
6187
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6108
6188
|
return __generator(this, function (_b) {
|
6109
6189
|
switch (_b.label) {
|
6110
6190
|
case 0:
|
@@ -6229,12 +6309,16 @@ var PerpetualsClient = (function () {
|
|
6229
6309
|
}
|
6230
6310
|
});
|
6231
6311
|
}); };
|
6232
|
-
this.forceClosePosition = function (
|
6233
|
-
|
6234
|
-
|
6235
|
-
|
6236
|
-
|
6312
|
+
this.forceClosePosition = function (positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
|
6313
|
+
var args_1 = [];
|
6314
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
6315
|
+
args_1[_i - 6] = arguments[_i];
|
6316
|
+
}
|
6317
|
+
return __awaiter(_this, __spreadArray([positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1], args_1, true), void 0, function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
6237
6318
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_44;
|
6319
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6320
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
6321
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6238
6322
|
return __generator(this, function (_b) {
|
6239
6323
|
switch (_b.label) {
|
6240
6324
|
case 0:
|
@@ -6306,11 +6390,15 @@ var PerpetualsClient = (function () {
|
|
6306
6390
|
});
|
6307
6391
|
});
|
6308
6392
|
};
|
6309
|
-
this.placeLimitOrder = function (
|
6310
|
-
|
6311
|
-
|
6312
|
-
|
6393
|
+
this.placeLimitOrder = function (targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1) {
|
6394
|
+
var args_1 = [];
|
6395
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6396
|
+
args_1[_i - 11] = arguments[_i];
|
6397
|
+
}
|
6398
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
6313
6399
|
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_45;
|
6400
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6401
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6314
6402
|
return __generator(this, function (_c) {
|
6315
6403
|
switch (_c.label) {
|
6316
6404
|
case 0:
|
@@ -6426,11 +6514,15 @@ var PerpetualsClient = (function () {
|
|
6426
6514
|
});
|
6427
6515
|
});
|
6428
6516
|
};
|
6429
|
-
this.editLimitOrder = function (
|
6430
|
-
|
6431
|
-
|
6432
|
-
|
6517
|
+
this.editLimitOrder = function (targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1) {
|
6518
|
+
var args_1 = [];
|
6519
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6520
|
+
args_1[_i - 11] = arguments[_i];
|
6521
|
+
}
|
6522
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
6433
6523
|
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_46;
|
6524
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6525
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6434
6526
|
return __generator(this, function (_b) {
|
6435
6527
|
switch (_b.label) {
|
6436
6528
|
case 0:
|
@@ -6529,12 +6621,16 @@ var PerpetualsClient = (function () {
|
|
6529
6621
|
});
|
6530
6622
|
});
|
6531
6623
|
};
|
6532
|
-
this.executeLimitOrder = function (
|
6533
|
-
|
6534
|
-
|
6535
|
-
|
6536
|
-
|
6624
|
+
this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6625
|
+
var args_1 = [];
|
6626
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
6627
|
+
args_1[_i - 7] = arguments[_i];
|
6628
|
+
}
|
6629
|
+
return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6537
6630
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_47;
|
6631
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6632
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6633
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6538
6634
|
return __generator(this, function (_a) {
|
6539
6635
|
switch (_a.label) {
|
6540
6636
|
case 0:
|
@@ -6594,12 +6690,16 @@ var PerpetualsClient = (function () {
|
|
6594
6690
|
});
|
6595
6691
|
});
|
6596
6692
|
};
|
6597
|
-
this.executeLimitWithSwap = function (
|
6598
|
-
|
6599
|
-
|
6600
|
-
|
6601
|
-
|
6693
|
+
this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6694
|
+
var args_1 = [];
|
6695
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
6696
|
+
args_1[_i - 8] = arguments[_i];
|
6697
|
+
}
|
6698
|
+
return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6602
6699
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_48;
|
6700
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6701
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6702
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6603
6703
|
return __generator(this, function (_a) {
|
6604
6704
|
switch (_a.label) {
|
6605
6705
|
case 0:
|
@@ -6865,16 +6965,20 @@ var PerpetualsClient = (function () {
|
|
6865
6965
|
}
|
6866
6966
|
});
|
6867
6967
|
}); };
|
6868
|
-
this.executeTriggerWithSwap = function (
|
6869
|
-
|
6870
|
-
|
6871
|
-
|
6872
|
-
|
6873
|
-
|
6874
|
-
|
6875
|
-
|
6876
|
-
|
6877
|
-
|
6968
|
+
this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
6969
|
+
var args_1 = [];
|
6970
|
+
for (var _i = 9; _i < arguments.length; _i++) {
|
6971
|
+
args_1[_i - 9] = arguments[_i];
|
6972
|
+
}
|
6973
|
+
return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6974
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_53;
|
6975
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6976
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6977
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6978
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6979
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6980
|
+
return __generator(this, function (_e) {
|
6981
|
+
switch (_e.label) {
|
6878
6982
|
case 0:
|
6879
6983
|
payerPubkey = this.provider.wallet.publicKey;
|
6880
6984
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
@@ -6885,9 +6989,9 @@ var PerpetualsClient = (function () {
|
|
6885
6989
|
instructions = [];
|
6886
6990
|
postInstructions = [];
|
6887
6991
|
additionalSigners = [];
|
6888
|
-
|
6992
|
+
_e.label = 1;
|
6889
6993
|
case 1:
|
6890
|
-
|
6994
|
+
_e.trys.push([1, 9, , 10]);
|
6891
6995
|
if (!false) return [3, 2];
|
6892
6996
|
return [3, 7];
|
6893
6997
|
case 2:
|
@@ -6896,8 +7000,8 @@ var PerpetualsClient = (function () {
|
|
6896
7000
|
if (!_a) return [3, 4];
|
6897
7001
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
6898
7002
|
case 3:
|
6899
|
-
_a = !(
|
6900
|
-
|
7003
|
+
_a = !(_e.sent());
|
7004
|
+
_e.label = 4;
|
6901
7005
|
case 4:
|
6902
7006
|
if (_a) {
|
6903
7007
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
@@ -6907,20 +7011,20 @@ var PerpetualsClient = (function () {
|
|
6907
7011
|
if (!_b) return [3, 6];
|
6908
7012
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
6909
7013
|
case 5:
|
6910
|
-
_b = !(
|
6911
|
-
|
7014
|
+
_b = !(_e.sent());
|
7015
|
+
_e.label = 6;
|
6912
7016
|
case 6:
|
6913
7017
|
if (_b) {
|
6914
7018
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
6915
7019
|
}
|
6916
|
-
|
7020
|
+
_e.label = 7;
|
6917
7021
|
case 7:
|
6918
7022
|
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
6919
7023
|
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
6920
7024
|
custodyAccountMetas = [];
|
6921
7025
|
custodyOracleAccountMetas = [];
|
6922
|
-
for (
|
6923
|
-
custody = _c
|
7026
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
7027
|
+
custody = _d[_c];
|
6924
7028
|
custodyAccountMetas.push({
|
6925
7029
|
pubkey: custody.custodyAccount,
|
6926
7030
|
isSigner: false,
|
@@ -6965,11 +7069,11 @@ var PerpetualsClient = (function () {
|
|
6965
7069
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6966
7070
|
.instruction()];
|
6967
7071
|
case 8:
|
6968
|
-
executeTriggerWithSwap =
|
7072
|
+
executeTriggerWithSwap = _e.sent();
|
6969
7073
|
instructions.push(executeTriggerWithSwap);
|
6970
7074
|
return [3, 10];
|
6971
7075
|
case 9:
|
6972
|
-
err_53 =
|
7076
|
+
err_53 = _e.sent();
|
6973
7077
|
console.log("perpClient executeTriggerWithSwap error:: ", err_53);
|
6974
7078
|
throw err_53;
|
6975
7079
|
case 10: return [2, {
|
@@ -6980,14 +7084,18 @@ var PerpetualsClient = (function () {
|
|
6980
7084
|
});
|
6981
7085
|
});
|
6982
7086
|
};
|
6983
|
-
this.executeTriggerOrder = function (
|
6984
|
-
|
6985
|
-
|
6986
|
-
|
6987
|
-
|
6988
|
-
|
6989
|
-
return __awaiter(_this, void 0, void 0, function () {
|
7087
|
+
this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
7088
|
+
var args_1 = [];
|
7089
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
7090
|
+
args_1[_i - 8] = arguments[_i];
|
7091
|
+
}
|
7092
|
+
return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6990
7093
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_54;
|
7094
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7095
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7096
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
7097
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
7098
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6991
7099
|
return __generator(this, function (_b) {
|
6992
7100
|
switch (_b.label) {
|
6993
7101
|
case 0:
|
@@ -7532,14 +7640,18 @@ var PerpetualsClient = (function () {
|
|
7532
7640
|
}
|
7533
7641
|
});
|
7534
7642
|
}); };
|
7535
|
-
this.addCompoundingLiquidity = function (
|
7536
|
-
|
7537
|
-
|
7538
|
-
|
7539
|
-
|
7540
|
-
|
7541
|
-
|
7542
|
-
|
7643
|
+
this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7644
|
+
var args_1 = [];
|
7645
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7646
|
+
args_1[_i - 5] = arguments[_i];
|
7647
|
+
}
|
7648
|
+
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) {
|
7649
|
+
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, addCompoundingLiquidity, err_65;
|
7650
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
7651
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7652
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
7653
|
+
return __generator(this, function (_f) {
|
7654
|
+
switch (_f.label) {
|
7543
7655
|
case 0:
|
7544
7656
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
7545
7657
|
preInstructions = [];
|
@@ -7556,8 +7668,8 @@ var PerpetualsClient = (function () {
|
|
7556
7668
|
custodyAccountMetas = [];
|
7557
7669
|
custodyOracleAccountMetas = [];
|
7558
7670
|
markets = [];
|
7559
|
-
for (
|
7560
|
-
custody = _a
|
7671
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
7672
|
+
custody = _b[_a];
|
7561
7673
|
custodyAccountMetas.push({
|
7562
7674
|
pubkey: custody.custodyAccount,
|
7563
7675
|
isSigner: false,
|
@@ -7569,8 +7681,8 @@ var PerpetualsClient = (function () {
|
|
7569
7681
|
isWritable: false,
|
7570
7682
|
});
|
7571
7683
|
}
|
7572
|
-
for (
|
7573
|
-
market = _c
|
7684
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
7685
|
+
market = _d[_c];
|
7574
7686
|
markets.push({
|
7575
7687
|
pubkey: market.marketAccount,
|
7576
7688
|
isSigner: false,
|
@@ -7579,26 +7691,26 @@ var PerpetualsClient = (function () {
|
|
7579
7691
|
}
|
7580
7692
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
7581
7693
|
case 1:
|
7582
|
-
if (!(
|
7694
|
+
if (!(_f.sent())) {
|
7583
7695
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
7584
7696
|
}
|
7585
7697
|
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
7586
7698
|
case 2:
|
7587
|
-
if (!(
|
7699
|
+
if (!(_f.sent())) {
|
7588
7700
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
7589
7701
|
}
|
7590
7702
|
if (!(inTokenSymbol == 'SOL')) return [3, 5];
|
7591
7703
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
7592
7704
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
7593
7705
|
if (!!skipBalanceChecks) return [3, 4];
|
7594
|
-
|
7706
|
+
_e = anchor_1.BN.bind;
|
7595
7707
|
return [4, this.provider.connection.getBalance(publicKey)];
|
7596
7708
|
case 3:
|
7597
|
-
unWrappedSolBalance = new (
|
7709
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
|
7598
7710
|
if (unWrappedSolBalance.lt(lamports)) {
|
7599
7711
|
throw "Insufficient SOL Funds";
|
7600
7712
|
}
|
7601
|
-
|
7713
|
+
_f.label = 4;
|
7602
7714
|
case 4:
|
7603
7715
|
if (!ephemeralSignerPubkey) {
|
7604
7716
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -7622,12 +7734,12 @@ var PerpetualsClient = (function () {
|
|
7622
7734
|
if (!!skipBalanceChecks) return [3, 7];
|
7623
7735
|
return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
|
7624
7736
|
case 6:
|
7625
|
-
if (!(
|
7737
|
+
if (!(_f.sent())) {
|
7626
7738
|
throw "Insufficient Funds , token Account doesn't exist";
|
7627
7739
|
}
|
7628
|
-
|
7740
|
+
_f.label = 7;
|
7629
7741
|
case 7:
|
7630
|
-
|
7742
|
+
_f.trys.push([7, 9, , 10]);
|
7631
7743
|
return [4, this.program.methods
|
7632
7744
|
.addCompoundingLiquidity({
|
7633
7745
|
amountIn: amountIn,
|
@@ -7656,11 +7768,11 @@ var PerpetualsClient = (function () {
|
|
7656
7768
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7657
7769
|
.instruction()];
|
7658
7770
|
case 8:
|
7659
|
-
addCompoundingLiquidity =
|
7771
|
+
addCompoundingLiquidity = _f.sent();
|
7660
7772
|
instructions.push(addCompoundingLiquidity);
|
7661
7773
|
return [3, 10];
|
7662
7774
|
case 9:
|
7663
|
-
err_65 =
|
7775
|
+
err_65 = _f.sent();
|
7664
7776
|
console.log("perpClient addCompoundingLiquidity error:: ", err_65);
|
7665
7777
|
return [3, 10];
|
7666
7778
|
case 10: return [2, {
|
@@ -7671,14 +7783,18 @@ var PerpetualsClient = (function () {
|
|
7671
7783
|
});
|
7672
7784
|
});
|
7673
7785
|
};
|
7674
|
-
this.removeCompoundingLiquidity = function (
|
7675
|
-
|
7676
|
-
|
7677
|
-
|
7678
|
-
|
7679
|
-
|
7680
|
-
|
7681
|
-
|
7786
|
+
this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7787
|
+
var args_1 = [];
|
7788
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7789
|
+
args_1[_i - 5] = arguments[_i];
|
7790
|
+
}
|
7791
|
+
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) {
|
7792
|
+
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, removeCompoundingLiquidity, err_66;
|
7793
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7794
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7795
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
7796
|
+
return __generator(this, function (_f) {
|
7797
|
+
switch (_f.label) {
|
7682
7798
|
case 0:
|
7683
7799
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
7684
7800
|
preInstructions = [];
|
@@ -7715,19 +7831,19 @@ var PerpetualsClient = (function () {
|
|
7715
7831
|
if (!_a) return [3, 3];
|
7716
7832
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
7717
7833
|
case 2:
|
7718
|
-
_a = !(
|
7719
|
-
|
7834
|
+
_a = !(_f.sent());
|
7835
|
+
_f.label = 3;
|
7720
7836
|
case 3:
|
7721
7837
|
if (_a) {
|
7722
7838
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
|
7723
7839
|
}
|
7724
|
-
|
7840
|
+
_f.label = 4;
|
7725
7841
|
case 4:
|
7726
7842
|
custodyAccountMetas = [];
|
7727
7843
|
custodyOracleAccountMetas = [];
|
7728
7844
|
markets = [];
|
7729
|
-
for (
|
7730
|
-
custody = _b
|
7845
|
+
for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
|
7846
|
+
custody = _c[_b];
|
7731
7847
|
custodyAccountMetas.push({
|
7732
7848
|
pubkey: custody.custodyAccount,
|
7733
7849
|
isSigner: false,
|
@@ -7739,8 +7855,8 @@ var PerpetualsClient = (function () {
|
|
7739
7855
|
isWritable: false,
|
7740
7856
|
});
|
7741
7857
|
}
|
7742
|
-
for (
|
7743
|
-
market = _d
|
7858
|
+
for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
|
7859
|
+
market = _e[_d];
|
7744
7860
|
markets.push({
|
7745
7861
|
pubkey: market.marketAccount,
|
7746
7862
|
isSigner: false,
|
@@ -7748,9 +7864,9 @@ var PerpetualsClient = (function () {
|
|
7748
7864
|
});
|
7749
7865
|
}
|
7750
7866
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
7751
|
-
|
7867
|
+
_f.label = 5;
|
7752
7868
|
case 5:
|
7753
|
-
|
7869
|
+
_f.trys.push([5, 7, , 8]);
|
7754
7870
|
return [4, this.program.methods
|
7755
7871
|
.removeCompoundingLiquidity({
|
7756
7872
|
compoundingAmountIn: compoundingAmountIn,
|
@@ -7779,11 +7895,11 @@ var PerpetualsClient = (function () {
|
|
7779
7895
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7780
7896
|
.instruction()];
|
7781
7897
|
case 6:
|
7782
|
-
removeCompoundingLiquidity =
|
7898
|
+
removeCompoundingLiquidity = _f.sent();
|
7783
7899
|
instructions.push(removeCompoundingLiquidity);
|
7784
7900
|
return [3, 8];
|
7785
7901
|
case 7:
|
7786
|
-
err_66 =
|
7902
|
+
err_66 = _f.sent();
|
7787
7903
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_66);
|
7788
7904
|
return [3, 8];
|
7789
7905
|
case 8: return [2, {
|
@@ -7794,12 +7910,16 @@ var PerpetualsClient = (function () {
|
|
7794
7910
|
});
|
7795
7911
|
});
|
7796
7912
|
};
|
7797
|
-
this.migrateStake = function (
|
7798
|
-
|
7799
|
-
|
7800
|
-
|
7801
|
-
|
7802
|
-
|
7913
|
+
this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
|
7914
|
+
var args_1 = [];
|
7915
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
7916
|
+
args_1[_i - 3] = arguments[_i];
|
7917
|
+
}
|
7918
|
+
return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
7919
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_67;
|
7920
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7921
|
+
return __generator(this, function (_g) {
|
7922
|
+
switch (_g.label) {
|
7803
7923
|
case 0:
|
7804
7924
|
publicKey = this.provider.wallet.publicKey;
|
7805
7925
|
preInstructions = [];
|
@@ -7814,8 +7934,8 @@ var PerpetualsClient = (function () {
|
|
7814
7934
|
if (!_a) return [3, 2];
|
7815
7935
|
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
7816
7936
|
case 1:
|
7817
|
-
_a = !(
|
7818
|
-
|
7937
|
+
_a = !(_g.sent());
|
7938
|
+
_g.label = 2;
|
7819
7939
|
case 2:
|
7820
7940
|
if (_a) {
|
7821
7941
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
@@ -7827,8 +7947,8 @@ var PerpetualsClient = (function () {
|
|
7827
7947
|
if (!_b) return [3, 4];
|
7828
7948
|
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
7829
7949
|
case 3:
|
7830
|
-
_b = (
|
7831
|
-
|
7950
|
+
_b = (_g.sent());
|
7951
|
+
_g.label = 4;
|
7832
7952
|
case 4:
|
7833
7953
|
if (_b) {
|
7834
7954
|
tokenStakeAccounts.push({
|
@@ -7841,8 +7961,8 @@ var PerpetualsClient = (function () {
|
|
7841
7961
|
custodyAccountMetas = [];
|
7842
7962
|
custodyOracleAccountMetas = [];
|
7843
7963
|
markets = [];
|
7844
|
-
for (
|
7845
|
-
custody = _c
|
7964
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
7965
|
+
custody = _d[_c];
|
7846
7966
|
custodyAccountMetas.push({
|
7847
7967
|
pubkey: custody.custodyAccount,
|
7848
7968
|
isSigner: false,
|
@@ -7854,17 +7974,17 @@ var PerpetualsClient = (function () {
|
|
7854
7974
|
isWritable: false,
|
7855
7975
|
});
|
7856
7976
|
}
|
7857
|
-
for (
|
7858
|
-
market = _e
|
7977
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
7978
|
+
market = _f[_e];
|
7859
7979
|
markets.push({
|
7860
7980
|
pubkey: market.marketAccount,
|
7861
7981
|
isSigner: false,
|
7862
7982
|
isWritable: false,
|
7863
7983
|
});
|
7864
7984
|
}
|
7865
|
-
|
7985
|
+
_g.label = 5;
|
7866
7986
|
case 5:
|
7867
|
-
|
7987
|
+
_g.trys.push([5, 7, , 8]);
|
7868
7988
|
return [4, this.program.methods
|
7869
7989
|
.migrateStake({
|
7870
7990
|
amount: amount
|
@@ -7890,11 +8010,11 @@ var PerpetualsClient = (function () {
|
|
7890
8010
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
|
7891
8011
|
.instruction()];
|
7892
8012
|
case 6:
|
7893
|
-
migrateStake =
|
8013
|
+
migrateStake = _g.sent();
|
7894
8014
|
instructions.push(migrateStake);
|
7895
8015
|
return [3, 8];
|
7896
8016
|
case 7:
|
7897
|
-
err_67 =
|
8017
|
+
err_67 = _g.sent();
|
7898
8018
|
console.log("perpClient migrateStake error:: ", err_67);
|
7899
8019
|
return [3, 8];
|
7900
8020
|
case 8: return [2, {
|
@@ -7988,12 +8108,16 @@ var PerpetualsClient = (function () {
|
|
7988
8108
|
}
|
7989
8109
|
});
|
7990
8110
|
}); };
|
7991
|
-
this.compoundingFee = function (
|
7992
|
-
|
7993
|
-
|
7994
|
-
|
7995
|
-
|
7996
|
-
|
8111
|
+
this.compoundingFee = function (poolConfig_1) {
|
8112
|
+
var args_1 = [];
|
8113
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
8114
|
+
args_1[_i - 1] = arguments[_i];
|
8115
|
+
}
|
8116
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
|
8117
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_69;
|
8118
|
+
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
8119
|
+
return __generator(this, function (_e) {
|
8120
|
+
switch (_e.label) {
|
7997
8121
|
case 0:
|
7998
8122
|
instructions = [];
|
7999
8123
|
additionalSigners = [];
|
@@ -8002,8 +8126,8 @@ var PerpetualsClient = (function () {
|
|
8002
8126
|
custodyAccountMetas = [];
|
8003
8127
|
custodyOracleAccountMetas = [];
|
8004
8128
|
markets = [];
|
8005
|
-
for (
|
8006
|
-
custody = _a
|
8129
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
8130
|
+
custody = _b[_a];
|
8007
8131
|
custodyAccountMetas.push({
|
8008
8132
|
pubkey: custody.custodyAccount,
|
8009
8133
|
isSigner: false,
|
@@ -8015,17 +8139,17 @@ var PerpetualsClient = (function () {
|
|
8015
8139
|
isWritable: false,
|
8016
8140
|
});
|
8017
8141
|
}
|
8018
|
-
for (
|
8019
|
-
market = _c
|
8142
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
8143
|
+
market = _d[_c];
|
8020
8144
|
markets.push({
|
8021
8145
|
pubkey: market.marketAccount,
|
8022
8146
|
isSigner: false,
|
8023
8147
|
isWritable: false,
|
8024
8148
|
});
|
8025
8149
|
}
|
8026
|
-
|
8150
|
+
_e.label = 1;
|
8027
8151
|
case 1:
|
8028
|
-
|
8152
|
+
_e.trys.push([1, 3, , 4]);
|
8029
8153
|
return [4, this.program.methods
|
8030
8154
|
.compoundFees({})
|
8031
8155
|
.accounts({
|
@@ -8044,11 +8168,11 @@ var PerpetualsClient = (function () {
|
|
8044
8168
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
8045
8169
|
.instruction()];
|
8046
8170
|
case 2:
|
8047
|
-
compoundingFee =
|
8171
|
+
compoundingFee = _e.sent();
|
8048
8172
|
instructions.push(compoundingFee);
|
8049
8173
|
return [3, 4];
|
8050
8174
|
case 3:
|
8051
|
-
err_69 =
|
8175
|
+
err_69 = _e.sent();
|
8052
8176
|
console.log("perpClient compoundingFee error:: ", err_69);
|
8053
8177
|
return [3, 4];
|
8054
8178
|
case 4: return [2, {
|
@@ -8209,9 +8333,9 @@ var PerpetualsClient = (function () {
|
|
8209
8333
|
}
|
8210
8334
|
}
|
8211
8335
|
};
|
8212
|
-
PerpetualsClient.prototype.sendTransaction = function (
|
8213
|
-
|
8214
|
-
|
8336
|
+
PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
|
8337
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
8338
|
+
if (opts === void 0) { opts = {}; }
|
8215
8339
|
return __generator(this, function (_a) {
|
8216
8340
|
switch (_a.label) {
|
8217
8341
|
case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|
@@ -8220,9 +8344,9 @@ var PerpetualsClient = (function () {
|
|
8220
8344
|
});
|
8221
8345
|
});
|
8222
8346
|
};
|
8223
|
-
PerpetualsClient.prototype.sendTransactionV3 = function (
|
8224
|
-
|
8225
|
-
|
8347
|
+
PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
|
8348
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
8349
|
+
if (opts === void 0) { opts = {}; }
|
8226
8350
|
return __generator(this, function (_a) {
|
8227
8351
|
switch (_a.label) {
|
8228
8352
|
case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|