flash-sdk 2.11.11 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +76 -76
- package/dist/PerpetualsClient.js +123 -119
- package/dist/PoolAccount.d.ts +8 -8
- package/dist/PoolConfig.d.ts +4 -4
- package/dist/PoolConfig.js +5 -5
- 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 +214 -53
- package/dist/idl/perpetuals.js +214 -53
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
|
@@ -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:
|
|
@@ -3268,7 +3268,7 @@ var PerpetualsClient = (function () {
|
|
|
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();
|
|
@@ -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, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount,
|
|
3387
|
+
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;
|
|
3388
3388
|
return __generator(this, function (_f) {
|
|
3389
3389
|
switch (_f.label) {
|
|
3390
3390
|
case 0:
|
|
@@ -3399,7 +3399,7 @@ var PerpetualsClient = (function () {
|
|
|
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(), lpTokenMint.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();
|
|
@@ -3494,7 +3494,7 @@ var PerpetualsClient = (function () {
|
|
|
3494
3494
|
custodyTokenAccount: inputCustodyConfig.tokenAccount,
|
|
3495
3495
|
lpTokenMint: lpTokenMint,
|
|
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,
|
|
@@ -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:
|
|
@@ -3963,7 +3963,7 @@ var PerpetualsClient = (function () {
|
|
|
3963
3963
|
case 1:
|
|
3964
3964
|
_a.trys.push([1, 4, , 5]);
|
|
3965
3965
|
lpTokenMint = poolConfig.lpTokenMint;
|
|
3966
|
-
|
|
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
3968
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.lpTokenMint, owner)];
|
|
3969
3969
|
case 2:
|
|
@@ -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,
|
|
@@ -4074,6 +4074,8 @@ var PerpetualsClient = (function () {
|
|
|
4074
4074
|
pool: pool,
|
|
4075
4075
|
rewardCustody: rewardCustodyConfig.custodyAccount,
|
|
4076
4076
|
feeDistributionTokenAccount: feeDistributionTokenAccount,
|
|
4077
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4078
|
+
program: this.program.programId,
|
|
4077
4079
|
})
|
|
4078
4080
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), flpStakeAccountMetas, true))
|
|
4079
4081
|
.instruction()];
|
|
@@ -4237,7 +4239,7 @@ var PerpetualsClient = (function () {
|
|
|
4237
4239
|
if (deactivated === void 0) { deactivated = true; }
|
|
4238
4240
|
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
|
4239
4241
|
return __awaiter(_this, void 0, void 0, function () {
|
|
4240
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool,
|
|
4242
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_17;
|
|
4241
4243
|
return __generator(this, function (_b) {
|
|
4242
4244
|
switch (_b.label) {
|
|
4243
4245
|
case 0:
|
|
@@ -4251,7 +4253,7 @@ var PerpetualsClient = (function () {
|
|
|
4251
4253
|
_b.trys.push([1, 6, , 7]);
|
|
4252
4254
|
lpTokenMint = poolConfig.lpTokenMint;
|
|
4253
4255
|
pool = poolConfig.poolAddress;
|
|
4254
|
-
|
|
4256
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), pool.toBuffer(), lpTokenMint.toBuffer()], this.program.programId)[0];
|
|
4255
4257
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.program.programId)[0];
|
|
4256
4258
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.lpTokenMint, publicKey)];
|
|
4257
4259
|
case 2:
|
|
@@ -4273,12 +4275,12 @@ var PerpetualsClient = (function () {
|
|
|
4273
4275
|
})
|
|
4274
4276
|
.accounts({
|
|
4275
4277
|
owner: publicKey,
|
|
4276
|
-
|
|
4278
|
+
receivingLpTokenAccount: userLpTokenAccount,
|
|
4277
4279
|
transferAuthority: poolConfig.transferAuthority,
|
|
4278
4280
|
perpetuals: this.perpetuals.publicKey,
|
|
4279
4281
|
pool: pool,
|
|
4280
4282
|
flpStakeAccount: flpStakeAccount,
|
|
4281
|
-
|
|
4283
|
+
poolStakedLpVault: poolStakedLpVault,
|
|
4282
4284
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4283
4285
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4284
4286
|
eventAuthority: this.eventAuthority.publicKey,
|
|
@@ -5002,8 +5004,8 @@ var PerpetualsClient = (function () {
|
|
|
5002
5004
|
}
|
|
5003
5005
|
});
|
|
5004
5006
|
}); };
|
|
5005
|
-
this.addCompoundingLiquidity = function (amountIn,
|
|
5006
|
-
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint,
|
|
5007
|
+
this.addCompoundingLiquidity = function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5008
|
+
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;
|
|
5007
5009
|
return __generator(this, function (_e) {
|
|
5008
5010
|
switch (_e.label) {
|
|
5009
5011
|
case 0:
|
|
@@ -5015,13 +5017,13 @@ var PerpetualsClient = (function () {
|
|
|
5015
5017
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
|
5016
5018
|
inCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inTokenSymbol).mintKey); });
|
|
5017
5019
|
lpTokenMint = poolConfig.lpTokenMint;
|
|
5018
|
-
|
|
5020
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
5019
5021
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.lpTokenMint, publicKey)];
|
|
5020
5022
|
case 1:
|
|
5021
5023
|
lpTokenAccount = _e.sent();
|
|
5022
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
|
5024
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
|
5023
5025
|
case 2:
|
|
5024
|
-
|
|
5026
|
+
compoundingTokenAccount = _e.sent();
|
|
5025
5027
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(inCustodyConfig.mintKey, publicKey)];
|
|
5026
5028
|
case 3:
|
|
5027
5029
|
fundingAccount = _e.sent();
|
|
@@ -5054,10 +5056,10 @@ var PerpetualsClient = (function () {
|
|
|
5054
5056
|
if (!(_e.sent())) {
|
|
5055
5057
|
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.lpTokenMint));
|
|
5056
5058
|
}
|
|
5057
|
-
return [4, (0, utils_1.checkIfAccountExists)(
|
|
5059
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
|
5058
5060
|
case 5:
|
|
5059
5061
|
if (!(_e.sent())) {
|
|
5060
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey,
|
|
5062
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
|
5061
5063
|
}
|
|
5062
5064
|
if (!(inTokenSymbol == 'SOL')) return [3, 8];
|
|
5063
5065
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
|
@@ -5096,20 +5098,20 @@ var PerpetualsClient = (function () {
|
|
|
5096
5098
|
}
|
|
5097
5099
|
_e.label = 10;
|
|
5098
5100
|
case 10:
|
|
5099
|
-
|
|
5101
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
|
5100
5102
|
_e.label = 11;
|
|
5101
5103
|
case 11:
|
|
5102
5104
|
_e.trys.push([11, 13, , 14]);
|
|
5103
5105
|
return [4, this.program.methods
|
|
5104
5106
|
.addCompoundingLiquidity({
|
|
5105
5107
|
amountIn: amountIn,
|
|
5106
|
-
|
|
5108
|
+
minCompoundingAmountOut: minCompoundingAmountOut
|
|
5107
5109
|
})
|
|
5108
5110
|
.accounts({
|
|
5109
5111
|
owner: publicKey,
|
|
5110
5112
|
fundingAccount: fundingAccount,
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
+
compoundingTokenAccount: compoundingTokenAccount,
|
|
5114
|
+
poolCompoundingLpVault: compoundingLpVault,
|
|
5113
5115
|
transferAuthority: poolConfig.transferAuthority,
|
|
5114
5116
|
perpetuals: poolConfig.perpetuals,
|
|
5115
5117
|
pool: poolConfig.poolAddress,
|
|
@@ -5119,7 +5121,7 @@ var PerpetualsClient = (function () {
|
|
|
5119
5121
|
rewardCustody: rewardCustody.custodyAccount,
|
|
5120
5122
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
|
5121
5123
|
lpTokenMint: lpTokenMint,
|
|
5122
|
-
|
|
5124
|
+
compoundingTokenMint: compoundingTokenMint,
|
|
5123
5125
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5124
5126
|
eventAuthority: this.eventAuthority.publicKey,
|
|
5125
5127
|
program: this.program.programId,
|
|
@@ -5142,10 +5144,10 @@ var PerpetualsClient = (function () {
|
|
|
5142
5144
|
}
|
|
5143
5145
|
});
|
|
5144
5146
|
}); };
|
|
5145
|
-
this.removeCompoundingLiquidity = function (
|
|
5147
|
+
this.removeCompoundingLiquidity = function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA) {
|
|
5146
5148
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5147
5149
|
return __awaiter(_this, void 0, void 0, function () {
|
|
5148
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint,
|
|
5150
|
+
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;
|
|
5149
5151
|
return __generator(this, function (_e) {
|
|
5150
5152
|
switch (_e.label) {
|
|
5151
5153
|
case 0:
|
|
@@ -5157,7 +5159,7 @@ var PerpetualsClient = (function () {
|
|
|
5157
5159
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
|
5158
5160
|
outCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outTokenSymbol).mintKey); });
|
|
5159
5161
|
lpTokenMint = poolConfig.lpTokenMint;
|
|
5160
|
-
|
|
5162
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
5161
5163
|
if (!(outCustodyConfig.symbol == 'SOL')) return [3, 2];
|
|
5162
5164
|
wrappedSolAccount = new web3_js_1.Keypair();
|
|
5163
5165
|
userReceivingTokenAccount = wrappedSolAccount.publicKey;
|
|
@@ -5218,26 +5220,26 @@ var PerpetualsClient = (function () {
|
|
|
5218
5220
|
isWritable: false,
|
|
5219
5221
|
});
|
|
5220
5222
|
}
|
|
5221
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
|
5223
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
|
5222
5224
|
case 7:
|
|
5223
|
-
|
|
5225
|
+
compoundingTokenAccount = _e.sent();
|
|
5224
5226
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(outCustodyConfig.mintKey, publicKey)];
|
|
5225
5227
|
case 8:
|
|
5226
5228
|
receivingAccount = _e.sent();
|
|
5227
|
-
|
|
5229
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
|
5228
5230
|
_e.label = 9;
|
|
5229
5231
|
case 9:
|
|
5230
5232
|
_e.trys.push([9, 11, , 12]);
|
|
5231
5233
|
return [4, this.program.methods
|
|
5232
5234
|
.removeCompoundingLiquidity({
|
|
5233
|
-
|
|
5235
|
+
compoundingAmountIn: compoundingAmountIn,
|
|
5234
5236
|
minAmountOut: minAmountOut
|
|
5235
5237
|
})
|
|
5236
5238
|
.accounts({
|
|
5237
5239
|
owner: publicKey,
|
|
5238
5240
|
receivingAccount: outCustodyConfig.symbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
+
compoundingTokenAccount: compoundingTokenAccount,
|
|
5242
|
+
poolCompoundingLpVault: compoundingLpVault,
|
|
5241
5243
|
transferAuthority: poolConfig.transferAuthority,
|
|
5242
5244
|
perpetuals: poolConfig.perpetuals,
|
|
5243
5245
|
pool: poolConfig.poolAddress,
|
|
@@ -5247,7 +5249,7 @@ var PerpetualsClient = (function () {
|
|
|
5247
5249
|
rewardCustody: rewardCustody.custodyAccount,
|
|
5248
5250
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
|
5249
5251
|
lpTokenMint: lpTokenMint,
|
|
5250
|
-
|
|
5252
|
+
compoundingTokenMint: compoundingTokenMint,
|
|
5251
5253
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5252
5254
|
eventAuthority: this.eventAuthority.publicKey,
|
|
5253
5255
|
program: this.program.programId,
|
|
@@ -5274,7 +5276,7 @@ var PerpetualsClient = (function () {
|
|
|
5274
5276
|
this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
|
5275
5277
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5276
5278
|
return __awaiter(_this, void 0, void 0, function () {
|
|
5277
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint,
|
|
5279
|
+
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;
|
|
5278
5280
|
return __generator(this, function (_e) {
|
|
5279
5281
|
switch (_e.label) {
|
|
5280
5282
|
case 0:
|
|
@@ -5285,23 +5287,23 @@ var PerpetualsClient = (function () {
|
|
|
5285
5287
|
additionalSigners = [];
|
|
5286
5288
|
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(rewardTokenMint); });
|
|
5287
5289
|
lpTokenMint = poolConfig.lpTokenMint;
|
|
5288
|
-
|
|
5289
|
-
return [4, (0, spl_token_1.getAssociatedTokenAddress)(
|
|
5290
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
5291
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(compoundingTokenMint, publicKey)];
|
|
5290
5292
|
case 1:
|
|
5291
|
-
|
|
5293
|
+
compoudingTokenAccount = _e.sent();
|
|
5292
5294
|
_a = createUserATA;
|
|
5293
5295
|
if (!_a) return [3, 3];
|
|
5294
|
-
return [4, (0, utils_1.checkIfAccountExists)(
|
|
5296
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
|
5295
5297
|
case 2:
|
|
5296
5298
|
_a = !(_e.sent());
|
|
5297
5299
|
_e.label = 3;
|
|
5298
5300
|
case 3:
|
|
5299
5301
|
if (_a) {
|
|
5300
|
-
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey,
|
|
5302
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
|
5301
5303
|
}
|
|
5302
5304
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), poolConfig.lpTokenMint.toBuffer()], this.programId)[0];
|
|
5306
|
+
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
|
5305
5307
|
custodyAccountMetas = [];
|
|
5306
5308
|
custodyOracleAccountMetas = [];
|
|
5307
5309
|
markets = [];
|
|
@@ -5335,17 +5337,17 @@ var PerpetualsClient = (function () {
|
|
|
5335
5337
|
})
|
|
5336
5338
|
.accounts({
|
|
5337
5339
|
owner: publicKey,
|
|
5338
|
-
|
|
5340
|
+
compoundingTokenAccount: compoudingTokenAccount,
|
|
5339
5341
|
transferAuthority: poolConfig.transferAuthority,
|
|
5340
5342
|
perpetuals: poolConfig.perpetuals,
|
|
5341
5343
|
pool: poolConfig.poolAddress,
|
|
5342
5344
|
flpStakeAccount: flpStakeAccount,
|
|
5343
5345
|
rewardCustody: rewardCustody.custodyAccount,
|
|
5344
5346
|
rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
+
poolStakedLpVault: poolStakedLpVault,
|
|
5348
|
+
poolCompoundingLpVault: compoundingLpVault,
|
|
5347
5349
|
lpTokenMint: lpTokenMint,
|
|
5348
|
-
|
|
5350
|
+
compoundingTokenMint: compoundingTokenMint,
|
|
5349
5351
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5350
5352
|
eventAuthority: this.eventAuthority.publicKey,
|
|
5351
5353
|
program: this.program.programId,
|
|
@@ -5369,77 +5371,79 @@ var PerpetualsClient = (function () {
|
|
|
5369
5371
|
});
|
|
5370
5372
|
});
|
|
5371
5373
|
};
|
|
5372
|
-
this.compoundingFee = function (
|
|
5373
|
-
|
|
5374
|
-
return
|
|
5375
|
-
|
|
5376
|
-
|
|
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
|
-
|
|
5374
|
+
this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
|
|
5375
|
+
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
|
5376
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
5377
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoundingLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_33;
|
|
5378
|
+
return __generator(this, function (_d) {
|
|
5379
|
+
switch (_d.label) {
|
|
5380
|
+
case 0:
|
|
5381
|
+
instructions = [];
|
|
5382
|
+
additionalSigners = [];
|
|
5383
|
+
rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardTokenSymbol).mintKey); });
|
|
5384
|
+
lpTokenMint = poolConfig.lpTokenMint;
|
|
5385
|
+
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
5386
|
+
compoundingLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("compounding_lp_token_account"), poolConfig.poolAddress.toBuffer(), compoundingTokenMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
|
|
5387
|
+
custodyAccountMetas = [];
|
|
5388
|
+
custodyOracleAccountMetas = [];
|
|
5389
|
+
markets = [];
|
|
5390
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
|
5391
|
+
custody = _a[_i];
|
|
5392
|
+
custodyAccountMetas.push({
|
|
5393
|
+
pubkey: custody.custodyAccount,
|
|
5394
|
+
isSigner: false,
|
|
5395
|
+
isWritable: false,
|
|
5396
|
+
});
|
|
5397
|
+
custodyOracleAccountMetas.push({
|
|
5398
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
|
5399
|
+
isSigner: false,
|
|
5400
|
+
isWritable: false,
|
|
5401
|
+
});
|
|
5402
|
+
}
|
|
5403
|
+
for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
|
|
5404
|
+
market = _c[_b];
|
|
5405
|
+
markets.push({
|
|
5406
|
+
pubkey: market.marketAccount,
|
|
5407
|
+
isSigner: false,
|
|
5408
|
+
isWritable: false,
|
|
5409
|
+
});
|
|
5410
|
+
}
|
|
5411
|
+
_d.label = 1;
|
|
5412
|
+
case 1:
|
|
5413
|
+
_d.trys.push([1, 3, , 4]);
|
|
5414
|
+
return [4, this.program.methods
|
|
5415
|
+
.compoundFees({})
|
|
5416
|
+
.accounts({
|
|
5417
|
+
poolCompoundingLpVault: compoundingLpVault,
|
|
5418
|
+
transferAuthority: poolConfig.transferAuthority,
|
|
5419
|
+
perpetuals: poolConfig.perpetuals,
|
|
5420
|
+
pool: poolConfig.poolAddress,
|
|
5421
|
+
rewardCustody: rewardCustody.custodyAccount,
|
|
5422
|
+
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
|
5423
|
+
lpTokenMint: lpTokenMint,
|
|
5424
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5425
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5426
|
+
program: this.program.programId,
|
|
5427
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
5428
|
+
})
|
|
5429
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
5430
|
+
.instruction()];
|
|
5431
|
+
case 2:
|
|
5432
|
+
compoundingFee = _d.sent();
|
|
5433
|
+
instructions.push(compoundingFee);
|
|
5434
|
+
return [3, 4];
|
|
5435
|
+
case 3:
|
|
5436
|
+
err_33 = _d.sent();
|
|
5437
|
+
console.log("perpClient compoundingFee error:: ", err_33);
|
|
5438
|
+
return [3, 4];
|
|
5439
|
+
case 4: return [2, {
|
|
5440
|
+
instructions: __spreadArray([], instructions, true),
|
|
5441
|
+
additionalSigners: additionalSigners
|
|
5442
|
+
}];
|
|
5443
|
+
}
|
|
5444
|
+
});
|
|
5441
5445
|
});
|
|
5442
|
-
}
|
|
5446
|
+
};
|
|
5443
5447
|
this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5444
5448
|
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_34;
|
|
5445
5449
|
return __generator(this, function (_a) {
|
|
@@ -5485,7 +5489,7 @@ var PerpetualsClient = (function () {
|
|
|
5485
5489
|
}
|
|
5486
5490
|
});
|
|
5487
5491
|
}); };
|
|
5488
|
-
this.
|
|
5492
|
+
this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5489
5493
|
var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_35;
|
|
5490
5494
|
return __generator(this, function (_a) {
|
|
5491
5495
|
switch (_a.label) {
|
package/dist/PoolAccount.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export declare class PoolAccount implements Pool {
|
|
|
7
7
|
name: string;
|
|
8
8
|
permissions: Permissions;
|
|
9
9
|
inceptionTime: BN;
|
|
10
|
-
|
|
10
|
+
lpMint: PublicKey;
|
|
11
11
|
oracleAuthority: PublicKey;
|
|
12
|
-
|
|
12
|
+
stakedLpVault: PublicKey;
|
|
13
13
|
rewardCustody: PublicKey;
|
|
14
14
|
custodies: PublicKey[];
|
|
15
15
|
ratios: TokenRatios[];
|
|
@@ -19,16 +19,16 @@ export declare class PoolAccount implements Pool {
|
|
|
19
19
|
totalStaked: StakeStats;
|
|
20
20
|
stakingFeeShareBps: BN;
|
|
21
21
|
bump: number;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
lpMintBump: number;
|
|
23
|
+
stakedLpVaultBump: number;
|
|
24
24
|
vpVolumeFactor: number;
|
|
25
25
|
padding: number[];
|
|
26
26
|
stakingFeeBoostBps: BN[];
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
compoundingMint: PublicKey;
|
|
28
|
+
compoundingLpVault: PublicKey;
|
|
29
29
|
compoundingStats: CompoundingStats;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
compoundingMintBump: number;
|
|
31
|
+
compoundingLpVaultBump: number;
|
|
32
32
|
constructor(publicKey: PublicKey, parseData: Pool);
|
|
33
33
|
static from(publicKey: PublicKey, parseData: Pool): PoolAccount;
|
|
34
34
|
updatePoolData(parseData: Pool): void;
|
package/dist/PoolConfig.d.ts
CHANGED
|
@@ -50,11 +50,11 @@ export declare class PoolConfig {
|
|
|
50
50
|
poolName: string;
|
|
51
51
|
poolAddress: PublicKey;
|
|
52
52
|
lpTokenMint: PublicKey;
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
compoundingTokenMint: PublicKey;
|
|
54
|
+
stakedLpVault: PublicKey;
|
|
55
55
|
lpDecimals: number;
|
|
56
|
+
compoundingLpTokenSymbol: string;
|
|
56
57
|
lpTokenSymbol: string;
|
|
57
|
-
stakedLpTokenSymbol: string;
|
|
58
58
|
perpetuals: PublicKey;
|
|
59
59
|
transferAuthority: PublicKey;
|
|
60
60
|
multisig: PublicKey;
|
|
@@ -71,7 +71,7 @@ export declare class PoolConfig {
|
|
|
71
71
|
tokens: Token[];
|
|
72
72
|
custodies: CustodyConfig[];
|
|
73
73
|
markets: MarketConfig[];
|
|
74
|
-
constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, fbNftRewardProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey,
|
|
74
|
+
constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, fbNftRewardProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, compoundingTokenMint: PublicKey, stakedLpVault: PublicKey, lpDecimals: number, compoundingLpTokenSymbol: string, lpTokenSymbol: string, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], backupOracle: PublicKey, nftCollectionAddress: PublicKey, rewardDistributionProgram: {
|
|
75
75
|
programId: PublicKey;
|
|
76
76
|
transferAuthority: PublicKey;
|
|
77
77
|
rewardVault: PublicKey;
|
package/dist/PoolConfig.js
CHANGED
|
@@ -19,7 +19,7 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
19
19
|
var PoolConfig_json_1 = __importDefault(require("./PoolConfig.json"));
|
|
20
20
|
var types_1 = require("./types");
|
|
21
21
|
var PoolConfig = (function () {
|
|
22
|
-
function PoolConfig(programId, perpComposibilityProgramId, fbNftRewardProgramId, cluster, poolName, poolAddress, lpTokenMint,
|
|
22
|
+
function PoolConfig(programId, perpComposibilityProgramId, fbNftRewardProgramId, cluster, poolName, poolAddress, lpTokenMint, compoundingTokenMint, stakedLpVault, lpDecimals, compoundingLpTokenSymbol, lpTokenSymbol, perpetuals, transferAuthority, multisig, addressLookupTableAddresses, backupOracle, nftCollectionAddress, rewardDistributionProgram, tokens, custodies, markets) {
|
|
23
23
|
var _this = this;
|
|
24
24
|
this.programId = programId;
|
|
25
25
|
this.perpComposibilityProgramId = perpComposibilityProgramId;
|
|
@@ -28,11 +28,11 @@ var PoolConfig = (function () {
|
|
|
28
28
|
this.poolName = poolName;
|
|
29
29
|
this.poolAddress = poolAddress;
|
|
30
30
|
this.lpTokenMint = lpTokenMint;
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
31
|
+
this.compoundingTokenMint = compoundingTokenMint;
|
|
32
|
+
this.stakedLpVault = stakedLpVault;
|
|
33
33
|
this.lpDecimals = lpDecimals;
|
|
34
|
+
this.compoundingLpTokenSymbol = compoundingLpTokenSymbol;
|
|
34
35
|
this.lpTokenSymbol = lpTokenSymbol;
|
|
35
|
-
this.stakedLpTokenSymbol = stakedLpTokenSymbol;
|
|
36
36
|
this.perpetuals = perpetuals;
|
|
37
37
|
this.transferAuthority = transferAuthority;
|
|
38
38
|
this.multisig = multisig;
|
|
@@ -165,7 +165,7 @@ var PoolConfig = (function () {
|
|
|
165
165
|
catch (error) {
|
|
166
166
|
console.log("ERROR: buildPoolconfigFromJson unable to load markets ");
|
|
167
167
|
}
|
|
168
|
-
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), new web3_js_1.PublicKey(poolConfig.fbNftRewardProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), new web3_js_1.PublicKey(poolConfig.
|
|
168
|
+
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), new web3_js_1.PublicKey(poolConfig.fbNftRewardProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), new web3_js_1.PublicKey(poolConfig.compoundingTokenMint), new web3_js_1.PublicKey(poolConfig.stakedLpVault), poolConfig.lpDecimals, poolConfig.compoundingLpTokenSymbol, poolConfig.lpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, new web3_js_1.PublicKey(poolConfig.backupOracle), new web3_js_1.PublicKey(poolConfig.nftCollectionAddress), {
|
|
169
169
|
programId: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.programId),
|
|
170
170
|
rewardMint: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.rewardMint),
|
|
171
171
|
rewardTokenAccount: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.rewardTokenAccount),
|