flash-sdk 11.1.1-alpha.0 → 11.1.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/OraclePrice.d.ts +1 -0
- package/dist/OrderAccount.d.ts +1 -0
- package/dist/PerpetualsClient.d.ts +28 -65
- package/dist/PerpetualsClient.js +86 -118
- package/dist/PoolAccount.d.ts +1 -0
- package/dist/PoolDataClient.d.ts +1 -0
- package/dist/PositionAccount.d.ts +1 -0
- package/dist/TokenStakeAccount.d.ts +1 -0
- package/dist/TokenVaultAccount.d.ts +1 -0
- package/dist/ViewHelper.js +2 -2
- package/dist/backupOracle.js +4 -4
- package/dist/constants/index.d.ts +1 -0
- package/dist/idl/perpetuals.d.ts +0 -210
- package/dist/idl/perpetuals.js +0 -210
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -3
- package/dist/utils/IdlCoder.js +7 -17
- package/dist/utils/alt.js +6 -5
- package/dist/utils/anchorCpiEvents.d.ts +1 -0
- package/dist/utils/anchorCpiEvents.js +4 -4
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +9 -9
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
24
|
-
return g
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -3627,7 +3627,7 @@ var PerpetualsClient = (function () {
|
|
|
3627
3627
|
args_1[_i - 4] = arguments[_i];
|
|
3628
3628
|
}
|
|
3629
3629
|
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
3630
|
-
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f,
|
|
3630
|
+
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, instruction, err_5;
|
|
3631
3631
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3632
3632
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3633
3633
|
return __generator(this, function (_g) {
|
|
@@ -3645,7 +3645,7 @@ var PerpetualsClient = (function () {
|
|
|
3645
3645
|
payToken = poolConfig.getTokenFromSymbol(payTokenSymbol);
|
|
3646
3646
|
_g.label = 1;
|
|
3647
3647
|
case 1:
|
|
3648
|
-
_g.trys.push([1,
|
|
3648
|
+
_g.trys.push([1, 10, , 11]);
|
|
3649
3649
|
userPayingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(payTokenCustodyConfig.mintKey, publicKey, true, payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3650
3650
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3651
3651
|
custodyAccountMetas = [];
|
|
@@ -3723,46 +3723,40 @@ var PerpetualsClient = (function () {
|
|
|
3723
3723
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
|
3724
3724
|
}
|
|
3725
3725
|
_g.label = 8;
|
|
3726
|
-
case 8:
|
|
3727
|
-
|
|
3728
|
-
|
|
3726
|
+
case 8: return [4, this.program.methods
|
|
3727
|
+
.addLiquidity({
|
|
3728
|
+
amountIn: tokenAmountIn,
|
|
3729
|
+
minLpAmountOut: minLpAmountOut
|
|
3730
|
+
})
|
|
3731
|
+
.accounts({
|
|
3732
|
+
owner: publicKey,
|
|
3733
|
+
fundingAccount: payTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userPayingTokenAccount,
|
|
3734
|
+
lpTokenAccount: lpTokenAccount,
|
|
3735
|
+
transferAuthority: poolConfig.transferAuthority,
|
|
3736
|
+
perpetuals: poolConfig.perpetuals,
|
|
3737
|
+
pool: poolConfig.poolAddress,
|
|
3738
|
+
custody: payTokenCustodyConfig.custodyAccount,
|
|
3739
|
+
custodyOracleAccount: this.useExtOracleAccount ? payTokenCustodyConfig.extOracleAccount : payTokenCustodyConfig.intOracleAccount,
|
|
3740
|
+
custodyTokenAccount: payTokenCustodyConfig.tokenAccount,
|
|
3741
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
3742
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3743
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3744
|
+
program: this.programId,
|
|
3745
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3746
|
+
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3747
|
+
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3748
|
+
})
|
|
3749
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3750
|
+
.instruction()];
|
|
3729
3751
|
case 9:
|
|
3730
|
-
whitelistExists = _g.sent();
|
|
3731
|
-
return [4, this.program.methods
|
|
3732
|
-
.addLiquidity({
|
|
3733
|
-
amountIn: tokenAmountIn,
|
|
3734
|
-
minLpAmountOut: minLpAmountOut
|
|
3735
|
-
})
|
|
3736
|
-
.accounts({
|
|
3737
|
-
owner: publicKey,
|
|
3738
|
-
fundingAccount: payTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userPayingTokenAccount,
|
|
3739
|
-
lpTokenAccount: lpTokenAccount,
|
|
3740
|
-
transferAuthority: poolConfig.transferAuthority,
|
|
3741
|
-
perpetuals: poolConfig.perpetuals,
|
|
3742
|
-
pool: poolConfig.poolAddress,
|
|
3743
|
-
custody: payTokenCustodyConfig.custodyAccount,
|
|
3744
|
-
custodyOracleAccount: this.useExtOracleAccount ? payTokenCustodyConfig.extOracleAccount : payTokenCustodyConfig.intOracleAccount,
|
|
3745
|
-
custodyTokenAccount: payTokenCustodyConfig.tokenAccount,
|
|
3746
|
-
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
3747
|
-
eventAuthority: this.eventAuthority.publicKey,
|
|
3748
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3749
|
-
program: this.programId,
|
|
3750
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3751
|
-
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3752
|
-
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3753
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3754
|
-
})
|
|
3755
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3756
|
-
.instruction()];
|
|
3757
|
-
case 10:
|
|
3758
3752
|
instruction = _g.sent();
|
|
3759
3753
|
instructions.push(instruction);
|
|
3760
|
-
return [3,
|
|
3761
|
-
case
|
|
3754
|
+
return [3, 11];
|
|
3755
|
+
case 10:
|
|
3762
3756
|
err_5 = _g.sent();
|
|
3763
3757
|
console.error("perpClient addLiquidity error:: ", err_5);
|
|
3764
3758
|
throw err_5;
|
|
3765
|
-
case
|
|
3759
|
+
case 11: return [2, {
|
|
3766
3760
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3767
3761
|
additionalSigners: additionalSigners
|
|
3768
3762
|
}];
|
|
@@ -3776,7 +3770,7 @@ var PerpetualsClient = (function () {
|
|
|
3776
3770
|
args_1[_i - 4] = arguments[_i];
|
|
3777
3771
|
}
|
|
3778
3772
|
return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
|
|
3779
|
-
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, inputToken, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market,
|
|
3773
|
+
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, inputToken, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, instruction;
|
|
3780
3774
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3781
3775
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3782
3776
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -3871,10 +3865,6 @@ var PerpetualsClient = (function () {
|
|
|
3871
3865
|
isWritable: false,
|
|
3872
3866
|
});
|
|
3873
3867
|
}
|
|
3874
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3875
|
-
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
3876
|
-
case 8:
|
|
3877
|
-
whitelistExists = _g.sent();
|
|
3878
3868
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
3879
3869
|
amountIn: amountIn,
|
|
3880
3870
|
minLpAmountOut: minLpAmountOut,
|
|
@@ -3897,12 +3887,11 @@ var PerpetualsClient = (function () {
|
|
|
3897
3887
|
program: this.programId,
|
|
3898
3888
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3899
3889
|
fundingMint: inputCustodyConfig.mintKey,
|
|
3900
|
-
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3901
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3890
|
+
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3902
3891
|
})
|
|
3903
3892
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3904
3893
|
.instruction()];
|
|
3905
|
-
case
|
|
3894
|
+
case 8:
|
|
3906
3895
|
instruction = _g.sent();
|
|
3907
3896
|
instructions.push(instruction);
|
|
3908
3897
|
return [2, {
|
|
@@ -3919,7 +3908,7 @@ var PerpetualsClient = (function () {
|
|
|
3919
3908
|
args_1[_i - 4] = arguments[_i];
|
|
3920
3909
|
}
|
|
3921
3910
|
return __awaiter(_this, __spreadArray([recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1], args_1, true), void 0, function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
|
|
3922
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e,
|
|
3911
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
|
|
3923
3912
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
3924
3913
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3925
3914
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
@@ -3940,7 +3929,7 @@ var PerpetualsClient = (function () {
|
|
|
3940
3929
|
recieveToken = poolConfig.getTokenFromSymbol(recieveTokenSymbol);
|
|
3941
3930
|
_f.label = 1;
|
|
3942
3931
|
case 1:
|
|
3943
|
-
_f.trys.push([1,
|
|
3932
|
+
_f.trys.push([1, 7, , 8]);
|
|
3944
3933
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3945
3934
|
custodyAccountMetas = [];
|
|
3946
3935
|
custodyOracleAccountMetas = [];
|
|
@@ -3999,38 +3988,32 @@ var PerpetualsClient = (function () {
|
|
|
3999
3988
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, recieveToken.mintKey, recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
4000
3989
|
}
|
|
4001
3990
|
_f.label = 5;
|
|
4002
|
-
case 5:
|
|
4003
|
-
|
|
4004
|
-
|
|
3991
|
+
case 5: return [4, this.program.methods
|
|
3992
|
+
.removeLiquidity({
|
|
3993
|
+
lpAmountIn: liquidityAmountIn,
|
|
3994
|
+
minAmountOut: minTokenAmountOut
|
|
3995
|
+
})
|
|
3996
|
+
.accounts({
|
|
3997
|
+
owner: publicKey,
|
|
3998
|
+
receivingAccount: recieveTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
3999
|
+
lpTokenAccount: stakedLpTokenAccount,
|
|
4000
|
+
transferAuthority: poolConfig.transferAuthority,
|
|
4001
|
+
perpetuals: poolConfig.perpetuals,
|
|
4002
|
+
pool: poolConfig.poolAddress,
|
|
4003
|
+
custody: recieveTokenCustodyConfig.custodyAccount,
|
|
4004
|
+
custodyOracleAccount: this.useExtOracleAccount ? recieveTokenCustodyConfig.extOracleAccount : recieveTokenCustodyConfig.intOracleAccount,
|
|
4005
|
+
custodyTokenAccount: recieveTokenCustodyConfig.tokenAccount,
|
|
4006
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
4007
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4008
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4009
|
+
program: this.programId,
|
|
4010
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4011
|
+
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4012
|
+
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
4013
|
+
})
|
|
4014
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4015
|
+
.instruction()];
|
|
4005
4016
|
case 6:
|
|
4006
|
-
whitelistExists = _f.sent();
|
|
4007
|
-
return [4, this.program.methods
|
|
4008
|
-
.removeLiquidity({
|
|
4009
|
-
lpAmountIn: liquidityAmountIn,
|
|
4010
|
-
minAmountOut: minTokenAmountOut
|
|
4011
|
-
})
|
|
4012
|
-
.accounts({
|
|
4013
|
-
owner: publicKey,
|
|
4014
|
-
receivingAccount: recieveTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
4015
|
-
lpTokenAccount: stakedLpTokenAccount,
|
|
4016
|
-
transferAuthority: poolConfig.transferAuthority,
|
|
4017
|
-
perpetuals: poolConfig.perpetuals,
|
|
4018
|
-
pool: poolConfig.poolAddress,
|
|
4019
|
-
custody: recieveTokenCustodyConfig.custodyAccount,
|
|
4020
|
-
custodyOracleAccount: this.useExtOracleAccount ? recieveTokenCustodyConfig.extOracleAccount : recieveTokenCustodyConfig.intOracleAccount,
|
|
4021
|
-
custodyTokenAccount: recieveTokenCustodyConfig.tokenAccount,
|
|
4022
|
-
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
4023
|
-
eventAuthority: this.eventAuthority.publicKey,
|
|
4024
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4025
|
-
program: this.programId,
|
|
4026
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4027
|
-
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4028
|
-
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4029
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4030
|
-
})
|
|
4031
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4032
|
-
.instruction()];
|
|
4033
|
-
case 7:
|
|
4034
4017
|
removeLiquidityTx = _f.sent();
|
|
4035
4018
|
instructions.push(removeLiquidityTx);
|
|
4036
4019
|
if (closeLpATA) {
|
|
@@ -4041,12 +4024,12 @@ var PerpetualsClient = (function () {
|
|
|
4041
4024
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
4042
4025
|
postInstructions.push(closeWsolATAIns);
|
|
4043
4026
|
}
|
|
4044
|
-
return [3,
|
|
4045
|
-
case
|
|
4027
|
+
return [3, 8];
|
|
4028
|
+
case 7:
|
|
4046
4029
|
err_6 = _f.sent();
|
|
4047
4030
|
console.log("perpClient removeLiquidity error:: ", err_6);
|
|
4048
4031
|
throw err_6;
|
|
4049
|
-
case
|
|
4032
|
+
case 8: return [2, {
|
|
4050
4033
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4051
4034
|
additionalSigners: additionalSigners
|
|
4052
4035
|
}];
|
|
@@ -4585,7 +4568,7 @@ var PerpetualsClient = (function () {
|
|
|
4585
4568
|
args_1[_i - 5] = arguments[_i];
|
|
4586
4569
|
}
|
|
4587
4570
|
return __awaiter(_this, __spreadArray([amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, enableDebugLogs) {
|
|
4588
|
-
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, heapSizeIx,
|
|
4571
|
+
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, heapSizeIx, addCompoundingLiquidity, err_16;
|
|
4589
4572
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4590
4573
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4591
4574
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4680,7 +4663,7 @@ var PerpetualsClient = (function () {
|
|
|
4680
4663
|
}
|
|
4681
4664
|
_f.label = 7;
|
|
4682
4665
|
case 7:
|
|
4683
|
-
_f.trys.push([7,
|
|
4666
|
+
_f.trys.push([7, 9, , 10]);
|
|
4684
4667
|
if (enableHeapSizeIx) {
|
|
4685
4668
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4686
4669
|
bytes: 64 * 1024,
|
|
@@ -4690,10 +4673,6 @@ var PerpetualsClient = (function () {
|
|
|
4690
4673
|
}
|
|
4691
4674
|
preInstructions.push(heapSizeIx);
|
|
4692
4675
|
}
|
|
4693
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4694
|
-
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
4695
|
-
case 8:
|
|
4696
|
-
whitelistExists = _f.sent();
|
|
4697
4676
|
return [4, this.program.methods
|
|
4698
4677
|
.addCompoundingLiquidity({
|
|
4699
4678
|
amountIn: amountIn,
|
|
@@ -4720,19 +4699,18 @@ var PerpetualsClient = (function () {
|
|
|
4720
4699
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4721
4700
|
fundingMint: inCustodyConfig.mintKey,
|
|
4722
4701
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4723
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4724
4702
|
})
|
|
4725
4703
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4726
4704
|
.instruction()];
|
|
4727
|
-
case
|
|
4705
|
+
case 8:
|
|
4728
4706
|
addCompoundingLiquidity = _f.sent();
|
|
4729
4707
|
instructions.push(addCompoundingLiquidity);
|
|
4730
|
-
return [3,
|
|
4731
|
-
case
|
|
4708
|
+
return [3, 10];
|
|
4709
|
+
case 9:
|
|
4732
4710
|
err_16 = _f.sent();
|
|
4733
4711
|
console.log("perpClient addCompoundingLiquidity error:: ", err_16);
|
|
4734
|
-
return [3,
|
|
4735
|
-
case
|
|
4712
|
+
return [3, 10];
|
|
4713
|
+
case 10: return [2, {
|
|
4736
4714
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4737
4715
|
additionalSigners: additionalSigners
|
|
4738
4716
|
}];
|
|
@@ -4746,7 +4724,7 @@ var PerpetualsClient = (function () {
|
|
|
4746
4724
|
args_1[_i - 5] = arguments[_i];
|
|
4747
4725
|
}
|
|
4748
4726
|
return __awaiter(_this, __spreadArray([compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, enableDebugLogs) {
|
|
4749
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, heapSizeIx,
|
|
4727
|
+
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, heapSizeIx, removeCompoundingLiquidity, err_17;
|
|
4750
4728
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4751
4729
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4752
4730
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4825,7 +4803,7 @@ var PerpetualsClient = (function () {
|
|
|
4825
4803
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
|
4826
4804
|
_f.label = 5;
|
|
4827
4805
|
case 5:
|
|
4828
|
-
_f.trys.push([5,
|
|
4806
|
+
_f.trys.push([5, 7, , 8]);
|
|
4829
4807
|
if (enableHeapSizeIx) {
|
|
4830
4808
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4831
4809
|
bytes: 64 * 1024,
|
|
@@ -4835,10 +4813,6 @@ var PerpetualsClient = (function () {
|
|
|
4835
4813
|
}
|
|
4836
4814
|
preInstructions.push(heapSizeIx);
|
|
4837
4815
|
}
|
|
4838
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4839
|
-
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
4840
|
-
case 6:
|
|
4841
|
-
whitelistExists = _f.sent();
|
|
4842
4816
|
return [4, this.program.methods
|
|
4843
4817
|
.removeCompoundingLiquidity({
|
|
4844
4818
|
compoundingAmountIn: compoundingAmountIn,
|
|
@@ -4864,20 +4838,19 @@ var PerpetualsClient = (function () {
|
|
|
4864
4838
|
program: this.program.programId,
|
|
4865
4839
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4866
4840
|
receivingMint: outCustodyConfig.mintKey,
|
|
4867
|
-
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
4868
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4841
|
+
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
4869
4842
|
})
|
|
4870
4843
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4871
4844
|
.instruction()];
|
|
4872
|
-
case
|
|
4845
|
+
case 6:
|
|
4873
4846
|
removeCompoundingLiquidity = _f.sent();
|
|
4874
4847
|
instructions.push(removeCompoundingLiquidity);
|
|
4875
|
-
return [3,
|
|
4876
|
-
case
|
|
4848
|
+
return [3, 8];
|
|
4849
|
+
case 7:
|
|
4877
4850
|
err_17 = _f.sent();
|
|
4878
4851
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
|
|
4879
|
-
return [3,
|
|
4880
|
-
case
|
|
4852
|
+
return [3, 8];
|
|
4853
|
+
case 8: return [2, {
|
|
4881
4854
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4882
4855
|
additionalSigners: additionalSigners
|
|
4883
4856
|
}];
|
|
@@ -6425,7 +6398,7 @@ var PerpetualsClient = (function () {
|
|
|
6425
6398
|
args_1[_i - 5] = arguments[_i];
|
|
6426
6399
|
}
|
|
6427
6400
|
return __awaiter(_this, __spreadArray([userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1], args_1, true), void 0, function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
6428
|
-
var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody,
|
|
6401
|
+
var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_40;
|
|
6429
6402
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6430
6403
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6431
6404
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
@@ -6489,7 +6462,7 @@ var PerpetualsClient = (function () {
|
|
|
6489
6462
|
}
|
|
6490
6463
|
_g.label = 6;
|
|
6491
6464
|
case 6:
|
|
6492
|
-
_g.trys.push([6,
|
|
6465
|
+
_g.trys.push([6, 19, , 20]);
|
|
6493
6466
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
|
6494
6467
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
|
6495
6468
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
|
@@ -6591,10 +6564,6 @@ var PerpetualsClient = (function () {
|
|
|
6591
6564
|
isWritable: false,
|
|
6592
6565
|
});
|
|
6593
6566
|
}
|
|
6594
|
-
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
6595
|
-
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
6596
|
-
case 18:
|
|
6597
|
-
whitelistExists = _g.sent();
|
|
6598
6567
|
params = {
|
|
6599
6568
|
amountIn: amountIn,
|
|
6600
6569
|
minAmountOut: minAmountOut,
|
|
@@ -6622,23 +6591,22 @@ var PerpetualsClient = (function () {
|
|
|
6622
6591
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6623
6592
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
6624
6593
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6625
|
-
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
6626
6594
|
})
|
|
6627
6595
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
6628
6596
|
.instruction()];
|
|
6629
|
-
case
|
|
6597
|
+
case 18:
|
|
6630
6598
|
inx = _g.sent();
|
|
6631
6599
|
instructions.push(inx);
|
|
6632
6600
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
|
6633
6601
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
|
6634
6602
|
instructions.push(closeWsolATAIns);
|
|
6635
6603
|
}
|
|
6636
|
-
return [3,
|
|
6637
|
-
case
|
|
6604
|
+
return [3, 20];
|
|
6605
|
+
case 19:
|
|
6638
6606
|
err_40 = _g.sent();
|
|
6639
6607
|
console.error("perpClient Swap error:: ", err_40);
|
|
6640
6608
|
throw err_40;
|
|
6641
|
-
case
|
|
6609
|
+
case 20: return [2, {
|
|
6642
6610
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6643
6611
|
additionalSigners: additionalSigners
|
|
6644
6612
|
}];
|
package/dist/PoolAccount.d.ts
CHANGED
package/dist/PoolDataClient.d.ts
CHANGED
package/dist/ViewHelper.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
13
|
-
return g
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
package/dist/backupOracle.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
13
|
-
return g
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -40,8 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
|
|
44
|
-
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|
|
43
|
+
exports.createBackupOracleInstruction = exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
|
|
45
44
|
var price_service_client_1 = require("@pythnetwork/price-service-client");
|
|
46
45
|
var web3_js_1 = require("@solana/web3.js");
|
|
47
46
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
@@ -157,3 +156,4 @@ function createBackupOracleInstruction(poolAddress_1) {
|
|
|
157
156
|
});
|
|
158
157
|
});
|
|
159
158
|
}
|
|
159
|
+
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|