flash-sdk 2.10.3 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +129 -16
- package/dist/PerpetualsClient.js +496 -116
- package/dist/PoolAccount.d.ts +8 -3
- package/dist/PoolConfig.d.ts +3 -1
- package/dist/PoolConfig.js +4 -2
- package/dist/PoolConfig.json +20 -0
- package/dist/idl/fbnft_rewards.d.ts +5 -0
- package/dist/idl/fbnft_rewards.js +5 -0
- package/dist/idl/perpetuals.d.ts +707 -40
- package/dist/idl/perpetuals.js +707 -40
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
@@ -196,6 +196,10 @@ var PerpetualsClient = (function () {
|
|
196
196
|
return _this.findProgramAddress("lp_token_mint", [_this.getPoolKey(name)])
|
197
197
|
.publicKey;
|
198
198
|
};
|
199
|
+
this.getPoolCompoundingTokenKey = function (name) {
|
200
|
+
return _this.findProgramAddress("compounding_token_mint", [_this.getPoolKey(name)])
|
201
|
+
.publicKey;
|
202
|
+
};
|
199
203
|
this.getCustodyKey = function (poolName, tokenMint) {
|
200
204
|
return _this.findProgramAddress("custody", [
|
201
205
|
_this.getPoolKey(poolName),
|
@@ -2364,6 +2368,77 @@ var PerpetualsClient = (function () {
|
|
2364
2368
|
});
|
2365
2369
|
});
|
2366
2370
|
};
|
2371
|
+
this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
2372
|
+
var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_3;
|
2373
|
+
return __generator(this, function (_b) {
|
2374
|
+
switch (_b.label) {
|
2375
|
+
case 0:
|
2376
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardTokenSymbol).mintKey); });
|
2377
|
+
if (!rewardCustody) {
|
2378
|
+
throw "rewardCustody not found";
|
2379
|
+
}
|
2380
|
+
custody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(swapTokenSymbol).mintKey); });
|
2381
|
+
if (!custody) {
|
2382
|
+
throw "custody not found";
|
2383
|
+
}
|
2384
|
+
publicKey = this.provider.wallet.publicKey;
|
2385
|
+
preInstructions = [];
|
2386
|
+
instructions = [];
|
2387
|
+
postInstructions = [];
|
2388
|
+
additionalSigners = [];
|
2389
|
+
_b.label = 1;
|
2390
|
+
case 1:
|
2391
|
+
_b.trys.push([1, 3, , 4]);
|
2392
|
+
custodyAccountMetas = [];
|
2393
|
+
custodyOracleAccountMetas = [];
|
2394
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
2395
|
+
custody_1 = _a[_i];
|
2396
|
+
custodyAccountMetas.push({
|
2397
|
+
pubkey: custody_1.custodyAccount,
|
2398
|
+
isSigner: false,
|
2399
|
+
isWritable: false,
|
2400
|
+
});
|
2401
|
+
custodyOracleAccountMetas.push({
|
2402
|
+
pubkey: this.useExtOracleAccount ? custody_1.extOracleAccount : custody_1.intOracleAccount,
|
2403
|
+
isSigner: false,
|
2404
|
+
isWritable: false,
|
2405
|
+
});
|
2406
|
+
}
|
2407
|
+
params = {};
|
2408
|
+
return [4, this.program.methods
|
2409
|
+
.swapFeeInternal(params)
|
2410
|
+
.accounts({
|
2411
|
+
owner: publicKey,
|
2412
|
+
perpetuals: poolConfig.perpetuals,
|
2413
|
+
pool: poolConfig.poolAddress,
|
2414
|
+
rewardCustody: rewardCustody.custodyAccount,
|
2415
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
2416
|
+
rewardCustodyTokenAccount: rewardCustody.tokenAccount,
|
2417
|
+
custody: custody.custodyAccount,
|
2418
|
+
custodyOracleAccount: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
2419
|
+
custodyTokenAccount: custody.tokenAccount,
|
2420
|
+
eventAuthority: this.eventAuthority.publicKey,
|
2421
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
2422
|
+
program: this.programId,
|
2423
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
2424
|
+
})
|
2425
|
+
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
2426
|
+
.instruction()];
|
2427
|
+
case 2:
|
2428
|
+
inx = _b.sent();
|
2429
|
+
instructions.push(inx);
|
2430
|
+
return [3, 4];
|
2431
|
+
case 3:
|
2432
|
+
err_3 = _b.sent();
|
2433
|
+
console.error("perpClient Swap error:: ", err_3);
|
2434
|
+
throw err_3;
|
2435
|
+
case 4: return [2, {
|
2436
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
2437
|
+
additionalSigners: additionalSigners
|
2438
|
+
}];
|
2439
|
+
}
|
2440
|
+
});
|
2441
|
+
}); };
|
2367
2442
|
this.addCollateral = function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks) {
|
2368
2443
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2369
2444
|
return __awaiter(_this, void 0, void 0, function () {
|
@@ -2931,7 +3006,7 @@ var PerpetualsClient = (function () {
|
|
2931
3006
|
this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks) {
|
2932
3007
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2933
3008
|
return __awaiter(_this, void 0, void 0, function () {
|
2934
|
-
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, accCreationLamports, lamports, unWrappedSolBalance, _d, tokenAccountBalance, _e, instruction,
|
3009
|
+
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, accCreationLamports, lamports, unWrappedSolBalance, _d, tokenAccountBalance, _e, instruction, err_4;
|
2935
3010
|
return __generator(this, function (_f) {
|
2936
3011
|
switch (_f.label) {
|
2937
3012
|
case 0:
|
@@ -3054,9 +3129,9 @@ var PerpetualsClient = (function () {
|
|
3054
3129
|
instructions.push(instruction);
|
3055
3130
|
return [3, 13];
|
3056
3131
|
case 12:
|
3057
|
-
|
3058
|
-
console.error("perpClient addLiquidity error:: ",
|
3059
|
-
throw
|
3132
|
+
err_4 = _f.sent();
|
3133
|
+
console.error("perpClient addLiquidity error:: ", err_4);
|
3134
|
+
throw err_4;
|
3060
3135
|
case 13: return [2, {
|
3061
3136
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3062
3137
|
additionalSigners: additionalSigners
|
@@ -3070,7 +3145,7 @@ var PerpetualsClient = (function () {
|
|
3070
3145
|
if (createUserATA === void 0) { createUserATA = true; }
|
3071
3146
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
3072
3147
|
return __awaiter(_this, void 0, void 0, function () {
|
3073
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns,
|
3148
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns, err_5;
|
3074
3149
|
return __generator(this, function (_e) {
|
3075
3150
|
switch (_e.label) {
|
3076
3151
|
case 0:
|
@@ -3186,9 +3261,9 @@ var PerpetualsClient = (function () {
|
|
3186
3261
|
}
|
3187
3262
|
return [3, 11];
|
3188
3263
|
case 10:
|
3189
|
-
|
3190
|
-
console.log("perpClient removeLiquidity error:: ",
|
3191
|
-
throw
|
3264
|
+
err_5 = _e.sent();
|
3265
|
+
console.log("perpClient removeLiquidity error:: ", err_5);
|
3266
|
+
throw err_5;
|
3192
3267
|
case 11: return [2, {
|
3193
3268
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3194
3269
|
additionalSigners: additionalSigners
|
@@ -3198,7 +3273,7 @@ var PerpetualsClient = (function () {
|
|
3198
3273
|
});
|
3199
3274
|
};
|
3200
3275
|
this.addReferral = function (nftTradingAccount, nftReferralAccount) { return __awaiter(_this, void 0, void 0, function () {
|
3201
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction,
|
3276
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction, err_6;
|
3202
3277
|
return __generator(this, function (_a) {
|
3203
3278
|
switch (_a.label) {
|
3204
3279
|
case 0:
|
@@ -3225,9 +3300,9 @@ var PerpetualsClient = (function () {
|
|
3225
3300
|
instructions.push(addReferralInstruction);
|
3226
3301
|
return [3, 4];
|
3227
3302
|
case 3:
|
3228
|
-
|
3229
|
-
console.log("perpClient addReferral error:: ",
|
3230
|
-
throw
|
3303
|
+
err_6 = _a.sent();
|
3304
|
+
console.log("perpClient addReferral error:: ", err_6);
|
3305
|
+
throw err_6;
|
3231
3306
|
case 4: return [2, {
|
3232
3307
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3233
3308
|
additionalSigners: additionalSigners
|
@@ -3236,7 +3311,7 @@ var PerpetualsClient = (function () {
|
|
3236
3311
|
});
|
3237
3312
|
}); };
|
3238
3313
|
this.createNftTradingAccount = function (nftMint, owner, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3239
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, nftTokenAccount, createNftTradingAccountInstruction,
|
3314
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, nftTokenAccount, createNftTradingAccountInstruction, err_7;
|
3240
3315
|
return __generator(this, function (_a) {
|
3241
3316
|
switch (_a.label) {
|
3242
3317
|
case 0:
|
@@ -3276,9 +3351,9 @@ var PerpetualsClient = (function () {
|
|
3276
3351
|
instructions.push(createNftTradingAccountInstruction);
|
3277
3352
|
return [3, 5];
|
3278
3353
|
case 4:
|
3279
|
-
|
3280
|
-
console.log("perpClient createNftAccount error:: ",
|
3281
|
-
throw
|
3354
|
+
err_7 = _a.sent();
|
3355
|
+
console.log("perpClient createNftAccount error:: ", err_7);
|
3356
|
+
throw err_7;
|
3282
3357
|
case 5: return [2, {
|
3283
3358
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3284
3359
|
additionalSigners: additionalSigners
|
@@ -3287,7 +3362,7 @@ var PerpetualsClient = (function () {
|
|
3287
3362
|
});
|
3288
3363
|
}); };
|
3289
3364
|
this.updateNftAccount = function (nftMint, updateReferer, updateBooster, flpStakeAccounts) { return __awaiter(_this, void 0, void 0, function () {
|
3290
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction,
|
3365
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction, err_8;
|
3291
3366
|
return __generator(this, function (_a) {
|
3292
3367
|
switch (_a.label) {
|
3293
3368
|
case 0:
|
@@ -3337,9 +3412,9 @@ var PerpetualsClient = (function () {
|
|
3337
3412
|
instructions.push(updateNftTradingAccountInstruction);
|
3338
3413
|
return [3, 5];
|
3339
3414
|
case 4:
|
3340
|
-
|
3341
|
-
console.log("perpClient updateNftAccount error:: ",
|
3342
|
-
throw
|
3415
|
+
err_8 = _a.sent();
|
3416
|
+
console.log("perpClient updateNftAccount error:: ", err_8);
|
3417
|
+
throw err_8;
|
3343
3418
|
case 5: return [2, {
|
3344
3419
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3345
3420
|
additionalSigners: additionalSigners
|
@@ -3348,7 +3423,7 @@ var PerpetualsClient = (function () {
|
|
3348
3423
|
});
|
3349
3424
|
}); };
|
3350
3425
|
this.levelUp = function (poolConfig, nftMint, authorizationRulesAccount) { return __awaiter(_this, void 0, void 0, function () {
|
3351
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction,
|
3426
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction, err_9;
|
3352
3427
|
return __generator(this, function (_a) {
|
3353
3428
|
switch (_a.label) {
|
3354
3429
|
case 0:
|
@@ -3387,9 +3462,9 @@ var PerpetualsClient = (function () {
|
|
3387
3462
|
instructions.push(levelUpInstruction);
|
3388
3463
|
return [3, 4];
|
3389
3464
|
case 3:
|
3390
|
-
|
3391
|
-
console.log("perpClient levelUp error:: ",
|
3392
|
-
throw
|
3465
|
+
err_9 = _a.sent();
|
3466
|
+
console.log("perpClient levelUp error:: ", err_9);
|
3467
|
+
throw err_9;
|
3393
3468
|
case 4: return [2, {
|
3394
3469
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3395
3470
|
additionalSigners: additionalSigners
|
@@ -3398,7 +3473,7 @@ var PerpetualsClient = (function () {
|
|
3398
3473
|
});
|
3399
3474
|
}); };
|
3400
3475
|
this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3401
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction,
|
3476
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_10;
|
3402
3477
|
return __generator(this, function (_a) {
|
3403
3478
|
switch (_a.label) {
|
3404
3479
|
case 0:
|
@@ -3436,9 +3511,65 @@ var PerpetualsClient = (function () {
|
|
3436
3511
|
instructions.push(initStakeInstruction);
|
3437
3512
|
return [3, 4];
|
3438
3513
|
case 3:
|
3439
|
-
|
3440
|
-
console.log("perpClient InitStaking error:: ",
|
3441
|
-
throw
|
3514
|
+
err_10 = _a.sent();
|
3515
|
+
console.log("perpClient InitStaking error:: ", err_10);
|
3516
|
+
throw err_10;
|
3517
|
+
case 4: return [2, {
|
3518
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3519
|
+
additionalSigners: additionalSigners
|
3520
|
+
}];
|
3521
|
+
}
|
3522
|
+
});
|
3523
|
+
}); };
|
3524
|
+
this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3525
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_11;
|
3526
|
+
return __generator(this, function (_a) {
|
3527
|
+
switch (_a.label) {
|
3528
|
+
case 0:
|
3529
|
+
publicKey = this.provider.wallet.publicKey;
|
3530
|
+
preInstructions = [];
|
3531
|
+
instructions = [];
|
3532
|
+
postInstructions = [];
|
3533
|
+
additionalSigners = [];
|
3534
|
+
_a.label = 1;
|
3535
|
+
case 1:
|
3536
|
+
_a.trys.push([1, 3, , 4]);
|
3537
|
+
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
3538
|
+
compoundingTokenMint = this.getPoolCompoundingTokenKey(poolConfig.poolName);
|
3539
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), compoundingTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
3540
|
+
metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), compoundingTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
3541
|
+
return [4, this.program.methods
|
3542
|
+
.initCompounding({
|
3543
|
+
feeShareBps: feeShareBps,
|
3544
|
+
metadataTitle: metadataTitle,
|
3545
|
+
metadataSymbol: metadataSymbol,
|
3546
|
+
metadataUri: metadataUri
|
3547
|
+
})
|
3548
|
+
.accounts({
|
3549
|
+
admin: publicKey,
|
3550
|
+
multisig: this.multisig.publicKey,
|
3551
|
+
transferAuthority: poolConfig.transferAuthority,
|
3552
|
+
perpetuals: this.perpetuals.publicKey,
|
3553
|
+
pool: poolConfig.poolAddress,
|
3554
|
+
custody: rewardCustodyConfig.custodyAccount,
|
3555
|
+
lpTokenMint: poolConfig.lpTokenMint,
|
3556
|
+
compoundingVault: compoundingVault,
|
3557
|
+
compoundingTokenMint: compoundingTokenMint,
|
3558
|
+
metadataAccount: metadataAccount,
|
3559
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
3560
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3561
|
+
metadataProgram: constants_1.METAPLEX_PROGRAM_ID,
|
3562
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY
|
3563
|
+
})
|
3564
|
+
.instruction()];
|
3565
|
+
case 2:
|
3566
|
+
initCompoundingInstruction = _a.sent();
|
3567
|
+
instructions.push(initCompoundingInstruction);
|
3568
|
+
return [3, 4];
|
3569
|
+
case 3:
|
3570
|
+
err_11 = _a.sent();
|
3571
|
+
console.log("perpClient initCompounding error:: ", err_11);
|
3572
|
+
throw err_11;
|
3442
3573
|
case 4: return [2, {
|
3443
3574
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3444
3575
|
additionalSigners: additionalSigners
|
@@ -3447,7 +3578,7 @@ var PerpetualsClient = (function () {
|
|
3447
3578
|
});
|
3448
3579
|
}); };
|
3449
3580
|
this.depositStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3450
|
-
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint,
|
3581
|
+
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedFlpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_12;
|
3451
3582
|
return __generator(this, function (_a) {
|
3452
3583
|
switch (_a.label) {
|
3453
3584
|
case 0:
|
@@ -3459,7 +3590,7 @@ var PerpetualsClient = (function () {
|
|
3459
3590
|
case 1:
|
3460
3591
|
_a.trys.push([1, 4, , 5]);
|
3461
3592
|
lpTokenMint = poolConfig.lpTokenMint;
|
3462
|
-
|
3593
|
+
poolStakedFlpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
3463
3594
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), owner.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
3464
3595
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.lpTokenMint, owner)];
|
3465
3596
|
case 2:
|
@@ -3476,7 +3607,7 @@ var PerpetualsClient = (function () {
|
|
3476
3607
|
perpetuals: this.perpetuals.publicKey,
|
3477
3608
|
pool: poolConfig.poolAddress,
|
3478
3609
|
flpStakeAccount: flpStakeAccount,
|
3479
|
-
|
3610
|
+
poolStakedFlpVault: poolStakedFlpVault,
|
3480
3611
|
systemProgram: web3_js_1.SystemProgram.programId,
|
3481
3612
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3482
3613
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -3487,9 +3618,9 @@ var PerpetualsClient = (function () {
|
|
3487
3618
|
instructions.push(depositStakeInstruction);
|
3488
3619
|
return [3, 5];
|
3489
3620
|
case 4:
|
3490
|
-
|
3491
|
-
console.log("perpClient depositStaking error:: ",
|
3492
|
-
throw
|
3621
|
+
err_12 = _a.sent();
|
3622
|
+
console.log("perpClient depositStaking error:: ", err_12);
|
3623
|
+
throw err_12;
|
3493
3624
|
case 5: return [2, {
|
3494
3625
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3495
3626
|
additionalSigners: additionalSigners
|
@@ -3532,7 +3663,7 @@ var PerpetualsClient = (function () {
|
|
3532
3663
|
});
|
3533
3664
|
}); };
|
3534
3665
|
this.refreshStake = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
3535
|
-
var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction,
|
3666
|
+
var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_13;
|
3536
3667
|
return __generator(this, function (_c) {
|
3537
3668
|
switch (_c.label) {
|
3538
3669
|
case 0:
|
@@ -3577,15 +3708,15 @@ var PerpetualsClient = (function () {
|
|
3577
3708
|
refreshStakeInstruction = _c.sent();
|
3578
3709
|
return [2, refreshStakeInstruction];
|
3579
3710
|
case 2:
|
3580
|
-
|
3581
|
-
console.log("perpClient refreshStaking error:: ",
|
3582
|
-
throw
|
3711
|
+
err_13 = _c.sent();
|
3712
|
+
console.log("perpClient refreshStaking error:: ", err_13);
|
3713
|
+
throw err_13;
|
3583
3714
|
case 3: return [2];
|
3584
3715
|
}
|
3585
3716
|
});
|
3586
3717
|
}); };
|
3587
3718
|
this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3588
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, lpTokenMint, flpStakeAccount, unstakeInstantInstruction,
|
3719
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, lpTokenMint, flpStakeAccount, unstakeInstantInstruction, err_14;
|
3589
3720
|
return __generator(this, function (_a) {
|
3590
3721
|
switch (_a.label) {
|
3591
3722
|
case 0:
|
@@ -3612,8 +3743,7 @@ var PerpetualsClient = (function () {
|
|
3612
3743
|
perpetuals: this.perpetuals.publicKey,
|
3613
3744
|
pool: pool,
|
3614
3745
|
flpStakeAccount: flpStakeAccount,
|
3615
|
-
rewardCustody: rewardCustodyConfig.custodyAccount
|
3616
|
-
feeDistributionTokenAccount: feeDistributionTokenAccount,
|
3746
|
+
rewardCustody: rewardCustodyConfig.custodyAccount
|
3617
3747
|
})
|
3618
3748
|
.instruction()];
|
3619
3749
|
case 2:
|
@@ -3621,9 +3751,9 @@ var PerpetualsClient = (function () {
|
|
3621
3751
|
instructions.push(unstakeInstantInstruction);
|
3622
3752
|
return [3, 4];
|
3623
3753
|
case 3:
|
3624
|
-
|
3625
|
-
console.log("perpClient unstakeInstant error:: ",
|
3626
|
-
throw
|
3754
|
+
err_14 = _a.sent();
|
3755
|
+
console.log("perpClient unstakeInstant error:: ", err_14);
|
3756
|
+
throw err_14;
|
3627
3757
|
case 4: return [2, {
|
3628
3758
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3629
3759
|
additionalSigners: additionalSigners
|
@@ -3632,7 +3762,7 @@ var PerpetualsClient = (function () {
|
|
3632
3762
|
});
|
3633
3763
|
}); };
|
3634
3764
|
this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
3635
|
-
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction,
|
3765
|
+
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_15;
|
3636
3766
|
return __generator(this, function (_c) {
|
3637
3767
|
switch (_c.label) {
|
3638
3768
|
case 0:
|
@@ -3676,15 +3806,15 @@ var PerpetualsClient = (function () {
|
|
3676
3806
|
refreshStakeInstruction = _c.sent();
|
3677
3807
|
return [2, refreshStakeInstruction];
|
3678
3808
|
case 2:
|
3679
|
-
|
3680
|
-
console.log("perpClient refreshStaking error:: ",
|
3681
|
-
throw
|
3809
|
+
err_15 = _c.sent();
|
3810
|
+
console.log("perpClient refreshStaking error:: ", err_15);
|
3811
|
+
throw err_15;
|
3682
3812
|
case 3: return [2];
|
3683
3813
|
}
|
3684
3814
|
});
|
3685
3815
|
}); };
|
3686
3816
|
this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3687
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction,
|
3817
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_16;
|
3688
3818
|
return __generator(this, function (_a) {
|
3689
3819
|
switch (_a.label) {
|
3690
3820
|
case 0:
|
@@ -3717,9 +3847,9 @@ var PerpetualsClient = (function () {
|
|
3717
3847
|
instructions.push(unstakeRequestInstruction);
|
3718
3848
|
return [3, 4];
|
3719
3849
|
case 3:
|
3720
|
-
|
3721
|
-
console.log("perpClient unstakeRequest error:: ",
|
3722
|
-
throw
|
3850
|
+
err_16 = _a.sent();
|
3851
|
+
console.log("perpClient unstakeRequest error:: ", err_16);
|
3852
|
+
throw err_16;
|
3723
3853
|
case 4: return [2, {
|
3724
3854
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3725
3855
|
additionalSigners: additionalSigners
|
@@ -3732,7 +3862,7 @@ var PerpetualsClient = (function () {
|
|
3732
3862
|
if (deactivated === void 0) { deactivated = true; }
|
3733
3863
|
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
3734
3864
|
return __awaiter(_this, void 0, void 0, function () {
|
3735
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool,
|
3865
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedFlpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_17;
|
3736
3866
|
return __generator(this, function (_b) {
|
3737
3867
|
switch (_b.label) {
|
3738
3868
|
case 0:
|
@@ -3746,7 +3876,7 @@ var PerpetualsClient = (function () {
|
|
3746
3876
|
_b.trys.push([1, 6, , 7]);
|
3747
3877
|
lpTokenMint = poolConfig.lpTokenMint;
|
3748
3878
|
pool = poolConfig.poolAddress;
|
3749
|
-
|
3879
|
+
poolStakedFlpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), pool.toBuffer(), lpTokenMint.toBuffer()], this.program.programId)[0];
|
3750
3880
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.program.programId)[0];
|
3751
3881
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.lpTokenMint, publicKey)];
|
3752
3882
|
case 2:
|
@@ -3773,7 +3903,7 @@ var PerpetualsClient = (function () {
|
|
3773
3903
|
perpetuals: this.perpetuals.publicKey,
|
3774
3904
|
pool: pool,
|
3775
3905
|
flpStakeAccount: flpStakeAccount,
|
3776
|
-
|
3906
|
+
poolStakedFlpVault: poolStakedFlpVault,
|
3777
3907
|
systemProgram: web3_js_1.SystemProgram.programId,
|
3778
3908
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3779
3909
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -3784,9 +3914,9 @@ var PerpetualsClient = (function () {
|
|
3784
3914
|
instructions.push(withdrawStakeInstruction);
|
3785
3915
|
return [3, 7];
|
3786
3916
|
case 6:
|
3787
|
-
|
3788
|
-
console.log("perpClient withdrawStake error:: ",
|
3789
|
-
throw
|
3917
|
+
err_17 = _b.sent();
|
3918
|
+
console.log("perpClient withdrawStake error:: ", err_17);
|
3919
|
+
throw err_17;
|
3790
3920
|
case 7: return [2, {
|
3791
3921
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3792
3922
|
additionalSigners: additionalSigners
|
@@ -3798,7 +3928,7 @@ var PerpetualsClient = (function () {
|
|
3798
3928
|
this.collectStakeFees = function (rewardSymbol, poolConfig, nftTradingAccount, nftBoostingAccount, createUserATA) {
|
3799
3929
|
if (createUserATA === void 0) { createUserATA = true; }
|
3800
3930
|
return __awaiter(_this, void 0, void 0, function () {
|
3801
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, boostingAccount, withdrawStakeInstruction,
|
3931
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, boostingAccount, withdrawStakeInstruction, err_18;
|
3802
3932
|
return __generator(this, function (_b) {
|
3803
3933
|
switch (_b.label) {
|
3804
3934
|
case 0:
|
@@ -3865,9 +3995,9 @@ var PerpetualsClient = (function () {
|
|
3865
3995
|
instructions.push(withdrawStakeInstruction);
|
3866
3996
|
return [3, 6];
|
3867
3997
|
case 5:
|
3868
|
-
|
3869
|
-
console.log("perpClient withdrawStake error:: ",
|
3870
|
-
throw
|
3998
|
+
err_18 = _b.sent();
|
3999
|
+
console.log("perpClient withdrawStake error:: ", err_18);
|
4000
|
+
throw err_18;
|
3871
4001
|
case 6: return [2, {
|
3872
4002
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3873
4003
|
additionalSigners: additionalSigners
|
@@ -3877,7 +4007,7 @@ var PerpetualsClient = (function () {
|
|
3877
4007
|
});
|
3878
4008
|
};
|
3879
4009
|
this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3880
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault,
|
4010
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_19;
|
3881
4011
|
return __generator(this, function (_a) {
|
3882
4012
|
switch (_a.label) {
|
3883
4013
|
case 0:
|
@@ -3914,9 +4044,9 @@ var PerpetualsClient = (function () {
|
|
3914
4044
|
instructions.push(initRewardVault);
|
3915
4045
|
return [3, 4];
|
3916
4046
|
case 3:
|
3917
|
-
|
3918
|
-
console.log("perpClient InitRewardVault error:: ",
|
3919
|
-
throw
|
4047
|
+
err_19 = _a.sent();
|
4048
|
+
console.log("perpClient InitRewardVault error:: ", err_19);
|
4049
|
+
throw err_19;
|
3920
4050
|
case 4: return [2, {
|
3921
4051
|
instructions: __spreadArray([], instructions, true),
|
3922
4052
|
additionalSigners: additionalSigners
|
@@ -3925,7 +4055,7 @@ var PerpetualsClient = (function () {
|
|
3925
4055
|
});
|
3926
4056
|
}); };
|
3927
4057
|
this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3928
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward,
|
4058
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_20;
|
3929
4059
|
return __generator(this, function (_a) {
|
3930
4060
|
switch (_a.label) {
|
3931
4061
|
case 0:
|
@@ -3958,9 +4088,9 @@ var PerpetualsClient = (function () {
|
|
3958
4088
|
instructions.push(distributeReward);
|
3959
4089
|
return [3, 5];
|
3960
4090
|
case 4:
|
3961
|
-
|
3962
|
-
console.log("perpClient distributeReward error:: ",
|
3963
|
-
throw
|
4091
|
+
err_20 = _a.sent();
|
4092
|
+
console.log("perpClient distributeReward error:: ", err_20);
|
4093
|
+
throw err_20;
|
3964
4094
|
case 5: return [2, {
|
3965
4095
|
instructions: __spreadArray([], instructions, true),
|
3966
4096
|
additionalSigners: additionalSigners
|
@@ -3971,7 +4101,7 @@ var PerpetualsClient = (function () {
|
|
3971
4101
|
this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
3972
4102
|
if (createUserATA === void 0) { createUserATA = true; }
|
3973
4103
|
return __awaiter(_this, void 0, void 0, function () {
|
3974
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward,
|
4104
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_21;
|
3975
4105
|
return __generator(this, function (_b) {
|
3976
4106
|
switch (_b.label) {
|
3977
4107
|
case 0:
|
@@ -4025,8 +4155,8 @@ var PerpetualsClient = (function () {
|
|
4025
4155
|
instructions.push(collectNftReward);
|
4026
4156
|
return [3, 8];
|
4027
4157
|
case 7:
|
4028
|
-
|
4029
|
-
throw
|
4158
|
+
err_21 = _b.sent();
|
4159
|
+
throw err_21;
|
4030
4160
|
case 8: return [2, {
|
4031
4161
|
instructions: __spreadArray([], instructions, true),
|
4032
4162
|
additionalSigners: additionalSigners
|
@@ -4038,7 +4168,7 @@ var PerpetualsClient = (function () {
|
|
4038
4168
|
this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
4039
4169
|
if (createUserATA === void 0) { createUserATA = true; }
|
4040
4170
|
return __awaiter(_this, void 0, void 0, function () {
|
4041
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction,
|
4171
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_22;
|
4042
4172
|
return __generator(this, function (_b) {
|
4043
4173
|
switch (_b.label) {
|
4044
4174
|
case 0:
|
@@ -4102,9 +4232,9 @@ var PerpetualsClient = (function () {
|
|
4102
4232
|
instructions.push(withdrawStakeInstruction);
|
4103
4233
|
return [3, 6];
|
4104
4234
|
case 5:
|
4105
|
-
|
4106
|
-
console.log("perpClient withdrawStake error:: ",
|
4107
|
-
throw
|
4235
|
+
err_22 = _b.sent();
|
4236
|
+
console.log("perpClient withdrawStake error:: ", err_22);
|
4237
|
+
throw err_22;
|
4108
4238
|
case 6: return [2, {
|
4109
4239
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4110
4240
|
additionalSigners: additionalSigners
|
@@ -4114,7 +4244,7 @@ var PerpetualsClient = (function () {
|
|
4114
4244
|
});
|
4115
4245
|
};
|
4116
4246
|
this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4117
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice,
|
4247
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_23;
|
4118
4248
|
return __generator(this, function (_a) {
|
4119
4249
|
switch (_a.label) {
|
4120
4250
|
case 0:
|
@@ -4153,9 +4283,9 @@ var PerpetualsClient = (function () {
|
|
4153
4283
|
instructions.push(setTriggerPrice);
|
4154
4284
|
return [3, 4];
|
4155
4285
|
case 3:
|
4156
|
-
|
4157
|
-
console.log("perpClient setTriggerPrice error:: ",
|
4158
|
-
throw
|
4286
|
+
err_23 = _a.sent();
|
4287
|
+
console.log("perpClient setTriggerPrice error:: ", err_23);
|
4288
|
+
throw err_23;
|
4159
4289
|
case 4: return [2, {
|
4160
4290
|
instructions: __spreadArray([], instructions, true),
|
4161
4291
|
additionalSigners: additionalSigners
|
@@ -4167,7 +4297,7 @@ var PerpetualsClient = (function () {
|
|
4167
4297
|
if (createUserATA === void 0) { createUserATA = true; }
|
4168
4298
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
4169
4299
|
return __awaiter(_this, void 0, void 0, function () {
|
4170
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, forceClosePosition, closeWsolATAIns,
|
4300
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, forceClosePosition, closeWsolATAIns, err_24;
|
4171
4301
|
return __generator(this, function (_b) {
|
4172
4302
|
switch (_b.label) {
|
4173
4303
|
case 0:
|
@@ -4250,9 +4380,9 @@ var PerpetualsClient = (function () {
|
|
4250
4380
|
}
|
4251
4381
|
return [3, 10];
|
4252
4382
|
case 9:
|
4253
|
-
|
4254
|
-
console.log("perpClient forceClosePosition error:: ",
|
4255
|
-
throw
|
4383
|
+
err_24 = _b.sent();
|
4384
|
+
console.log("perpClient forceClosePosition error:: ", err_24);
|
4385
|
+
throw err_24;
|
4256
4386
|
case 10: return [2, {
|
4257
4387
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4258
4388
|
additionalSigners: additionalSigners
|
@@ -4262,7 +4392,7 @@ var PerpetualsClient = (function () {
|
|
4262
4392
|
});
|
4263
4393
|
};
|
4264
4394
|
this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4265
|
-
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData,
|
4395
|
+
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_25;
|
4266
4396
|
return __generator(this, function (_a) {
|
4267
4397
|
switch (_a.label) {
|
4268
4398
|
case 0:
|
@@ -4291,15 +4421,15 @@ var PerpetualsClient = (function () {
|
|
4291
4421
|
console.log(getPositionData);
|
4292
4422
|
return [2, getPositionData];
|
4293
4423
|
case 3:
|
4294
|
-
|
4295
|
-
console.log("perpClient setPool error:: ",
|
4296
|
-
throw
|
4424
|
+
err_25 = _a.sent();
|
4425
|
+
console.log("perpClient setPool error:: ", err_25);
|
4426
|
+
throw err_25;
|
4297
4427
|
case 4: return [2];
|
4298
4428
|
}
|
4299
4429
|
});
|
4300
4430
|
}); };
|
4301
4431
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4302
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
4432
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_26;
|
4303
4433
|
return __generator(this, function (_a) {
|
4304
4434
|
switch (_a.label) {
|
4305
4435
|
case 0:
|
@@ -4332,9 +4462,9 @@ var PerpetualsClient = (function () {
|
|
4332
4462
|
instructions.push(withdrawFeesIx);
|
4333
4463
|
return [3, 5];
|
4334
4464
|
case 4:
|
4335
|
-
|
4336
|
-
console.log("perpClient setPool error:: ",
|
4337
|
-
throw
|
4465
|
+
err_26 = _a.sent();
|
4466
|
+
console.log("perpClient setPool error:: ", err_26);
|
4467
|
+
throw err_26;
|
4338
4468
|
case 5: return [2, {
|
4339
4469
|
instructions: __spreadArray([], instructions, true),
|
4340
4470
|
additionalSigners: additionalSigners
|
@@ -4343,7 +4473,7 @@ var PerpetualsClient = (function () {
|
|
4343
4473
|
});
|
4344
4474
|
}); };
|
4345
4475
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
4346
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
4476
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_27;
|
4347
4477
|
return __generator(this, function (_a) {
|
4348
4478
|
switch (_a.label) {
|
4349
4479
|
case 0:
|
@@ -4370,9 +4500,9 @@ var PerpetualsClient = (function () {
|
|
4370
4500
|
instructions.push(setPermissionsInstruction);
|
4371
4501
|
return [3, 4];
|
4372
4502
|
case 3:
|
4373
|
-
|
4374
|
-
console.log("perpClient setPool error:: ",
|
4375
|
-
throw
|
4503
|
+
err_27 = _a.sent();
|
4504
|
+
console.log("perpClient setPool error:: ", err_27);
|
4505
|
+
throw err_27;
|
4376
4506
|
case 4: return [2, {
|
4377
4507
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4378
4508
|
additionalSigners: additionalSigners
|
@@ -4381,7 +4511,7 @@ var PerpetualsClient = (function () {
|
|
4381
4511
|
});
|
4382
4512
|
}); };
|
4383
4513
|
this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4384
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e,
|
4514
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_28;
|
4385
4515
|
var _f;
|
4386
4516
|
return __generator(this, function (_g) {
|
4387
4517
|
switch (_g.label) {
|
@@ -4442,9 +4572,9 @@ var PerpetualsClient = (function () {
|
|
4442
4572
|
instructions.push(reimburse);
|
4443
4573
|
return [3, 5];
|
4444
4574
|
case 4:
|
4445
|
-
|
4446
|
-
console.log("perpClient setPool error:: ",
|
4447
|
-
throw
|
4575
|
+
err_28 = _g.sent();
|
4576
|
+
console.log("perpClient setPool error:: ", err_28);
|
4577
|
+
throw err_28;
|
4448
4578
|
case 5: return [2, {
|
4449
4579
|
instructions: __spreadArray([], instructions, true),
|
4450
4580
|
additionalSigners: additionalSigners
|
@@ -4453,7 +4583,7 @@ var PerpetualsClient = (function () {
|
|
4453
4583
|
});
|
4454
4584
|
}); };
|
4455
4585
|
this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4456
|
-
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice,
|
4586
|
+
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_29;
|
4457
4587
|
return __generator(this, function (_a) {
|
4458
4588
|
switch (_a.label) {
|
4459
4589
|
case 0:
|
@@ -4486,9 +4616,259 @@ var PerpetualsClient = (function () {
|
|
4486
4616
|
instructions.push(setInternalOraclePrice);
|
4487
4617
|
return [3, 4];
|
4488
4618
|
case 3:
|
4489
|
-
|
4490
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
4491
|
-
throw
|
4619
|
+
err_29 = _a.sent();
|
4620
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_29);
|
4621
|
+
throw err_29;
|
4622
|
+
case 4: return [2, {
|
4623
|
+
instructions: __spreadArray([], instructions, true),
|
4624
|
+
additionalSigners: additionalSigners
|
4625
|
+
}];
|
4626
|
+
}
|
4627
|
+
});
|
4628
|
+
}); };
|
4629
|
+
this.addCompoundingLiquidity = function (amountIn, minSflpAmountOut, inTokenSymbol, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4630
|
+
var publicKey, instructions, additionalSigners, rewardCustody, inCustodyConfig, lpTokenMint, sFlpTokenMint, sflpTokenAccount, fundingAccount, compoundingVault, addCompoundingLiquidity, err_30;
|
4631
|
+
return __generator(this, function (_a) {
|
4632
|
+
switch (_a.label) {
|
4633
|
+
case 0:
|
4634
|
+
publicKey = this.provider.wallet.publicKey;
|
4635
|
+
instructions = [];
|
4636
|
+
additionalSigners = [];
|
4637
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
4638
|
+
inCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inTokenSymbol).mintKey); });
|
4639
|
+
lpTokenMint = poolConfig.lpTokenMint;
|
4640
|
+
sFlpTokenMint = poolConfig.sFlpTokenMint;
|
4641
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(sFlpTokenMint, publicKey)];
|
4642
|
+
case 1:
|
4643
|
+
sflpTokenAccount = _a.sent();
|
4644
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(inCustodyConfig.mintKey, publicKey)];
|
4645
|
+
case 2:
|
4646
|
+
fundingAccount = _a.sent();
|
4647
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), sFlpTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
4648
|
+
_a.label = 3;
|
4649
|
+
case 3:
|
4650
|
+
_a.trys.push([3, 5, , 6]);
|
4651
|
+
return [4, this.program.methods
|
4652
|
+
.addCompoundingLiquidity({
|
4653
|
+
amountIn: amountIn,
|
4654
|
+
minSflpAmountOut: minSflpAmountOut
|
4655
|
+
})
|
4656
|
+
.accounts({
|
4657
|
+
owner: publicKey,
|
4658
|
+
fundingAccount: fundingAccount,
|
4659
|
+
sflpTokenAccount: sflpTokenAccount,
|
4660
|
+
poolCompoundingFlpVault: compoundingVault,
|
4661
|
+
transferAuthority: poolConfig.transferAuthority,
|
4662
|
+
perpetuals: poolConfig.perpetuals,
|
4663
|
+
pool: poolConfig.poolAddress,
|
4664
|
+
inCustody: inCustodyConfig.custodyAccount,
|
4665
|
+
inCustodyOracleAccount: this.useExtOracleAccount ? inCustodyConfig.extOracleAccount : inCustodyConfig.intOracleAccount,
|
4666
|
+
inCustodyTokenAccount: inCustodyConfig.tokenAccount,
|
4667
|
+
rewardCustody: rewardCustody.custodyAccount,
|
4668
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
4669
|
+
lpTokenMint: lpTokenMint,
|
4670
|
+
sflpTokenMint: sFlpTokenMint,
|
4671
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
4672
|
+
eventAuthority: this.eventAuthority.publicKey,
|
4673
|
+
program: this.program.programId,
|
4674
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
4675
|
+
})
|
4676
|
+
.instruction()];
|
4677
|
+
case 4:
|
4678
|
+
addCompoundingLiquidity = _a.sent();
|
4679
|
+
instructions.push(addCompoundingLiquidity);
|
4680
|
+
return [3, 6];
|
4681
|
+
case 5:
|
4682
|
+
err_30 = _a.sent();
|
4683
|
+
console.log("perpClient addCompoundingLiquidity error:: ", err_30);
|
4684
|
+
return [3, 6];
|
4685
|
+
case 6: return [2, {
|
4686
|
+
instructions: __spreadArray([], instructions, true),
|
4687
|
+
additionalSigners: additionalSigners
|
4688
|
+
}];
|
4689
|
+
}
|
4690
|
+
});
|
4691
|
+
}); };
|
4692
|
+
this.removeCompoundingLiquidity = function (sflpAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4693
|
+
var publicKey, instructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, sFlpTokenMint, sflpTokenAccount, receivingAccount, compoundingVault, removeCompoundingLiquidity, err_31;
|
4694
|
+
return __generator(this, function (_a) {
|
4695
|
+
switch (_a.label) {
|
4696
|
+
case 0:
|
4697
|
+
publicKey = this.provider.wallet.publicKey;
|
4698
|
+
instructions = [];
|
4699
|
+
additionalSigners = [];
|
4700
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
4701
|
+
outCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outTokenSymbol).mintKey); });
|
4702
|
+
lpTokenMint = poolConfig.lpTokenMint;
|
4703
|
+
sFlpTokenMint = poolConfig.sFlpTokenMint;
|
4704
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(sFlpTokenMint, publicKey)];
|
4705
|
+
case 1:
|
4706
|
+
sflpTokenAccount = _a.sent();
|
4707
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(outCustodyConfig.mintKey, publicKey)];
|
4708
|
+
case 2:
|
4709
|
+
receivingAccount = _a.sent();
|
4710
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), sFlpTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
4711
|
+
_a.label = 3;
|
4712
|
+
case 3:
|
4713
|
+
_a.trys.push([3, 5, , 6]);
|
4714
|
+
return [4, this.program.methods
|
4715
|
+
.removeCompoundingLiquidity({
|
4716
|
+
sflpAmountIn: sflpAmountIn,
|
4717
|
+
minAmountOut: minAmountOut
|
4718
|
+
})
|
4719
|
+
.accounts({
|
4720
|
+
owner: publicKey,
|
4721
|
+
receivingAccount: receivingAccount,
|
4722
|
+
sflpTokenAccount: sflpTokenAccount,
|
4723
|
+
poolCompoundingFlpVault: compoundingVault,
|
4724
|
+
transferAuthority: poolConfig.transferAuthority,
|
4725
|
+
perpetuals: poolConfig.perpetuals,
|
4726
|
+
pool: poolConfig.poolAddress,
|
4727
|
+
outCustody: outCustodyConfig.custodyAccount,
|
4728
|
+
outCustodyOracleAccount: this.useExtOracleAccount ? outCustodyConfig.extOracleAccount : outCustodyConfig.intOracleAccount,
|
4729
|
+
outCustodyTokenAccount: outCustodyConfig.tokenAccount,
|
4730
|
+
rewardCustody: rewardCustody.custodyAccount,
|
4731
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
4732
|
+
lpTokenMint: lpTokenMint,
|
4733
|
+
sflpTokenMint: sFlpTokenMint,
|
4734
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
4735
|
+
eventAuthority: this.eventAuthority.publicKey,
|
4736
|
+
program: this.program.programId,
|
4737
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
4738
|
+
})
|
4739
|
+
.instruction()];
|
4740
|
+
case 4:
|
4741
|
+
removeCompoundingLiquidity = _a.sent();
|
4742
|
+
instructions.push(removeCompoundingLiquidity);
|
4743
|
+
return [3, 6];
|
4744
|
+
case 5:
|
4745
|
+
err_31 = _a.sent();
|
4746
|
+
console.log("perpClient removeCompoundingLiquidity error:: ", err_31);
|
4747
|
+
return [3, 6];
|
4748
|
+
case 6: return [2, {
|
4749
|
+
instructions: __spreadArray([], instructions, true),
|
4750
|
+
additionalSigners: additionalSigners
|
4751
|
+
}];
|
4752
|
+
}
|
4753
|
+
});
|
4754
|
+
}); };
|
4755
|
+
this.migrateStake = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4756
|
+
var publicKey, instructions, additionalSigners, rewardCustody, lpTokenMint, sFlpTokenMint, sflpTokenAccount, flpStakeAccount, compoundingVault, poolStakedFlpVault, migrateStake, err_32;
|
4757
|
+
return __generator(this, function (_a) {
|
4758
|
+
switch (_a.label) {
|
4759
|
+
case 0:
|
4760
|
+
publicKey = this.provider.wallet.publicKey;
|
4761
|
+
instructions = [];
|
4762
|
+
additionalSigners = [];
|
4763
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
4764
|
+
lpTokenMint = poolConfig.lpTokenMint;
|
4765
|
+
sFlpTokenMint = poolConfig.sFlpTokenMint;
|
4766
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(sFlpTokenMint, publicKey)];
|
4767
|
+
case 1:
|
4768
|
+
sflpTokenAccount = _a.sent();
|
4769
|
+
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
4770
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), sFlpTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
4771
|
+
poolStakedFlpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
4772
|
+
_a.label = 2;
|
4773
|
+
case 2:
|
4774
|
+
_a.trys.push([2, 4, , 5]);
|
4775
|
+
return [4, this.program.methods
|
4776
|
+
.migrateStake({
|
4777
|
+
amount: amount
|
4778
|
+
})
|
4779
|
+
.accounts({
|
4780
|
+
owner: publicKey,
|
4781
|
+
sflpTokenAccount: sflpTokenAccount,
|
4782
|
+
transferAuthority: poolConfig.transferAuthority,
|
4783
|
+
perpetuals: poolConfig.perpetuals,
|
4784
|
+
pool: poolConfig.poolAddress,
|
4785
|
+
flpStakeAccount: flpStakeAccount,
|
4786
|
+
rewardCustody: rewardCustody.custodyAccount,
|
4787
|
+
poolStakedFlpVault: poolStakedFlpVault,
|
4788
|
+
poolCompoundingFlpVault: compoundingVault,
|
4789
|
+
sflpTokenMint: sFlpTokenMint,
|
4790
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
4791
|
+
})
|
4792
|
+
.instruction()];
|
4793
|
+
case 3:
|
4794
|
+
migrateStake = _a.sent();
|
4795
|
+
instructions.push(migrateStake);
|
4796
|
+
return [3, 5];
|
4797
|
+
case 4:
|
4798
|
+
err_32 = _a.sent();
|
4799
|
+
console.log("perpClient migrateStake error:: ", err_32);
|
4800
|
+
return [3, 5];
|
4801
|
+
case 5: return [2, {
|
4802
|
+
instructions: __spreadArray([], instructions, true),
|
4803
|
+
additionalSigners: additionalSigners
|
4804
|
+
}];
|
4805
|
+
}
|
4806
|
+
});
|
4807
|
+
}); };
|
4808
|
+
this.compoundingFee = function (rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4809
|
+
var publicKey, instructions, additionalSigners, rewardCustody, lpTokenMint, sFlpTokenMint, compoundingVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_33;
|
4810
|
+
return __generator(this, function (_d) {
|
4811
|
+
switch (_d.label) {
|
4812
|
+
case 0:
|
4813
|
+
publicKey = this.provider.wallet.publicKey;
|
4814
|
+
instructions = [];
|
4815
|
+
additionalSigners = [];
|
4816
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
4817
|
+
lpTokenMint = poolConfig.lpTokenMint;
|
4818
|
+
sFlpTokenMint = poolConfig.sFlpTokenMint;
|
4819
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), sFlpTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
4820
|
+
custodyAccountMetas = [];
|
4821
|
+
custodyOracleAccountMetas = [];
|
4822
|
+
markets = [];
|
4823
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
4824
|
+
custody = _a[_i];
|
4825
|
+
custodyAccountMetas.push({
|
4826
|
+
pubkey: custody.custodyAccount,
|
4827
|
+
isSigner: false,
|
4828
|
+
isWritable: false,
|
4829
|
+
});
|
4830
|
+
custodyOracleAccountMetas.push({
|
4831
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
4832
|
+
isSigner: false,
|
4833
|
+
isWritable: false,
|
4834
|
+
});
|
4835
|
+
}
|
4836
|
+
for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
|
4837
|
+
market = _c[_b];
|
4838
|
+
markets.push({
|
4839
|
+
pubkey: market.marketAccount,
|
4840
|
+
isSigner: false,
|
4841
|
+
isWritable: false,
|
4842
|
+
});
|
4843
|
+
}
|
4844
|
+
_d.label = 1;
|
4845
|
+
case 1:
|
4846
|
+
_d.trys.push([1, 3, , 4]);
|
4847
|
+
return [4, this.program.methods
|
4848
|
+
.compoundFees({})
|
4849
|
+
.accounts({
|
4850
|
+
poolCompoundingFlpVault: compoundingVault,
|
4851
|
+
transferAuthority: poolConfig.transferAuthority,
|
4852
|
+
perpetuals: poolConfig.perpetuals,
|
4853
|
+
pool: poolConfig.poolAddress,
|
4854
|
+
rewardCustody: rewardCustody.custodyAccount,
|
4855
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
4856
|
+
lpTokenMint: lpTokenMint,
|
4857
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
4858
|
+
eventAuthority: this.eventAuthority.publicKey,
|
4859
|
+
program: this.program.programId,
|
4860
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
4861
|
+
})
|
4862
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
4863
|
+
.instruction()];
|
4864
|
+
case 2:
|
4865
|
+
compoundingFee = _d.sent();
|
4866
|
+
instructions.push(compoundingFee);
|
4867
|
+
return [3, 4];
|
4868
|
+
case 3:
|
4869
|
+
err_33 = _d.sent();
|
4870
|
+
console.log("perpClient compoundingFee error:: ", err_33);
|
4871
|
+
return [3, 4];
|
4492
4872
|
case 4: return [2, {
|
4493
4873
|
instructions: __spreadArray([], instructions, true),
|
4494
4874
|
additionalSigners: additionalSigners
|
@@ -4497,7 +4877,7 @@ var PerpetualsClient = (function () {
|
|
4497
4877
|
});
|
4498
4878
|
}); };
|
4499
4879
|
this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4500
|
-
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault,
|
4880
|
+
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_34;
|
4501
4881
|
return __generator(this, function (_a) {
|
4502
4882
|
switch (_a.label) {
|
4503
4883
|
case 0:
|
@@ -4531,9 +4911,9 @@ var PerpetualsClient = (function () {
|
|
4531
4911
|
instructions.push(initRewardVault);
|
4532
4912
|
return [3, 4];
|
4533
4913
|
case 3:
|
4534
|
-
|
4535
|
-
console.log("rewardDistribution InitRewardVault error:: ",
|
4536
|
-
throw
|
4914
|
+
err_34 = _a.sent();
|
4915
|
+
console.log("rewardDistribution InitRewardVault error:: ", err_34);
|
4916
|
+
throw err_34;
|
4537
4917
|
case 4: return [2, {
|
4538
4918
|
instructions: __spreadArray([], instructions, true),
|
4539
4919
|
additionalSigners: additionalSigners
|
@@ -4542,7 +4922,7 @@ var PerpetualsClient = (function () {
|
|
4542
4922
|
});
|
4543
4923
|
}); };
|
4544
4924
|
this.rewardDistribution = function (counter, owner, rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4545
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward,
|
4925
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_35;
|
4546
4926
|
return __generator(this, function (_a) {
|
4547
4927
|
switch (_a.label) {
|
4548
4928
|
case 0:
|
@@ -4583,9 +4963,9 @@ var PerpetualsClient = (function () {
|
|
4583
4963
|
instructions.push(distributeReward);
|
4584
4964
|
return [3, 5];
|
4585
4965
|
case 4:
|
4586
|
-
|
4587
|
-
console.log("rewardDistribution distributeReward error:: ",
|
4588
|
-
throw
|
4966
|
+
err_35 = _a.sent();
|
4967
|
+
console.log("rewardDistribution distributeReward error:: ", err_35);
|
4968
|
+
throw err_35;
|
4589
4969
|
case 5: return [2, {
|
4590
4970
|
instructions: __spreadArray([], instructions, true),
|
4591
4971
|
additionalSigners: additionalSigners
|
@@ -4596,7 +4976,7 @@ var PerpetualsClient = (function () {
|
|
4596
4976
|
this.collectReward = function (counter, owner, rewardSymbol, poolConfig, createUserATA) {
|
4597
4977
|
if (createUserATA === void 0) { createUserATA = true; }
|
4598
4978
|
return __awaiter(_this, void 0, void 0, function () {
|
4599
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectNftReward,
|
4979
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectNftReward, err_36;
|
4600
4980
|
return __generator(this, function (_b) {
|
4601
4981
|
switch (_b.label) {
|
4602
4982
|
case 0:
|
@@ -4644,8 +5024,8 @@ var PerpetualsClient = (function () {
|
|
4644
5024
|
instructions.push(collectNftReward);
|
4645
5025
|
return [3, 7];
|
4646
5026
|
case 6:
|
4647
|
-
|
4648
|
-
throw
|
5027
|
+
err_36 = _b.sent();
|
5028
|
+
throw err_36;
|
4649
5029
|
case 7: return [2, {
|
4650
5030
|
instructions: __spreadArray([], instructions, true),
|
4651
5031
|
additionalSigners: additionalSigners
|