flash-sdk 2.47.2 → 2.47.3
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 +515 -375
- 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
@@ -2149,36 +2149,40 @@ var PerpetualsClient = (function () {
|
|
2149
2149
|
}
|
2150
2150
|
});
|
2151
2151
|
}); };
|
2152
|
-
this.getAddLiquidityAmountAndFeeView = function (
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2152
|
+
this.getAddLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
|
2153
|
+
var args_1 = [];
|
2154
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2155
|
+
args_1[_i - 4] = arguments[_i];
|
2156
|
+
}
|
2157
|
+
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) {
|
2158
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
|
2159
|
+
var _e;
|
2160
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2161
|
+
return __generator(this, function (_f) {
|
2162
|
+
switch (_f.label) {
|
2159
2163
|
case 0:
|
2160
2164
|
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2161
2165
|
custodies = POOL_CONFIG.custodies;
|
2162
2166
|
custodyMetas = [];
|
2163
2167
|
marketMetas = [];
|
2164
|
-
for (
|
2165
|
-
token = custodies_5[
|
2168
|
+
for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
|
2169
|
+
token = custodies_5[_a];
|
2166
2170
|
custodyMetas.push({
|
2167
2171
|
isSigner: false,
|
2168
2172
|
isWritable: false,
|
2169
2173
|
pubkey: token.custodyAccount,
|
2170
2174
|
});
|
2171
2175
|
}
|
2172
|
-
for (
|
2173
|
-
custody = custodies_6[
|
2176
|
+
for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
|
2177
|
+
custody = custodies_6[_b];
|
2174
2178
|
custodyMetas.push({
|
2175
2179
|
isSigner: false,
|
2176
2180
|
isWritable: false,
|
2177
2181
|
pubkey: custody.intOracleAccount,
|
2178
2182
|
});
|
2179
2183
|
}
|
2180
|
-
for (
|
2181
|
-
market = _c
|
2184
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2185
|
+
market = _d[_c];
|
2182
2186
|
marketMetas.push({
|
2183
2187
|
pubkey: market.marketAccount,
|
2184
2188
|
isSigner: false,
|
@@ -2201,14 +2205,14 @@ var PerpetualsClient = (function () {
|
|
2201
2205
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2202
2206
|
.transaction()];
|
2203
2207
|
case 1:
|
2204
|
-
transaction =
|
2208
|
+
transaction = _f.sent();
|
2205
2209
|
return [4, backUpOracleInstructionPromise];
|
2206
2210
|
case 2:
|
2207
|
-
backUpOracleInstruction =
|
2208
|
-
(
|
2211
|
+
backUpOracleInstruction = _f.sent();
|
2212
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
2209
2213
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2210
2214
|
case 3:
|
2211
|
-
result =
|
2215
|
+
result = _f.sent();
|
2212
2216
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
|
2213
2217
|
res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
|
2214
2218
|
return [2, {
|
@@ -2219,36 +2223,40 @@ var PerpetualsClient = (function () {
|
|
2219
2223
|
});
|
2220
2224
|
});
|
2221
2225
|
};
|
2222
|
-
this.getRemoveLiquidityAmountAndFeeView = function (
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2226
|
+
this.getRemoveLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
|
2227
|
+
var args_1 = [];
|
2228
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2229
|
+
args_1[_i - 4] = arguments[_i];
|
2230
|
+
}
|
2231
|
+
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) {
|
2232
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
|
2233
|
+
var _e;
|
2234
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2235
|
+
return __generator(this, function (_f) {
|
2236
|
+
switch (_f.label) {
|
2229
2237
|
case 0:
|
2230
2238
|
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2231
2239
|
custodies = POOL_CONFIG.custodies;
|
2232
2240
|
custodyMetas = [];
|
2233
2241
|
marketMetas = [];
|
2234
|
-
for (
|
2235
|
-
token = custodies_7[
|
2242
|
+
for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
|
2243
|
+
token = custodies_7[_a];
|
2236
2244
|
custodyMetas.push({
|
2237
2245
|
isSigner: false,
|
2238
2246
|
isWritable: false,
|
2239
2247
|
pubkey: token.custodyAccount,
|
2240
2248
|
});
|
2241
2249
|
}
|
2242
|
-
for (
|
2243
|
-
custody = custodies_8[
|
2250
|
+
for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
|
2251
|
+
custody = custodies_8[_b];
|
2244
2252
|
custodyMetas.push({
|
2245
2253
|
isSigner: false,
|
2246
2254
|
isWritable: false,
|
2247
2255
|
pubkey: custody.intOracleAccount,
|
2248
2256
|
});
|
2249
2257
|
}
|
2250
|
-
for (
|
2251
|
-
market = _c
|
2258
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2259
|
+
market = _d[_c];
|
2252
2260
|
marketMetas.push({
|
2253
2261
|
pubkey: market.marketAccount,
|
2254
2262
|
isSigner: false,
|
@@ -2271,14 +2279,14 @@ var PerpetualsClient = (function () {
|
|
2271
2279
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2272
2280
|
.transaction()];
|
2273
2281
|
case 1:
|
2274
|
-
transaction =
|
2282
|
+
transaction = _f.sent();
|
2275
2283
|
return [4, backUpOracleInstructionPromise];
|
2276
2284
|
case 2:
|
2277
|
-
backUpOracleInstruction =
|
2278
|
-
(
|
2285
|
+
backUpOracleInstruction = _f.sent();
|
2286
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
2279
2287
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2280
2288
|
case 3:
|
2281
|
-
result =
|
2289
|
+
result = _f.sent();
|
2282
2290
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
|
2283
2291
|
if (result.value.err) {
|
2284
2292
|
return [2, {
|
@@ -2354,36 +2362,40 @@ var PerpetualsClient = (function () {
|
|
2354
2362
|
}
|
2355
2363
|
});
|
2356
2364
|
}); };
|
2357
|
-
this.getAddCompoundingLiquidityAmountAndFeeView = function (
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2365
|
+
this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
|
2366
|
+
var args_1 = [];
|
2367
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2368
|
+
args_1[_i - 4] = arguments[_i];
|
2369
|
+
}
|
2370
|
+
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) {
|
2371
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
|
2372
|
+
var _e;
|
2373
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2374
|
+
return __generator(this, function (_f) {
|
2375
|
+
switch (_f.label) {
|
2364
2376
|
case 0:
|
2365
2377
|
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2366
2378
|
custodies = POOL_CONFIG.custodies;
|
2367
2379
|
custodyMetas = [];
|
2368
2380
|
marketMetas = [];
|
2369
|
-
for (
|
2370
|
-
token = custodies_11[
|
2381
|
+
for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
|
2382
|
+
token = custodies_11[_a];
|
2371
2383
|
custodyMetas.push({
|
2372
2384
|
isSigner: false,
|
2373
2385
|
isWritable: false,
|
2374
2386
|
pubkey: token.custodyAccount,
|
2375
2387
|
});
|
2376
2388
|
}
|
2377
|
-
for (
|
2378
|
-
custody = custodies_12[
|
2389
|
+
for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
|
2390
|
+
custody = custodies_12[_b];
|
2379
2391
|
custodyMetas.push({
|
2380
2392
|
isSigner: false,
|
2381
2393
|
isWritable: false,
|
2382
2394
|
pubkey: custody.intOracleAccount,
|
2383
2395
|
});
|
2384
2396
|
}
|
2385
|
-
for (
|
2386
|
-
market = _c
|
2397
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2398
|
+
market = _d[_c];
|
2387
2399
|
marketMetas.push({
|
2388
2400
|
pubkey: market.marketAccount,
|
2389
2401
|
isSigner: false,
|
@@ -2394,7 +2406,7 @@ var PerpetualsClient = (function () {
|
|
2394
2406
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
2395
2407
|
return [4, backUpOracleInstructionPromise];
|
2396
2408
|
case 1:
|
2397
|
-
backUpOracleInstruction =
|
2409
|
+
backUpOracleInstruction = _f.sent();
|
2398
2410
|
return [4, this.program.methods
|
2399
2411
|
.getAddCompoundingLiquidityAmountAndFee({
|
2400
2412
|
amountIn: amount,
|
@@ -2413,11 +2425,11 @@ var PerpetualsClient = (function () {
|
|
2413
2425
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2414
2426
|
.transaction()];
|
2415
2427
|
case 2:
|
2416
|
-
transaction =
|
2417
|
-
(
|
2428
|
+
transaction = _f.sent();
|
2429
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
2418
2430
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2419
2431
|
case 3:
|
2420
|
-
result =
|
2432
|
+
result = _f.sent();
|
2421
2433
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
|
2422
2434
|
res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
|
2423
2435
|
return [2, {
|
@@ -2428,36 +2440,40 @@ var PerpetualsClient = (function () {
|
|
2428
2440
|
});
|
2429
2441
|
});
|
2430
2442
|
};
|
2431
|
-
this.getRemoveCompoundingLiquidityAmountAndFeeView = function (
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2443
|
+
this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
|
2444
|
+
var args_1 = [];
|
2445
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
2446
|
+
args_1[_i - 4] = arguments[_i];
|
2447
|
+
}
|
2448
|
+
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) {
|
2449
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
|
2450
|
+
var _e;
|
2451
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
2452
|
+
return __generator(this, function (_f) {
|
2453
|
+
switch (_f.label) {
|
2438
2454
|
case 0:
|
2439
2455
|
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
2440
2456
|
custodies = POOL_CONFIG.custodies;
|
2441
2457
|
custodyMetas = [];
|
2442
2458
|
marketMetas = [];
|
2443
|
-
for (
|
2444
|
-
token = custodies_13[
|
2459
|
+
for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
|
2460
|
+
token = custodies_13[_a];
|
2445
2461
|
custodyMetas.push({
|
2446
2462
|
isSigner: false,
|
2447
2463
|
isWritable: false,
|
2448
2464
|
pubkey: token.custodyAccount,
|
2449
2465
|
});
|
2450
2466
|
}
|
2451
|
-
for (
|
2452
|
-
custody = custodies_14[
|
2467
|
+
for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
|
2468
|
+
custody = custodies_14[_b];
|
2453
2469
|
custodyMetas.push({
|
2454
2470
|
isSigner: false,
|
2455
2471
|
isWritable: false,
|
2456
2472
|
pubkey: custody.intOracleAccount,
|
2457
2473
|
});
|
2458
2474
|
}
|
2459
|
-
for (
|
2460
|
-
market = _c
|
2475
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
2476
|
+
market = _d[_c];
|
2461
2477
|
marketMetas.push({
|
2462
2478
|
pubkey: market.marketAccount,
|
2463
2479
|
isSigner: false,
|
@@ -2468,7 +2484,7 @@ var PerpetualsClient = (function () {
|
|
2468
2484
|
rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
|
2469
2485
|
return [4, backUpOracleInstructionPromise];
|
2470
2486
|
case 1:
|
2471
|
-
backUpOracleInstruction =
|
2487
|
+
backUpOracleInstruction = _f.sent();
|
2472
2488
|
return [4, this.program.methods
|
2473
2489
|
.getRemoveCompoundingLiquidityAmountAndFee({
|
2474
2490
|
compoundingAmountIn: amount,
|
@@ -2487,11 +2503,11 @@ var PerpetualsClient = (function () {
|
|
2487
2503
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
2488
2504
|
.transaction()];
|
2489
2505
|
case 2:
|
2490
|
-
transaction =
|
2491
|
-
(
|
2506
|
+
transaction = _f.sent();
|
2507
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
2492
2508
|
return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
|
2493
2509
|
case 3:
|
2494
|
-
result =
|
2510
|
+
result = _f.sent();
|
2495
2511
|
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
|
2496
2512
|
if (result.value.err) {
|
2497
2513
|
return [2, {
|
@@ -2630,14 +2646,18 @@ var PerpetualsClient = (function () {
|
|
2630
2646
|
}
|
2631
2647
|
});
|
2632
2648
|
}); };
|
2633
|
-
this.openPosition = function (
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2649
|
+
this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
|
2650
|
+
var args_1 = [];
|
2651
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
2652
|
+
args_1[_i - 8] = arguments[_i];
|
2653
|
+
}
|
2654
|
+
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) {
|
2640
2655
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
|
2656
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2657
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2658
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2659
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2660
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2641
2661
|
return __generator(this, function (_c) {
|
2642
2662
|
switch (_c.label) {
|
2643
2663
|
case 0:
|
@@ -2741,15 +2761,19 @@ var PerpetualsClient = (function () {
|
|
2741
2761
|
});
|
2742
2762
|
});
|
2743
2763
|
};
|
2744
|
-
this.closePosition = function (
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2751
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2764
|
+
this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
2765
|
+
var args_1 = [];
|
2766
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
2767
|
+
args_1[_i - 6] = arguments[_i];
|
2768
|
+
}
|
2769
|
+
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) {
|
2752
2770
|
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_2;
|
2771
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2772
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2773
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2774
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
2775
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
2776
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2753
2777
|
return __generator(this, function (_b) {
|
2754
2778
|
switch (_b.label) {
|
2755
2779
|
case 0:
|
@@ -2846,14 +2870,18 @@ var PerpetualsClient = (function () {
|
|
2846
2870
|
});
|
2847
2871
|
});
|
2848
2872
|
};
|
2849
|
-
this.swapAndOpen = function (
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2873
|
+
this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
|
2874
|
+
var args_1 = [];
|
2875
|
+
for (var _i = 10; _i < arguments.length; _i++) {
|
2876
|
+
args_1[_i - 10] = arguments[_i];
|
2877
|
+
}
|
2878
|
+
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) {
|
2856
2879
|
var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_2;
|
2880
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2881
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2882
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2883
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2884
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2857
2885
|
return __generator(this, function (_c) {
|
2858
2886
|
switch (_c.label) {
|
2859
2887
|
case 0:
|
@@ -2993,13 +3021,17 @@ var PerpetualsClient = (function () {
|
|
2993
3021
|
});
|
2994
3022
|
});
|
2995
3023
|
};
|
2996
|
-
this.closeAndSwap = function (
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
return __awaiter(_this,
|
3024
|
+
this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
3025
|
+
var args_1 = [];
|
3026
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3027
|
+
args_1[_i - 8] = arguments[_i];
|
3028
|
+
}
|
3029
|
+
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) {
|
3002
3030
|
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_3;
|
3031
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3032
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3033
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3034
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3003
3035
|
return __generator(this, function (_a) {
|
3004
3036
|
switch (_a.label) {
|
3005
3037
|
case 0:
|
@@ -3113,16 +3145,20 @@ var PerpetualsClient = (function () {
|
|
3113
3145
|
});
|
3114
3146
|
});
|
3115
3147
|
};
|
3116
|
-
this.swap = function (
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3148
|
+
this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
|
3149
|
+
var args_1 = [];
|
3150
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
3151
|
+
args_1[_i - 5] = arguments[_i];
|
3152
|
+
}
|
3153
|
+
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) {
|
3154
|
+
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_4;
|
3155
|
+
if (useFeesPool === void 0) { useFeesPool = false; }
|
3156
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3157
|
+
if (unWrapSol === void 0) { unWrapSol = false; }
|
3158
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3159
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3160
|
+
return __generator(this, function (_g) {
|
3161
|
+
switch (_g.label) {
|
3126
3162
|
case 0:
|
3127
3163
|
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
3128
3164
|
if (!userInputCustodyConfig) {
|
@@ -3140,10 +3176,10 @@ var PerpetualsClient = (function () {
|
|
3140
3176
|
if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
|
3141
3177
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
|
3142
3178
|
case 1:
|
3143
|
-
wsolAssociatedTokenAccount =
|
3179
|
+
wsolAssociatedTokenAccount = _g.sent();
|
3144
3180
|
return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
|
3145
3181
|
case 2:
|
3146
|
-
wsolATAExist =
|
3182
|
+
wsolATAExist = _g.sent();
|
3147
3183
|
if (!wsolATAExist) {
|
3148
3184
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
|
3149
3185
|
}
|
@@ -3151,11 +3187,11 @@ var PerpetualsClient = (function () {
|
|
3151
3187
|
_a = anchor_1.BN.bind;
|
3152
3188
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3153
3189
|
case 3:
|
3154
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
3190
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3155
3191
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3156
3192
|
throw "Insufficient SOL Funds";
|
3157
3193
|
}
|
3158
|
-
|
3194
|
+
_g.label = 4;
|
3159
3195
|
case 4:
|
3160
3196
|
instructions.push(web3_js_1.SystemProgram.transfer({
|
3161
3197
|
fromPubkey: publicKey,
|
@@ -3177,20 +3213,20 @@ var PerpetualsClient = (function () {
|
|
3177
3213
|
additionalSigners: additionalSigners
|
3178
3214
|
}];
|
3179
3215
|
}
|
3180
|
-
|
3216
|
+
_g.label = 6;
|
3181
3217
|
case 6:
|
3182
|
-
|
3218
|
+
_g.trys.push([6, 19, , 20]);
|
3183
3219
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
3184
3220
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
3185
3221
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
3186
3222
|
case 7:
|
3187
|
-
accCreationLamports = (
|
3223
|
+
accCreationLamports = (_g.sent());
|
3188
3224
|
console.log("accCreationLamports:", accCreationLamports);
|
3189
3225
|
lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
|
3190
3226
|
_b = anchor_1.BN.bind;
|
3191
3227
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3192
3228
|
case 8:
|
3193
|
-
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0,
|
3229
|
+
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3194
3230
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3195
3231
|
throw "Insufficient SOL Funds";
|
3196
3232
|
}
|
@@ -3217,18 +3253,18 @@ var PerpetualsClient = (function () {
|
|
3217
3253
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
|
3218
3254
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
3219
3255
|
case 10:
|
3220
|
-
if (!(
|
3256
|
+
if (!(_g.sent())) {
|
3221
3257
|
throw "Insufficient Funds , Token Account doesn't exist";
|
3222
3258
|
}
|
3223
3259
|
if (!!skipBalanceChecks) return [3, 12];
|
3224
3260
|
_c = anchor_1.BN.bind;
|
3225
3261
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
3226
3262
|
case 11:
|
3227
|
-
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (
|
3263
|
+
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
3228
3264
|
if (tokenAccountBalance.lt(amountIn)) {
|
3229
3265
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
3230
3266
|
}
|
3231
|
-
|
3267
|
+
_g.label = 12;
|
3232
3268
|
case 12:
|
3233
3269
|
if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
|
3234
3270
|
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
@@ -3253,23 +3289,23 @@ var PerpetualsClient = (function () {
|
|
3253
3289
|
return [3, 17];
|
3254
3290
|
case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
|
3255
3291
|
case 14:
|
3256
|
-
userOutputTokenAccount =
|
3292
|
+
userOutputTokenAccount = _g.sent();
|
3257
3293
|
_d = createUserATA;
|
3258
3294
|
if (!_d) return [3, 16];
|
3259
3295
|
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
3260
3296
|
case 15:
|
3261
|
-
_d = !(
|
3262
|
-
|
3297
|
+
_d = !(_g.sent());
|
3298
|
+
_g.label = 16;
|
3263
3299
|
case 16:
|
3264
3300
|
if (_d) {
|
3265
3301
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
|
3266
3302
|
}
|
3267
|
-
|
3303
|
+
_g.label = 17;
|
3268
3304
|
case 17:
|
3269
3305
|
custodyAccountMetas = [];
|
3270
3306
|
custodyOracleAccountMetas = [];
|
3271
|
-
for (
|
3272
|
-
custody = _e
|
3307
|
+
for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
|
3308
|
+
custody = _f[_e];
|
3273
3309
|
custodyAccountMetas.push({
|
3274
3310
|
pubkey: custody.custodyAccount,
|
3275
3311
|
isSigner: false,
|
@@ -3309,7 +3345,7 @@ var PerpetualsClient = (function () {
|
|
3309
3345
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
3310
3346
|
.instruction()];
|
3311
3347
|
case 18:
|
3312
|
-
inx =
|
3348
|
+
inx = _g.sent();
|
3313
3349
|
instructions.push(inx);
|
3314
3350
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
3315
3351
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
@@ -3317,7 +3353,7 @@ var PerpetualsClient = (function () {
|
|
3317
3353
|
}
|
3318
3354
|
return [3, 20];
|
3319
3355
|
case 19:
|
3320
|
-
err_4 =
|
3356
|
+
err_4 = _g.sent();
|
3321
3357
|
console.error("perpClient Swap error:: ", err_4);
|
3322
3358
|
throw err_4;
|
3323
3359
|
case 20: return [2, {
|
@@ -3399,11 +3435,15 @@ var PerpetualsClient = (function () {
|
|
3399
3435
|
}
|
3400
3436
|
});
|
3401
3437
|
}); };
|
3402
|
-
this.addCollateral = function (
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3438
|
+
this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3439
|
+
var args_1 = [];
|
3440
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3441
|
+
args_1[_i - 6] = arguments[_i];
|
3442
|
+
}
|
3443
|
+
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) {
|
3406
3444
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
|
3445
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3446
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3407
3447
|
return __generator(this, function (_c) {
|
3408
3448
|
switch (_c.label) {
|
3409
3449
|
case 0:
|
@@ -3497,11 +3537,15 @@ var PerpetualsClient = (function () {
|
|
3497
3537
|
});
|
3498
3538
|
});
|
3499
3539
|
};
|
3500
|
-
this.swapAndAddCollateral = function (
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3540
|
+
this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
|
3541
|
+
var args_1 = [];
|
3542
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3543
|
+
args_1[_i - 8] = arguments[_i];
|
3544
|
+
}
|
3545
|
+
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) {
|
3504
3546
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
|
3547
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3548
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3505
3549
|
return __generator(this, function (_c) {
|
3506
3550
|
switch (_c.label) {
|
3507
3551
|
case 0:
|
@@ -3612,12 +3656,16 @@ var PerpetualsClient = (function () {
|
|
3612
3656
|
});
|
3613
3657
|
});
|
3614
3658
|
};
|
3615
|
-
this.removeCollateral = function (
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3659
|
+
this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3660
|
+
var args_1 = [];
|
3661
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3662
|
+
args_1[_i - 6] = arguments[_i];
|
3663
|
+
}
|
3664
|
+
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) {
|
3620
3665
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_3;
|
3666
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3667
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
3668
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3621
3669
|
return __generator(this, function (_b) {
|
3622
3670
|
switch (_b.label) {
|
3623
3671
|
case 0:
|
@@ -3718,10 +3766,14 @@ var PerpetualsClient = (function () {
|
|
3718
3766
|
});
|
3719
3767
|
});
|
3720
3768
|
};
|
3721
|
-
this.removeCollateralAndSwap = function (
|
3722
|
-
|
3723
|
-
|
3769
|
+
this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
|
3770
|
+
var args_1 = [];
|
3771
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
3772
|
+
args_1[_i - 7] = arguments[_i];
|
3773
|
+
}
|
3774
|
+
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) {
|
3724
3775
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
|
3776
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3725
3777
|
return __generator(this, function (_a) {
|
3726
3778
|
switch (_a.label) {
|
3727
3779
|
case 0:
|
@@ -3814,12 +3866,16 @@ var PerpetualsClient = (function () {
|
|
3814
3866
|
});
|
3815
3867
|
});
|
3816
3868
|
};
|
3817
|
-
this.increaseSize = function (
|
3818
|
-
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3869
|
+
this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3870
|
+
var args_1 = [];
|
3871
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3872
|
+
args_1[_i - 8] = arguments[_i];
|
3873
|
+
}
|
3874
|
+
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) {
|
3822
3875
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3876
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3877
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3878
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3823
3879
|
return __generator(this, function (_a) {
|
3824
3880
|
switch (_a.label) {
|
3825
3881
|
case 0:
|
@@ -3874,12 +3930,16 @@ var PerpetualsClient = (function () {
|
|
3874
3930
|
});
|
3875
3931
|
});
|
3876
3932
|
};
|
3877
|
-
this.decreaseSize = function (
|
3878
|
-
|
3879
|
-
|
3880
|
-
|
3881
|
-
|
3933
|
+
this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3934
|
+
var args_1 = [];
|
3935
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3936
|
+
args_1[_i - 8] = arguments[_i];
|
3937
|
+
}
|
3938
|
+
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) {
|
3882
3939
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3940
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3941
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3942
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3883
3943
|
return __generator(this, function (_a) {
|
3884
3944
|
switch (_a.label) {
|
3885
3945
|
case 0:
|
@@ -3934,13 +3994,17 @@ var PerpetualsClient = (function () {
|
|
3934
3994
|
});
|
3935
3995
|
});
|
3936
3996
|
};
|
3937
|
-
this.addLiquidity = function (
|
3938
|
-
|
3939
|
-
|
3940
|
-
|
3941
|
-
|
3942
|
-
|
3943
|
-
|
3997
|
+
this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
|
3998
|
+
var args_1 = [];
|
3999
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4000
|
+
args_1[_i - 4] = arguments[_i];
|
4001
|
+
}
|
4002
|
+
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
4003
|
+
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_6;
|
4004
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
4005
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4006
|
+
return __generator(this, function (_g) {
|
4007
|
+
switch (_g.label) {
|
3944
4008
|
case 0:
|
3945
4009
|
publicKey = this.provider.wallet.publicKey;
|
3946
4010
|
payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
|
@@ -3951,16 +4015,16 @@ var PerpetualsClient = (function () {
|
|
3951
4015
|
instructions = [];
|
3952
4016
|
postInstructions = [];
|
3953
4017
|
additionalSigners = [];
|
3954
|
-
|
4018
|
+
_g.label = 1;
|
3955
4019
|
case 1:
|
3956
|
-
|
4020
|
+
_g.trys.push([1, 10, , 11]);
|
3957
4021
|
userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
|
3958
4022
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
3959
4023
|
custodyAccountMetas = [];
|
3960
4024
|
custodyOracleAccountMetas = [];
|
3961
4025
|
markets = [];
|
3962
|
-
for (
|
3963
|
-
custody = _a
|
4026
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4027
|
+
custody = _b[_a];
|
3964
4028
|
custodyAccountMetas.push({
|
3965
4029
|
pubkey: custody.custodyAccount,
|
3966
4030
|
isSigner: false,
|
@@ -3972,8 +4036,8 @@ var PerpetualsClient = (function () {
|
|
3972
4036
|
isWritable: false,
|
3973
4037
|
});
|
3974
4038
|
}
|
3975
|
-
for (
|
3976
|
-
market = _c
|
4039
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4040
|
+
market = _d[_c];
|
3977
4041
|
markets.push({
|
3978
4042
|
pubkey: market.marketAccount,
|
3979
4043
|
isSigner: false,
|
@@ -3982,21 +4046,21 @@ var PerpetualsClient = (function () {
|
|
3982
4046
|
}
|
3983
4047
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
3984
4048
|
case 2:
|
3985
|
-
if (!(
|
4049
|
+
if (!(_g.sent())) {
|
3986
4050
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
3987
4051
|
}
|
3988
4052
|
if (!(payTokenSymbol == 'SOL')) return [3, 5];
|
3989
4053
|
console.log("payTokenSymbol === SOL", payTokenSymbol);
|
3990
4054
|
lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
3991
4055
|
if (!!skipBalanceChecks) return [3, 4];
|
3992
|
-
|
4056
|
+
_e = anchor_1.BN.bind;
|
3993
4057
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3994
4058
|
case 3:
|
3995
|
-
unWrappedSolBalance = new (
|
4059
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3996
4060
|
if (unWrappedSolBalance.lt(lamports)) {
|
3997
4061
|
throw "Insufficient SOL Funds";
|
3998
4062
|
}
|
3999
|
-
|
4063
|
+
_g.label = 4;
|
4000
4064
|
case 4:
|
4001
4065
|
if (!ephemeralSignerPubkey) {
|
4002
4066
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -4020,17 +4084,17 @@ var PerpetualsClient = (function () {
|
|
4020
4084
|
if (!!skipBalanceChecks) return [3, 8];
|
4021
4085
|
return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
|
4022
4086
|
case 6:
|
4023
|
-
if (!(
|
4087
|
+
if (!(_g.sent())) {
|
4024
4088
|
throw "Insufficient Funds , token Account doesn't exist";
|
4025
4089
|
}
|
4026
|
-
|
4090
|
+
_f = anchor_1.BN.bind;
|
4027
4091
|
return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
|
4028
4092
|
case 7:
|
4029
|
-
tokenAccountBalance = new (
|
4093
|
+
tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4030
4094
|
if (tokenAccountBalance.lt(tokenAmountIn)) {
|
4031
4095
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
4032
4096
|
}
|
4033
|
-
|
4097
|
+
_g.label = 8;
|
4034
4098
|
case 8: return [4, this.program.methods
|
4035
4099
|
.addLiquidity({
|
4036
4100
|
amountIn: tokenAmountIn,
|
@@ -4055,11 +4119,11 @@ var PerpetualsClient = (function () {
|
|
4055
4119
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4056
4120
|
.instruction()];
|
4057
4121
|
case 9:
|
4058
|
-
instruction =
|
4122
|
+
instruction = _g.sent();
|
4059
4123
|
instructions.push(instruction);
|
4060
4124
|
return [3, 11];
|
4061
4125
|
case 10:
|
4062
|
-
err_6 =
|
4126
|
+
err_6 = _g.sent();
|
4063
4127
|
console.error("perpClient addLiquidity error:: ", err_6);
|
4064
4128
|
throw err_6;
|
4065
4129
|
case 11: return [2, {
|
@@ -4070,14 +4134,18 @@ var PerpetualsClient = (function () {
|
|
4070
4134
|
});
|
4071
4135
|
});
|
4072
4136
|
};
|
4073
|
-
this.addLiquidityAndStake = function (
|
4074
|
-
|
4075
|
-
|
4076
|
-
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4137
|
+
this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
|
4138
|
+
var args_1 = [];
|
4139
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4140
|
+
args_1[_i - 4] = arguments[_i];
|
4141
|
+
}
|
4142
|
+
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) {
|
4143
|
+
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;
|
4144
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
4145
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4146
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4147
|
+
return __generator(this, function (_g) {
|
4148
|
+
switch (_g.label) {
|
4081
4149
|
case 0:
|
4082
4150
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
4083
4151
|
preInstructions = [];
|
@@ -4097,14 +4165,14 @@ var PerpetualsClient = (function () {
|
|
4097
4165
|
_a = anchor_1.BN.bind;
|
4098
4166
|
return [4, this.provider.connection.getBalance(publicKey)];
|
4099
4167
|
case 1:
|
4100
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
4168
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
4101
4169
|
if (unWrappedSolBalance.lt(lamports)) {
|
4102
4170
|
throw "Insufficient SOL Funds";
|
4103
4171
|
}
|
4104
|
-
|
4172
|
+
_g.label = 2;
|
4105
4173
|
case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
4106
4174
|
case 3:
|
4107
|
-
if (!(
|
4175
|
+
if (!(_g.sent())) {
|
4108
4176
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
4109
4177
|
}
|
4110
4178
|
if (!ephemeralSignerPubkey) {
|
@@ -4130,23 +4198,23 @@ var PerpetualsClient = (function () {
|
|
4130
4198
|
if (!!skipBalanceChecks) return [3, 7];
|
4131
4199
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
4132
4200
|
case 5:
|
4133
|
-
if (!(
|
4201
|
+
if (!(_g.sent())) {
|
4134
4202
|
throw "Insufficient Funds , token Account doesn't exist";
|
4135
4203
|
}
|
4136
4204
|
_b = anchor_1.BN.bind;
|
4137
4205
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
4138
4206
|
case 6:
|
4139
|
-
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (
|
4207
|
+
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4140
4208
|
if (tokenAccountBalance.lt(amountIn)) {
|
4141
4209
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
4142
4210
|
}
|
4143
|
-
|
4211
|
+
_g.label = 7;
|
4144
4212
|
case 7:
|
4145
4213
|
custodyAccountMetas = [];
|
4146
4214
|
custodyOracleAccountMetas = [];
|
4147
4215
|
markets = [];
|
4148
|
-
for (
|
4149
|
-
custody = _c
|
4216
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
4217
|
+
custody = _d[_c];
|
4150
4218
|
custodyAccountMetas.push({
|
4151
4219
|
pubkey: custody.custodyAccount,
|
4152
4220
|
isSigner: false,
|
@@ -4158,8 +4226,8 @@ var PerpetualsClient = (function () {
|
|
4158
4226
|
isWritable: false,
|
4159
4227
|
});
|
4160
4228
|
}
|
4161
|
-
for (
|
4162
|
-
market = _e
|
4229
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
4230
|
+
market = _f[_e];
|
4163
4231
|
markets.push({
|
4164
4232
|
pubkey: market.marketAccount,
|
4165
4233
|
isSigner: false,
|
@@ -4191,7 +4259,7 @@ var PerpetualsClient = (function () {
|
|
4191
4259
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4192
4260
|
.instruction()];
|
4193
4261
|
case 8:
|
4194
|
-
instruction =
|
4262
|
+
instruction = _g.sent();
|
4195
4263
|
instructions.push(instruction);
|
4196
4264
|
return [2, {
|
4197
4265
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -4201,16 +4269,20 @@ var PerpetualsClient = (function () {
|
|
4201
4269
|
});
|
4202
4270
|
});
|
4203
4271
|
};
|
4204
|
-
this.removeLiquidity = function (
|
4205
|
-
|
4206
|
-
|
4207
|
-
|
4208
|
-
|
4209
|
-
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
4213
|
-
|
4272
|
+
this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
|
4273
|
+
var args_1 = [];
|
4274
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4275
|
+
args_1[_i - 4] = arguments[_i];
|
4276
|
+
}
|
4277
|
+
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) {
|
4278
|
+
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_7;
|
4279
|
+
if (closeLpATA === void 0) { closeLpATA = false; }
|
4280
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
4281
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
4282
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4283
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4284
|
+
return __generator(this, function (_f) {
|
4285
|
+
switch (_f.label) {
|
4214
4286
|
case 0:
|
4215
4287
|
recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
|
4216
4288
|
if (!recieveTokenCustodyConfig) {
|
@@ -4221,15 +4293,15 @@ var PerpetualsClient = (function () {
|
|
4221
4293
|
instructions = [];
|
4222
4294
|
postInstructions = [];
|
4223
4295
|
additionalSigners = [];
|
4224
|
-
|
4296
|
+
_f.label = 1;
|
4225
4297
|
case 1:
|
4226
|
-
|
4298
|
+
_f.trys.push([1, 7, , 8]);
|
4227
4299
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
4228
4300
|
custodyAccountMetas = [];
|
4229
4301
|
custodyOracleAccountMetas = [];
|
4230
4302
|
markets = [];
|
4231
|
-
for (
|
4232
|
-
custody = _a
|
4303
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4304
|
+
custody = _b[_a];
|
4233
4305
|
custodyAccountMetas.push({
|
4234
4306
|
pubkey: custody.custodyAccount,
|
4235
4307
|
isSigner: false,
|
@@ -4241,8 +4313,8 @@ var PerpetualsClient = (function () {
|
|
4241
4313
|
isWritable: false,
|
4242
4314
|
});
|
4243
4315
|
}
|
4244
|
-
for (
|
4245
|
-
market = _c
|
4316
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4317
|
+
market = _d[_c];
|
4246
4318
|
markets.push({
|
4247
4319
|
pubkey: market.marketAccount,
|
4248
4320
|
isSigner: false,
|
@@ -4271,17 +4343,17 @@ var PerpetualsClient = (function () {
|
|
4271
4343
|
return [3, 5];
|
4272
4344
|
case 2:
|
4273
4345
|
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
|
4274
|
-
|
4275
|
-
if (!
|
4346
|
+
_e = createUserATA;
|
4347
|
+
if (!_e) return [3, 4];
|
4276
4348
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
4277
4349
|
case 3:
|
4278
|
-
|
4279
|
-
|
4350
|
+
_e = !(_f.sent());
|
4351
|
+
_f.label = 4;
|
4280
4352
|
case 4:
|
4281
|
-
if (
|
4353
|
+
if (_e) {
|
4282
4354
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
|
4283
4355
|
}
|
4284
|
-
|
4356
|
+
_f.label = 5;
|
4285
4357
|
case 5: return [4, this.program.methods
|
4286
4358
|
.removeLiquidity({
|
4287
4359
|
lpAmountIn: liquidityAmountIn,
|
@@ -4306,7 +4378,7 @@ var PerpetualsClient = (function () {
|
|
4306
4378
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4307
4379
|
.instruction()];
|
4308
4380
|
case 6:
|
4309
|
-
removeLiquidityTx =
|
4381
|
+
removeLiquidityTx = _f.sent();
|
4310
4382
|
instructions.push(removeLiquidityTx);
|
4311
4383
|
if (closeLpATA) {
|
4312
4384
|
closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
|
@@ -4318,7 +4390,7 @@ var PerpetualsClient = (function () {
|
|
4318
4390
|
}
|
4319
4391
|
return [3, 8];
|
4320
4392
|
case 7:
|
4321
|
-
err_7 =
|
4393
|
+
err_7 = _f.sent();
|
4322
4394
|
console.log("perpClient removeLiquidity error:: ", err_7);
|
4323
4395
|
throw err_7;
|
4324
4396
|
case 8: return [2, {
|
@@ -4736,22 +4808,26 @@ var PerpetualsClient = (function () {
|
|
4736
4808
|
}
|
4737
4809
|
});
|
4738
4810
|
}); };
|
4739
|
-
this.refreshStakeWithTokenStake = function (
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4811
|
+
this.refreshStakeWithTokenStake = function (rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1) {
|
4812
|
+
var args_1 = [];
|
4813
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
4814
|
+
args_1[_i - 3] = arguments[_i];
|
4815
|
+
}
|
4816
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
|
4817
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
|
4818
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
4819
|
+
return __generator(this, function (_c) {
|
4820
|
+
switch (_c.label) {
|
4745
4821
|
case 0:
|
4746
|
-
|
4822
|
+
_c.trys.push([0, 2, , 3]);
|
4747
4823
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
4748
4824
|
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
4749
4825
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
4750
4826
|
pool = poolConfig.poolAddress;
|
4751
4827
|
feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
|
4752
4828
|
custodyAccountMetas = [];
|
4753
|
-
for (
|
4754
|
-
custody = _a
|
4829
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4830
|
+
custody = _b[_a];
|
4755
4831
|
custodyAccountMetas.push({
|
4756
4832
|
pubkey: custody.custodyAccount,
|
4757
4833
|
isSigner: false,
|
@@ -4783,10 +4859,10 @@ var PerpetualsClient = (function () {
|
|
4783
4859
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
|
4784
4860
|
.instruction()];
|
4785
4861
|
case 1:
|
4786
|
-
refreshStakeInstruction =
|
4862
|
+
refreshStakeInstruction = _c.sent();
|
4787
4863
|
return [2, refreshStakeInstruction];
|
4788
4864
|
case 2:
|
4789
|
-
err_16 =
|
4865
|
+
err_16 = _c.sent();
|
4790
4866
|
console.log("perpClient refreshStaking error:: ", err_16);
|
4791
4867
|
throw err_16;
|
4792
4868
|
case 3: return [2];
|
@@ -4953,12 +5029,16 @@ var PerpetualsClient = (function () {
|
|
4953
5029
|
}
|
4954
5030
|
});
|
4955
5031
|
}); };
|
4956
|
-
this.withdrawStake = function (
|
4957
|
-
|
4958
|
-
|
4959
|
-
|
4960
|
-
|
5032
|
+
this.withdrawStake = function (poolConfig_1) {
|
5033
|
+
var args_1 = [];
|
5034
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
5035
|
+
args_1[_i - 1] = arguments[_i];
|
5036
|
+
}
|
5037
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
|
4961
5038
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_20;
|
5039
|
+
if (pendingActivation === void 0) { pendingActivation = true; }
|
5040
|
+
if (deactivated === void 0) { deactivated = true; }
|
5041
|
+
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
4962
5042
|
return __generator(this, function (_b) {
|
4963
5043
|
switch (_b.label) {
|
4964
5044
|
case 0:
|
@@ -5020,10 +5100,14 @@ var PerpetualsClient = (function () {
|
|
5020
5100
|
});
|
5021
5101
|
});
|
5022
5102
|
};
|
5023
|
-
this.collectStakeFees = function (
|
5024
|
-
|
5025
|
-
|
5103
|
+
this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
|
5104
|
+
var args_1 = [];
|
5105
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5106
|
+
args_1[_i - 3] = arguments[_i];
|
5107
|
+
}
|
5108
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
|
5026
5109
|
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
|
5110
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5027
5111
|
return __generator(this, function (_b) {
|
5028
5112
|
switch (_b.label) {
|
5029
5113
|
case 0:
|
@@ -5696,10 +5780,14 @@ var PerpetualsClient = (function () {
|
|
5696
5780
|
}
|
5697
5781
|
});
|
5698
5782
|
}); };
|
5699
|
-
this.collectTokenReward = function (
|
5700
|
-
|
5701
|
-
|
5783
|
+
this.collectTokenReward = function (owner_1, poolConfig_1) {
|
5784
|
+
var args_1 = [];
|
5785
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
5786
|
+
args_1[_i - 2] = arguments[_i];
|
5787
|
+
}
|
5788
|
+
return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
|
5702
5789
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
|
5790
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5703
5791
|
return __generator(this, function (_b) {
|
5704
5792
|
switch (_b.label) {
|
5705
5793
|
case 0:
|
@@ -5883,10 +5971,14 @@ var PerpetualsClient = (function () {
|
|
5883
5971
|
}
|
5884
5972
|
});
|
5885
5973
|
}); };
|
5886
|
-
this.collectNftReward = function (
|
5887
|
-
|
5888
|
-
|
5974
|
+
this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
|
5975
|
+
var args_1 = [];
|
5976
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5977
|
+
args_1[_i - 3] = arguments[_i];
|
5978
|
+
}
|
5979
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
5889
5980
|
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_38;
|
5981
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5890
5982
|
return __generator(this, function (_b) {
|
5891
5983
|
switch (_b.label) {
|
5892
5984
|
case 0:
|
@@ -5946,10 +6038,14 @@ var PerpetualsClient = (function () {
|
|
5946
6038
|
});
|
5947
6039
|
});
|
5948
6040
|
};
|
5949
|
-
this.collectAndDistributeFee = function (
|
5950
|
-
|
5951
|
-
|
6041
|
+
this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
|
6042
|
+
var args_1 = [];
|
6043
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
6044
|
+
args_1[_i - 2] = arguments[_i];
|
6045
|
+
}
|
6046
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
5952
6047
|
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_39;
|
6048
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5953
6049
|
return __generator(this, function (_b) {
|
5954
6050
|
switch (_b.label) {
|
5955
6051
|
case 0:
|
@@ -6074,12 +6170,16 @@ var PerpetualsClient = (function () {
|
|
6074
6170
|
}
|
6075
6171
|
});
|
6076
6172
|
}); };
|
6077
|
-
this.forceClosePosition = function (
|
6078
|
-
|
6079
|
-
|
6080
|
-
|
6081
|
-
|
6173
|
+
this.forceClosePosition = function (positionAccount_1, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
|
6174
|
+
var args_1 = [];
|
6175
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
6176
|
+
args_1[_i - 6] = arguments[_i];
|
6177
|
+
}
|
6178
|
+
return __awaiter(_this, __spreadArray([positionAccount_1, 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) {
|
6082
6179
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_41;
|
6180
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6181
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
6182
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6083
6183
|
return __generator(this, function (_b) {
|
6084
6184
|
switch (_b.label) {
|
6085
6185
|
case 0:
|
@@ -6151,11 +6251,15 @@ var PerpetualsClient = (function () {
|
|
6151
6251
|
});
|
6152
6252
|
});
|
6153
6253
|
};
|
6154
|
-
this.placeLimitOrder = function (
|
6155
|
-
|
6156
|
-
|
6157
|
-
|
6254
|
+
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) {
|
6255
|
+
var args_1 = [];
|
6256
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6257
|
+
args_1[_i - 11] = arguments[_i];
|
6258
|
+
}
|
6259
|
+
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) {
|
6158
6260
|
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_42;
|
6261
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6262
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6159
6263
|
return __generator(this, function (_c) {
|
6160
6264
|
switch (_c.label) {
|
6161
6265
|
case 0:
|
@@ -6271,11 +6375,15 @@ var PerpetualsClient = (function () {
|
|
6271
6375
|
});
|
6272
6376
|
});
|
6273
6377
|
};
|
6274
|
-
this.editLimitOrder = function (
|
6275
|
-
|
6276
|
-
|
6277
|
-
|
6378
|
+
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) {
|
6379
|
+
var args_1 = [];
|
6380
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6381
|
+
args_1[_i - 11] = arguments[_i];
|
6382
|
+
}
|
6383
|
+
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) {
|
6278
6384
|
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_43;
|
6385
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6386
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6279
6387
|
return __generator(this, function (_b) {
|
6280
6388
|
switch (_b.label) {
|
6281
6389
|
case 0:
|
@@ -6374,12 +6482,16 @@ var PerpetualsClient = (function () {
|
|
6374
6482
|
});
|
6375
6483
|
});
|
6376
6484
|
};
|
6377
|
-
this.executeLimitOrder = function (
|
6378
|
-
|
6379
|
-
|
6380
|
-
|
6381
|
-
|
6485
|
+
this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6486
|
+
var args_1 = [];
|
6487
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
6488
|
+
args_1[_i - 7] = arguments[_i];
|
6489
|
+
}
|
6490
|
+
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) {
|
6382
6491
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_44;
|
6492
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6493
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6494
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6383
6495
|
return __generator(this, function (_a) {
|
6384
6496
|
switch (_a.label) {
|
6385
6497
|
case 0:
|
@@ -6439,12 +6551,16 @@ var PerpetualsClient = (function () {
|
|
6439
6551
|
});
|
6440
6552
|
});
|
6441
6553
|
};
|
6442
|
-
this.executeLimitWithSwap = function (
|
6443
|
-
|
6444
|
-
|
6445
|
-
|
6446
|
-
|
6554
|
+
this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6555
|
+
var args_1 = [];
|
6556
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
6557
|
+
args_1[_i - 8] = arguments[_i];
|
6558
|
+
}
|
6559
|
+
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) {
|
6447
6560
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_45;
|
6561
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6562
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6563
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6448
6564
|
return __generator(this, function (_a) {
|
6449
6565
|
switch (_a.label) {
|
6450
6566
|
case 0:
|
@@ -6710,16 +6826,20 @@ var PerpetualsClient = (function () {
|
|
6710
6826
|
}
|
6711
6827
|
});
|
6712
6828
|
}); };
|
6713
|
-
this.executeTriggerWithSwap = function (
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
|
6718
|
-
|
6719
|
-
|
6720
|
-
|
6721
|
-
|
6722
|
-
|
6829
|
+
this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
6830
|
+
var args_1 = [];
|
6831
|
+
for (var _i = 9; _i < arguments.length; _i++) {
|
6832
|
+
args_1[_i - 9] = arguments[_i];
|
6833
|
+
}
|
6834
|
+
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) {
|
6835
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_50;
|
6836
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6837
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6838
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6839
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6840
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6841
|
+
return __generator(this, function (_e) {
|
6842
|
+
switch (_e.label) {
|
6723
6843
|
case 0:
|
6724
6844
|
payerPubkey = this.provider.wallet.publicKey;
|
6725
6845
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
@@ -6730,9 +6850,9 @@ var PerpetualsClient = (function () {
|
|
6730
6850
|
instructions = [];
|
6731
6851
|
postInstructions = [];
|
6732
6852
|
additionalSigners = [];
|
6733
|
-
|
6853
|
+
_e.label = 1;
|
6734
6854
|
case 1:
|
6735
|
-
|
6855
|
+
_e.trys.push([1, 9, , 10]);
|
6736
6856
|
if (!false) return [3, 2];
|
6737
6857
|
return [3, 7];
|
6738
6858
|
case 2:
|
@@ -6741,8 +6861,8 @@ var PerpetualsClient = (function () {
|
|
6741
6861
|
if (!_a) return [3, 4];
|
6742
6862
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
6743
6863
|
case 3:
|
6744
|
-
_a = !(
|
6745
|
-
|
6864
|
+
_a = !(_e.sent());
|
6865
|
+
_e.label = 4;
|
6746
6866
|
case 4:
|
6747
6867
|
if (_a) {
|
6748
6868
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
@@ -6752,20 +6872,20 @@ var PerpetualsClient = (function () {
|
|
6752
6872
|
if (!_b) return [3, 6];
|
6753
6873
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
6754
6874
|
case 5:
|
6755
|
-
_b = !(
|
6756
|
-
|
6875
|
+
_b = !(_e.sent());
|
6876
|
+
_e.label = 6;
|
6757
6877
|
case 6:
|
6758
6878
|
if (_b) {
|
6759
6879
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
6760
6880
|
}
|
6761
|
-
|
6881
|
+
_e.label = 7;
|
6762
6882
|
case 7:
|
6763
6883
|
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
6764
6884
|
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
6765
6885
|
custodyAccountMetas = [];
|
6766
6886
|
custodyOracleAccountMetas = [];
|
6767
|
-
for (
|
6768
|
-
custody = _c
|
6887
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
6888
|
+
custody = _d[_c];
|
6769
6889
|
custodyAccountMetas.push({
|
6770
6890
|
pubkey: custody.custodyAccount,
|
6771
6891
|
isSigner: false,
|
@@ -6810,11 +6930,11 @@ var PerpetualsClient = (function () {
|
|
6810
6930
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6811
6931
|
.instruction()];
|
6812
6932
|
case 8:
|
6813
|
-
executeTriggerWithSwap =
|
6933
|
+
executeTriggerWithSwap = _e.sent();
|
6814
6934
|
instructions.push(executeTriggerWithSwap);
|
6815
6935
|
return [3, 10];
|
6816
6936
|
case 9:
|
6817
|
-
err_50 =
|
6937
|
+
err_50 = _e.sent();
|
6818
6938
|
console.log("perpClient executeTriggerWithSwap error:: ", err_50);
|
6819
6939
|
throw err_50;
|
6820
6940
|
case 10: return [2, {
|
@@ -6825,14 +6945,18 @@ var PerpetualsClient = (function () {
|
|
6825
6945
|
});
|
6826
6946
|
});
|
6827
6947
|
};
|
6828
|
-
this.executeTriggerOrder = function (
|
6829
|
-
|
6830
|
-
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
6834
|
-
return __awaiter(_this, void 0, void 0, function () {
|
6948
|
+
this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
6949
|
+
var args_1 = [];
|
6950
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
6951
|
+
args_1[_i - 8] = arguments[_i];
|
6952
|
+
}
|
6953
|
+
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) {
|
6835
6954
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_51;
|
6955
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6956
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6957
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6958
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6959
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6836
6960
|
return __generator(this, function (_b) {
|
6837
6961
|
switch (_b.label) {
|
6838
6962
|
case 0:
|
@@ -7184,14 +7308,18 @@ var PerpetualsClient = (function () {
|
|
7184
7308
|
}
|
7185
7309
|
});
|
7186
7310
|
}); };
|
7187
|
-
this.addCompoundingLiquidity = function (
|
7188
|
-
|
7189
|
-
|
7190
|
-
|
7191
|
-
|
7192
|
-
|
7193
|
-
|
7194
|
-
|
7311
|
+
this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7312
|
+
var args_1 = [];
|
7313
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7314
|
+
args_1[_i - 5] = arguments[_i];
|
7315
|
+
}
|
7316
|
+
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) {
|
7317
|
+
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_58;
|
7318
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
7319
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7320
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
7321
|
+
return __generator(this, function (_f) {
|
7322
|
+
switch (_f.label) {
|
7195
7323
|
case 0:
|
7196
7324
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
7197
7325
|
preInstructions = [];
|
@@ -7208,8 +7336,8 @@ var PerpetualsClient = (function () {
|
|
7208
7336
|
custodyAccountMetas = [];
|
7209
7337
|
custodyOracleAccountMetas = [];
|
7210
7338
|
markets = [];
|
7211
|
-
for (
|
7212
|
-
custody = _a
|
7339
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
7340
|
+
custody = _b[_a];
|
7213
7341
|
custodyAccountMetas.push({
|
7214
7342
|
pubkey: custody.custodyAccount,
|
7215
7343
|
isSigner: false,
|
@@ -7221,8 +7349,8 @@ var PerpetualsClient = (function () {
|
|
7221
7349
|
isWritable: false,
|
7222
7350
|
});
|
7223
7351
|
}
|
7224
|
-
for (
|
7225
|
-
market = _c
|
7352
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
7353
|
+
market = _d[_c];
|
7226
7354
|
markets.push({
|
7227
7355
|
pubkey: market.marketAccount,
|
7228
7356
|
isSigner: false,
|
@@ -7231,26 +7359,26 @@ var PerpetualsClient = (function () {
|
|
7231
7359
|
}
|
7232
7360
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
7233
7361
|
case 1:
|
7234
|
-
if (!(
|
7362
|
+
if (!(_f.sent())) {
|
7235
7363
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
7236
7364
|
}
|
7237
7365
|
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
7238
7366
|
case 2:
|
7239
|
-
if (!(
|
7367
|
+
if (!(_f.sent())) {
|
7240
7368
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
7241
7369
|
}
|
7242
7370
|
if (!(inTokenSymbol == 'SOL')) return [3, 5];
|
7243
7371
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
7244
7372
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
7245
7373
|
if (!!skipBalanceChecks) return [3, 4];
|
7246
|
-
|
7374
|
+
_e = anchor_1.BN.bind;
|
7247
7375
|
return [4, this.provider.connection.getBalance(publicKey)];
|
7248
7376
|
case 3:
|
7249
|
-
unWrappedSolBalance = new (
|
7377
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
|
7250
7378
|
if (unWrappedSolBalance.lt(lamports)) {
|
7251
7379
|
throw "Insufficient SOL Funds";
|
7252
7380
|
}
|
7253
|
-
|
7381
|
+
_f.label = 4;
|
7254
7382
|
case 4:
|
7255
7383
|
if (!ephemeralSignerPubkey) {
|
7256
7384
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -7274,12 +7402,12 @@ var PerpetualsClient = (function () {
|
|
7274
7402
|
if (!!skipBalanceChecks) return [3, 7];
|
7275
7403
|
return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
|
7276
7404
|
case 6:
|
7277
|
-
if (!(
|
7405
|
+
if (!(_f.sent())) {
|
7278
7406
|
throw "Insufficient Funds , token Account doesn't exist";
|
7279
7407
|
}
|
7280
|
-
|
7408
|
+
_f.label = 7;
|
7281
7409
|
case 7:
|
7282
|
-
|
7410
|
+
_f.trys.push([7, 9, , 10]);
|
7283
7411
|
return [4, this.program.methods
|
7284
7412
|
.addCompoundingLiquidity({
|
7285
7413
|
amountIn: amountIn,
|
@@ -7308,11 +7436,11 @@ var PerpetualsClient = (function () {
|
|
7308
7436
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7309
7437
|
.instruction()];
|
7310
7438
|
case 8:
|
7311
|
-
addCompoundingLiquidity =
|
7439
|
+
addCompoundingLiquidity = _f.sent();
|
7312
7440
|
instructions.push(addCompoundingLiquidity);
|
7313
7441
|
return [3, 10];
|
7314
7442
|
case 9:
|
7315
|
-
err_58 =
|
7443
|
+
err_58 = _f.sent();
|
7316
7444
|
console.log("perpClient addCompoundingLiquidity error:: ", err_58);
|
7317
7445
|
return [3, 10];
|
7318
7446
|
case 10: return [2, {
|
@@ -7323,14 +7451,18 @@ var PerpetualsClient = (function () {
|
|
7323
7451
|
});
|
7324
7452
|
});
|
7325
7453
|
};
|
7326
|
-
this.removeCompoundingLiquidity = function (
|
7327
|
-
|
7328
|
-
|
7329
|
-
|
7330
|
-
|
7331
|
-
|
7332
|
-
|
7333
|
-
|
7454
|
+
this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7455
|
+
var args_1 = [];
|
7456
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7457
|
+
args_1[_i - 5] = arguments[_i];
|
7458
|
+
}
|
7459
|
+
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) {
|
7460
|
+
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_59;
|
7461
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7462
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7463
|
+
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
7464
|
+
return __generator(this, function (_f) {
|
7465
|
+
switch (_f.label) {
|
7334
7466
|
case 0:
|
7335
7467
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
7336
7468
|
preInstructions = [];
|
@@ -7367,19 +7499,19 @@ var PerpetualsClient = (function () {
|
|
7367
7499
|
if (!_a) return [3, 3];
|
7368
7500
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
7369
7501
|
case 2:
|
7370
|
-
_a = !(
|
7371
|
-
|
7502
|
+
_a = !(_f.sent());
|
7503
|
+
_f.label = 3;
|
7372
7504
|
case 3:
|
7373
7505
|
if (_a) {
|
7374
7506
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
|
7375
7507
|
}
|
7376
|
-
|
7508
|
+
_f.label = 4;
|
7377
7509
|
case 4:
|
7378
7510
|
custodyAccountMetas = [];
|
7379
7511
|
custodyOracleAccountMetas = [];
|
7380
7512
|
markets = [];
|
7381
|
-
for (
|
7382
|
-
custody = _b
|
7513
|
+
for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
|
7514
|
+
custody = _c[_b];
|
7383
7515
|
custodyAccountMetas.push({
|
7384
7516
|
pubkey: custody.custodyAccount,
|
7385
7517
|
isSigner: false,
|
@@ -7391,8 +7523,8 @@ var PerpetualsClient = (function () {
|
|
7391
7523
|
isWritable: false,
|
7392
7524
|
});
|
7393
7525
|
}
|
7394
|
-
for (
|
7395
|
-
market = _d
|
7526
|
+
for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
|
7527
|
+
market = _e[_d];
|
7396
7528
|
markets.push({
|
7397
7529
|
pubkey: market.marketAccount,
|
7398
7530
|
isSigner: false,
|
@@ -7400,9 +7532,9 @@ var PerpetualsClient = (function () {
|
|
7400
7532
|
});
|
7401
7533
|
}
|
7402
7534
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
7403
|
-
|
7535
|
+
_f.label = 5;
|
7404
7536
|
case 5:
|
7405
|
-
|
7537
|
+
_f.trys.push([5, 7, , 8]);
|
7406
7538
|
return [4, this.program.methods
|
7407
7539
|
.removeCompoundingLiquidity({
|
7408
7540
|
compoundingAmountIn: compoundingAmountIn,
|
@@ -7431,11 +7563,11 @@ var PerpetualsClient = (function () {
|
|
7431
7563
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7432
7564
|
.instruction()];
|
7433
7565
|
case 6:
|
7434
|
-
removeCompoundingLiquidity =
|
7566
|
+
removeCompoundingLiquidity = _f.sent();
|
7435
7567
|
instructions.push(removeCompoundingLiquidity);
|
7436
7568
|
return [3, 8];
|
7437
7569
|
case 7:
|
7438
|
-
err_59 =
|
7570
|
+
err_59 = _f.sent();
|
7439
7571
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_59);
|
7440
7572
|
return [3, 8];
|
7441
7573
|
case 8: return [2, {
|
@@ -7446,12 +7578,16 @@ var PerpetualsClient = (function () {
|
|
7446
7578
|
});
|
7447
7579
|
});
|
7448
7580
|
};
|
7449
|
-
this.migrateStake = function (
|
7450
|
-
|
7451
|
-
|
7452
|
-
|
7453
|
-
|
7454
|
-
|
7581
|
+
this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
|
7582
|
+
var args_1 = [];
|
7583
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
7584
|
+
args_1[_i - 3] = arguments[_i];
|
7585
|
+
}
|
7586
|
+
return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
7587
|
+
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_60;
|
7588
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7589
|
+
return __generator(this, function (_g) {
|
7590
|
+
switch (_g.label) {
|
7455
7591
|
case 0:
|
7456
7592
|
publicKey = this.provider.wallet.publicKey;
|
7457
7593
|
preInstructions = [];
|
@@ -7466,8 +7602,8 @@ var PerpetualsClient = (function () {
|
|
7466
7602
|
if (!_a) return [3, 2];
|
7467
7603
|
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
7468
7604
|
case 1:
|
7469
|
-
_a = !(
|
7470
|
-
|
7605
|
+
_a = !(_g.sent());
|
7606
|
+
_g.label = 2;
|
7471
7607
|
case 2:
|
7472
7608
|
if (_a) {
|
7473
7609
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
@@ -7479,8 +7615,8 @@ var PerpetualsClient = (function () {
|
|
7479
7615
|
if (!_b) return [3, 4];
|
7480
7616
|
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
7481
7617
|
case 3:
|
7482
|
-
_b = (
|
7483
|
-
|
7618
|
+
_b = (_g.sent());
|
7619
|
+
_g.label = 4;
|
7484
7620
|
case 4:
|
7485
7621
|
if (_b) {
|
7486
7622
|
tokenStakeAccounts.push({
|
@@ -7493,8 +7629,8 @@ var PerpetualsClient = (function () {
|
|
7493
7629
|
custodyAccountMetas = [];
|
7494
7630
|
custodyOracleAccountMetas = [];
|
7495
7631
|
markets = [];
|
7496
|
-
for (
|
7497
|
-
custody = _c
|
7632
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
7633
|
+
custody = _d[_c];
|
7498
7634
|
custodyAccountMetas.push({
|
7499
7635
|
pubkey: custody.custodyAccount,
|
7500
7636
|
isSigner: false,
|
@@ -7506,17 +7642,17 @@ var PerpetualsClient = (function () {
|
|
7506
7642
|
isWritable: false,
|
7507
7643
|
});
|
7508
7644
|
}
|
7509
|
-
for (
|
7510
|
-
market = _e
|
7645
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
7646
|
+
market = _f[_e];
|
7511
7647
|
markets.push({
|
7512
7648
|
pubkey: market.marketAccount,
|
7513
7649
|
isSigner: false,
|
7514
7650
|
isWritable: false,
|
7515
7651
|
});
|
7516
7652
|
}
|
7517
|
-
|
7653
|
+
_g.label = 5;
|
7518
7654
|
case 5:
|
7519
|
-
|
7655
|
+
_g.trys.push([5, 7, , 8]);
|
7520
7656
|
return [4, this.program.methods
|
7521
7657
|
.migrateStake({
|
7522
7658
|
amount: amount
|
@@ -7542,11 +7678,11 @@ var PerpetualsClient = (function () {
|
|
7542
7678
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
|
7543
7679
|
.instruction()];
|
7544
7680
|
case 6:
|
7545
|
-
migrateStake =
|
7681
|
+
migrateStake = _g.sent();
|
7546
7682
|
instructions.push(migrateStake);
|
7547
7683
|
return [3, 8];
|
7548
7684
|
case 7:
|
7549
|
-
err_60 =
|
7685
|
+
err_60 = _g.sent();
|
7550
7686
|
console.log("perpClient migrateStake error:: ", err_60);
|
7551
7687
|
return [3, 8];
|
7552
7688
|
case 8: return [2, {
|
@@ -7640,12 +7776,16 @@ var PerpetualsClient = (function () {
|
|
7640
7776
|
}
|
7641
7777
|
});
|
7642
7778
|
}); };
|
7643
|
-
this.compoundingFee = function (
|
7644
|
-
|
7645
|
-
|
7646
|
-
|
7647
|
-
|
7648
|
-
|
7779
|
+
this.compoundingFee = function (poolConfig_1) {
|
7780
|
+
var args_1 = [];
|
7781
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
7782
|
+
args_1[_i - 1] = arguments[_i];
|
7783
|
+
}
|
7784
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
|
7785
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_62;
|
7786
|
+
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
7787
|
+
return __generator(this, function (_e) {
|
7788
|
+
switch (_e.label) {
|
7649
7789
|
case 0:
|
7650
7790
|
instructions = [];
|
7651
7791
|
additionalSigners = [];
|
@@ -7654,8 +7794,8 @@ var PerpetualsClient = (function () {
|
|
7654
7794
|
custodyAccountMetas = [];
|
7655
7795
|
custodyOracleAccountMetas = [];
|
7656
7796
|
markets = [];
|
7657
|
-
for (
|
7658
|
-
custody = _a
|
7797
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
7798
|
+
custody = _b[_a];
|
7659
7799
|
custodyAccountMetas.push({
|
7660
7800
|
pubkey: custody.custodyAccount,
|
7661
7801
|
isSigner: false,
|
@@ -7667,17 +7807,17 @@ var PerpetualsClient = (function () {
|
|
7667
7807
|
isWritable: false,
|
7668
7808
|
});
|
7669
7809
|
}
|
7670
|
-
for (
|
7671
|
-
market = _c
|
7810
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
7811
|
+
market = _d[_c];
|
7672
7812
|
markets.push({
|
7673
7813
|
pubkey: market.marketAccount,
|
7674
7814
|
isSigner: false,
|
7675
7815
|
isWritable: false,
|
7676
7816
|
});
|
7677
7817
|
}
|
7678
|
-
|
7818
|
+
_e.label = 1;
|
7679
7819
|
case 1:
|
7680
|
-
|
7820
|
+
_e.trys.push([1, 3, , 4]);
|
7681
7821
|
return [4, this.program.methods
|
7682
7822
|
.compoundFees({})
|
7683
7823
|
.accounts({
|
@@ -7696,11 +7836,11 @@ var PerpetualsClient = (function () {
|
|
7696
7836
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7697
7837
|
.instruction()];
|
7698
7838
|
case 2:
|
7699
|
-
compoundingFee =
|
7839
|
+
compoundingFee = _e.sent();
|
7700
7840
|
instructions.push(compoundingFee);
|
7701
7841
|
return [3, 4];
|
7702
7842
|
case 3:
|
7703
|
-
err_62 =
|
7843
|
+
err_62 = _e.sent();
|
7704
7844
|
console.log("perpClient compoundingFee error:: ", err_62);
|
7705
7845
|
return [3, 4];
|
7706
7846
|
case 4: return [2, {
|
@@ -7861,9 +8001,9 @@ var PerpetualsClient = (function () {
|
|
7861
8001
|
}
|
7862
8002
|
}
|
7863
8003
|
};
|
7864
|
-
PerpetualsClient.prototype.sendTransaction = function (
|
7865
|
-
|
7866
|
-
|
8004
|
+
PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
|
8005
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
8006
|
+
if (opts === void 0) { opts = {}; }
|
7867
8007
|
return __generator(this, function (_a) {
|
7868
8008
|
switch (_a.label) {
|
7869
8009
|
case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|
@@ -7872,9 +8012,9 @@ var PerpetualsClient = (function () {
|
|
7872
8012
|
});
|
7873
8013
|
});
|
7874
8014
|
};
|
7875
|
-
PerpetualsClient.prototype.sendTransactionV3 = function (
|
7876
|
-
|
7877
|
-
|
8015
|
+
PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
|
8016
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
8017
|
+
if (opts === void 0) { opts = {}; }
|
7878
8018
|
return __generator(this, function (_a) {
|
7879
8019
|
switch (_a.label) {
|
7880
8020
|
case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|