flash-sdk 2.46.3 → 2.46.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OraclePrice.d.ts +0 -1
- package/dist/OrderAccount.d.ts +0 -1
- package/dist/PerpetualsClient.d.ts +2 -3
- package/dist/PerpetualsClient.js +646 -471
- package/dist/PoolAccount.d.ts +0 -1
- package/dist/PoolDataClient.d.ts +0 -1
- package/dist/PositionAccount.d.ts +0 -1
- package/dist/TokenVaultAccount.d.ts +0 -1
- package/dist/TradingAccount.d.ts +0 -1
- package/dist/ViewHelper.js +2 -2
- package/dist/backupOracle.js +7 -7
- package/dist/constants/index.d.ts +0 -1
- package/dist/idl/perpetuals.d.ts +374 -0
- package/dist/idl/perpetuals.js +374 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +3 -3
- package/dist/utils/IdlCoder.js +17 -7
- package/dist/utils/alt.d.ts +0 -1
- package/dist/utils/alt.js +5 -6
- package/dist/utils/anchorCpiEvents.d.ts +0 -1
- package/dist/utils/anchorCpiEvents.js +4 -4
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +59 -59
- package/package.json +8 -5
package/dist/PerpetualsClient.js
CHANGED
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
20
20
|
});
|
21
21
|
};
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
24
|
-
return g =
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
26
26
|
function step(op) {
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
@@ -2618,14 +2618,18 @@ var PerpetualsClient = (function () {
|
|
2618
2618
|
}
|
2619
2619
|
});
|
2620
2620
|
}); };
|
2621
|
-
this.openPosition = function (
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2621
|
+
this.openPosition = function (targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1) {
|
2622
|
+
var args_1 = [];
|
2623
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
2624
|
+
args_1[_i - 8] = arguments[_i];
|
2625
|
+
}
|
2626
|
+
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) {
|
2628
2627
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
|
2628
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2629
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2630
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2631
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2632
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2629
2633
|
return __generator(this, function (_c) {
|
2630
2634
|
switch (_c.label) {
|
2631
2635
|
case 0:
|
@@ -2729,15 +2733,19 @@ var PerpetualsClient = (function () {
|
|
2729
2733
|
});
|
2730
2734
|
});
|
2731
2735
|
};
|
2732
|
-
this.closePosition = function (
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2739
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2736
|
+
this.closePosition = function (marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
2737
|
+
var args_1 = [];
|
2738
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
2739
|
+
args_1[_i - 6] = arguments[_i];
|
2740
|
+
}
|
2741
|
+
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) {
|
2740
2742
|
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_2;
|
2743
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2744
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2745
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2746
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
2747
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
2748
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2741
2749
|
return __generator(this, function (_b) {
|
2742
2750
|
switch (_b.label) {
|
2743
2751
|
case 0:
|
@@ -2834,14 +2842,18 @@ var PerpetualsClient = (function () {
|
|
2834
2842
|
});
|
2835
2843
|
});
|
2836
2844
|
};
|
2837
|
-
this.swapAndOpen = function (
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
return __awaiter(_this, void 0, void 0, function () {
|
2845
|
+
this.swapAndOpen = function (targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, minCollateralAmountOut_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1) {
|
2846
|
+
var args_1 = [];
|
2847
|
+
for (var _i = 10; _i < arguments.length; _i++) {
|
2848
|
+
args_1[_i - 10] = arguments[_i];
|
2849
|
+
}
|
2850
|
+
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) {
|
2844
2851
|
var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_2;
|
2852
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2853
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2854
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2855
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2856
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2845
2857
|
return __generator(this, function (_c) {
|
2846
2858
|
switch (_c.label) {
|
2847
2859
|
case 0:
|
@@ -2981,13 +2993,17 @@ var PerpetualsClient = (function () {
|
|
2981
2993
|
});
|
2982
2994
|
});
|
2983
2995
|
};
|
2984
|
-
this.closeAndSwap = function (
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
return __awaiter(_this,
|
2996
|
+
this.closeAndSwap = function (targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, minSwapAmountOut_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1) {
|
2997
|
+
var args_1 = [];
|
2998
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
2999
|
+
args_1[_i - 8] = arguments[_i];
|
3000
|
+
}
|
3001
|
+
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) {
|
2990
3002
|
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_3;
|
3003
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3004
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3005
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3006
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2991
3007
|
return __generator(this, function (_a) {
|
2992
3008
|
switch (_a.label) {
|
2993
3009
|
case 0:
|
@@ -3101,16 +3117,20 @@ var PerpetualsClient = (function () {
|
|
3101
3117
|
});
|
3102
3118
|
});
|
3103
3119
|
};
|
3104
|
-
this.swap = function (
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3120
|
+
this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
|
3121
|
+
var args_1 = [];
|
3122
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
3123
|
+
args_1[_i - 5] = arguments[_i];
|
3124
|
+
}
|
3125
|
+
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) {
|
3126
|
+
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;
|
3127
|
+
if (useFeesPool === void 0) { useFeesPool = false; }
|
3128
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3129
|
+
if (unWrapSol === void 0) { unWrapSol = false; }
|
3130
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3131
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3132
|
+
return __generator(this, function (_g) {
|
3133
|
+
switch (_g.label) {
|
3114
3134
|
case 0:
|
3115
3135
|
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
3116
3136
|
if (!userInputCustodyConfig) {
|
@@ -3128,10 +3148,10 @@ var PerpetualsClient = (function () {
|
|
3128
3148
|
if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
|
3129
3149
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
|
3130
3150
|
case 1:
|
3131
|
-
wsolAssociatedTokenAccount =
|
3151
|
+
wsolAssociatedTokenAccount = _g.sent();
|
3132
3152
|
return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
|
3133
3153
|
case 2:
|
3134
|
-
wsolATAExist =
|
3154
|
+
wsolATAExist = _g.sent();
|
3135
3155
|
if (!wsolATAExist) {
|
3136
3156
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
|
3137
3157
|
}
|
@@ -3139,11 +3159,11 @@ var PerpetualsClient = (function () {
|
|
3139
3159
|
_a = anchor_1.BN.bind;
|
3140
3160
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3141
3161
|
case 3:
|
3142
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
3162
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3143
3163
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3144
3164
|
throw "Insufficient SOL Funds";
|
3145
3165
|
}
|
3146
|
-
|
3166
|
+
_g.label = 4;
|
3147
3167
|
case 4:
|
3148
3168
|
instructions.push(web3_js_1.SystemProgram.transfer({
|
3149
3169
|
fromPubkey: publicKey,
|
@@ -3165,20 +3185,20 @@ var PerpetualsClient = (function () {
|
|
3165
3185
|
additionalSigners: additionalSigners
|
3166
3186
|
}];
|
3167
3187
|
}
|
3168
|
-
|
3188
|
+
_g.label = 6;
|
3169
3189
|
case 6:
|
3170
|
-
|
3190
|
+
_g.trys.push([6, 19, , 20]);
|
3171
3191
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
3172
3192
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
3173
3193
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
3174
3194
|
case 7:
|
3175
|
-
accCreationLamports = (
|
3195
|
+
accCreationLamports = (_g.sent());
|
3176
3196
|
console.log("accCreationLamports:", accCreationLamports);
|
3177
3197
|
lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
|
3178
3198
|
_b = anchor_1.BN.bind;
|
3179
3199
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3180
3200
|
case 8:
|
3181
|
-
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0,
|
3201
|
+
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3182
3202
|
if (unWrappedSolBalance.lt(amountIn)) {
|
3183
3203
|
throw "Insufficient SOL Funds";
|
3184
3204
|
}
|
@@ -3205,18 +3225,18 @@ var PerpetualsClient = (function () {
|
|
3205
3225
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true);
|
3206
3226
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
3207
3227
|
case 10:
|
3208
|
-
if (!(
|
3228
|
+
if (!(_g.sent())) {
|
3209
3229
|
throw "Insufficient Funds , Token Account doesn't exist";
|
3210
3230
|
}
|
3211
3231
|
if (!!skipBalanceChecks) return [3, 12];
|
3212
3232
|
_c = anchor_1.BN.bind;
|
3213
3233
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
3214
3234
|
case 11:
|
3215
|
-
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (
|
3235
|
+
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
3216
3236
|
if (tokenAccountBalance.lt(amountIn)) {
|
3217
3237
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
3218
3238
|
}
|
3219
|
-
|
3239
|
+
_g.label = 12;
|
3220
3240
|
case 12:
|
3221
3241
|
if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
|
3222
3242
|
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
@@ -3241,23 +3261,23 @@ var PerpetualsClient = (function () {
|
|
3241
3261
|
return [3, 17];
|
3242
3262
|
case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true)];
|
3243
3263
|
case 14:
|
3244
|
-
userOutputTokenAccount =
|
3264
|
+
userOutputTokenAccount = _g.sent();
|
3245
3265
|
_d = createUserATA;
|
3246
3266
|
if (!_d) return [3, 16];
|
3247
3267
|
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
3248
3268
|
case 15:
|
3249
|
-
_d = !(
|
3250
|
-
|
3269
|
+
_d = !(_g.sent());
|
3270
|
+
_g.label = 16;
|
3251
3271
|
case 16:
|
3252
3272
|
if (_d) {
|
3253
3273
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
|
3254
3274
|
}
|
3255
|
-
|
3275
|
+
_g.label = 17;
|
3256
3276
|
case 17:
|
3257
3277
|
custodyAccountMetas = [];
|
3258
3278
|
custodyOracleAccountMetas = [];
|
3259
|
-
for (
|
3260
|
-
custody = _e
|
3279
|
+
for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
|
3280
|
+
custody = _f[_e];
|
3261
3281
|
custodyAccountMetas.push({
|
3262
3282
|
pubkey: custody.custodyAccount,
|
3263
3283
|
isSigner: false,
|
@@ -3297,7 +3317,7 @@ var PerpetualsClient = (function () {
|
|
3297
3317
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
3298
3318
|
.instruction()];
|
3299
3319
|
case 18:
|
3300
|
-
inx =
|
3320
|
+
inx = _g.sent();
|
3301
3321
|
instructions.push(inx);
|
3302
3322
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
3303
3323
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
@@ -3305,7 +3325,7 @@ var PerpetualsClient = (function () {
|
|
3305
3325
|
}
|
3306
3326
|
return [3, 20];
|
3307
3327
|
case 19:
|
3308
|
-
err_4 =
|
3328
|
+
err_4 = _g.sent();
|
3309
3329
|
console.error("perpClient Swap error:: ", err_4);
|
3310
3330
|
throw err_4;
|
3311
3331
|
case 20: return [2, {
|
@@ -3387,11 +3407,15 @@ var PerpetualsClient = (function () {
|
|
3387
3407
|
}
|
3388
3408
|
});
|
3389
3409
|
}); };
|
3390
|
-
this.addCollateral = function (
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3410
|
+
this.addCollateral = function (collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3411
|
+
var args_1 = [];
|
3412
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3413
|
+
args_1[_i - 6] = arguments[_i];
|
3414
|
+
}
|
3415
|
+
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) {
|
3394
3416
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
|
3417
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3418
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3395
3419
|
return __generator(this, function (_c) {
|
3396
3420
|
switch (_c.label) {
|
3397
3421
|
case 0:
|
@@ -3485,11 +3509,15 @@ var PerpetualsClient = (function () {
|
|
3485
3509
|
});
|
3486
3510
|
});
|
3487
3511
|
};
|
3488
|
-
this.swapAndAddCollateral = function (
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3512
|
+
this.swapAndAddCollateral = function (targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, minCollateralAmountOut_1, side_1, positionPubKey_1, poolConfig_1) {
|
3513
|
+
var args_1 = [];
|
3514
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3515
|
+
args_1[_i - 8] = arguments[_i];
|
3516
|
+
}
|
3517
|
+
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) {
|
3492
3518
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
|
3519
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3520
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3493
3521
|
return __generator(this, function (_c) {
|
3494
3522
|
switch (_c.label) {
|
3495
3523
|
case 0:
|
@@ -3600,12 +3628,16 @@ var PerpetualsClient = (function () {
|
|
3600
3628
|
});
|
3601
3629
|
});
|
3602
3630
|
};
|
3603
|
-
this.removeCollateral = function (
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3607
|
-
|
3631
|
+
this.removeCollateral = function (collateralWithFee_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1) {
|
3632
|
+
var args_1 = [];
|
3633
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
3634
|
+
args_1[_i - 6] = arguments[_i];
|
3635
|
+
}
|
3636
|
+
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) {
|
3608
3637
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_3;
|
3638
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3639
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
3640
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3609
3641
|
return __generator(this, function (_b) {
|
3610
3642
|
switch (_b.label) {
|
3611
3643
|
case 0:
|
@@ -3706,10 +3738,14 @@ var PerpetualsClient = (function () {
|
|
3706
3738
|
});
|
3707
3739
|
});
|
3708
3740
|
};
|
3709
|
-
this.removeCollateralAndSwap = function (
|
3710
|
-
|
3711
|
-
|
3741
|
+
this.removeCollateralAndSwap = function (targetSymbol_1, collateralSymbol_1, outputSymbol_1, minSwapAmountOut_1, collateralDelta_1, side_1, poolConfig_1) {
|
3742
|
+
var args_1 = [];
|
3743
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
3744
|
+
args_1[_i - 7] = arguments[_i];
|
3745
|
+
}
|
3746
|
+
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) {
|
3712
3747
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
|
3748
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3713
3749
|
return __generator(this, function (_a) {
|
3714
3750
|
switch (_a.label) {
|
3715
3751
|
case 0:
|
@@ -3802,12 +3838,16 @@ var PerpetualsClient = (function () {
|
|
3802
3838
|
});
|
3803
3839
|
});
|
3804
3840
|
};
|
3805
|
-
this.increaseSize = function (
|
3806
|
-
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3841
|
+
this.increaseSize = function (targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3842
|
+
var args_1 = [];
|
3843
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3844
|
+
args_1[_i - 8] = arguments[_i];
|
3845
|
+
}
|
3846
|
+
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) {
|
3810
3847
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3848
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3849
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3850
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3811
3851
|
return __generator(this, function (_a) {
|
3812
3852
|
switch (_a.label) {
|
3813
3853
|
case 0:
|
@@ -3862,12 +3902,16 @@ var PerpetualsClient = (function () {
|
|
3862
3902
|
});
|
3863
3903
|
});
|
3864
3904
|
};
|
3865
|
-
this.decreaseSize = function (
|
3866
|
-
|
3867
|
-
|
3868
|
-
|
3869
|
-
|
3905
|
+
this.decreaseSize = function (targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1) {
|
3906
|
+
var args_1 = [];
|
3907
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
3908
|
+
args_1[_i - 8] = arguments[_i];
|
3909
|
+
}
|
3910
|
+
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) {
|
3870
3911
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3912
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3913
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3914
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3871
3915
|
return __generator(this, function (_a) {
|
3872
3916
|
switch (_a.label) {
|
3873
3917
|
case 0:
|
@@ -3922,13 +3966,17 @@ var PerpetualsClient = (function () {
|
|
3922
3966
|
});
|
3923
3967
|
});
|
3924
3968
|
};
|
3925
|
-
this.addLiquidity = function (
|
3926
|
-
|
3927
|
-
|
3928
|
-
|
3929
|
-
|
3930
|
-
|
3931
|
-
|
3969
|
+
this.addLiquidity = function (payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1) {
|
3970
|
+
var args_1 = [];
|
3971
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
3972
|
+
args_1[_i - 4] = arguments[_i];
|
3973
|
+
}
|
3974
|
+
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
3975
|
+
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;
|
3976
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3977
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3978
|
+
return __generator(this, function (_g) {
|
3979
|
+
switch (_g.label) {
|
3932
3980
|
case 0:
|
3933
3981
|
publicKey = this.provider.wallet.publicKey;
|
3934
3982
|
payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
|
@@ -3939,16 +3987,16 @@ var PerpetualsClient = (function () {
|
|
3939
3987
|
instructions = [];
|
3940
3988
|
postInstructions = [];
|
3941
3989
|
additionalSigners = [];
|
3942
|
-
|
3990
|
+
_g.label = 1;
|
3943
3991
|
case 1:
|
3944
|
-
|
3992
|
+
_g.trys.push([1, 10, , 11]);
|
3945
3993
|
userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true);
|
3946
3994
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
3947
3995
|
custodyAccountMetas = [];
|
3948
3996
|
custodyOracleAccountMetas = [];
|
3949
3997
|
markets = [];
|
3950
|
-
for (
|
3951
|
-
custody = _a
|
3998
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
3999
|
+
custody = _b[_a];
|
3952
4000
|
custodyAccountMetas.push({
|
3953
4001
|
pubkey: custody.custodyAccount,
|
3954
4002
|
isSigner: false,
|
@@ -3960,8 +4008,8 @@ var PerpetualsClient = (function () {
|
|
3960
4008
|
isWritable: false,
|
3961
4009
|
});
|
3962
4010
|
}
|
3963
|
-
for (
|
3964
|
-
market = _c
|
4011
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4012
|
+
market = _d[_c];
|
3965
4013
|
markets.push({
|
3966
4014
|
pubkey: market.marketAccount,
|
3967
4015
|
isSigner: false,
|
@@ -3970,21 +4018,21 @@ var PerpetualsClient = (function () {
|
|
3970
4018
|
}
|
3971
4019
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
3972
4020
|
case 2:
|
3973
|
-
if (!(
|
4021
|
+
if (!(_g.sent())) {
|
3974
4022
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
3975
4023
|
}
|
3976
4024
|
if (!(payTokenSymbol == 'SOL')) return [3, 5];
|
3977
4025
|
console.log("payTokenSymbol === SOL", payTokenSymbol);
|
3978
4026
|
lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
3979
4027
|
if (!!skipBalanceChecks) return [3, 4];
|
3980
|
-
|
4028
|
+
_e = anchor_1.BN.bind;
|
3981
4029
|
return [4, this.provider.connection.getBalance(publicKey)];
|
3982
4030
|
case 3:
|
3983
|
-
unWrappedSolBalance = new (
|
4031
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
3984
4032
|
if (unWrappedSolBalance.lt(lamports)) {
|
3985
4033
|
throw "Insufficient SOL Funds";
|
3986
4034
|
}
|
3987
|
-
|
4035
|
+
_g.label = 4;
|
3988
4036
|
case 4:
|
3989
4037
|
if (!ephemeralSignerPubkey) {
|
3990
4038
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -4008,17 +4056,17 @@ var PerpetualsClient = (function () {
|
|
4008
4056
|
if (!!skipBalanceChecks) return [3, 8];
|
4009
4057
|
return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
|
4010
4058
|
case 6:
|
4011
|
-
if (!(
|
4059
|
+
if (!(_g.sent())) {
|
4012
4060
|
throw "Insufficient Funds , token Account doesn't exist";
|
4013
4061
|
}
|
4014
|
-
|
4062
|
+
_f = anchor_1.BN.bind;
|
4015
4063
|
return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
|
4016
4064
|
case 7:
|
4017
|
-
tokenAccountBalance = new (
|
4065
|
+
tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4018
4066
|
if (tokenAccountBalance.lt(tokenAmountIn)) {
|
4019
4067
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
4020
4068
|
}
|
4021
|
-
|
4069
|
+
_g.label = 8;
|
4022
4070
|
case 8: return [4, this.program.methods
|
4023
4071
|
.addLiquidity({
|
4024
4072
|
amountIn: tokenAmountIn,
|
@@ -4043,11 +4091,11 @@ var PerpetualsClient = (function () {
|
|
4043
4091
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4044
4092
|
.instruction()];
|
4045
4093
|
case 9:
|
4046
|
-
instruction =
|
4094
|
+
instruction = _g.sent();
|
4047
4095
|
instructions.push(instruction);
|
4048
4096
|
return [3, 11];
|
4049
4097
|
case 10:
|
4050
|
-
err_6 =
|
4098
|
+
err_6 = _g.sent();
|
4051
4099
|
console.error("perpClient addLiquidity error:: ", err_6);
|
4052
4100
|
throw err_6;
|
4053
4101
|
case 11: return [2, {
|
@@ -4058,13 +4106,17 @@ var PerpetualsClient = (function () {
|
|
4058
4106
|
});
|
4059
4107
|
});
|
4060
4108
|
};
|
4061
|
-
this.addLiquidityAndStake = function (
|
4062
|
-
|
4063
|
-
|
4064
|
-
|
4065
|
-
|
4066
|
-
|
4067
|
-
|
4109
|
+
this.addLiquidityAndStake = function (inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1) {
|
4110
|
+
var args_1 = [];
|
4111
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4112
|
+
args_1[_i - 4] = arguments[_i];
|
4113
|
+
}
|
4114
|
+
return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
4115
|
+
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;
|
4116
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
4117
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4118
|
+
return __generator(this, function (_g) {
|
4119
|
+
switch (_g.label) {
|
4068
4120
|
case 0:
|
4069
4121
|
publicKey = this.provider.wallet.publicKey;
|
4070
4122
|
preInstructions = [];
|
@@ -4084,14 +4136,14 @@ var PerpetualsClient = (function () {
|
|
4084
4136
|
_a = anchor_1.BN.bind;
|
4085
4137
|
return [4, this.provider.connection.getBalance(publicKey)];
|
4086
4138
|
case 1:
|
4087
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
4139
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
4088
4140
|
if (unWrappedSolBalance.lt(lamports)) {
|
4089
4141
|
throw "Insufficient SOL Funds";
|
4090
4142
|
}
|
4091
|
-
|
4143
|
+
_g.label = 2;
|
4092
4144
|
case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
4093
4145
|
case 3:
|
4094
|
-
if (!(
|
4146
|
+
if (!(_g.sent())) {
|
4095
4147
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
4096
4148
|
}
|
4097
4149
|
if (!ephemeralSignerPubkey) {
|
@@ -4117,23 +4169,23 @@ var PerpetualsClient = (function () {
|
|
4117
4169
|
if (!!skipBalanceChecks) return [3, 7];
|
4118
4170
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
4119
4171
|
case 5:
|
4120
|
-
if (!(
|
4172
|
+
if (!(_g.sent())) {
|
4121
4173
|
throw "Insufficient Funds , token Account doesn't exist";
|
4122
4174
|
}
|
4123
4175
|
_b = anchor_1.BN.bind;
|
4124
4176
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
4125
4177
|
case 6:
|
4126
|
-
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (
|
4178
|
+
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
4127
4179
|
if (tokenAccountBalance.lt(amountIn)) {
|
4128
4180
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
4129
4181
|
}
|
4130
|
-
|
4182
|
+
_g.label = 7;
|
4131
4183
|
case 7:
|
4132
4184
|
custodyAccountMetas = [];
|
4133
4185
|
custodyOracleAccountMetas = [];
|
4134
4186
|
markets = [];
|
4135
|
-
for (
|
4136
|
-
custody = _c
|
4187
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
4188
|
+
custody = _d[_c];
|
4137
4189
|
custodyAccountMetas.push({
|
4138
4190
|
pubkey: custody.custodyAccount,
|
4139
4191
|
isSigner: false,
|
@@ -4145,8 +4197,8 @@ var PerpetualsClient = (function () {
|
|
4145
4197
|
isWritable: false,
|
4146
4198
|
});
|
4147
4199
|
}
|
4148
|
-
for (
|
4149
|
-
market = _e
|
4200
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
4201
|
+
market = _f[_e];
|
4150
4202
|
markets.push({
|
4151
4203
|
pubkey: market.marketAccount,
|
4152
4204
|
isSigner: false,
|
@@ -4178,7 +4230,7 @@ var PerpetualsClient = (function () {
|
|
4178
4230
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4179
4231
|
.instruction()];
|
4180
4232
|
case 8:
|
4181
|
-
instruction =
|
4233
|
+
instruction = _g.sent();
|
4182
4234
|
instructions.push(instruction);
|
4183
4235
|
return [2, {
|
4184
4236
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -4188,15 +4240,19 @@ var PerpetualsClient = (function () {
|
|
4188
4240
|
});
|
4189
4241
|
});
|
4190
4242
|
};
|
4191
|
-
this.removeLiquidity = function (
|
4192
|
-
|
4193
|
-
|
4194
|
-
|
4195
|
-
|
4196
|
-
return __awaiter(_this,
|
4197
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets,
|
4198
|
-
|
4199
|
-
|
4243
|
+
this.removeLiquidity = function (recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1) {
|
4244
|
+
var args_1 = [];
|
4245
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
4246
|
+
args_1[_i - 4] = arguments[_i];
|
4247
|
+
}
|
4248
|
+
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) {
|
4249
|
+
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;
|
4250
|
+
if (closeLpATA === void 0) { closeLpATA = false; }
|
4251
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
4252
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
4253
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4254
|
+
return __generator(this, function (_f) {
|
4255
|
+
switch (_f.label) {
|
4200
4256
|
case 0:
|
4201
4257
|
recieveTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey); });
|
4202
4258
|
if (!recieveTokenCustodyConfig) {
|
@@ -4207,15 +4263,15 @@ var PerpetualsClient = (function () {
|
|
4207
4263
|
instructions = [];
|
4208
4264
|
postInstructions = [];
|
4209
4265
|
additionalSigners = [];
|
4210
|
-
|
4266
|
+
_f.label = 1;
|
4211
4267
|
case 1:
|
4212
|
-
|
4268
|
+
_f.trys.push([1, 7, , 8]);
|
4213
4269
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
4214
4270
|
custodyAccountMetas = [];
|
4215
4271
|
custodyOracleAccountMetas = [];
|
4216
4272
|
markets = [];
|
4217
|
-
for (
|
4218
|
-
custody = _a
|
4273
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
4274
|
+
custody = _b[_a];
|
4219
4275
|
custodyAccountMetas.push({
|
4220
4276
|
pubkey: custody.custodyAccount,
|
4221
4277
|
isSigner: false,
|
@@ -4227,8 +4283,8 @@ var PerpetualsClient = (function () {
|
|
4227
4283
|
isWritable: false,
|
4228
4284
|
});
|
4229
4285
|
}
|
4230
|
-
for (
|
4231
|
-
market = _c
|
4286
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
4287
|
+
market = _d[_c];
|
4232
4288
|
markets.push({
|
4233
4289
|
pubkey: market.marketAccount,
|
4234
4290
|
isSigner: false,
|
@@ -4257,17 +4313,17 @@ var PerpetualsClient = (function () {
|
|
4257
4313
|
return [3, 5];
|
4258
4314
|
case 2:
|
4259
4315
|
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey, publicKey, true);
|
4260
|
-
|
4261
|
-
if (!
|
4316
|
+
_e = createUserATA;
|
4317
|
+
if (!_e) return [3, 4];
|
4262
4318
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
4263
4319
|
case 3:
|
4264
|
-
|
4265
|
-
|
4320
|
+
_e = !(_f.sent());
|
4321
|
+
_f.label = 4;
|
4266
4322
|
case 4:
|
4267
|
-
if (
|
4323
|
+
if (_e) {
|
4268
4324
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(recieveTokenSymbol).mintKey));
|
4269
4325
|
}
|
4270
|
-
|
4326
|
+
_f.label = 5;
|
4271
4327
|
case 5: return [4, this.program.methods
|
4272
4328
|
.removeLiquidity({
|
4273
4329
|
lpAmountIn: liquidityAmountIn,
|
@@ -4292,7 +4348,7 @@ var PerpetualsClient = (function () {
|
|
4292
4348
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4293
4349
|
.instruction()];
|
4294
4350
|
case 6:
|
4295
|
-
removeLiquidityTx =
|
4351
|
+
removeLiquidityTx = _f.sent();
|
4296
4352
|
instructions.push(removeLiquidityTx);
|
4297
4353
|
if (closeLpATA) {
|
4298
4354
|
closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
|
@@ -4304,7 +4360,7 @@ var PerpetualsClient = (function () {
|
|
4304
4360
|
}
|
4305
4361
|
return [3, 8];
|
4306
4362
|
case 7:
|
4307
|
-
err_7 =
|
4363
|
+
err_7 = _f.sent();
|
4308
4364
|
console.log("perpClient removeLiquidity error:: ", err_7);
|
4309
4365
|
throw err_7;
|
4310
4366
|
case 8: return [2, {
|
@@ -4667,8 +4723,63 @@ var PerpetualsClient = (function () {
|
|
4667
4723
|
}
|
4668
4724
|
});
|
4669
4725
|
}); };
|
4726
|
+
this.refreshStakeWithAllFlpStakeAccounts = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
4727
|
+
var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_15;
|
4728
|
+
return __generator(this, function (_c) {
|
4729
|
+
switch (_c.label) {
|
4730
|
+
case 0:
|
4731
|
+
_c.trys.push([0, 2, , 3]);
|
4732
|
+
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
4733
|
+
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
4734
|
+
pool = poolConfig.poolAddress;
|
4735
|
+
feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
|
4736
|
+
custodyAccountMetas = [];
|
4737
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
4738
|
+
custody = _a[_i];
|
4739
|
+
custodyAccountMetas.push({
|
4740
|
+
pubkey: custody.custodyAccount,
|
4741
|
+
isSigner: false,
|
4742
|
+
isWritable: false,
|
4743
|
+
});
|
4744
|
+
}
|
4745
|
+
maxFlpStakeAccountPkLength = 32 - 4 + custodyAccountMetas.length;
|
4746
|
+
if (flpStakeAccountPks.length > maxFlpStakeAccountPkLength) {
|
4747
|
+
throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
|
4748
|
+
}
|
4749
|
+
flpStakeAccountMetas = [];
|
4750
|
+
for (_b = 0, flpStakeAccountPks_1 = flpStakeAccountPks; _b < flpStakeAccountPks_1.length; _b++) {
|
4751
|
+
flpStakeAccountPk = flpStakeAccountPks_1[_b];
|
4752
|
+
flpStakeAccountMetas.push({
|
4753
|
+
pubkey: flpStakeAccountPk,
|
4754
|
+
isSigner: false,
|
4755
|
+
isWritable: true,
|
4756
|
+
});
|
4757
|
+
}
|
4758
|
+
return [4, this.program.methods
|
4759
|
+
.refreshStake({})
|
4760
|
+
.accounts({
|
4761
|
+
perpetuals: this.perpetuals.publicKey,
|
4762
|
+
pool: pool,
|
4763
|
+
rewardCustody: rewardCustodyConfig.custodyAccount,
|
4764
|
+
feeDistributionTokenAccount: feeDistributionTokenAccount,
|
4765
|
+
eventAuthority: this.eventAuthority.publicKey,
|
4766
|
+
program: this.program.programId,
|
4767
|
+
})
|
4768
|
+
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), flpStakeAccountMetas, true))
|
4769
|
+
.instruction()];
|
4770
|
+
case 1:
|
4771
|
+
refreshStakeInstruction = _c.sent();
|
4772
|
+
return [2, refreshStakeInstruction];
|
4773
|
+
case 2:
|
4774
|
+
err_15 = _c.sent();
|
4775
|
+
console.log("perpClient refreshStaking error:: ", err_15);
|
4776
|
+
throw err_15;
|
4777
|
+
case 3: return [2];
|
4778
|
+
}
|
4779
|
+
});
|
4780
|
+
}); };
|
4670
4781
|
this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk) { return __awaiter(_this, void 0, void 0, function () {
|
4671
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction,
|
4782
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
|
4672
4783
|
return __generator(this, function (_b) {
|
4673
4784
|
switch (_b.label) {
|
4674
4785
|
case 0:
|
@@ -4715,15 +4826,15 @@ var PerpetualsClient = (function () {
|
|
4715
4826
|
refreshStakeInstruction = _b.sent();
|
4716
4827
|
return [2, refreshStakeInstruction];
|
4717
4828
|
case 2:
|
4718
|
-
|
4719
|
-
console.log("perpClient refreshStaking error:: ",
|
4720
|
-
throw
|
4829
|
+
err_16 = _b.sent();
|
4830
|
+
console.log("perpClient refreshStaking error:: ", err_16);
|
4831
|
+
throw err_16;
|
4721
4832
|
case 3: return [2];
|
4722
4833
|
}
|
4723
4834
|
});
|
4724
4835
|
}); };
|
4725
4836
|
this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4726
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction,
|
4837
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
|
4727
4838
|
return __generator(this, function (_b) {
|
4728
4839
|
switch (_b.label) {
|
4729
4840
|
case 0:
|
@@ -4774,9 +4885,9 @@ var PerpetualsClient = (function () {
|
|
4774
4885
|
instructions.push(unstakeInstantInstruction);
|
4775
4886
|
return [3, 6];
|
4776
4887
|
case 5:
|
4777
|
-
|
4778
|
-
console.log("perpClient unstakeInstant error:: ",
|
4779
|
-
throw
|
4888
|
+
err_17 = _b.sent();
|
4889
|
+
console.log("perpClient unstakeInstant error:: ", err_17);
|
4890
|
+
throw err_17;
|
4780
4891
|
case 6: return [2, {
|
4781
4892
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4782
4893
|
additionalSigners: additionalSigners
|
@@ -4785,7 +4896,7 @@ var PerpetualsClient = (function () {
|
|
4785
4896
|
});
|
4786
4897
|
}); };
|
4787
4898
|
this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
4788
|
-
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b,
|
4899
|
+
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_18;
|
4789
4900
|
return __generator(this, function (_c) {
|
4790
4901
|
switch (_c.label) {
|
4791
4902
|
case 0:
|
@@ -4806,8 +4917,8 @@ var PerpetualsClient = (function () {
|
|
4806
4917
|
throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
|
4807
4918
|
}
|
4808
4919
|
flpStakeAccountMetas = [];
|
4809
|
-
for (_b = 0,
|
4810
|
-
flpStakeAccountPk =
|
4920
|
+
for (_b = 0, flpStakeAccountPks_2 = flpStakeAccountPks; _b < flpStakeAccountPks_2.length; _b++) {
|
4921
|
+
flpStakeAccountPk = flpStakeAccountPks_2[_b];
|
4811
4922
|
flpStakeAccountMetas.push({
|
4812
4923
|
pubkey: flpStakeAccountPk,
|
4813
4924
|
isSigner: false,
|
@@ -4829,15 +4940,15 @@ var PerpetualsClient = (function () {
|
|
4829
4940
|
refreshStakeInstruction = _c.sent();
|
4830
4941
|
return [2, refreshStakeInstruction];
|
4831
4942
|
case 2:
|
4832
|
-
|
4833
|
-
console.log("perpClient refreshStaking error:: ",
|
4834
|
-
throw
|
4943
|
+
err_18 = _c.sent();
|
4944
|
+
console.log("perpClient refreshStaking error:: ", err_18);
|
4945
|
+
throw err_18;
|
4835
4946
|
case 3: return [2];
|
4836
4947
|
}
|
4837
4948
|
});
|
4838
4949
|
}); };
|
4839
4950
|
this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4840
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction,
|
4951
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_19;
|
4841
4952
|
return __generator(this, function (_a) {
|
4842
4953
|
switch (_a.label) {
|
4843
4954
|
case 0:
|
@@ -4871,9 +4982,9 @@ var PerpetualsClient = (function () {
|
|
4871
4982
|
instructions.push(unstakeRequestInstruction);
|
4872
4983
|
return [3, 4];
|
4873
4984
|
case 3:
|
4874
|
-
|
4875
|
-
console.log("perpClient unstakeRequest error:: ",
|
4876
|
-
throw
|
4985
|
+
err_19 = _a.sent();
|
4986
|
+
console.log("perpClient unstakeRequest error:: ", err_19);
|
4987
|
+
throw err_19;
|
4877
4988
|
case 4: return [2, {
|
4878
4989
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4879
4990
|
additionalSigners: additionalSigners
|
@@ -4881,12 +4992,16 @@ var PerpetualsClient = (function () {
|
|
4881
4992
|
}
|
4882
4993
|
});
|
4883
4994
|
}); };
|
4884
|
-
this.withdrawStake = function (
|
4885
|
-
|
4886
|
-
|
4887
|
-
|
4888
|
-
|
4889
|
-
|
4995
|
+
this.withdrawStake = function (poolConfig_1) {
|
4996
|
+
var args_1 = [];
|
4997
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
4998
|
+
args_1[_i - 1] = arguments[_i];
|
4999
|
+
}
|
5000
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA) {
|
5001
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_20;
|
5002
|
+
if (pendingActivation === void 0) { pendingActivation = true; }
|
5003
|
+
if (deactivated === void 0) { deactivated = true; }
|
5004
|
+
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
4890
5005
|
return __generator(this, function (_b) {
|
4891
5006
|
switch (_b.label) {
|
4892
5007
|
case 0:
|
@@ -4937,9 +5052,9 @@ var PerpetualsClient = (function () {
|
|
4937
5052
|
instructions.push(withdrawStakeInstruction);
|
4938
5053
|
return [3, 6];
|
4939
5054
|
case 5:
|
4940
|
-
|
4941
|
-
console.log("perpClient withdrawStake error:: ",
|
4942
|
-
throw
|
5055
|
+
err_20 = _b.sent();
|
5056
|
+
console.log("perpClient withdrawStake error:: ", err_20);
|
5057
|
+
throw err_20;
|
4943
5058
|
case 6: return [2, {
|
4944
5059
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4945
5060
|
additionalSigners: additionalSigners
|
@@ -4948,10 +5063,14 @@ var PerpetualsClient = (function () {
|
|
4948
5063
|
});
|
4949
5064
|
});
|
4950
5065
|
};
|
4951
|
-
this.collectStakeFees = function (
|
4952
|
-
|
4953
|
-
|
4954
|
-
|
5066
|
+
this.collectStakeFees = function (rewardSymbol_1, poolConfig_1, tokenStakeAccount_1) {
|
5067
|
+
var args_1 = [];
|
5068
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5069
|
+
args_1[_i - 3] = arguments[_i];
|
5070
|
+
}
|
5071
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
|
5072
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
|
5073
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
4955
5074
|
return __generator(this, function (_b) {
|
4956
5075
|
switch (_b.label) {
|
4957
5076
|
case 0:
|
@@ -5010,9 +5129,9 @@ var PerpetualsClient = (function () {
|
|
5010
5129
|
instructions.push(withdrawStakeInstruction);
|
5011
5130
|
return [3, 6];
|
5012
5131
|
case 5:
|
5013
|
-
|
5014
|
-
console.log("perpClient withdrawStake error:: ",
|
5015
|
-
throw
|
5132
|
+
err_21 = _b.sent();
|
5133
|
+
console.log("perpClient withdrawStake error:: ", err_21);
|
5134
|
+
throw err_21;
|
5016
5135
|
case 6: return [2, {
|
5017
5136
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5018
5137
|
additionalSigners: additionalSigners
|
@@ -5022,7 +5141,7 @@ var PerpetualsClient = (function () {
|
|
5022
5141
|
});
|
5023
5142
|
};
|
5024
5143
|
this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5025
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction,
|
5144
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_22;
|
5026
5145
|
return __generator(this, function (_a) {
|
5027
5146
|
switch (_a.label) {
|
5028
5147
|
case 0:
|
@@ -5063,9 +5182,9 @@ var PerpetualsClient = (function () {
|
|
5063
5182
|
instructions.push(initTokenVaultInstruction);
|
5064
5183
|
return [3, 4];
|
5065
5184
|
case 3:
|
5066
|
-
|
5067
|
-
console.log("perpClient InitTokenVaultInstruction error:: ",
|
5068
|
-
throw
|
5185
|
+
err_22 = _a.sent();
|
5186
|
+
console.log("perpClient InitTokenVaultInstruction error:: ", err_22);
|
5187
|
+
throw err_22;
|
5069
5188
|
case 4: return [2, {
|
5070
5189
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5071
5190
|
additionalSigners: additionalSigners
|
@@ -5074,7 +5193,7 @@ var PerpetualsClient = (function () {
|
|
5074
5193
|
});
|
5075
5194
|
}); };
|
5076
5195
|
this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5077
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction,
|
5196
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_23;
|
5078
5197
|
return __generator(this, function (_a) {
|
5079
5198
|
switch (_a.label) {
|
5080
5199
|
case 0:
|
@@ -5104,9 +5223,9 @@ var PerpetualsClient = (function () {
|
|
5104
5223
|
instructions.push(setTokenVaultConfigInstruction);
|
5105
5224
|
return [3, 4];
|
5106
5225
|
case 3:
|
5107
|
-
|
5108
|
-
console.log("perpClient setTokenVaultConfigInstruction error:: ",
|
5109
|
-
throw
|
5226
|
+
err_23 = _a.sent();
|
5227
|
+
console.log("perpClient setTokenVaultConfigInstruction error:: ", err_23);
|
5228
|
+
throw err_23;
|
5110
5229
|
case 4: return [2, {
|
5111
5230
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5112
5231
|
additionalSigners: additionalSigners
|
@@ -5115,7 +5234,7 @@ var PerpetualsClient = (function () {
|
|
5115
5234
|
});
|
5116
5235
|
}); };
|
5117
5236
|
this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5118
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction,
|
5237
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_24;
|
5119
5238
|
return __generator(this, function (_a) {
|
5120
5239
|
switch (_a.label) {
|
5121
5240
|
case 0:
|
@@ -5153,9 +5272,9 @@ var PerpetualsClient = (function () {
|
|
5153
5272
|
instructions.push(withdrawInstantFeeInstruction);
|
5154
5273
|
return [3, 6];
|
5155
5274
|
case 5:
|
5156
|
-
|
5157
|
-
console.log("perpClient withdrawInstantFeeInstruction error:: ",
|
5158
|
-
throw
|
5275
|
+
err_24 = _a.sent();
|
5276
|
+
console.log("perpClient withdrawInstantFeeInstruction error:: ", err_24);
|
5277
|
+
throw err_24;
|
5159
5278
|
case 6: return [2, {
|
5160
5279
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5161
5280
|
additionalSigners: additionalSigners
|
@@ -5164,7 +5283,7 @@ var PerpetualsClient = (function () {
|
|
5164
5283
|
});
|
5165
5284
|
}); };
|
5166
5285
|
this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
|
5167
|
-
var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction,
|
5286
|
+
var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_25;
|
5168
5287
|
return __generator(this, function (_b) {
|
5169
5288
|
switch (_b.label) {
|
5170
5289
|
case 0:
|
@@ -5228,9 +5347,9 @@ var PerpetualsClient = (function () {
|
|
5228
5347
|
instructions.push(burnAndClaimInstruction);
|
5229
5348
|
return [3, 8];
|
5230
5349
|
case 7:
|
5231
|
-
|
5232
|
-
console.log("perpClient burnAndClaimInstruction error:: ",
|
5233
|
-
throw
|
5350
|
+
err_25 = _b.sent();
|
5351
|
+
console.log("perpClient burnAndClaimInstruction error:: ", err_25);
|
5352
|
+
throw err_25;
|
5234
5353
|
case 8: return [2, {
|
5235
5354
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5236
5355
|
additionalSigners: additionalSigners
|
@@ -5239,7 +5358,7 @@ var PerpetualsClient = (function () {
|
|
5239
5358
|
});
|
5240
5359
|
}); };
|
5241
5360
|
this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5242
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction,
|
5361
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_26;
|
5243
5362
|
return __generator(this, function (_a) {
|
5244
5363
|
switch (_a.label) {
|
5245
5364
|
case 0:
|
@@ -5290,9 +5409,9 @@ var PerpetualsClient = (function () {
|
|
5290
5409
|
instructions.push(burnAndStakeInstruction);
|
5291
5410
|
return [3, 4];
|
5292
5411
|
case 3:
|
5293
|
-
|
5294
|
-
console.log("perpClient burnAndStakeInstruction error:: ",
|
5295
|
-
throw
|
5412
|
+
err_26 = _a.sent();
|
5413
|
+
console.log("perpClient burnAndStakeInstruction error:: ", err_26);
|
5414
|
+
throw err_26;
|
5296
5415
|
case 4: return [2, {
|
5297
5416
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5298
5417
|
additionalSigners: additionalSigners
|
@@ -5301,7 +5420,7 @@ var PerpetualsClient = (function () {
|
|
5301
5420
|
});
|
5302
5421
|
}); };
|
5303
5422
|
this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5304
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction,
|
5423
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_27;
|
5305
5424
|
return __generator(this, function (_a) {
|
5306
5425
|
switch (_a.label) {
|
5307
5426
|
case 0:
|
@@ -5342,9 +5461,9 @@ var PerpetualsClient = (function () {
|
|
5342
5461
|
instructions.push(depositTokenStakeInstruction);
|
5343
5462
|
return [3, 5];
|
5344
5463
|
case 4:
|
5345
|
-
|
5346
|
-
console.log("perpClient depositStakingInstruction error:: ",
|
5347
|
-
throw
|
5464
|
+
err_27 = _a.sent();
|
5465
|
+
console.log("perpClient depositStakingInstruction error:: ", err_27);
|
5466
|
+
throw err_27;
|
5348
5467
|
case 5: return [2, {
|
5349
5468
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5350
5469
|
additionalSigners: additionalSigners
|
@@ -5353,7 +5472,7 @@ var PerpetualsClient = (function () {
|
|
5353
5472
|
});
|
5354
5473
|
}); };
|
5355
5474
|
this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5356
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction,
|
5475
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_28;
|
5357
5476
|
return __generator(this, function (_a) {
|
5358
5477
|
switch (_a.label) {
|
5359
5478
|
case 0:
|
@@ -5382,9 +5501,9 @@ var PerpetualsClient = (function () {
|
|
5382
5501
|
instructions.push(unstakeTokenRequestInstruction);
|
5383
5502
|
return [3, 4];
|
5384
5503
|
case 3:
|
5385
|
-
|
5386
|
-
console.log("perpClient unstakeTokenRequestInstruction error:: ",
|
5387
|
-
throw
|
5504
|
+
err_28 = _a.sent();
|
5505
|
+
console.log("perpClient unstakeTokenRequestInstruction error:: ", err_28);
|
5506
|
+
throw err_28;
|
5388
5507
|
case 4: return [2, {
|
5389
5508
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5390
5509
|
additionalSigners: additionalSigners
|
@@ -5393,7 +5512,7 @@ var PerpetualsClient = (function () {
|
|
5393
5512
|
});
|
5394
5513
|
}); };
|
5395
5514
|
this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5396
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction,
|
5515
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_29;
|
5397
5516
|
return __generator(this, function (_a) {
|
5398
5517
|
switch (_a.label) {
|
5399
5518
|
case 0:
|
@@ -5433,9 +5552,9 @@ var PerpetualsClient = (function () {
|
|
5433
5552
|
instructions.push(unstakeTokenInstantInstruction);
|
5434
5553
|
return [3, 5];
|
5435
5554
|
case 4:
|
5436
|
-
|
5437
|
-
console.log("perpClient unstakeTokenInstantInstruction error:: ",
|
5438
|
-
throw
|
5555
|
+
err_29 = _a.sent();
|
5556
|
+
console.log("perpClient unstakeTokenInstantInstruction error:: ", err_29);
|
5557
|
+
throw err_29;
|
5439
5558
|
case 5: return [2, {
|
5440
5559
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5441
5560
|
additionalSigners: additionalSigners
|
@@ -5444,7 +5563,7 @@ var PerpetualsClient = (function () {
|
|
5444
5563
|
});
|
5445
5564
|
}); };
|
5446
5565
|
this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5447
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction,
|
5566
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_30;
|
5448
5567
|
return __generator(this, function (_a) {
|
5449
5568
|
switch (_a.label) {
|
5450
5569
|
case 0:
|
@@ -5484,9 +5603,9 @@ var PerpetualsClient = (function () {
|
|
5484
5603
|
instructions.push(withdrawTokenInstruction);
|
5485
5604
|
return [3, 5];
|
5486
5605
|
case 4:
|
5487
|
-
|
5488
|
-
console.log("perpClient withdrawTokenInstruction error:: ",
|
5489
|
-
throw
|
5606
|
+
err_30 = _a.sent();
|
5607
|
+
console.log("perpClient withdrawTokenInstruction error:: ", err_30);
|
5608
|
+
throw err_30;
|
5490
5609
|
case 5: return [2, {
|
5491
5610
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5492
5611
|
additionalSigners: additionalSigners
|
@@ -5495,7 +5614,7 @@ var PerpetualsClient = (function () {
|
|
5495
5614
|
});
|
5496
5615
|
}); };
|
5497
5616
|
this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5498
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction,
|
5617
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_31;
|
5499
5618
|
return __generator(this, function (_a) {
|
5500
5619
|
switch (_a.label) {
|
5501
5620
|
case 0:
|
@@ -5524,9 +5643,9 @@ var PerpetualsClient = (function () {
|
|
5524
5643
|
instructions.push(cancelUnstakeRequestInstruction);
|
5525
5644
|
return [3, 4];
|
5526
5645
|
case 3:
|
5527
|
-
|
5528
|
-
console.log("perpClient cancelUnstakeRequestInstruction error:: ",
|
5529
|
-
throw
|
5646
|
+
err_31 = _a.sent();
|
5647
|
+
console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_31);
|
5648
|
+
throw err_31;
|
5530
5649
|
case 4: return [2, {
|
5531
5650
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5532
5651
|
additionalSigners: additionalSigners
|
@@ -5535,7 +5654,7 @@ var PerpetualsClient = (function () {
|
|
5535
5654
|
});
|
5536
5655
|
}); };
|
5537
5656
|
this.distributeTokenReward = function (amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5538
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction,
|
5657
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_32;
|
5539
5658
|
return __generator(this, function (_a) {
|
5540
5659
|
switch (_a.label) {
|
5541
5660
|
case 0:
|
@@ -5571,9 +5690,9 @@ var PerpetualsClient = (function () {
|
|
5571
5690
|
instructions.push(distributeTokenRewardInstruction);
|
5572
5691
|
return [3, 4];
|
5573
5692
|
case 3:
|
5574
|
-
|
5575
|
-
console.log("perpClient distributeTokenRewardInstruction error:: ",
|
5576
|
-
throw
|
5693
|
+
err_32 = _a.sent();
|
5694
|
+
console.log("perpClient distributeTokenRewardInstruction error:: ", err_32);
|
5695
|
+
throw err_32;
|
5577
5696
|
case 4: return [2, {
|
5578
5697
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5579
5698
|
additionalSigners: additionalSigners
|
@@ -5582,7 +5701,7 @@ var PerpetualsClient = (function () {
|
|
5582
5701
|
});
|
5583
5702
|
}); };
|
5584
5703
|
this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5585
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction,
|
5704
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_33;
|
5586
5705
|
return __generator(this, function (_a) {
|
5587
5706
|
switch (_a.label) {
|
5588
5707
|
case 0:
|
@@ -5614,9 +5733,9 @@ var PerpetualsClient = (function () {
|
|
5614
5733
|
instructions.push(setTokenRewardInstruction);
|
5615
5734
|
return [3, 4];
|
5616
5735
|
case 3:
|
5617
|
-
|
5618
|
-
console.log("perpClient setTokenRewardInstruction error:: ",
|
5619
|
-
throw
|
5736
|
+
err_33 = _a.sent();
|
5737
|
+
console.log("perpClient setTokenRewardInstruction error:: ", err_33);
|
5738
|
+
throw err_33;
|
5620
5739
|
case 4: return [2, {
|
5621
5740
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5622
5741
|
additionalSigners: additionalSigners
|
@@ -5624,10 +5743,14 @@ var PerpetualsClient = (function () {
|
|
5624
5743
|
}
|
5625
5744
|
});
|
5626
5745
|
}); };
|
5627
|
-
this.collectTokenReward = function (
|
5628
|
-
|
5629
|
-
|
5630
|
-
|
5746
|
+
this.collectTokenReward = function (owner_1, poolConfig_1) {
|
5747
|
+
var args_1 = [];
|
5748
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
5749
|
+
args_1[_i - 2] = arguments[_i];
|
5750
|
+
}
|
5751
|
+
return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
|
5752
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
|
5753
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5631
5754
|
return __generator(this, function (_b) {
|
5632
5755
|
switch (_b.label) {
|
5633
5756
|
case 0:
|
@@ -5671,9 +5794,9 @@ var PerpetualsClient = (function () {
|
|
5671
5794
|
instructions.push(collectTokenRewardInstruction);
|
5672
5795
|
return [3, 6];
|
5673
5796
|
case 5:
|
5674
|
-
|
5675
|
-
console.log("perpClient collectTokenRewardInstruction error:: ",
|
5676
|
-
throw
|
5797
|
+
err_34 = _b.sent();
|
5798
|
+
console.log("perpClient collectTokenRewardInstruction error:: ", err_34);
|
5799
|
+
throw err_34;
|
5677
5800
|
case 6: return [2, {
|
5678
5801
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5679
5802
|
additionalSigners: additionalSigners
|
@@ -5683,7 +5806,7 @@ var PerpetualsClient = (function () {
|
|
5683
5806
|
});
|
5684
5807
|
};
|
5685
5808
|
this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
|
5686
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction,
|
5809
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_35;
|
5687
5810
|
return __generator(this, function (_a) {
|
5688
5811
|
switch (_a.label) {
|
5689
5812
|
case 0:
|
@@ -5711,9 +5834,9 @@ var PerpetualsClient = (function () {
|
|
5711
5834
|
instructions.push(setTokenStakeLevelInstruction);
|
5712
5835
|
return [3, 4];
|
5713
5836
|
case 3:
|
5714
|
-
|
5715
|
-
console.log("perpClient setTokenStakeLevelInstruction error:: ",
|
5716
|
-
throw
|
5837
|
+
err_35 = _a.sent();
|
5838
|
+
console.log("perpClient setTokenStakeLevelInstruction error:: ", err_35);
|
5839
|
+
throw err_35;
|
5717
5840
|
case 4: return [2, {
|
5718
5841
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5719
5842
|
additionalSigners: additionalSigners
|
@@ -5722,7 +5845,7 @@ var PerpetualsClient = (function () {
|
|
5722
5845
|
});
|
5723
5846
|
}); };
|
5724
5847
|
this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5725
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault,
|
5848
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_36;
|
5726
5849
|
return __generator(this, function (_a) {
|
5727
5850
|
switch (_a.label) {
|
5728
5851
|
case 0:
|
@@ -5759,9 +5882,9 @@ var PerpetualsClient = (function () {
|
|
5759
5882
|
instructions.push(initRewardVault);
|
5760
5883
|
return [3, 4];
|
5761
5884
|
case 3:
|
5762
|
-
|
5763
|
-
console.log("perpClient InitRewardVault error:: ",
|
5764
|
-
throw
|
5885
|
+
err_36 = _a.sent();
|
5886
|
+
console.log("perpClient InitRewardVault error:: ", err_36);
|
5887
|
+
throw err_36;
|
5765
5888
|
case 4: return [2, {
|
5766
5889
|
instructions: __spreadArray([], instructions, true),
|
5767
5890
|
additionalSigners: additionalSigners
|
@@ -5770,7 +5893,7 @@ var PerpetualsClient = (function () {
|
|
5770
5893
|
});
|
5771
5894
|
}); };
|
5772
5895
|
this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5773
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward,
|
5896
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_37;
|
5774
5897
|
return __generator(this, function (_a) {
|
5775
5898
|
switch (_a.label) {
|
5776
5899
|
case 0:
|
@@ -5801,9 +5924,9 @@ var PerpetualsClient = (function () {
|
|
5801
5924
|
instructions.push(distributeReward);
|
5802
5925
|
return [3, 4];
|
5803
5926
|
case 3:
|
5804
|
-
|
5805
|
-
console.log("perpClient distributeReward error:: ",
|
5806
|
-
throw
|
5927
|
+
err_37 = _a.sent();
|
5928
|
+
console.log("perpClient distributeReward error:: ", err_37);
|
5929
|
+
throw err_37;
|
5807
5930
|
case 4: return [2, {
|
5808
5931
|
instructions: __spreadArray([], instructions, true),
|
5809
5932
|
additionalSigners: additionalSigners
|
@@ -5811,10 +5934,14 @@ var PerpetualsClient = (function () {
|
|
5811
5934
|
}
|
5812
5935
|
});
|
5813
5936
|
}); };
|
5814
|
-
this.collectNftReward = function (
|
5815
|
-
|
5816
|
-
|
5817
|
-
|
5937
|
+
this.collectNftReward = function (rewardSymbol_1, poolConfig_1, nftMint_1) {
|
5938
|
+
var args_1 = [];
|
5939
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
5940
|
+
args_1[_i - 3] = arguments[_i];
|
5941
|
+
}
|
5942
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
5943
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_38;
|
5944
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5818
5945
|
return __generator(this, function (_b) {
|
5819
5946
|
switch (_b.label) {
|
5820
5947
|
case 0:
|
@@ -5864,8 +5991,8 @@ var PerpetualsClient = (function () {
|
|
5864
5991
|
instructions.push(collectNftReward);
|
5865
5992
|
return [3, 6];
|
5866
5993
|
case 5:
|
5867
|
-
|
5868
|
-
throw
|
5994
|
+
err_38 = _b.sent();
|
5995
|
+
throw err_38;
|
5869
5996
|
case 6: return [2, {
|
5870
5997
|
instructions: __spreadArray([], instructions, true),
|
5871
5998
|
additionalSigners: additionalSigners
|
@@ -5874,10 +6001,14 @@ var PerpetualsClient = (function () {
|
|
5874
6001
|
});
|
5875
6002
|
});
|
5876
6003
|
};
|
5877
|
-
this.collectAndDistributeFee = function (
|
5878
|
-
|
5879
|
-
|
5880
|
-
|
6004
|
+
this.collectAndDistributeFee = function (rewardSymbol_1, poolConfig_1) {
|
6005
|
+
var args_1 = [];
|
6006
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
6007
|
+
args_1[_i - 2] = arguments[_i];
|
6008
|
+
}
|
6009
|
+
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
6010
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_39;
|
6011
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5881
6012
|
return __generator(this, function (_b) {
|
5882
6013
|
switch (_b.label) {
|
5883
6014
|
case 0:
|
@@ -5941,9 +6072,9 @@ var PerpetualsClient = (function () {
|
|
5941
6072
|
instructions.push(withdrawStakeInstruction);
|
5942
6073
|
return [3, 6];
|
5943
6074
|
case 5:
|
5944
|
-
|
5945
|
-
console.log("perpClient withdrawStake error:: ",
|
5946
|
-
throw
|
6075
|
+
err_39 = _b.sent();
|
6076
|
+
console.log("perpClient withdrawStake error:: ", err_39);
|
6077
|
+
throw err_39;
|
5947
6078
|
case 6: return [2, {
|
5948
6079
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5949
6080
|
additionalSigners: additionalSigners
|
@@ -5953,7 +6084,7 @@ var PerpetualsClient = (function () {
|
|
5953
6084
|
});
|
5954
6085
|
};
|
5955
6086
|
this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5956
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice,
|
6087
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_40;
|
5957
6088
|
return __generator(this, function (_a) {
|
5958
6089
|
switch (_a.label) {
|
5959
6090
|
case 0:
|
@@ -5992,9 +6123,9 @@ var PerpetualsClient = (function () {
|
|
5992
6123
|
instructions.push(setTriggerPrice);
|
5993
6124
|
return [3, 4];
|
5994
6125
|
case 3:
|
5995
|
-
|
5996
|
-
console.log("perpClient setTriggerPrice error:: ",
|
5997
|
-
throw
|
6126
|
+
err_40 = _a.sent();
|
6127
|
+
console.log("perpClient setTriggerPrice error:: ", err_40);
|
6128
|
+
throw err_40;
|
5998
6129
|
case 4: return [2, {
|
5999
6130
|
instructions: __spreadArray([], instructions, true),
|
6000
6131
|
additionalSigners: additionalSigners
|
@@ -6002,12 +6133,16 @@ var PerpetualsClient = (function () {
|
|
6002
6133
|
}
|
6003
6134
|
});
|
6004
6135
|
}); };
|
6005
|
-
this.forceClosePosition = function (
|
6006
|
-
|
6007
|
-
|
6008
|
-
|
6009
|
-
|
6010
|
-
|
6136
|
+
this.forceClosePosition = function (positionAccount_1, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
|
6137
|
+
var args_1 = [];
|
6138
|
+
for (var _i = 6; _i < arguments.length; _i++) {
|
6139
|
+
args_1[_i - 6] = arguments[_i];
|
6140
|
+
}
|
6141
|
+
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) {
|
6142
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_41;
|
6143
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6144
|
+
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
6145
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6011
6146
|
return __generator(this, function (_b) {
|
6012
6147
|
switch (_b.label) {
|
6013
6148
|
case 0:
|
@@ -6068,9 +6203,9 @@ var PerpetualsClient = (function () {
|
|
6068
6203
|
}
|
6069
6204
|
return [3, 7];
|
6070
6205
|
case 6:
|
6071
|
-
|
6072
|
-
console.log("perpClient forceClosePosition error:: ",
|
6073
|
-
throw
|
6206
|
+
err_41 = _b.sent();
|
6207
|
+
console.log("perpClient forceClosePosition error:: ", err_41);
|
6208
|
+
throw err_41;
|
6074
6209
|
case 7: return [2, {
|
6075
6210
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6076
6211
|
additionalSigners: additionalSigners
|
@@ -6079,11 +6214,15 @@ var PerpetualsClient = (function () {
|
|
6079
6214
|
});
|
6080
6215
|
});
|
6081
6216
|
};
|
6082
|
-
this.placeLimitOrder = function (
|
6083
|
-
|
6084
|
-
|
6085
|
-
|
6086
|
-
|
6217
|
+
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) {
|
6218
|
+
var args_1 = [];
|
6219
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6220
|
+
args_1[_i - 11] = arguments[_i];
|
6221
|
+
}
|
6222
|
+
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) {
|
6223
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_42;
|
6224
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6225
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6087
6226
|
return __generator(this, function (_c) {
|
6088
6227
|
switch (_c.label) {
|
6089
6228
|
case 0:
|
@@ -6188,9 +6327,9 @@ var PerpetualsClient = (function () {
|
|
6188
6327
|
instructions.push(placeLimitOrder);
|
6189
6328
|
return [3, 11];
|
6190
6329
|
case 10:
|
6191
|
-
|
6192
|
-
console.log("perpClient placeLimitOrder error:: ",
|
6193
|
-
throw
|
6330
|
+
err_42 = _c.sent();
|
6331
|
+
console.log("perpClient placeLimitOrder error:: ", err_42);
|
6332
|
+
throw err_42;
|
6194
6333
|
case 11: return [2, {
|
6195
6334
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6196
6335
|
additionalSigners: additionalSigners
|
@@ -6199,11 +6338,15 @@ var PerpetualsClient = (function () {
|
|
6199
6338
|
});
|
6200
6339
|
});
|
6201
6340
|
};
|
6202
|
-
this.editLimitOrder = function (
|
6203
|
-
|
6204
|
-
|
6205
|
-
|
6206
|
-
|
6341
|
+
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) {
|
6342
|
+
var args_1 = [];
|
6343
|
+
for (var _i = 11; _i < arguments.length; _i++) {
|
6344
|
+
args_1[_i - 11] = arguments[_i];
|
6345
|
+
}
|
6346
|
+
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) {
|
6347
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_43;
|
6348
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6349
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6207
6350
|
return __generator(this, function (_b) {
|
6208
6351
|
switch (_b.label) {
|
6209
6352
|
case 0:
|
@@ -6291,9 +6434,9 @@ var PerpetualsClient = (function () {
|
|
6291
6434
|
instructions.push(editLimitOrder);
|
6292
6435
|
return [3, 8];
|
6293
6436
|
case 7:
|
6294
|
-
|
6295
|
-
console.log("perpClient editLimitOrder error:: ",
|
6296
|
-
throw
|
6437
|
+
err_43 = _b.sent();
|
6438
|
+
console.log("perpClient editLimitOrder error:: ", err_43);
|
6439
|
+
throw err_43;
|
6297
6440
|
case 8: return [2, {
|
6298
6441
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6299
6442
|
additionalSigners: additionalSigners
|
@@ -6302,12 +6445,16 @@ var PerpetualsClient = (function () {
|
|
6302
6445
|
});
|
6303
6446
|
});
|
6304
6447
|
};
|
6305
|
-
this.executeLimitOrder = function (
|
6306
|
-
|
6307
|
-
|
6308
|
-
|
6309
|
-
|
6310
|
-
|
6448
|
+
this.executeLimitOrder = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6449
|
+
var args_1 = [];
|
6450
|
+
for (var _i = 7; _i < arguments.length; _i++) {
|
6451
|
+
args_1[_i - 7] = arguments[_i];
|
6452
|
+
}
|
6453
|
+
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) {
|
6454
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_44;
|
6455
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6456
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6457
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6311
6458
|
return __generator(this, function (_a) {
|
6312
6459
|
switch (_a.label) {
|
6313
6460
|
case 0:
|
@@ -6356,9 +6503,9 @@ var PerpetualsClient = (function () {
|
|
6356
6503
|
instructions.push(executeLimitOrder);
|
6357
6504
|
return [3, 4];
|
6358
6505
|
case 3:
|
6359
|
-
|
6360
|
-
console.log("perpClient executeLimitOrder error:: ",
|
6361
|
-
throw
|
6506
|
+
err_44 = _a.sent();
|
6507
|
+
console.log("perpClient executeLimitOrder error:: ", err_44);
|
6508
|
+
throw err_44;
|
6362
6509
|
case 4: return [2, {
|
6363
6510
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6364
6511
|
additionalSigners: additionalSigners
|
@@ -6367,12 +6514,16 @@ var PerpetualsClient = (function () {
|
|
6367
6514
|
});
|
6368
6515
|
});
|
6369
6516
|
};
|
6370
|
-
this.executeLimitWithSwap = function (
|
6371
|
-
|
6372
|
-
|
6373
|
-
|
6374
|
-
|
6375
|
-
|
6517
|
+
this.executeLimitWithSwap = function (userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1) {
|
6518
|
+
var args_1 = [];
|
6519
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
6520
|
+
args_1[_i - 8] = arguments[_i];
|
6521
|
+
}
|
6522
|
+
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) {
|
6523
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_45;
|
6524
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6525
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6526
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6376
6527
|
return __generator(this, function (_a) {
|
6377
6528
|
switch (_a.label) {
|
6378
6529
|
case 0:
|
@@ -6424,9 +6575,9 @@ var PerpetualsClient = (function () {
|
|
6424
6575
|
instructions.push(executeLimitWithSwap);
|
6425
6576
|
return [3, 4];
|
6426
6577
|
case 3:
|
6427
|
-
|
6428
|
-
console.log("perpClient executeLimitWithSwap error:: ",
|
6429
|
-
throw
|
6578
|
+
err_45 = _a.sent();
|
6579
|
+
console.log("perpClient executeLimitWithSwap error:: ", err_45);
|
6580
|
+
throw err_45;
|
6430
6581
|
case 4: return [2, {
|
6431
6582
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6432
6583
|
additionalSigners: additionalSigners
|
@@ -6436,7 +6587,7 @@ var PerpetualsClient = (function () {
|
|
6436
6587
|
});
|
6437
6588
|
};
|
6438
6589
|
this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6439
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder,
|
6590
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_46;
|
6440
6591
|
return __generator(this, function (_a) {
|
6441
6592
|
switch (_a.label) {
|
6442
6593
|
case 0:
|
@@ -6484,9 +6635,9 @@ var PerpetualsClient = (function () {
|
|
6484
6635
|
instructions.push(placeTriggerOrder);
|
6485
6636
|
return [3, 4];
|
6486
6637
|
case 3:
|
6487
|
-
|
6488
|
-
console.log("perpClient placeTriggerOrder error:: ",
|
6489
|
-
throw
|
6638
|
+
err_46 = _a.sent();
|
6639
|
+
console.log("perpClient placeTriggerOrder error:: ", err_46);
|
6640
|
+
throw err_46;
|
6490
6641
|
case 4: return [2, {
|
6491
6642
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6492
6643
|
additionalSigners: additionalSigners
|
@@ -6495,7 +6646,7 @@ var PerpetualsClient = (function () {
|
|
6495
6646
|
});
|
6496
6647
|
}); };
|
6497
6648
|
this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6498
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder,
|
6649
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_47;
|
6499
6650
|
return __generator(this, function (_a) {
|
6500
6651
|
switch (_a.label) {
|
6501
6652
|
case 0:
|
@@ -6542,9 +6693,9 @@ var PerpetualsClient = (function () {
|
|
6542
6693
|
instructions.push(editTriggerOrder);
|
6543
6694
|
return [3, 4];
|
6544
6695
|
case 3:
|
6545
|
-
|
6546
|
-
console.log("perpClient editTriggerOrder error:: ",
|
6547
|
-
throw
|
6696
|
+
err_47 = _a.sent();
|
6697
|
+
console.log("perpClient editTriggerOrder error:: ", err_47);
|
6698
|
+
throw err_47;
|
6548
6699
|
case 4: return [2, {
|
6549
6700
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6550
6701
|
additionalSigners: additionalSigners
|
@@ -6553,7 +6704,7 @@ var PerpetualsClient = (function () {
|
|
6553
6704
|
});
|
6554
6705
|
}); };
|
6555
6706
|
this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6556
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder,
|
6707
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_48;
|
6557
6708
|
return __generator(this, function (_a) {
|
6558
6709
|
switch (_a.label) {
|
6559
6710
|
case 0:
|
@@ -6586,9 +6737,9 @@ var PerpetualsClient = (function () {
|
|
6586
6737
|
instructions.push(cancelTriggerOrder);
|
6587
6738
|
return [3, 4];
|
6588
6739
|
case 3:
|
6589
|
-
|
6590
|
-
console.log("perpClient cancelTriggerOrder error:: ",
|
6591
|
-
throw
|
6740
|
+
err_48 = _a.sent();
|
6741
|
+
console.log("perpClient cancelTriggerOrder error:: ", err_48);
|
6742
|
+
throw err_48;
|
6592
6743
|
case 4: return [2, {
|
6593
6744
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6594
6745
|
additionalSigners: additionalSigners
|
@@ -6597,7 +6748,7 @@ var PerpetualsClient = (function () {
|
|
6597
6748
|
});
|
6598
6749
|
}); };
|
6599
6750
|
this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6600
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders,
|
6751
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_49;
|
6601
6752
|
return __generator(this, function (_a) {
|
6602
6753
|
switch (_a.label) {
|
6603
6754
|
case 0:
|
@@ -6628,9 +6779,9 @@ var PerpetualsClient = (function () {
|
|
6628
6779
|
instructions.push(cancelAllTriggerOrders);
|
6629
6780
|
return [3, 4];
|
6630
6781
|
case 3:
|
6631
|
-
|
6632
|
-
console.log("perpClient cancelAllTriggerOrders error:: ",
|
6633
|
-
throw
|
6782
|
+
err_49 = _a.sent();
|
6783
|
+
console.log("perpClient cancelAllTriggerOrders error:: ", err_49);
|
6784
|
+
throw err_49;
|
6634
6785
|
case 4: return [2, {
|
6635
6786
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6636
6787
|
additionalSigners: additionalSigners
|
@@ -6638,16 +6789,20 @@ var PerpetualsClient = (function () {
|
|
6638
6789
|
}
|
6639
6790
|
});
|
6640
6791
|
}); };
|
6641
|
-
this.executeTriggerWithSwap = function (
|
6642
|
-
|
6643
|
-
|
6644
|
-
|
6645
|
-
|
6646
|
-
|
6647
|
-
|
6648
|
-
|
6649
|
-
|
6650
|
-
|
6792
|
+
this.executeTriggerWithSwap = function (owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
6793
|
+
var args_1 = [];
|
6794
|
+
for (var _i = 9; _i < arguments.length; _i++) {
|
6795
|
+
args_1[_i - 9] = arguments[_i];
|
6796
|
+
}
|
6797
|
+
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) {
|
6798
|
+
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;
|
6799
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6800
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6801
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6802
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6803
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6804
|
+
return __generator(this, function (_e) {
|
6805
|
+
switch (_e.label) {
|
6651
6806
|
case 0:
|
6652
6807
|
payerPubkey = this.provider.wallet.publicKey;
|
6653
6808
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
@@ -6658,9 +6813,9 @@ var PerpetualsClient = (function () {
|
|
6658
6813
|
instructions = [];
|
6659
6814
|
postInstructions = [];
|
6660
6815
|
additionalSigners = [];
|
6661
|
-
|
6816
|
+
_e.label = 1;
|
6662
6817
|
case 1:
|
6663
|
-
|
6818
|
+
_e.trys.push([1, 9, , 10]);
|
6664
6819
|
if (!false) return [3, 2];
|
6665
6820
|
return [3, 7];
|
6666
6821
|
case 2:
|
@@ -6669,8 +6824,8 @@ var PerpetualsClient = (function () {
|
|
6669
6824
|
if (!_a) return [3, 4];
|
6670
6825
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
6671
6826
|
case 3:
|
6672
|
-
_a = !(
|
6673
|
-
|
6827
|
+
_a = !(_e.sent());
|
6828
|
+
_e.label = 4;
|
6674
6829
|
case 4:
|
6675
6830
|
if (_a) {
|
6676
6831
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
@@ -6680,20 +6835,20 @@ var PerpetualsClient = (function () {
|
|
6680
6835
|
if (!_b) return [3, 6];
|
6681
6836
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
6682
6837
|
case 5:
|
6683
|
-
_b = !(
|
6684
|
-
|
6838
|
+
_b = !(_e.sent());
|
6839
|
+
_e.label = 6;
|
6685
6840
|
case 6:
|
6686
6841
|
if (_b) {
|
6687
6842
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
6688
6843
|
}
|
6689
|
-
|
6844
|
+
_e.label = 7;
|
6690
6845
|
case 7:
|
6691
6846
|
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
6692
6847
|
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
6693
6848
|
custodyAccountMetas = [];
|
6694
6849
|
custodyOracleAccountMetas = [];
|
6695
|
-
for (
|
6696
|
-
custody = _c
|
6850
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
6851
|
+
custody = _d[_c];
|
6697
6852
|
custodyAccountMetas.push({
|
6698
6853
|
pubkey: custody.custodyAccount,
|
6699
6854
|
isSigner: false,
|
@@ -6738,13 +6893,13 @@ var PerpetualsClient = (function () {
|
|
6738
6893
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6739
6894
|
.instruction()];
|
6740
6895
|
case 8:
|
6741
|
-
executeTriggerWithSwap =
|
6896
|
+
executeTriggerWithSwap = _e.sent();
|
6742
6897
|
instructions.push(executeTriggerWithSwap);
|
6743
6898
|
return [3, 10];
|
6744
6899
|
case 9:
|
6745
|
-
|
6746
|
-
console.log("perpClient executeTriggerWithSwap error:: ",
|
6747
|
-
throw
|
6900
|
+
err_50 = _e.sent();
|
6901
|
+
console.log("perpClient executeTriggerWithSwap error:: ", err_50);
|
6902
|
+
throw err_50;
|
6748
6903
|
case 10: return [2, {
|
6749
6904
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6750
6905
|
additionalSigners: additionalSigners
|
@@ -6753,14 +6908,18 @@ var PerpetualsClient = (function () {
|
|
6753
6908
|
});
|
6754
6909
|
});
|
6755
6910
|
};
|
6756
|
-
this.executeTriggerOrder = function (
|
6757
|
-
|
6758
|
-
|
6759
|
-
|
6760
|
-
|
6761
|
-
|
6762
|
-
|
6763
|
-
|
6911
|
+
this.executeTriggerOrder = function (owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1) {
|
6912
|
+
var args_1 = [];
|
6913
|
+
for (var _i = 8; _i < arguments.length; _i++) {
|
6914
|
+
args_1[_i - 8] = arguments[_i];
|
6915
|
+
}
|
6916
|
+
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) {
|
6917
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_51;
|
6918
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6919
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6920
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6921
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6922
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6764
6923
|
return __generator(this, function (_b) {
|
6765
6924
|
switch (_b.label) {
|
6766
6925
|
case 0:
|
@@ -6826,9 +6985,9 @@ var PerpetualsClient = (function () {
|
|
6826
6985
|
instructions.push(executeTriggerOrder);
|
6827
6986
|
return [3, 8];
|
6828
6987
|
case 7:
|
6829
|
-
|
6830
|
-
console.log("perpClient executeTriggerOrder error:: ",
|
6831
|
-
throw
|
6988
|
+
err_51 = _b.sent();
|
6989
|
+
console.log("perpClient executeTriggerOrder error:: ", err_51);
|
6990
|
+
throw err_51;
|
6832
6991
|
case 8: return [2, {
|
6833
6992
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6834
6993
|
additionalSigners: additionalSigners
|
@@ -6838,7 +6997,7 @@ var PerpetualsClient = (function () {
|
|
6838
6997
|
});
|
6839
6998
|
};
|
6840
6999
|
this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6841
|
-
var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder,
|
7000
|
+
var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_52;
|
6842
7001
|
return __generator(this, function (_a) {
|
6843
7002
|
switch (_a.label) {
|
6844
7003
|
case 0:
|
@@ -6868,9 +7027,9 @@ var PerpetualsClient = (function () {
|
|
6868
7027
|
instructions.push(migrateTriggerOrder);
|
6869
7028
|
return [3, 4];
|
6870
7029
|
case 3:
|
6871
|
-
|
6872
|
-
console.log("perpClient migrateTriggerOrder error:: ",
|
6873
|
-
throw
|
7030
|
+
err_52 = _a.sent();
|
7031
|
+
console.log("perpClient migrateTriggerOrder error:: ", err_52);
|
7032
|
+
throw err_52;
|
6874
7033
|
case 4: return [2, {
|
6875
7034
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6876
7035
|
additionalSigners: additionalSigners
|
@@ -6879,7 +7038,7 @@ var PerpetualsClient = (function () {
|
|
6879
7038
|
});
|
6880
7039
|
}); };
|
6881
7040
|
this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6882
|
-
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData,
|
7041
|
+
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_53;
|
6883
7042
|
return __generator(this, function (_a) {
|
6884
7043
|
switch (_a.label) {
|
6885
7044
|
case 0:
|
@@ -6908,15 +7067,15 @@ var PerpetualsClient = (function () {
|
|
6908
7067
|
console.log(getPositionData);
|
6909
7068
|
return [2, getPositionData];
|
6910
7069
|
case 3:
|
6911
|
-
|
6912
|
-
console.log("perpClient setPool error:: ",
|
6913
|
-
throw
|
7070
|
+
err_53 = _a.sent();
|
7071
|
+
console.log("perpClient setPool error:: ", err_53);
|
7072
|
+
throw err_53;
|
6914
7073
|
case 4: return [2];
|
6915
7074
|
}
|
6916
7075
|
});
|
6917
7076
|
}); };
|
6918
7077
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6919
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
7078
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_54;
|
6920
7079
|
return __generator(this, function (_a) {
|
6921
7080
|
switch (_a.label) {
|
6922
7081
|
case 0:
|
@@ -6949,9 +7108,9 @@ var PerpetualsClient = (function () {
|
|
6949
7108
|
instructions.push(withdrawFeesIx);
|
6950
7109
|
return [3, 5];
|
6951
7110
|
case 4:
|
6952
|
-
|
6953
|
-
console.log("perpClient setPool error:: ",
|
6954
|
-
throw
|
7111
|
+
err_54 = _a.sent();
|
7112
|
+
console.log("perpClient setPool error:: ", err_54);
|
7113
|
+
throw err_54;
|
6955
7114
|
case 5: return [2, {
|
6956
7115
|
instructions: __spreadArray([], instructions, true),
|
6957
7116
|
additionalSigners: additionalSigners
|
@@ -6960,7 +7119,7 @@ var PerpetualsClient = (function () {
|
|
6960
7119
|
});
|
6961
7120
|
}); };
|
6962
7121
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
6963
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
7122
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_55;
|
6964
7123
|
return __generator(this, function (_a) {
|
6965
7124
|
switch (_a.label) {
|
6966
7125
|
case 0:
|
@@ -6987,9 +7146,9 @@ var PerpetualsClient = (function () {
|
|
6987
7146
|
instructions.push(setPermissionsInstruction);
|
6988
7147
|
return [3, 4];
|
6989
7148
|
case 3:
|
6990
|
-
|
6991
|
-
console.log("perpClient setPool error:: ",
|
6992
|
-
throw
|
7149
|
+
err_55 = _a.sent();
|
7150
|
+
console.log("perpClient setPool error:: ", err_55);
|
7151
|
+
throw err_55;
|
6993
7152
|
case 4: return [2, {
|
6994
7153
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6995
7154
|
additionalSigners: additionalSigners
|
@@ -6998,7 +7157,7 @@ var PerpetualsClient = (function () {
|
|
6998
7157
|
});
|
6999
7158
|
}); };
|
7000
7159
|
this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7001
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e,
|
7160
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_56;
|
7002
7161
|
var _f;
|
7003
7162
|
return __generator(this, function (_g) {
|
7004
7163
|
switch (_g.label) {
|
@@ -7058,9 +7217,9 @@ var PerpetualsClient = (function () {
|
|
7058
7217
|
instructions.push(reimburse);
|
7059
7218
|
return [3, 5];
|
7060
7219
|
case 4:
|
7061
|
-
|
7062
|
-
console.log("perpClient setPool error:: ",
|
7063
|
-
throw
|
7220
|
+
err_56 = _g.sent();
|
7221
|
+
console.log("perpClient setPool error:: ", err_56);
|
7222
|
+
throw err_56;
|
7064
7223
|
case 5: return [2, {
|
7065
7224
|
instructions: __spreadArray([], instructions, true),
|
7066
7225
|
additionalSigners: additionalSigners
|
@@ -7069,7 +7228,7 @@ var PerpetualsClient = (function () {
|
|
7069
7228
|
});
|
7070
7229
|
}); };
|
7071
7230
|
this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7072
|
-
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice,
|
7231
|
+
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_57;
|
7073
7232
|
return __generator(this, function (_a) {
|
7074
7233
|
switch (_a.label) {
|
7075
7234
|
case 0:
|
@@ -7102,9 +7261,9 @@ var PerpetualsClient = (function () {
|
|
7102
7261
|
instructions.push(setInternalOraclePrice);
|
7103
7262
|
return [3, 4];
|
7104
7263
|
case 3:
|
7105
|
-
|
7106
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
7107
|
-
throw
|
7264
|
+
err_57 = _a.sent();
|
7265
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_57);
|
7266
|
+
throw err_57;
|
7108
7267
|
case 4: return [2, {
|
7109
7268
|
instructions: __spreadArray([], instructions, true),
|
7110
7269
|
additionalSigners: additionalSigners
|
@@ -7112,13 +7271,17 @@ var PerpetualsClient = (function () {
|
|
7112
7271
|
}
|
7113
7272
|
});
|
7114
7273
|
}); };
|
7115
|
-
this.addCompoundingLiquidity = function (
|
7116
|
-
|
7117
|
-
|
7118
|
-
|
7119
|
-
|
7120
|
-
|
7121
|
-
|
7274
|
+
this.addCompoundingLiquidity = function (amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7275
|
+
var args_1 = [];
|
7276
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7277
|
+
args_1[_i - 5] = arguments[_i];
|
7278
|
+
}
|
7279
|
+
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) {
|
7280
|
+
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;
|
7281
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
7282
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7283
|
+
return __generator(this, function (_f) {
|
7284
|
+
switch (_f.label) {
|
7122
7285
|
case 0:
|
7123
7286
|
publicKey = this.provider.wallet.publicKey;
|
7124
7287
|
preInstructions = [];
|
@@ -7135,8 +7298,8 @@ var PerpetualsClient = (function () {
|
|
7135
7298
|
custodyAccountMetas = [];
|
7136
7299
|
custodyOracleAccountMetas = [];
|
7137
7300
|
markets = [];
|
7138
|
-
for (
|
7139
|
-
custody = _a
|
7301
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
7302
|
+
custody = _b[_a];
|
7140
7303
|
custodyAccountMetas.push({
|
7141
7304
|
pubkey: custody.custodyAccount,
|
7142
7305
|
isSigner: false,
|
@@ -7148,8 +7311,8 @@ var PerpetualsClient = (function () {
|
|
7148
7311
|
isWritable: false,
|
7149
7312
|
});
|
7150
7313
|
}
|
7151
|
-
for (
|
7152
|
-
market = _c
|
7314
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
7315
|
+
market = _d[_c];
|
7153
7316
|
markets.push({
|
7154
7317
|
pubkey: market.marketAccount,
|
7155
7318
|
isSigner: false,
|
@@ -7158,26 +7321,26 @@ var PerpetualsClient = (function () {
|
|
7158
7321
|
}
|
7159
7322
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
7160
7323
|
case 1:
|
7161
|
-
if (!(
|
7324
|
+
if (!(_f.sent())) {
|
7162
7325
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
7163
7326
|
}
|
7164
7327
|
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
7165
7328
|
case 2:
|
7166
|
-
if (!(
|
7329
|
+
if (!(_f.sent())) {
|
7167
7330
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
7168
7331
|
}
|
7169
7332
|
if (!(inTokenSymbol == 'SOL')) return [3, 5];
|
7170
7333
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
7171
7334
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
7172
7335
|
if (!!skipBalanceChecks) return [3, 4];
|
7173
|
-
|
7336
|
+
_e = anchor_1.BN.bind;
|
7174
7337
|
return [4, this.provider.connection.getBalance(publicKey)];
|
7175
7338
|
case 3:
|
7176
|
-
unWrappedSolBalance = new (
|
7339
|
+
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
|
7177
7340
|
if (unWrappedSolBalance.lt(lamports)) {
|
7178
7341
|
throw "Insufficient SOL Funds";
|
7179
7342
|
}
|
7180
|
-
|
7343
|
+
_f.label = 4;
|
7181
7344
|
case 4:
|
7182
7345
|
if (!ephemeralSignerPubkey) {
|
7183
7346
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -7201,12 +7364,12 @@ var PerpetualsClient = (function () {
|
|
7201
7364
|
if (!!skipBalanceChecks) return [3, 7];
|
7202
7365
|
return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
|
7203
7366
|
case 6:
|
7204
|
-
if (!(
|
7367
|
+
if (!(_f.sent())) {
|
7205
7368
|
throw "Insufficient Funds , token Account doesn't exist";
|
7206
7369
|
}
|
7207
|
-
|
7370
|
+
_f.label = 7;
|
7208
7371
|
case 7:
|
7209
|
-
|
7372
|
+
_f.trys.push([7, 9, , 10]);
|
7210
7373
|
return [4, this.program.methods
|
7211
7374
|
.addCompoundingLiquidity({
|
7212
7375
|
amountIn: amountIn,
|
@@ -7235,12 +7398,12 @@ var PerpetualsClient = (function () {
|
|
7235
7398
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7236
7399
|
.instruction()];
|
7237
7400
|
case 8:
|
7238
|
-
addCompoundingLiquidity =
|
7401
|
+
addCompoundingLiquidity = _f.sent();
|
7239
7402
|
instructions.push(addCompoundingLiquidity);
|
7240
7403
|
return [3, 10];
|
7241
7404
|
case 9:
|
7242
|
-
|
7243
|
-
console.log("perpClient addCompoundingLiquidity error:: ",
|
7405
|
+
err_58 = _f.sent();
|
7406
|
+
console.log("perpClient addCompoundingLiquidity error:: ", err_58);
|
7244
7407
|
return [3, 10];
|
7245
7408
|
case 10: return [2, {
|
7246
7409
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7250,13 +7413,17 @@ var PerpetualsClient = (function () {
|
|
7250
7413
|
});
|
7251
7414
|
});
|
7252
7415
|
};
|
7253
|
-
this.removeCompoundingLiquidity = function (
|
7254
|
-
|
7255
|
-
|
7256
|
-
|
7257
|
-
|
7258
|
-
|
7259
|
-
|
7416
|
+
this.removeCompoundingLiquidity = function (compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1) {
|
7417
|
+
var args_1 = [];
|
7418
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
7419
|
+
args_1[_i - 5] = arguments[_i];
|
7420
|
+
}
|
7421
|
+
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) {
|
7422
|
+
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;
|
7423
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7424
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7425
|
+
return __generator(this, function (_f) {
|
7426
|
+
switch (_f.label) {
|
7260
7427
|
case 0:
|
7261
7428
|
publicKey = this.provider.wallet.publicKey;
|
7262
7429
|
preInstructions = [];
|
@@ -7293,19 +7460,19 @@ var PerpetualsClient = (function () {
|
|
7293
7460
|
if (!_a) return [3, 3];
|
7294
7461
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
7295
7462
|
case 2:
|
7296
|
-
_a = !(
|
7297
|
-
|
7463
|
+
_a = !(_f.sent());
|
7464
|
+
_f.label = 3;
|
7298
7465
|
case 3:
|
7299
7466
|
if (_a) {
|
7300
7467
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey));
|
7301
7468
|
}
|
7302
|
-
|
7469
|
+
_f.label = 4;
|
7303
7470
|
case 4:
|
7304
7471
|
custodyAccountMetas = [];
|
7305
7472
|
custodyOracleAccountMetas = [];
|
7306
7473
|
markets = [];
|
7307
|
-
for (
|
7308
|
-
custody = _b
|
7474
|
+
for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
|
7475
|
+
custody = _c[_b];
|
7309
7476
|
custodyAccountMetas.push({
|
7310
7477
|
pubkey: custody.custodyAccount,
|
7311
7478
|
isSigner: false,
|
@@ -7317,8 +7484,8 @@ var PerpetualsClient = (function () {
|
|
7317
7484
|
isWritable: false,
|
7318
7485
|
});
|
7319
7486
|
}
|
7320
|
-
for (
|
7321
|
-
market = _d
|
7487
|
+
for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
|
7488
|
+
market = _e[_d];
|
7322
7489
|
markets.push({
|
7323
7490
|
pubkey: market.marketAccount,
|
7324
7491
|
isSigner: false,
|
@@ -7326,9 +7493,9 @@ var PerpetualsClient = (function () {
|
|
7326
7493
|
});
|
7327
7494
|
}
|
7328
7495
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
7329
|
-
|
7496
|
+
_f.label = 5;
|
7330
7497
|
case 5:
|
7331
|
-
|
7498
|
+
_f.trys.push([5, 7, , 8]);
|
7332
7499
|
return [4, this.program.methods
|
7333
7500
|
.removeCompoundingLiquidity({
|
7334
7501
|
compoundingAmountIn: compoundingAmountIn,
|
@@ -7357,12 +7524,12 @@ var PerpetualsClient = (function () {
|
|
7357
7524
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7358
7525
|
.instruction()];
|
7359
7526
|
case 6:
|
7360
|
-
removeCompoundingLiquidity =
|
7527
|
+
removeCompoundingLiquidity = _f.sent();
|
7361
7528
|
instructions.push(removeCompoundingLiquidity);
|
7362
7529
|
return [3, 8];
|
7363
7530
|
case 7:
|
7364
|
-
|
7365
|
-
console.log("perpClient removeCompoundingLiquidity error:: ",
|
7531
|
+
err_59 = _f.sent();
|
7532
|
+
console.log("perpClient removeCompoundingLiquidity error:: ", err_59);
|
7366
7533
|
return [3, 8];
|
7367
7534
|
case 8: return [2, {
|
7368
7535
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7372,12 +7539,16 @@ var PerpetualsClient = (function () {
|
|
7372
7539
|
});
|
7373
7540
|
});
|
7374
7541
|
};
|
7375
|
-
this.migrateStake = function (
|
7376
|
-
|
7377
|
-
|
7378
|
-
|
7379
|
-
|
7380
|
-
|
7542
|
+
this.migrateStake = function (amount_1, rewardTokenMint_1, poolConfig_1) {
|
7543
|
+
var args_1 = [];
|
7544
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
7545
|
+
args_1[_i - 3] = arguments[_i];
|
7546
|
+
}
|
7547
|
+
return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
7548
|
+
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;
|
7549
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
7550
|
+
return __generator(this, function (_g) {
|
7551
|
+
switch (_g.label) {
|
7381
7552
|
case 0:
|
7382
7553
|
publicKey = this.provider.wallet.publicKey;
|
7383
7554
|
preInstructions = [];
|
@@ -7392,8 +7563,8 @@ var PerpetualsClient = (function () {
|
|
7392
7563
|
if (!_a) return [3, 2];
|
7393
7564
|
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
7394
7565
|
case 1:
|
7395
|
-
_a = !(
|
7396
|
-
|
7566
|
+
_a = !(_g.sent());
|
7567
|
+
_g.label = 2;
|
7397
7568
|
case 2:
|
7398
7569
|
if (_a) {
|
7399
7570
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
@@ -7405,8 +7576,8 @@ var PerpetualsClient = (function () {
|
|
7405
7576
|
if (!_b) return [3, 4];
|
7406
7577
|
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
7407
7578
|
case 3:
|
7408
|
-
_b = (
|
7409
|
-
|
7579
|
+
_b = (_g.sent());
|
7580
|
+
_g.label = 4;
|
7410
7581
|
case 4:
|
7411
7582
|
if (_b) {
|
7412
7583
|
tokenStakeAccounts.push({
|
@@ -7419,8 +7590,8 @@ var PerpetualsClient = (function () {
|
|
7419
7590
|
custodyAccountMetas = [];
|
7420
7591
|
custodyOracleAccountMetas = [];
|
7421
7592
|
markets = [];
|
7422
|
-
for (
|
7423
|
-
custody = _c
|
7593
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
7594
|
+
custody = _d[_c];
|
7424
7595
|
custodyAccountMetas.push({
|
7425
7596
|
pubkey: custody.custodyAccount,
|
7426
7597
|
isSigner: false,
|
@@ -7432,17 +7603,17 @@ var PerpetualsClient = (function () {
|
|
7432
7603
|
isWritable: false,
|
7433
7604
|
});
|
7434
7605
|
}
|
7435
|
-
for (
|
7436
|
-
market = _e
|
7606
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
7607
|
+
market = _f[_e];
|
7437
7608
|
markets.push({
|
7438
7609
|
pubkey: market.marketAccount,
|
7439
7610
|
isSigner: false,
|
7440
7611
|
isWritable: false,
|
7441
7612
|
});
|
7442
7613
|
}
|
7443
|
-
|
7614
|
+
_g.label = 5;
|
7444
7615
|
case 5:
|
7445
|
-
|
7616
|
+
_g.trys.push([5, 7, , 8]);
|
7446
7617
|
return [4, this.program.methods
|
7447
7618
|
.migrateStake({
|
7448
7619
|
amount: amount
|
@@ -7468,12 +7639,12 @@ var PerpetualsClient = (function () {
|
|
7468
7639
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
|
7469
7640
|
.instruction()];
|
7470
7641
|
case 6:
|
7471
|
-
migrateStake =
|
7642
|
+
migrateStake = _g.sent();
|
7472
7643
|
instructions.push(migrateStake);
|
7473
7644
|
return [3, 8];
|
7474
7645
|
case 7:
|
7475
|
-
|
7476
|
-
console.log("perpClient migrateStake error:: ",
|
7646
|
+
err_60 = _g.sent();
|
7647
|
+
console.log("perpClient migrateStake error:: ", err_60);
|
7477
7648
|
return [3, 8];
|
7478
7649
|
case 8: return [2, {
|
7479
7650
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7484,7 +7655,7 @@ var PerpetualsClient = (function () {
|
|
7484
7655
|
});
|
7485
7656
|
};
|
7486
7657
|
this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7487
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp,
|
7658
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_61;
|
7488
7659
|
return __generator(this, function (_d) {
|
7489
7660
|
switch (_d.label) {
|
7490
7661
|
case 0:
|
@@ -7556,8 +7727,8 @@ var PerpetualsClient = (function () {
|
|
7556
7727
|
instructions.push(migrateFlp);
|
7557
7728
|
return [3, 4];
|
7558
7729
|
case 3:
|
7559
|
-
|
7560
|
-
console.log("perpClient migrateFlp error:: ",
|
7730
|
+
err_61 = _d.sent();
|
7731
|
+
console.log("perpClient migrateFlp error:: ", err_61);
|
7561
7732
|
return [3, 4];
|
7562
7733
|
case 4: return [2, {
|
7563
7734
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7566,12 +7737,16 @@ var PerpetualsClient = (function () {
|
|
7566
7737
|
}
|
7567
7738
|
});
|
7568
7739
|
}); };
|
7569
|
-
this.compoundingFee = function (
|
7570
|
-
|
7571
|
-
|
7572
|
-
|
7573
|
-
|
7574
|
-
|
7740
|
+
this.compoundingFee = function (poolConfig_1) {
|
7741
|
+
var args_1 = [];
|
7742
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
7743
|
+
args_1[_i - 1] = arguments[_i];
|
7744
|
+
}
|
7745
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
|
7746
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_62;
|
7747
|
+
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
7748
|
+
return __generator(this, function (_e) {
|
7749
|
+
switch (_e.label) {
|
7575
7750
|
case 0:
|
7576
7751
|
instructions = [];
|
7577
7752
|
additionalSigners = [];
|
@@ -7580,8 +7755,8 @@ var PerpetualsClient = (function () {
|
|
7580
7755
|
custodyAccountMetas = [];
|
7581
7756
|
custodyOracleAccountMetas = [];
|
7582
7757
|
markets = [];
|
7583
|
-
for (
|
7584
|
-
custody = _a
|
7758
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
7759
|
+
custody = _b[_a];
|
7585
7760
|
custodyAccountMetas.push({
|
7586
7761
|
pubkey: custody.custodyAccount,
|
7587
7762
|
isSigner: false,
|
@@ -7593,17 +7768,17 @@ var PerpetualsClient = (function () {
|
|
7593
7768
|
isWritable: false,
|
7594
7769
|
});
|
7595
7770
|
}
|
7596
|
-
for (
|
7597
|
-
market = _c
|
7771
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
7772
|
+
market = _d[_c];
|
7598
7773
|
markets.push({
|
7599
7774
|
pubkey: market.marketAccount,
|
7600
7775
|
isSigner: false,
|
7601
7776
|
isWritable: false,
|
7602
7777
|
});
|
7603
7778
|
}
|
7604
|
-
|
7779
|
+
_e.label = 1;
|
7605
7780
|
case 1:
|
7606
|
-
|
7781
|
+
_e.trys.push([1, 3, , 4]);
|
7607
7782
|
return [4, this.program.methods
|
7608
7783
|
.compoundFees({})
|
7609
7784
|
.accounts({
|
@@ -7622,12 +7797,12 @@ var PerpetualsClient = (function () {
|
|
7622
7797
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7623
7798
|
.instruction()];
|
7624
7799
|
case 2:
|
7625
|
-
compoundingFee =
|
7800
|
+
compoundingFee = _e.sent();
|
7626
7801
|
instructions.push(compoundingFee);
|
7627
7802
|
return [3, 4];
|
7628
7803
|
case 3:
|
7629
|
-
|
7630
|
-
console.log("perpClient compoundingFee error:: ",
|
7804
|
+
err_62 = _e.sent();
|
7805
|
+
console.log("perpClient compoundingFee error:: ", err_62);
|
7631
7806
|
return [3, 4];
|
7632
7807
|
case 4: return [2, {
|
7633
7808
|
instructions: __spreadArray([], instructions, true),
|
@@ -7638,7 +7813,7 @@ var PerpetualsClient = (function () {
|
|
7638
7813
|
});
|
7639
7814
|
};
|
7640
7815
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7641
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
7816
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_63;
|
7642
7817
|
return __generator(this, function (_a) {
|
7643
7818
|
switch (_a.label) {
|
7644
7819
|
case 0:
|
@@ -7676,8 +7851,8 @@ var PerpetualsClient = (function () {
|
|
7676
7851
|
instructions.push(renameFlp);
|
7677
7852
|
return [3, 4];
|
7678
7853
|
case 3:
|
7679
|
-
|
7680
|
-
console.log("perpClient renameFlp error:: ",
|
7854
|
+
err_63 = _a.sent();
|
7855
|
+
console.log("perpClient renameFlp error:: ", err_63);
|
7681
7856
|
return [3, 4];
|
7682
7857
|
case 4: return [2, {
|
7683
7858
|
instructions: __spreadArray([], instructions, true),
|
@@ -7787,9 +7962,9 @@ var PerpetualsClient = (function () {
|
|
7787
7962
|
}
|
7788
7963
|
}
|
7789
7964
|
};
|
7790
|
-
PerpetualsClient.prototype.sendTransaction = function (
|
7791
|
-
|
7792
|
-
|
7965
|
+
PerpetualsClient.prototype.sendTransaction = function (ixs_1) {
|
7966
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
7967
|
+
if (opts === void 0) { opts = {}; }
|
7793
7968
|
return __generator(this, function (_a) {
|
7794
7969
|
switch (_a.label) {
|
7795
7970
|
case 0: return [4, (0, rpc_1.sendTransaction)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|
@@ -7798,9 +7973,9 @@ var PerpetualsClient = (function () {
|
|
7798
7973
|
});
|
7799
7974
|
});
|
7800
7975
|
};
|
7801
|
-
PerpetualsClient.prototype.sendTransactionV3 = function (
|
7802
|
-
|
7803
|
-
|
7976
|
+
PerpetualsClient.prototype.sendTransactionV3 = function (ixs_1) {
|
7977
|
+
return __awaiter(this, arguments, void 0, function (ixs, opts) {
|
7978
|
+
if (opts === void 0) { opts = {}; }
|
7804
7979
|
return __generator(this, function (_a) {
|
7805
7980
|
switch (_a.label) {
|
7806
7981
|
case 0: return [4, (0, rpc_1.sendTransactionV3)(this.program.provider, ixs, __assign({ postSendTxCallback: this.postSendTxCallback, prioritizationFee: this.prioritizationFee }, opts))];
|