flash-sdk 2.11.12 → 2.12.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 +76 -76
- package/dist/PerpetualsClient.js +153 -152
- package/dist/PoolAccount.d.ts +8 -8
- package/dist/PoolConfig.d.ts +5 -5
- package/dist/PoolConfig.js +6 -6
- package/dist/PoolConfig.json +40 -40
- package/dist/idl/perp_composability.d.ts +1 -1
- package/dist/idl/perp_composability.js +1 -1
- package/dist/idl/perpetuals.d.ts +48 -62
- package/dist/idl/perpetuals.js +48 -62
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
@@ -603,7 +603,7 @@ var PerpetualsClient = (function () {
|
|
603
603
|
.accounts({
|
604
604
|
perpetuals: this.perpetuals.publicKey,
|
605
605
|
pool: poolConfig.poolAddress,
|
606
|
-
lpTokenMint: poolConfig.
|
606
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
607
607
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
608
608
|
})
|
609
609
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
@@ -650,7 +650,7 @@ var PerpetualsClient = (function () {
|
|
650
650
|
.accounts({
|
651
651
|
perpetuals: this.perpetuals.publicKey,
|
652
652
|
pool: poolConfig.poolAddress,
|
653
|
-
lpTokenMint: poolConfig.
|
653
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
654
654
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
655
655
|
})
|
656
656
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
@@ -697,7 +697,7 @@ var PerpetualsClient = (function () {
|
|
697
697
|
.accounts({
|
698
698
|
perpetuals: this.perpetuals.publicKey,
|
699
699
|
pool: poolConfig.poolAddress,
|
700
|
-
lpTokenMint: poolConfig.
|
700
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
701
701
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
702
702
|
})
|
703
703
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
@@ -3135,7 +3135,7 @@ var PerpetualsClient = (function () {
|
|
3135
3135
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(payTokenCustodyConfig.mintKey, publicKey)];
|
3136
3136
|
case 2:
|
3137
3137
|
userPayingTokenAccount = _f.sent();
|
3138
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.
|
3138
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.stakedLpTokenMint, publicKey)];
|
3139
3139
|
case 3:
|
3140
3140
|
lpTokenAccount = _f.sent();
|
3141
3141
|
custodyAccountMetas = [];
|
@@ -3165,7 +3165,7 @@ var PerpetualsClient = (function () {
|
|
3165
3165
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
3166
3166
|
case 4:
|
3167
3167
|
if (!(_f.sent())) {
|
3168
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.
|
3168
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
3169
3169
|
}
|
3170
3170
|
if (!(payTokenSymbol == 'SOL')) return [3, 7];
|
3171
3171
|
console.log("payTokenSymbol === SOL", payTokenSymbol);
|
@@ -3226,7 +3226,7 @@ var PerpetualsClient = (function () {
|
|
3226
3226
|
custody: payTokenCustodyConfig.custodyAccount,
|
3227
3227
|
custodyOracleAccount: this.useExtOracleAccount ? payTokenCustodyConfig.extOracleAccount : payTokenCustodyConfig.intOracleAccount,
|
3228
3228
|
custodyTokenAccount: payTokenCustodyConfig.tokenAccount,
|
3229
|
-
lpTokenMint: poolConfig.
|
3229
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
3230
3230
|
eventAuthority: this.eventAuthority.publicKey,
|
3231
3231
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3232
3232
|
program: this.programId,
|
@@ -3253,7 +3253,7 @@ var PerpetualsClient = (function () {
|
|
3253
3253
|
this.addLiquidityAndStake = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks) {
|
3254
3254
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3255
3255
|
return __awaiter(_this, void 0, void 0, function () {
|
3256
|
-
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount,
|
3256
|
+
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, instruction;
|
3257
3257
|
return __generator(this, function (_f) {
|
3258
3258
|
switch (_f.label) {
|
3259
3259
|
case 0:
|
@@ -3262,13 +3262,13 @@ var PerpetualsClient = (function () {
|
|
3262
3262
|
instructions = [];
|
3263
3263
|
postInstructions = [];
|
3264
3264
|
additionalSigners = [];
|
3265
|
-
lpTokenMint = poolConfig.
|
3265
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
3266
3266
|
inputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inputSymbol).mintKey); });
|
3267
3267
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(lpTokenMint, publicKey)];
|
3268
3268
|
case 1:
|
3269
3269
|
lpTokenAccount = _f.sent();
|
3270
3270
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
3271
|
-
|
3271
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
3272
3272
|
if (!(inputSymbol == 'SOL')) return [3, 5];
|
3273
3273
|
console.log("inputSymbol === SOL", inputSymbol);
|
3274
3274
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -3288,7 +3288,7 @@ var PerpetualsClient = (function () {
|
|
3288
3288
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
3289
3289
|
case 4:
|
3290
3290
|
if (!(_f.sent())) {
|
3291
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.
|
3291
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
3292
3292
|
}
|
3293
3293
|
preInstructions = [
|
3294
3294
|
web3_js_1.SystemProgram.createAccount({
|
@@ -3361,7 +3361,7 @@ var PerpetualsClient = (function () {
|
|
3361
3361
|
custodyTokenAccount: inputCustodyConfig.tokenAccount,
|
3362
3362
|
lpTokenMint: lpTokenMint,
|
3363
3363
|
flpStakeAccount: flpStakeAccount,
|
3364
|
-
|
3364
|
+
poolStakedLpVault: poolStakedLpVault,
|
3365
3365
|
systemProgram: web3_js_1.SystemProgram.programId,
|
3366
3366
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3367
3367
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -3384,7 +3384,7 @@ var PerpetualsClient = (function () {
|
|
3384
3384
|
this.addLiquidityAndStakeComposibility = function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks) {
|
3385
3385
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3386
3386
|
return __awaiter(_this, void 0, void 0, function () {
|
3387
|
-
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount,
|
3387
|
+
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, stakedLpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, instruction;
|
3388
3388
|
return __generator(this, function (_f) {
|
3389
3389
|
switch (_f.label) {
|
3390
3390
|
case 0:
|
@@ -3393,13 +3393,13 @@ var PerpetualsClient = (function () {
|
|
3393
3393
|
instructions = [];
|
3394
3394
|
postInstructions = [];
|
3395
3395
|
additionalSigners = [];
|
3396
|
-
|
3396
|
+
stakedLpTokenMint = poolConfig.stakedLpTokenMint;
|
3397
3397
|
inputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inputSymbol).mintKey); });
|
3398
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
3398
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(stakedLpTokenMint, publicKey)];
|
3399
3399
|
case 1:
|
3400
3400
|
lpTokenAccount = _f.sent();
|
3401
3401
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
3402
|
-
|
3402
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), stakedLpTokenMint.toBuffer()], this.programId)[0];
|
3403
3403
|
if (!(inputSymbol == 'SOL')) return [3, 5];
|
3404
3404
|
console.log("inputSymbol === SOL", inputSymbol);
|
3405
3405
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -3419,7 +3419,7 @@ var PerpetualsClient = (function () {
|
|
3419
3419
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
3420
3420
|
case 4:
|
3421
3421
|
if (!(_f.sent())) {
|
3422
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.
|
3422
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
3423
3423
|
}
|
3424
3424
|
preInstructions = [
|
3425
3425
|
web3_js_1.SystemProgram.createAccount({
|
@@ -3492,9 +3492,9 @@ var PerpetualsClient = (function () {
|
|
3492
3492
|
custody: inputCustodyConfig.custodyAccount,
|
3493
3493
|
custodyOracleAccount: this.useExtOracleAccount ? inputCustodyConfig.extOracleAccount : inputCustodyConfig.intOracleAccount,
|
3494
3494
|
custodyTokenAccount: inputCustodyConfig.tokenAccount,
|
3495
|
-
lpTokenMint:
|
3495
|
+
lpTokenMint: stakedLpTokenMint,
|
3496
3496
|
flpStakeAccount: flpStakeAccount,
|
3497
|
-
|
3497
|
+
poolStakedLpVault: poolStakedLpVault,
|
3498
3498
|
systemProgram: web3_js_1.SystemProgram.programId,
|
3499
3499
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3500
3500
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -3518,7 +3518,7 @@ var PerpetualsClient = (function () {
|
|
3518
3518
|
if (createUserATA === void 0) { createUserATA = true; }
|
3519
3519
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
3520
3520
|
return __awaiter(_this, void 0, void 0, function () {
|
3521
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners,
|
3521
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns, err_5;
|
3522
3522
|
return __generator(this, function (_e) {
|
3523
3523
|
switch (_e.label) {
|
3524
3524
|
case 0:
|
@@ -3534,9 +3534,9 @@ var PerpetualsClient = (function () {
|
|
3534
3534
|
_e.label = 1;
|
3535
3535
|
case 1:
|
3536
3536
|
_e.trys.push([1, 10, , 11]);
|
3537
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.
|
3537
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.stakedLpTokenMint, publicKey)];
|
3538
3538
|
case 2:
|
3539
|
-
|
3539
|
+
stakedLpTokenAccount = _e.sent();
|
3540
3540
|
custodyAccountMetas = [];
|
3541
3541
|
custodyOracleAccountMetas = [];
|
3542
3542
|
markets = [];
|
@@ -3606,14 +3606,14 @@ var PerpetualsClient = (function () {
|
|
3606
3606
|
.accounts({
|
3607
3607
|
owner: publicKey,
|
3608
3608
|
receivingAccount: recieveTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
|
3609
|
-
lpTokenAccount:
|
3609
|
+
lpTokenAccount: stakedLpTokenAccount,
|
3610
3610
|
transferAuthority: poolConfig.transferAuthority,
|
3611
3611
|
perpetuals: poolConfig.perpetuals,
|
3612
3612
|
pool: poolConfig.poolAddress,
|
3613
3613
|
custody: recieveTokenCustodyConfig.custodyAccount,
|
3614
3614
|
custodyOracleAccount: this.useExtOracleAccount ? recieveTokenCustodyConfig.extOracleAccount : recieveTokenCustodyConfig.intOracleAccount,
|
3615
3615
|
custodyTokenAccount: recieveTokenCustodyConfig.tokenAccount,
|
3616
|
-
lpTokenMint: poolConfig.
|
3616
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
3617
3617
|
eventAuthority: this.eventAuthority.publicKey,
|
3618
3618
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3619
3619
|
program: this.programId,
|
@@ -3625,7 +3625,7 @@ var PerpetualsClient = (function () {
|
|
3625
3625
|
removeLiquidityTx = _e.sent();
|
3626
3626
|
instructions.push(removeLiquidityTx);
|
3627
3627
|
if (closeLpATA) {
|
3628
|
-
closeInx = (0, spl_token_1.createCloseAccountInstruction)(
|
3628
|
+
closeInx = (0, spl_token_1.createCloseAccountInstruction)(stakedLpTokenAccount, publicKey, publicKey);
|
3629
3629
|
instructions.push(closeInx);
|
3630
3630
|
}
|
3631
3631
|
if (recieveTokenSymbol == 'WSOL' && closeUsersWSOLATA) {
|
@@ -3858,7 +3858,7 @@ var PerpetualsClient = (function () {
|
|
3858
3858
|
_a.label = 1;
|
3859
3859
|
case 1:
|
3860
3860
|
_a.trys.push([1, 3, , 4]);
|
3861
|
-
lpTokenMint = poolConfig.
|
3861
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
3862
3862
|
stakedLpTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
3863
3863
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
3864
3864
|
return [4, this.program.methods
|
@@ -3909,7 +3909,7 @@ var PerpetualsClient = (function () {
|
|
3909
3909
|
_a.trys.push([1, 3, , 4]);
|
3910
3910
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
3911
3911
|
compoundingTokenMint = this.getPoolCompoundingTokenKey(poolConfig.poolName);
|
3912
|
-
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), poolConfig.
|
3912
|
+
compoundingVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), poolConfig.stakedLpTokenMint.toBuffer()], this.programId)[0];
|
3913
3913
|
metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), compoundingTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
3914
3914
|
return [4, this.program.methods
|
3915
3915
|
.initCompounding({
|
@@ -3925,7 +3925,7 @@ var PerpetualsClient = (function () {
|
|
3925
3925
|
perpetuals: this.perpetuals.publicKey,
|
3926
3926
|
pool: poolConfig.poolAddress,
|
3927
3927
|
custody: rewardCustodyConfig.custodyAccount,
|
3928
|
-
lpTokenMint: poolConfig.
|
3928
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
3929
3929
|
compoundingVault: compoundingVault,
|
3930
3930
|
compoundingTokenMint: compoundingTokenMint,
|
3931
3931
|
metadataAccount: metadataAccount,
|
@@ -3951,7 +3951,7 @@ var PerpetualsClient = (function () {
|
|
3951
3951
|
});
|
3952
3952
|
}); };
|
3953
3953
|
this.depositStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3954
|
-
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint,
|
3954
|
+
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_12;
|
3955
3955
|
return __generator(this, function (_a) {
|
3956
3956
|
switch (_a.label) {
|
3957
3957
|
case 0:
|
@@ -3962,10 +3962,10 @@ var PerpetualsClient = (function () {
|
|
3962
3962
|
_a.label = 1;
|
3963
3963
|
case 1:
|
3964
3964
|
_a.trys.push([1, 4, , 5]);
|
3965
|
-
lpTokenMint = poolConfig.
|
3966
|
-
|
3965
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
3966
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
3967
3967
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), owner.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
3968
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.
|
3968
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.stakedLpTokenMint, owner)];
|
3969
3969
|
case 2:
|
3970
3970
|
userLpTokenAccount = _a.sent();
|
3971
3971
|
return [4, this.program.methods
|
@@ -3975,12 +3975,12 @@ var PerpetualsClient = (function () {
|
|
3975
3975
|
.accounts({
|
3976
3976
|
owner: owner,
|
3977
3977
|
feePayer: feePayer,
|
3978
|
-
|
3978
|
+
fundingLpTokenAccount: userLpTokenAccount,
|
3979
3979
|
transferAuthority: poolConfig.transferAuthority,
|
3980
3980
|
perpetuals: this.perpetuals.publicKey,
|
3981
3981
|
pool: poolConfig.poolAddress,
|
3982
3982
|
flpStakeAccount: flpStakeAccount,
|
3983
|
-
|
3983
|
+
poolStakedLpVault: poolStakedLpVault,
|
3984
3984
|
systemProgram: web3_js_1.SystemProgram.programId,
|
3985
3985
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3986
3986
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -4091,7 +4091,7 @@ var PerpetualsClient = (function () {
|
|
4091
4091
|
});
|
4092
4092
|
}); };
|
4093
4093
|
this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4094
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount,
|
4094
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, flpStakeAccount, unstakeInstantInstruction, err_14;
|
4095
4095
|
return __generator(this, function (_a) {
|
4096
4096
|
switch (_a.label) {
|
4097
4097
|
case 0:
|
@@ -4107,7 +4107,6 @@ var PerpetualsClient = (function () {
|
|
4107
4107
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
4108
4108
|
pool = poolConfig.poolAddress;
|
4109
4109
|
feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
|
4110
|
-
lpTokenMint = poolConfig.lpTokenMint;
|
4111
4110
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.programId)[0];
|
4112
4111
|
return [4, this.program.methods
|
4113
4112
|
.unstakeInstant({
|
@@ -4239,7 +4238,7 @@ var PerpetualsClient = (function () {
|
|
4239
4238
|
if (deactivated === void 0) { deactivated = true; }
|
4240
4239
|
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
4241
4240
|
return __awaiter(_this, void 0, void 0, function () {
|
4242
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool,
|
4241
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_17;
|
4243
4242
|
return __generator(this, function (_b) {
|
4244
4243
|
switch (_b.label) {
|
4245
4244
|
case 0:
|
@@ -4251,11 +4250,11 @@ var PerpetualsClient = (function () {
|
|
4251
4250
|
_b.label = 1;
|
4252
4251
|
case 1:
|
4253
4252
|
_b.trys.push([1, 6, , 7]);
|
4254
|
-
lpTokenMint = poolConfig.
|
4253
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
4255
4254
|
pool = poolConfig.poolAddress;
|
4256
|
-
|
4255
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), pool.toBuffer(), lpTokenMint.toBuffer()], this.program.programId)[0];
|
4257
4256
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.program.programId)[0];
|
4258
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.
|
4257
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.stakedLpTokenMint, publicKey)];
|
4259
4258
|
case 2:
|
4260
4259
|
userLpTokenAccount = _b.sent();
|
4261
4260
|
_a = createUserLPTA;
|
@@ -4266,7 +4265,7 @@ var PerpetualsClient = (function () {
|
|
4266
4265
|
_b.label = 4;
|
4267
4266
|
case 4:
|
4268
4267
|
if (_a) {
|
4269
|
-
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userLpTokenAccount, publicKey, poolConfig.
|
4268
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userLpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
4270
4269
|
}
|
4271
4270
|
return [4, this.program.methods
|
4272
4271
|
.withdrawStake({
|
@@ -4275,12 +4274,12 @@ var PerpetualsClient = (function () {
|
|
4275
4274
|
})
|
4276
4275
|
.accounts({
|
4277
4276
|
owner: publicKey,
|
4278
|
-
|
4277
|
+
receivingLpTokenAccount: userLpTokenAccount,
|
4279
4278
|
transferAuthority: poolConfig.transferAuthority,
|
4280
4279
|
perpetuals: this.perpetuals.publicKey,
|
4281
4280
|
pool: pool,
|
4282
4281
|
flpStakeAccount: flpStakeAccount,
|
4283
|
-
|
4282
|
+
poolStakedLpVault: poolStakedLpVault,
|
4284
4283
|
systemProgram: web3_js_1.SystemProgram.programId,
|
4285
4284
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
4286
4285
|
eventAuthority: this.eventAuthority.publicKey,
|
@@ -5004,8 +5003,8 @@ var PerpetualsClient = (function () {
|
|
5004
5003
|
}
|
5005
5004
|
});
|
5006
5005
|
}); };
|
5007
|
-
this.addCompoundingLiquidity = function (amountIn,
|
5008
|
-
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint,
|
5006
|
+
this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5007
|
+
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, accCreationLamports, lamports, unWrappedSolBalance, _d, compoundingLpVault, addCompoundingLiquidity, err_30;
|
5009
5008
|
return __generator(this, function (_e) {
|
5010
5009
|
switch (_e.label) {
|
5011
5010
|
case 0:
|
@@ -5016,14 +5015,14 @@ var PerpetualsClient = (function () {
|
|
5016
5015
|
postInstructions = [];
|
5017
5016
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
5018
5017
|
inCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inTokenSymbol).mintKey); });
|
5019
|
-
lpTokenMint = poolConfig.
|
5020
|
-
|
5021
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.
|
5018
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
5019
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
5020
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.stakedLpTokenMint, publicKey)];
|
5022
5021
|
case 1:
|
5023
5022
|
lpTokenAccount = _e.sent();
|
5024
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
5023
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
5025
5024
|
case 2:
|
5026
|
-
|
5025
|
+
compoundingTokenAccount = _e.sent();
|
5027
5026
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(inCustodyConfig.mintKey, publicKey)];
|
5028
5027
|
case 3:
|
5029
5028
|
fundingAccount = _e.sent();
|
@@ -5054,12 +5053,12 @@ var PerpetualsClient = (function () {
|
|
5054
5053
|
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
5055
5054
|
case 4:
|
5056
5055
|
if (!(_e.sent())) {
|
5057
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.
|
5056
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
5058
5057
|
}
|
5059
|
-
return [4, (0, utils_1.checkIfAccountExists)(
|
5058
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
5060
5059
|
case 5:
|
5061
5060
|
if (!(_e.sent())) {
|
5062
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey,
|
5061
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
5063
5062
|
}
|
5064
5063
|
if (!(inTokenSymbol == 'SOL')) return [3, 8];
|
5065
5064
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
@@ -5098,20 +5097,20 @@ var PerpetualsClient = (function () {
|
|
5098
5097
|
}
|
5099
5098
|
_e.label = 10;
|
5100
5099
|
case 10:
|
5101
|
-
|
5100
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
5102
5101
|
_e.label = 11;
|
5103
5102
|
case 11:
|
5104
5103
|
_e.trys.push([11, 13, , 14]);
|
5105
5104
|
return [4, this.program.methods
|
5106
5105
|
.addCompoundingLiquidity({
|
5107
5106
|
amountIn: amountIn,
|
5108
|
-
|
5107
|
+
minCompoundingAmountOut: minCompoundingAmountOut
|
5109
5108
|
})
|
5110
5109
|
.accounts({
|
5111
5110
|
owner: publicKey,
|
5112
5111
|
fundingAccount: fundingAccount,
|
5113
|
-
|
5114
|
-
|
5112
|
+
compoundingTokenAccount: compoundingTokenAccount,
|
5113
|
+
poolCompoundingLpVault: compoundingLpVault,
|
5115
5114
|
transferAuthority: poolConfig.transferAuthority,
|
5116
5115
|
perpetuals: poolConfig.perpetuals,
|
5117
5116
|
pool: poolConfig.poolAddress,
|
@@ -5121,7 +5120,7 @@ var PerpetualsClient = (function () {
|
|
5121
5120
|
rewardCustody: rewardCustody.custodyAccount,
|
5122
5121
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
5123
5122
|
lpTokenMint: lpTokenMint,
|
5124
|
-
|
5123
|
+
compoundingTokenMint: compoundingTokenMint,
|
5125
5124
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5126
5125
|
eventAuthority: this.eventAuthority.publicKey,
|
5127
5126
|
program: this.program.programId,
|
@@ -5144,10 +5143,10 @@ var PerpetualsClient = (function () {
|
|
5144
5143
|
}
|
5145
5144
|
});
|
5146
5145
|
}); };
|
5147
|
-
this.removeCompoundingLiquidity = function (
|
5146
|
+
this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA) {
|
5148
5147
|
if (createUserATA === void 0) { createUserATA = true; }
|
5149
5148
|
return __awaiter(_this, void 0, void 0, function () {
|
5150
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint,
|
5149
|
+
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, receivingAccount, compoundingLpVault, removeCompoundingLiquidity, err_31;
|
5151
5150
|
return __generator(this, function (_e) {
|
5152
5151
|
switch (_e.label) {
|
5153
5152
|
case 0:
|
@@ -5158,8 +5157,8 @@ var PerpetualsClient = (function () {
|
|
5158
5157
|
additionalSigners = [];
|
5159
5158
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
5160
5159
|
outCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outTokenSymbol).mintKey); });
|
5161
|
-
lpTokenMint = poolConfig.
|
5162
|
-
|
5160
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
5161
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
5163
5162
|
if (!(outCustodyConfig.symbol == 'SOL')) return [3, 2];
|
5164
5163
|
wrappedSolAccount = new web3_js_1.Keypair();
|
5165
5164
|
userReceivingTokenAccount = wrappedSolAccount.publicKey;
|
@@ -5220,26 +5219,26 @@ var PerpetualsClient = (function () {
|
|
5220
5219
|
isWritable: false,
|
5221
5220
|
});
|
5222
5221
|
}
|
5223
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
5222
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
5224
5223
|
case 7:
|
5225
|
-
|
5224
|
+
compoundingTokenAccount = _e.sent();
|
5226
5225
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(outCustodyConfig.mintKey, publicKey)];
|
5227
5226
|
case 8:
|
5228
5227
|
receivingAccount = _e.sent();
|
5229
|
-
|
5228
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
5230
5229
|
_e.label = 9;
|
5231
5230
|
case 9:
|
5232
5231
|
_e.trys.push([9, 11, , 12]);
|
5233
5232
|
return [4, this.program.methods
|
5234
5233
|
.removeCompoundingLiquidity({
|
5235
|
-
|
5234
|
+
compoundingAmountIn: compoundingAmountIn,
|
5236
5235
|
minAmountOut: minAmountOut
|
5237
5236
|
})
|
5238
5237
|
.accounts({
|
5239
5238
|
owner: publicKey,
|
5240
5239
|
receivingAccount: outCustodyConfig.symbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
|
5241
|
-
|
5242
|
-
|
5240
|
+
compoundingTokenAccount: compoundingTokenAccount,
|
5241
|
+
poolCompoundingLpVault: compoundingLpVault,
|
5243
5242
|
transferAuthority: poolConfig.transferAuthority,
|
5244
5243
|
perpetuals: poolConfig.perpetuals,
|
5245
5244
|
pool: poolConfig.poolAddress,
|
@@ -5249,7 +5248,7 @@ var PerpetualsClient = (function () {
|
|
5249
5248
|
rewardCustody: rewardCustody.custodyAccount,
|
5250
5249
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
5251
5250
|
lpTokenMint: lpTokenMint,
|
5252
|
-
|
5251
|
+
compoundingTokenMint: compoundingTokenMint,
|
5253
5252
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5254
5253
|
eventAuthority: this.eventAuthority.publicKey,
|
5255
5254
|
program: this.program.programId,
|
@@ -5276,7 +5275,7 @@ var PerpetualsClient = (function () {
|
|
5276
5275
|
this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
5277
5276
|
if (createUserATA === void 0) { createUserATA = true; }
|
5278
5277
|
return __awaiter(_this, void 0, void 0, function () {
|
5279
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint,
|
5278
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, compoundingLpVault, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_32;
|
5280
5279
|
return __generator(this, function (_e) {
|
5281
5280
|
switch (_e.label) {
|
5282
5281
|
case 0:
|
@@ -5286,24 +5285,24 @@ var PerpetualsClient = (function () {
|
|
5286
5285
|
postInstructions = [];
|
5287
5286
|
additionalSigners = [];
|
5288
5287
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
5289
|
-
lpTokenMint = poolConfig.
|
5290
|
-
|
5291
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
5288
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
5289
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
5290
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
5292
5291
|
case 1:
|
5293
|
-
|
5292
|
+
compoudingTokenAccount = _e.sent();
|
5294
5293
|
_a = createUserATA;
|
5295
5294
|
if (!_a) return [3, 3];
|
5296
|
-
return [4, (0, utils_1.checkIfAccountExists)(
|
5295
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
5297
5296
|
case 2:
|
5298
5297
|
_a = !(_e.sent());
|
5299
5298
|
_e.label = 3;
|
5300
5299
|
case 3:
|
5301
5300
|
if (_a) {
|
5302
|
-
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey,
|
5301
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
5303
5302
|
}
|
5304
5303
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
5305
|
-
|
5306
|
-
|
5304
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), poolConfig.stakedLpTokenMint.toBuffer()], this.programId)[0];
|
5305
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
5307
5306
|
custodyAccountMetas = [];
|
5308
5307
|
custodyOracleAccountMetas = [];
|
5309
5308
|
markets = [];
|
@@ -5337,17 +5336,17 @@ var PerpetualsClient = (function () {
|
|
5337
5336
|
})
|
5338
5337
|
.accounts({
|
5339
5338
|
owner: publicKey,
|
5340
|
-
|
5339
|
+
compoundingTokenAccount: compoudingTokenAccount,
|
5341
5340
|
transferAuthority: poolConfig.transferAuthority,
|
5342
5341
|
perpetuals: poolConfig.perpetuals,
|
5343
5342
|
pool: poolConfig.poolAddress,
|
5344
5343
|
flpStakeAccount: flpStakeAccount,
|
5345
5344
|
rewardCustody: rewardCustody.custodyAccount,
|
5346
5345
|
rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
|
5347
|
-
|
5348
|
-
|
5346
|
+
poolStakedLpVault: poolStakedLpVault,
|
5347
|
+
poolCompoundingLpVault: compoundingLpVault,
|
5349
5348
|
lpTokenMint: lpTokenMint,
|
5350
|
-
|
5349
|
+
compoundingTokenMint: compoundingTokenMint,
|
5351
5350
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5352
5351
|
eventAuthority: this.eventAuthority.publicKey,
|
5353
5352
|
program: this.program.programId,
|
@@ -5371,77 +5370,79 @@ var PerpetualsClient = (function () {
|
|
5371
5370
|
});
|
5372
5371
|
});
|
5373
5372
|
};
|
5374
|
-
this.compoundingFee = function (
|
5375
|
-
|
5376
|
-
return
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
|
5393
|
-
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5397
|
-
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5405
|
-
|
5406
|
-
|
5407
|
-
|
5408
|
-
|
5409
|
-
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5415
|
-
|
5416
|
-
|
5417
|
-
|
5418
|
-
|
5419
|
-
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5426
|
-
|
5427
|
-
|
5428
|
-
|
5429
|
-
|
5430
|
-
|
5431
|
-
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5373
|
+
this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
|
5374
|
+
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
5375
|
+
return __awaiter(_this, void 0, void 0, function () {
|
5376
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoundingLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_33;
|
5377
|
+
return __generator(this, function (_d) {
|
5378
|
+
switch (_d.label) {
|
5379
|
+
case 0:
|
5380
|
+
instructions = [];
|
5381
|
+
additionalSigners = [];
|
5382
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardTokenSymbol).mintKey); });
|
5383
|
+
lpTokenMint = poolConfig.stakedLpTokenMint;
|
5384
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
5385
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), compoundingTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
5386
|
+
custodyAccountMetas = [];
|
5387
|
+
custodyOracleAccountMetas = [];
|
5388
|
+
markets = [];
|
5389
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
5390
|
+
custody = _a[_i];
|
5391
|
+
custodyAccountMetas.push({
|
5392
|
+
pubkey: custody.custodyAccount,
|
5393
|
+
isSigner: false,
|
5394
|
+
isWritable: false,
|
5395
|
+
});
|
5396
|
+
custodyOracleAccountMetas.push({
|
5397
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
5398
|
+
isSigner: false,
|
5399
|
+
isWritable: false,
|
5400
|
+
});
|
5401
|
+
}
|
5402
|
+
for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
|
5403
|
+
market = _c[_b];
|
5404
|
+
markets.push({
|
5405
|
+
pubkey: market.marketAccount,
|
5406
|
+
isSigner: false,
|
5407
|
+
isWritable: false,
|
5408
|
+
});
|
5409
|
+
}
|
5410
|
+
_d.label = 1;
|
5411
|
+
case 1:
|
5412
|
+
_d.trys.push([1, 3, , 4]);
|
5413
|
+
return [4, this.program.methods
|
5414
|
+
.compoundFees({})
|
5415
|
+
.accounts({
|
5416
|
+
poolCompoundingLpVault: compoundingLpVault,
|
5417
|
+
transferAuthority: poolConfig.transferAuthority,
|
5418
|
+
perpetuals: poolConfig.perpetuals,
|
5419
|
+
pool: poolConfig.poolAddress,
|
5420
|
+
rewardCustody: rewardCustody.custodyAccount,
|
5421
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
5422
|
+
lpTokenMint: lpTokenMint,
|
5423
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5424
|
+
eventAuthority: this.eventAuthority.publicKey,
|
5425
|
+
program: this.program.programId,
|
5426
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
5427
|
+
})
|
5428
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
5429
|
+
.instruction()];
|
5430
|
+
case 2:
|
5431
|
+
compoundingFee = _d.sent();
|
5432
|
+
instructions.push(compoundingFee);
|
5433
|
+
return [3, 4];
|
5434
|
+
case 3:
|
5435
|
+
err_33 = _d.sent();
|
5436
|
+
console.log("perpClient compoundingFee error:: ", err_33);
|
5437
|
+
return [3, 4];
|
5438
|
+
case 4: return [2, {
|
5439
|
+
instructions: __spreadArray([], instructions, true),
|
5440
|
+
additionalSigners: additionalSigners
|
5441
|
+
}];
|
5442
|
+
}
|
5443
|
+
});
|
5443
5444
|
});
|
5444
|
-
}
|
5445
|
+
};
|
5445
5446
|
this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5446
5447
|
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_34;
|
5447
5448
|
return __generator(this, function (_a) {
|
@@ -5487,7 +5488,7 @@ var PerpetualsClient = (function () {
|
|
5487
5488
|
}
|
5488
5489
|
});
|
5489
5490
|
}); };
|
5490
|
-
this.
|
5491
|
+
this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
|
5491
5492
|
var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_35;
|
5492
5493
|
return __generator(this, function (_a) {
|
5493
5494
|
switch (_a.label) {
|