flash-sdk 11.1.0 → 11.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OraclePrice.d.ts +0 -1
- package/dist/OrderAccount.d.ts +0 -1
- package/dist/PerpetualsClient.d.ts +65 -28
- package/dist/PerpetualsClient.js +118 -86
- package/dist/PoolAccount.d.ts +0 -1
- package/dist/PoolDataClient.d.ts +0 -1
- package/dist/PositionAccount.d.ts +0 -1
- package/dist/TokenStakeAccount.d.ts +0 -1
- package/dist/TokenVaultAccount.d.ts +0 -1
- package/dist/ViewHelper.js +2 -2
- package/dist/backupOracle.js +4 -4
- package/dist/constants/index.d.ts +0 -1
- package/dist/idl/perpetuals.d.ts +210 -0
- package/dist/idl/perpetuals.js +210 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +3 -3
- package/dist/utils/IdlCoder.js +17 -7
- package/dist/utils/alt.js +5 -6
- package/dist/utils/anchorCpiEvents.d.ts +0 -1
- package/dist/utils/anchorCpiEvents.js +4 -4
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -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, instruction, err_5;
|
|
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, whitelistPda, whitelistExists, 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, 11, , 12]);
|
|
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,40 +3723,46 @@ 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
|
-
|
|
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()];
|
|
3726
|
+
case 8:
|
|
3727
|
+
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
3728
|
+
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
3751
3729
|
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:
|
|
3752
3758
|
instruction = _g.sent();
|
|
3753
3759
|
instructions.push(instruction);
|
|
3754
|
-
return [3,
|
|
3755
|
-
case
|
|
3760
|
+
return [3, 12];
|
|
3761
|
+
case 11:
|
|
3756
3762
|
err_5 = _g.sent();
|
|
3757
3763
|
console.error("perpClient addLiquidity error:: ", err_5);
|
|
3758
3764
|
throw err_5;
|
|
3759
|
-
case
|
|
3765
|
+
case 12: return [2, {
|
|
3760
3766
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3761
3767
|
additionalSigners: additionalSigners
|
|
3762
3768
|
}];
|
|
@@ -3770,7 +3776,7 @@ var PerpetualsClient = (function () {
|
|
|
3770
3776
|
args_1[_i - 4] = arguments[_i];
|
|
3771
3777
|
}
|
|
3772
3778
|
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) {
|
|
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;
|
|
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, whitelistPda, whitelistExists, instruction;
|
|
3774
3780
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3775
3781
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3776
3782
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -3865,6 +3871,10 @@ var PerpetualsClient = (function () {
|
|
|
3865
3871
|
isWritable: false,
|
|
3866
3872
|
});
|
|
3867
3873
|
}
|
|
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();
|
|
3868
3878
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
3869
3879
|
amountIn: amountIn,
|
|
3870
3880
|
minLpAmountOut: minLpAmountOut,
|
|
@@ -3887,11 +3897,12 @@ var PerpetualsClient = (function () {
|
|
|
3887
3897
|
program: this.programId,
|
|
3888
3898
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3889
3899
|
fundingMint: inputCustodyConfig.mintKey,
|
|
3890
|
-
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3900
|
+
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3901
|
+
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
3891
3902
|
})
|
|
3892
3903
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
3893
3904
|
.instruction()];
|
|
3894
|
-
case
|
|
3905
|
+
case 9:
|
|
3895
3906
|
instruction = _g.sent();
|
|
3896
3907
|
instructions.push(instruction);
|
|
3897
3908
|
return [2, {
|
|
@@ -3908,7 +3919,7 @@ var PerpetualsClient = (function () {
|
|
|
3908
3919
|
args_1[_i - 4] = arguments[_i];
|
|
3909
3920
|
}
|
|
3910
3921
|
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) {
|
|
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;
|
|
3922
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, whitelistPda, whitelistExists, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
|
|
3912
3923
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
3913
3924
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3914
3925
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
@@ -3929,7 +3940,7 @@ var PerpetualsClient = (function () {
|
|
|
3929
3940
|
recieveToken = poolConfig.getTokenFromSymbol(recieveTokenSymbol);
|
|
3930
3941
|
_f.label = 1;
|
|
3931
3942
|
case 1:
|
|
3932
|
-
_f.trys.push([1,
|
|
3943
|
+
_f.trys.push([1, 8, , 9]);
|
|
3933
3944
|
stakedLpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3934
3945
|
custodyAccountMetas = [];
|
|
3935
3946
|
custodyOracleAccountMetas = [];
|
|
@@ -3988,32 +3999,38 @@ var PerpetualsClient = (function () {
|
|
|
3988
3999
|
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));
|
|
3989
4000
|
}
|
|
3990
4001
|
_f.label = 5;
|
|
3991
|
-
case 5:
|
|
3992
|
-
|
|
3993
|
-
|
|
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()];
|
|
4002
|
+
case 5:
|
|
4003
|
+
whitelistPda = this.findProgramAddress("whitelist", publicKey).publicKey;
|
|
4004
|
+
return [4, (0, utils_1.checkIfAccountExists)(whitelistPda, this.provider.connection)];
|
|
4016
4005
|
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:
|
|
4017
4034
|
removeLiquidityTx = _f.sent();
|
|
4018
4035
|
instructions.push(removeLiquidityTx);
|
|
4019
4036
|
if (closeLpATA) {
|
|
@@ -4024,12 +4041,12 @@ var PerpetualsClient = (function () {
|
|
|
4024
4041
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
4025
4042
|
postInstructions.push(closeWsolATAIns);
|
|
4026
4043
|
}
|
|
4027
|
-
return [3,
|
|
4028
|
-
case
|
|
4044
|
+
return [3, 9];
|
|
4045
|
+
case 8:
|
|
4029
4046
|
err_6 = _f.sent();
|
|
4030
4047
|
console.log("perpClient removeLiquidity error:: ", err_6);
|
|
4031
4048
|
throw err_6;
|
|
4032
|
-
case
|
|
4049
|
+
case 9: return [2, {
|
|
4033
4050
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4034
4051
|
additionalSigners: additionalSigners
|
|
4035
4052
|
}];
|
|
@@ -4568,7 +4585,7 @@ var PerpetualsClient = (function () {
|
|
|
4568
4585
|
args_1[_i - 5] = arguments[_i];
|
|
4569
4586
|
}
|
|
4570
4587
|
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) {
|
|
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;
|
|
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, whitelistPda, whitelistExists, addCompoundingLiquidity, err_16;
|
|
4572
4589
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4573
4590
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4574
4591
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4663,7 +4680,7 @@ var PerpetualsClient = (function () {
|
|
|
4663
4680
|
}
|
|
4664
4681
|
_f.label = 7;
|
|
4665
4682
|
case 7:
|
|
4666
|
-
_f.trys.push([7,
|
|
4683
|
+
_f.trys.push([7, 10, , 11]);
|
|
4667
4684
|
if (enableHeapSizeIx) {
|
|
4668
4685
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4669
4686
|
bytes: 64 * 1024,
|
|
@@ -4673,6 +4690,10 @@ var PerpetualsClient = (function () {
|
|
|
4673
4690
|
}
|
|
4674
4691
|
preInstructions.push(heapSizeIx);
|
|
4675
4692
|
}
|
|
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();
|
|
4676
4697
|
return [4, this.program.methods
|
|
4677
4698
|
.addCompoundingLiquidity({
|
|
4678
4699
|
amountIn: amountIn,
|
|
@@ -4699,18 +4720,19 @@ var PerpetualsClient = (function () {
|
|
|
4699
4720
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4700
4721
|
fundingMint: inCustodyConfig.mintKey,
|
|
4701
4722
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4723
|
+
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4702
4724
|
})
|
|
4703
4725
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4704
4726
|
.instruction()];
|
|
4705
|
-
case
|
|
4727
|
+
case 9:
|
|
4706
4728
|
addCompoundingLiquidity = _f.sent();
|
|
4707
4729
|
instructions.push(addCompoundingLiquidity);
|
|
4708
|
-
return [3,
|
|
4709
|
-
case
|
|
4730
|
+
return [3, 11];
|
|
4731
|
+
case 10:
|
|
4710
4732
|
err_16 = _f.sent();
|
|
4711
4733
|
console.log("perpClient addCompoundingLiquidity error:: ", err_16);
|
|
4712
|
-
return [3,
|
|
4713
|
-
case
|
|
4734
|
+
return [3, 11];
|
|
4735
|
+
case 11: return [2, {
|
|
4714
4736
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4715
4737
|
additionalSigners: additionalSigners
|
|
4716
4738
|
}];
|
|
@@ -4724,7 +4746,7 @@ var PerpetualsClient = (function () {
|
|
|
4724
4746
|
args_1[_i - 5] = arguments[_i];
|
|
4725
4747
|
}
|
|
4726
4748
|
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) {
|
|
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;
|
|
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, whitelistPda, whitelistExists, removeCompoundingLiquidity, err_17;
|
|
4728
4750
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4729
4751
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4730
4752
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
@@ -4803,7 +4825,7 @@ var PerpetualsClient = (function () {
|
|
|
4803
4825
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
|
4804
4826
|
_f.label = 5;
|
|
4805
4827
|
case 5:
|
|
4806
|
-
_f.trys.push([5,
|
|
4828
|
+
_f.trys.push([5, 8, , 9]);
|
|
4807
4829
|
if (enableHeapSizeIx) {
|
|
4808
4830
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4809
4831
|
bytes: 64 * 1024,
|
|
@@ -4813,6 +4835,10 @@ var PerpetualsClient = (function () {
|
|
|
4813
4835
|
}
|
|
4814
4836
|
preInstructions.push(heapSizeIx);
|
|
4815
4837
|
}
|
|
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();
|
|
4816
4842
|
return [4, this.program.methods
|
|
4817
4843
|
.removeCompoundingLiquidity({
|
|
4818
4844
|
compoundingAmountIn: compoundingAmountIn,
|
|
@@ -4838,19 +4864,20 @@ var PerpetualsClient = (function () {
|
|
|
4838
4864
|
program: this.program.programId,
|
|
4839
4865
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4840
4866
|
receivingMint: outCustodyConfig.mintKey,
|
|
4841
|
-
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
4867
|
+
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4868
|
+
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
4842
4869
|
})
|
|
4843
4870
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
4844
4871
|
.instruction()];
|
|
4845
|
-
case
|
|
4872
|
+
case 7:
|
|
4846
4873
|
removeCompoundingLiquidity = _f.sent();
|
|
4847
4874
|
instructions.push(removeCompoundingLiquidity);
|
|
4848
|
-
return [3,
|
|
4849
|
-
case
|
|
4875
|
+
return [3, 9];
|
|
4876
|
+
case 8:
|
|
4850
4877
|
err_17 = _f.sent();
|
|
4851
4878
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
|
|
4852
|
-
return [3,
|
|
4853
|
-
case
|
|
4879
|
+
return [3, 9];
|
|
4880
|
+
case 9: return [2, {
|
|
4854
4881
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4855
4882
|
additionalSigners: additionalSigners
|
|
4856
4883
|
}];
|
|
@@ -6398,7 +6425,7 @@ var PerpetualsClient = (function () {
|
|
|
6398
6425
|
args_1[_i - 5] = arguments[_i];
|
|
6399
6426
|
}
|
|
6400
6427
|
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) {
|
|
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;
|
|
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, whitelistPda, whitelistExists, params, inx, closeWsolATAIns, err_40;
|
|
6402
6429
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6403
6430
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6404
6431
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
@@ -6462,7 +6489,7 @@ var PerpetualsClient = (function () {
|
|
|
6462
6489
|
}
|
|
6463
6490
|
_g.label = 6;
|
|
6464
6491
|
case 6:
|
|
6465
|
-
_g.trys.push([6,
|
|
6492
|
+
_g.trys.push([6, 20, , 21]);
|
|
6466
6493
|
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
|
6467
6494
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
|
6468
6495
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
|
@@ -6564,6 +6591,10 @@ var PerpetualsClient = (function () {
|
|
|
6564
6591
|
isWritable: false,
|
|
6565
6592
|
});
|
|
6566
6593
|
}
|
|
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();
|
|
6567
6598
|
params = {
|
|
6568
6599
|
amountIn: amountIn,
|
|
6569
6600
|
minAmountOut: minAmountOut,
|
|
@@ -6591,22 +6622,23 @@ var PerpetualsClient = (function () {
|
|
|
6591
6622
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6592
6623
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
6593
6624
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6625
|
+
whitelist: whitelistExists ? whitelistPda : undefined,
|
|
6594
6626
|
})
|
|
6595
6627
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
6596
6628
|
.instruction()];
|
|
6597
|
-
case
|
|
6629
|
+
case 19:
|
|
6598
6630
|
inx = _g.sent();
|
|
6599
6631
|
instructions.push(inx);
|
|
6600
6632
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
|
6601
6633
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
|
6602
6634
|
instructions.push(closeWsolATAIns);
|
|
6603
6635
|
}
|
|
6604
|
-
return [3,
|
|
6605
|
-
case
|
|
6636
|
+
return [3, 21];
|
|
6637
|
+
case 20:
|
|
6606
6638
|
err_40 = _g.sent();
|
|
6607
6639
|
console.error("perpClient Swap error:: ", err_40);
|
|
6608
6640
|
throw err_40;
|
|
6609
|
-
case
|
|
6641
|
+
case 21: return [2, {
|
|
6610
6642
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6611
6643
|
additionalSigners: additionalSigners
|
|
6612
6644
|
}];
|
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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,7 +40,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.
|
|
43
|
+
exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
|
|
44
|
+
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|
|
44
45
|
var price_service_client_1 = require("@pythnetwork/price-service-client");
|
|
45
46
|
var web3_js_1 = require("@solana/web3.js");
|
|
46
47
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
@@ -156,4 +157,3 @@ function createBackupOracleInstruction(poolAddress_1) {
|
|
|
156
157
|
});
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
|
-
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|