flash-sdk 12.1.2-alpha.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +30 -26
- package/dist/PerpetualsClient.js +979 -744
- package/dist/PoolConfig.json +6 -6
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +2 -1
- package/dist/idl/perpetuals.d.ts +234 -127
- package/dist/idl/perpetuals.json +234 -127
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/generated.d.ts +7 -10
- package/package.json +3 -4
package/dist/PerpetualsClient.js
CHANGED
|
@@ -2709,7 +2709,7 @@ var PerpetualsClient = (function () {
|
|
|
2709
2709
|
for (var _i = 8; _i < arguments.length; _i++) {
|
|
2710
2710
|
args_1[_i - 8] = arguments[_i];
|
|
2711
2711
|
}
|
|
2712
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey
|
|
2712
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
2713
2713
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, collateralToken, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
|
|
2714
2714
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
2715
2715
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
@@ -2718,7 +2718,7 @@ var PerpetualsClient = (function () {
|
|
|
2718
2718
|
return __generator(this, function (_c) {
|
|
2719
2719
|
switch (_c.label) {
|
|
2720
2720
|
case 0:
|
|
2721
|
-
publicKey =
|
|
2721
|
+
publicKey = this.provider.wallet.publicKey;
|
|
2722
2722
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
2723
2723
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
2724
2724
|
collateralToken = poolConfig.getTokenFromSymbol(collateralSymbol);
|
|
@@ -2821,48 +2821,59 @@ var PerpetualsClient = (function () {
|
|
|
2821
2821
|
for (var _i = 6; _i < arguments.length; _i++) {
|
|
2822
2822
|
args_1[_i - 6] = arguments[_i];
|
|
2823
2823
|
}
|
|
2824
|
-
return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey
|
|
2825
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_1;
|
|
2824
|
+
return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
|
2825
|
+
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_1;
|
|
2826
2826
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
2827
2827
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
2828
2828
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
2829
2829
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
2830
2830
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
2831
|
-
return __generator(this, function (
|
|
2832
|
-
switch (
|
|
2831
|
+
return __generator(this, function (_b) {
|
|
2832
|
+
switch (_b.label) {
|
|
2833
2833
|
case 0:
|
|
2834
|
-
|
|
2834
|
+
console.log("close position :::", marketSymbol, poolConfig.getTokenFromSymbol(marketSymbol).mintKey.toBase58());
|
|
2835
|
+
publicKey = this.provider.wallet.publicKey;
|
|
2835
2836
|
preInstructions = [];
|
|
2836
2837
|
instructions = [];
|
|
2837
2838
|
postInstructions = [];
|
|
2838
2839
|
additionalSigners = [];
|
|
2839
|
-
|
|
2840
|
+
_b.label = 1;
|
|
2840
2841
|
case 1:
|
|
2841
|
-
|
|
2842
|
-
if (collateralSymbol == 'SOL')
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
}
|
|
2848
|
-
preInstructions = [
|
|
2849
|
-
web3_js_1.SystemProgram.createAccount({
|
|
2850
|
-
fromPubkey: publicKey,
|
|
2851
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
2852
|
-
lamports: lamports,
|
|
2853
|
-
space: 165,
|
|
2854
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2855
|
-
}),
|
|
2856
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
2857
|
-
];
|
|
2858
|
-
postInstructions = [
|
|
2859
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
2860
|
-
];
|
|
2842
|
+
_b.trys.push([1, 7, , 8]);
|
|
2843
|
+
if (!(collateralSymbol == 'SOL')) return [3, 2];
|
|
2844
|
+
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
|
2845
|
+
if (!ephemeralSignerPubkey) {
|
|
2846
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
2847
|
+
additionalSigners.push(wrappedSolAccount);
|
|
2861
2848
|
}
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2849
|
+
preInstructions = [
|
|
2850
|
+
web3_js_1.SystemProgram.createAccount({
|
|
2851
|
+
fromPubkey: publicKey,
|
|
2852
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
2853
|
+
lamports: lamports,
|
|
2854
|
+
space: 165,
|
|
2855
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2856
|
+
}),
|
|
2857
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
2858
|
+
];
|
|
2859
|
+
postInstructions = [
|
|
2860
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
2861
|
+
];
|
|
2862
|
+
return [3, 5];
|
|
2863
|
+
case 2:
|
|
2864
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
2865
|
+
_a = createUserATA;
|
|
2866
|
+
if (!_a) return [3, 4];
|
|
2867
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
2868
|
+
case 3:
|
|
2869
|
+
_a = !(_b.sent());
|
|
2870
|
+
_b.label = 4;
|
|
2871
|
+
case 4:
|
|
2872
|
+
if (_a) {
|
|
2873
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
2865
2874
|
}
|
|
2875
|
+
_b.label = 5;
|
|
2876
|
+
case 5:
|
|
2866
2877
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
2867
2878
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(marketSymbol).mintKey); });
|
|
2868
2879
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
@@ -2893,19 +2904,19 @@ var PerpetualsClient = (function () {
|
|
|
2893
2904
|
})
|
|
2894
2905
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, privilege), true))
|
|
2895
2906
|
.instruction()];
|
|
2896
|
-
case
|
|
2897
|
-
instruction =
|
|
2907
|
+
case 6:
|
|
2908
|
+
instruction = _b.sent();
|
|
2898
2909
|
instructions.push(instruction);
|
|
2899
2910
|
if (collateralSymbol == 'WSOL' && closeUsersWSOLATA) {
|
|
2900
2911
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
2901
2912
|
postInstructions.push(closeWsolATAIns);
|
|
2902
2913
|
}
|
|
2903
|
-
return [3,
|
|
2904
|
-
case
|
|
2905
|
-
error_1 =
|
|
2914
|
+
return [3, 8];
|
|
2915
|
+
case 7:
|
|
2916
|
+
error_1 = _b.sent();
|
|
2906
2917
|
console.error("perpclient closePosition error:", error_1);
|
|
2907
2918
|
throw error_1;
|
|
2908
|
-
case
|
|
2919
|
+
case 8: return [2, {
|
|
2909
2920
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
2910
2921
|
additionalSigners: additionalSigners
|
|
2911
2922
|
}];
|
|
@@ -2918,7 +2929,7 @@ var PerpetualsClient = (function () {
|
|
|
2918
2929
|
for (var _i = 9; _i < arguments.length; _i++) {
|
|
2919
2930
|
args_1[_i - 9] = arguments[_i];
|
|
2920
2931
|
}
|
|
2921
|
-
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey
|
|
2932
|
+
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
2922
2933
|
var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, targetToken, userInputTokenAccount, userInputToken, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_3;
|
|
2923
2934
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
2924
2935
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
@@ -2927,7 +2938,7 @@ var PerpetualsClient = (function () {
|
|
|
2927
2938
|
return __generator(this, function (_c) {
|
|
2928
2939
|
switch (_c.label) {
|
|
2929
2940
|
case 0:
|
|
2930
|
-
publicKey =
|
|
2941
|
+
publicKey = this.provider.wallet.publicKey;
|
|
2931
2942
|
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
|
2932
2943
|
if (!userInputCustodyConfig) {
|
|
2933
2944
|
throw "userInputCustodyConfig not found";
|
|
@@ -2951,7 +2962,7 @@ var PerpetualsClient = (function () {
|
|
|
2951
2962
|
additionalSigners = [];
|
|
2952
2963
|
targetToken = poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol);
|
|
2953
2964
|
userInputToken = poolConfig.getTokenFromSymbol(userInputTokenSymbol);
|
|
2954
|
-
if (!(userInputTokenSymbol == 'SOL')) return [3,
|
|
2965
|
+
if (!(userInputTokenSymbol == 'SOL')) return [3, 5];
|
|
2955
2966
|
console.log("inputSymbol === SOL", userInputTokenSymbol);
|
|
2956
2967
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
|
2957
2968
|
if (!!skipBalanceChecks) return [3, 2];
|
|
@@ -2981,33 +2992,41 @@ var PerpetualsClient = (function () {
|
|
|
2981
2992
|
postInstructions = [
|
|
2982
2993
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
2983
2994
|
];
|
|
2984
|
-
if (
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
}
|
|
2988
|
-
return [3, 7];
|
|
2995
|
+
if (!!poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).mintKey.equals(spl_token_1.NATIVE_MINT)) return [3, 4];
|
|
2996
|
+
userOutputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
2997
|
+
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
|
2989
2998
|
case 3:
|
|
2999
|
+
if (!(_c.sent())) {
|
|
3000
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).mintKey));
|
|
3001
|
+
}
|
|
3002
|
+
_c.label = 4;
|
|
3003
|
+
case 4: return [3, 10];
|
|
3004
|
+
case 5:
|
|
2990
3005
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
2991
|
-
if (!!skipBalanceChecks) return [3,
|
|
3006
|
+
if (!!skipBalanceChecks) return [3, 8];
|
|
2992
3007
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
|
2993
|
-
case
|
|
3008
|
+
case 6:
|
|
2994
3009
|
if (!(_c.sent())) {
|
|
2995
3010
|
throw "Insufficient Funds , Token Account doesn't exist";
|
|
2996
3011
|
}
|
|
2997
3012
|
_b = anchor_1.BN.bind;
|
|
2998
3013
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
|
2999
|
-
case
|
|
3014
|
+
case 7:
|
|
3000
3015
|
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_c.sent()).value.amount]))();
|
|
3001
3016
|
if (tokenAccountBalance.lt(amountIn)) {
|
|
3002
3017
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
|
3003
3018
|
}
|
|
3004
|
-
_c.label =
|
|
3005
|
-
case
|
|
3019
|
+
_c.label = 8;
|
|
3020
|
+
case 8:
|
|
3006
3021
|
userOutputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3022
|
+
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
|
3023
|
+
case 9:
|
|
3024
|
+
if (!(_c.sent())) {
|
|
3025
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).mintKey, poolConfig.getTokenFromSymbol(targetCustodyConfig.symbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3026
|
+
}
|
|
3027
|
+
_c.label = 10;
|
|
3028
|
+
case 10:
|
|
3029
|
+
_c.trys.push([10, 12, , 13]);
|
|
3011
3030
|
return [4, this.program.methods
|
|
3012
3031
|
.swapAndOpen({
|
|
3013
3032
|
amountIn: amountIn,
|
|
@@ -3042,15 +3061,15 @@ var PerpetualsClient = (function () {
|
|
|
3042
3061
|
})
|
|
3043
3062
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, privilege), true))
|
|
3044
3063
|
.instruction()];
|
|
3045
|
-
case
|
|
3064
|
+
case 11:
|
|
3046
3065
|
inx = _c.sent();
|
|
3047
3066
|
instructions.push(inx);
|
|
3048
|
-
return [3,
|
|
3049
|
-
case
|
|
3067
|
+
return [3, 13];
|
|
3068
|
+
case 12:
|
|
3050
3069
|
err_3 = _c.sent();
|
|
3051
3070
|
console.error("perpClient SwapAndOpen error:: ", err_3);
|
|
3052
3071
|
throw err_3;
|
|
3053
|
-
case
|
|
3072
|
+
case 13: return [2, {
|
|
3054
3073
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3055
3074
|
additionalSigners: additionalSigners
|
|
3056
3075
|
}];
|
|
@@ -3063,7 +3082,7 @@ var PerpetualsClient = (function () {
|
|
|
3063
3082
|
for (var _i = 7; _i < arguments.length; _i++) {
|
|
3064
3083
|
args_1[_i - 7] = arguments[_i];
|
|
3065
3084
|
}
|
|
3066
|
-
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, ephemeralSignerPubkey
|
|
3085
|
+
return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, ephemeralSignerPubkey) {
|
|
3067
3086
|
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, collateralToken, userOutputToken, lamports, userCollateralTokenAccount, inx, err_4;
|
|
3068
3087
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
3069
3088
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
@@ -3071,7 +3090,7 @@ var PerpetualsClient = (function () {
|
|
|
3071
3090
|
return __generator(this, function (_a) {
|
|
3072
3091
|
switch (_a.label) {
|
|
3073
3092
|
case 0:
|
|
3074
|
-
publicKey =
|
|
3093
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3075
3094
|
userOutputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey); });
|
|
3076
3095
|
if (!userOutputCustodyConfig) {
|
|
3077
3096
|
throw "userOutputCustodyConfig not found";
|
|
@@ -3095,37 +3114,46 @@ var PerpetualsClient = (function () {
|
|
|
3095
3114
|
additionalSigners = [];
|
|
3096
3115
|
collateralToken = poolConfig.getTokenFromSymbol(collateralTokenSymbol);
|
|
3097
3116
|
userOutputToken = poolConfig.getTokenFromSymbol(userOutputTokenSymbol);
|
|
3098
|
-
if (userOutputTokenSymbol == 'SOL')
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
additionalSigners.push(wrappedSolAccount);
|
|
3104
|
-
}
|
|
3105
|
-
preInstructions = [
|
|
3106
|
-
web3_js_1.SystemProgram.createAccount({
|
|
3107
|
-
fromPubkey: publicKey,
|
|
3108
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3109
|
-
lamports: lamports,
|
|
3110
|
-
space: 165,
|
|
3111
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3112
|
-
}),
|
|
3113
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3114
|
-
];
|
|
3115
|
-
postInstructions = [
|
|
3116
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3117
|
-
];
|
|
3117
|
+
if (!(userOutputTokenSymbol == 'SOL')) return [3, 1];
|
|
3118
|
+
console.log("outputSymbol === SOL", userOutputTokenSymbol);
|
|
3119
|
+
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
|
3120
|
+
if (!ephemeralSignerPubkey) {
|
|
3121
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
3118
3122
|
additionalSigners.push(wrappedSolAccount);
|
|
3119
3123
|
}
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3124
|
+
preInstructions = [
|
|
3125
|
+
web3_js_1.SystemProgram.createAccount({
|
|
3126
|
+
fromPubkey: publicKey,
|
|
3127
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3128
|
+
lamports: lamports,
|
|
3129
|
+
space: 165,
|
|
3130
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3131
|
+
}),
|
|
3132
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3133
|
+
];
|
|
3134
|
+
postInstructions = [
|
|
3135
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3136
|
+
];
|
|
3137
|
+
additionalSigners.push(wrappedSolAccount);
|
|
3138
|
+
return [3, 3];
|
|
3139
|
+
case 1:
|
|
3140
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(userOutputToken.mintKey, publicKey, true, userOutputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3141
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
3142
|
+
case 2:
|
|
3143
|
+
if (!(_a.sent())) {
|
|
3144
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, userOutputToken.mintKey, userOutputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3123
3145
|
}
|
|
3146
|
+
_a.label = 3;
|
|
3147
|
+
case 3:
|
|
3124
3148
|
userCollateralTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralToken.mintKey, publicKey, true, collateralToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3149
|
+
return [4, (0, utils_1.checkIfAccountExists)(userCollateralTokenAccount, this.provider.connection)];
|
|
3150
|
+
case 4:
|
|
3151
|
+
if (!(_a.sent())) {
|
|
3152
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userCollateralTokenAccount, publicKey, collateralToken.mintKey, collateralToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3153
|
+
}
|
|
3154
|
+
_a.label = 5;
|
|
3155
|
+
case 5:
|
|
3156
|
+
_a.trys.push([5, 7, , 8]);
|
|
3129
3157
|
return [4, this.program.methods
|
|
3130
3158
|
.closeAndSwap({
|
|
3131
3159
|
priceWithSlippage: priceWithSlippage,
|
|
@@ -3157,15 +3185,15 @@ var PerpetualsClient = (function () {
|
|
|
3157
3185
|
})
|
|
3158
3186
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, privilege), true))
|
|
3159
3187
|
.instruction()];
|
|
3160
|
-
case
|
|
3188
|
+
case 6:
|
|
3161
3189
|
inx = _a.sent();
|
|
3162
3190
|
instructions.push(inx);
|
|
3163
|
-
return [3,
|
|
3164
|
-
case
|
|
3191
|
+
return [3, 8];
|
|
3192
|
+
case 7:
|
|
3165
3193
|
err_4 = _a.sent();
|
|
3166
3194
|
console.error("perpClient CloseAndSwap error:: ", err_4);
|
|
3167
3195
|
throw err_4;
|
|
3168
|
-
case
|
|
3196
|
+
case 8: return [2, {
|
|
3169
3197
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3170
3198
|
additionalSigners: additionalSigners
|
|
3171
3199
|
}];
|
|
@@ -3178,14 +3206,14 @@ var PerpetualsClient = (function () {
|
|
|
3178
3206
|
for (var _i = 6; _i < arguments.length; _i++) {
|
|
3179
3207
|
args_1[_i - 6] = arguments[_i];
|
|
3180
3208
|
}
|
|
3181
|
-
return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey
|
|
3209
|
+
return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
3182
3210
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
|
|
3183
3211
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3184
3212
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3185
3213
|
return __generator(this, function (_c) {
|
|
3186
3214
|
switch (_c.label) {
|
|
3187
3215
|
case 0:
|
|
3188
|
-
publicKey =
|
|
3216
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3189
3217
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
3190
3218
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
3191
3219
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
@@ -3279,14 +3307,14 @@ var PerpetualsClient = (function () {
|
|
|
3279
3307
|
for (var _i = 7; _i < arguments.length; _i++) {
|
|
3280
3308
|
args_1[_i - 7] = arguments[_i];
|
|
3281
3309
|
}
|
|
3282
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey
|
|
3310
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
3283
3311
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
|
|
3284
3312
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3285
3313
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3286
3314
|
return __generator(this, function (_c) {
|
|
3287
3315
|
switch (_c.label) {
|
|
3288
3316
|
case 0:
|
|
3289
|
-
publicKey =
|
|
3317
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3290
3318
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
3291
3319
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
3292
3320
|
inputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inputSymbol).mintKey); });
|
|
@@ -3350,7 +3378,11 @@ var PerpetualsClient = (function () {
|
|
|
3350
3378
|
_c.label = 6;
|
|
3351
3379
|
case 6:
|
|
3352
3380
|
userCollateralTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralCustodyConfig.mintKey, publicKey, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3353
|
-
|
|
3381
|
+
return [4, (0, utils_1.checkIfAccountExists)(userCollateralTokenAccount, this.provider.connection)];
|
|
3382
|
+
case 7:
|
|
3383
|
+
if (!(_c.sent())) {
|
|
3384
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userCollateralTokenAccount, publicKey, collateralCustodyConfig.mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3385
|
+
}
|
|
3354
3386
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
3355
3387
|
return [4, this.program.methods.swapAndAddCollateral({
|
|
3356
3388
|
amountIn: amountIn,
|
|
@@ -3376,7 +3408,7 @@ var PerpetualsClient = (function () {
|
|
|
3376
3408
|
fundingMint: poolConfig.getTokenFromSymbol(inputSymbol).mintKey,
|
|
3377
3409
|
})
|
|
3378
3410
|
.instruction()];
|
|
3379
|
-
case
|
|
3411
|
+
case 8:
|
|
3380
3412
|
instruction = _c.sent();
|
|
3381
3413
|
instructions.push(instruction);
|
|
3382
3414
|
return [2, {
|
|
@@ -3392,15 +3424,15 @@ var PerpetualsClient = (function () {
|
|
|
3392
3424
|
for (var _i = 6; _i < arguments.length; _i++) {
|
|
3393
3425
|
args_1[_i - 6] = arguments[_i];
|
|
3394
3426
|
}
|
|
3395
|
-
return __awaiter(_this, __spreadArray([collateralDeltaUsd_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralDeltaUsd, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey
|
|
3396
|
-
var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, marketAccount, instruction, closeWsolATAIns, error_2;
|
|
3427
|
+
return __awaiter(_this, __spreadArray([collateralDeltaUsd_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralDeltaUsd, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
|
3428
|
+
var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_2;
|
|
3397
3429
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
3398
3430
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
|
3399
3431
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3400
|
-
return __generator(this, function (
|
|
3401
|
-
switch (
|
|
3432
|
+
return __generator(this, function (_b) {
|
|
3433
|
+
switch (_b.label) {
|
|
3402
3434
|
case 0:
|
|
3403
|
-
publicKey =
|
|
3435
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3404
3436
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) {
|
|
3405
3437
|
return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
|
|
3406
3438
|
});
|
|
@@ -3414,35 +3446,45 @@ var PerpetualsClient = (function () {
|
|
|
3414
3446
|
instructions = [];
|
|
3415
3447
|
postInstructions = [];
|
|
3416
3448
|
additionalSigners = [];
|
|
3417
|
-
|
|
3449
|
+
_b.label = 1;
|
|
3418
3450
|
case 1:
|
|
3419
|
-
|
|
3451
|
+
_b.trys.push([1, 7, , 8]);
|
|
3420
3452
|
console.log("removeCollateral -- collateralSymbol:", collateralSymbol);
|
|
3421
|
-
if (collateralSymbol == 'SOL')
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
}
|
|
3428
|
-
preInstructions = [
|
|
3429
|
-
web3_js_1.SystemProgram.createAccount({
|
|
3430
|
-
fromPubkey: publicKey,
|
|
3431
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3432
|
-
lamports: lamports,
|
|
3433
|
-
space: 165,
|
|
3434
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3435
|
-
}),
|
|
3436
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3437
|
-
];
|
|
3438
|
-
postInstructions = [
|
|
3439
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3440
|
-
];
|
|
3453
|
+
if (!(collateralSymbol == 'SOL')) return [3, 2];
|
|
3454
|
+
console.log("remove collateral in SOL ...create WSOL temp and close it ");
|
|
3455
|
+
lamports = this.minimumBalanceForRentExemptAccountLamports;
|
|
3456
|
+
if (!ephemeralSignerPubkey) {
|
|
3457
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
3458
|
+
additionalSigners.push(wrappedSolAccount);
|
|
3441
3459
|
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3460
|
+
preInstructions = [
|
|
3461
|
+
web3_js_1.SystemProgram.createAccount({
|
|
3462
|
+
fromPubkey: publicKey,
|
|
3463
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3464
|
+
lamports: lamports,
|
|
3465
|
+
space: 165,
|
|
3466
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3467
|
+
}),
|
|
3468
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3469
|
+
];
|
|
3470
|
+
postInstructions = [
|
|
3471
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3472
|
+
];
|
|
3473
|
+
return [3, 5];
|
|
3474
|
+
case 2:
|
|
3475
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3476
|
+
_a = createUserATA;
|
|
3477
|
+
if (!_a) return [3, 4];
|
|
3478
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
3479
|
+
case 3:
|
|
3480
|
+
_a = !(_b.sent());
|
|
3481
|
+
_b.label = 4;
|
|
3482
|
+
case 4:
|
|
3483
|
+
if (_a) {
|
|
3484
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3445
3485
|
}
|
|
3486
|
+
_b.label = 5;
|
|
3487
|
+
case 5:
|
|
3446
3488
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
3447
3489
|
return [4, this.program.methods
|
|
3448
3490
|
.removeCollateral({
|
|
@@ -3467,19 +3509,19 @@ var PerpetualsClient = (function () {
|
|
|
3467
3509
|
receivingMint: collateralCustodyConfig.mintKey
|
|
3468
3510
|
})
|
|
3469
3511
|
.instruction()];
|
|
3470
|
-
case
|
|
3471
|
-
instruction =
|
|
3512
|
+
case 6:
|
|
3513
|
+
instruction = _b.sent();
|
|
3472
3514
|
instructions.push(instruction);
|
|
3473
3515
|
if (collateralSymbol == 'WSOL' && closeUsersWSOLATA) {
|
|
3474
3516
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
|
3475
3517
|
postInstructions.push(closeWsolATAIns);
|
|
3476
3518
|
}
|
|
3477
|
-
return [3,
|
|
3478
|
-
case
|
|
3479
|
-
error_2 =
|
|
3519
|
+
return [3, 8];
|
|
3520
|
+
case 7:
|
|
3521
|
+
error_2 = _b.sent();
|
|
3480
3522
|
console.error("perpclient removeCollateral error:", error_2);
|
|
3481
3523
|
throw error_2;
|
|
3482
|
-
case
|
|
3524
|
+
case 8: return [2, {
|
|
3483
3525
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3484
3526
|
additionalSigners: additionalSigners
|
|
3485
3527
|
}];
|
|
@@ -3492,13 +3534,13 @@ var PerpetualsClient = (function () {
|
|
|
3492
3534
|
for (var _i = 6; _i < arguments.length; _i++) {
|
|
3493
3535
|
args_1[_i - 6] = arguments[_i];
|
|
3494
3536
|
}
|
|
3495
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, collateralDeltaUsd_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, collateralDeltaUsd, side, poolConfig, ephemeralSignerPubkey
|
|
3537
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, collateralDeltaUsd_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, collateralDeltaUsd, side, poolConfig, ephemeralSignerPubkey) {
|
|
3496
3538
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
|
|
3497
3539
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3498
3540
|
return __generator(this, function (_a) {
|
|
3499
3541
|
switch (_a.label) {
|
|
3500
3542
|
case 0:
|
|
3501
|
-
publicKey =
|
|
3543
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3502
3544
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
3503
3545
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
3504
3546
|
outputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outputSymbol).mintKey); });
|
|
@@ -3509,33 +3551,42 @@ var PerpetualsClient = (function () {
|
|
|
3509
3551
|
instructions = [];
|
|
3510
3552
|
postInstructions = [];
|
|
3511
3553
|
additionalSigners = [];
|
|
3512
|
-
if (outputSymbol == 'SOL')
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
}
|
|
3519
|
-
preInstructions = [
|
|
3520
|
-
web3_js_1.SystemProgram.createAccount({
|
|
3521
|
-
fromPubkey: publicKey,
|
|
3522
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3523
|
-
lamports: lamports,
|
|
3524
|
-
space: 165,
|
|
3525
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3526
|
-
}),
|
|
3527
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3528
|
-
];
|
|
3529
|
-
postInstructions = [
|
|
3530
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3531
|
-
];
|
|
3554
|
+
if (!(outputSymbol == 'SOL')) return [3, 1];
|
|
3555
|
+
console.log("outputSymbol === SOL", outputSymbol);
|
|
3556
|
+
lamports = this.minimumBalanceForRentExemptAccountLamports;
|
|
3557
|
+
if (!ephemeralSignerPubkey) {
|
|
3558
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
3559
|
+
additionalSigners.push(wrappedSolAccount);
|
|
3532
3560
|
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3561
|
+
preInstructions = [
|
|
3562
|
+
web3_js_1.SystemProgram.createAccount({
|
|
3563
|
+
fromPubkey: publicKey,
|
|
3564
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
3565
|
+
lamports: lamports,
|
|
3566
|
+
space: 165,
|
|
3567
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3568
|
+
}),
|
|
3569
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
3570
|
+
];
|
|
3571
|
+
postInstructions = [
|
|
3572
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3573
|
+
];
|
|
3574
|
+
return [3, 3];
|
|
3575
|
+
case 1:
|
|
3576
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(outputSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(outputSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3577
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
3578
|
+
case 2:
|
|
3579
|
+
if (!(_a.sent())) {
|
|
3580
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(outputSymbol).mintKey, poolConfig.getTokenFromSymbol(outputSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3536
3581
|
}
|
|
3582
|
+
_a.label = 3;
|
|
3583
|
+
case 3:
|
|
3537
3584
|
userCollateralTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3538
|
-
|
|
3585
|
+
return [4, (0, utils_1.checkIfAccountExists)(userCollateralTokenAccount, this.provider.connection)];
|
|
3586
|
+
case 4:
|
|
3587
|
+
if (!(_a.sent())) {
|
|
3588
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userCollateralTokenAccount, publicKey, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
3589
|
+
}
|
|
3539
3590
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
3540
3591
|
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
|
3541
3592
|
return [4, this.program.methods
|
|
@@ -3567,7 +3618,7 @@ var PerpetualsClient = (function () {
|
|
|
3567
3618
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
3568
3619
|
})
|
|
3569
3620
|
.instruction()];
|
|
3570
|
-
case
|
|
3621
|
+
case 5:
|
|
3571
3622
|
instruction = _a.sent();
|
|
3572
3623
|
instructions.push(instruction);
|
|
3573
3624
|
return [2, {
|
|
@@ -3583,14 +3634,14 @@ var PerpetualsClient = (function () {
|
|
|
3583
3634
|
for (var _i = 8; _i < arguments.length; _i++) {
|
|
3584
3635
|
args_1[_i - 8] = arguments[_i];
|
|
3585
3636
|
}
|
|
3586
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount
|
|
3637
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount) {
|
|
3587
3638
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
|
3588
3639
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
3589
3640
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
3590
3641
|
return __generator(this, function (_a) {
|
|
3591
3642
|
switch (_a.label) {
|
|
3592
3643
|
case 0:
|
|
3593
|
-
publicKey =
|
|
3644
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3594
3645
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) {
|
|
3595
3646
|
return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
|
|
3596
3647
|
});
|
|
@@ -3646,14 +3697,14 @@ var PerpetualsClient = (function () {
|
|
|
3646
3697
|
for (var _i = 8; _i < arguments.length; _i++) {
|
|
3647
3698
|
args_1[_i - 8] = arguments[_i];
|
|
3648
3699
|
}
|
|
3649
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount
|
|
3700
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount) {
|
|
3650
3701
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
|
3651
3702
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
3652
3703
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
3653
3704
|
return __generator(this, function (_a) {
|
|
3654
3705
|
switch (_a.label) {
|
|
3655
3706
|
case 0:
|
|
3656
|
-
publicKey =
|
|
3707
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3657
3708
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) {
|
|
3658
3709
|
return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
|
|
3659
3710
|
});
|
|
@@ -3709,7 +3760,7 @@ var PerpetualsClient = (function () {
|
|
|
3709
3760
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3710
3761
|
args_1[_i - 4] = arguments[_i];
|
|
3711
3762
|
}
|
|
3712
|
-
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser, includeRemainingAccounts
|
|
3763
|
+
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser, includeRemainingAccounts) {
|
|
3713
3764
|
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, whitelistMeta, instruction, err_5;
|
|
3714
3765
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3715
3766
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
@@ -3718,7 +3769,7 @@ var PerpetualsClient = (function () {
|
|
|
3718
3769
|
return __generator(this, function (_g) {
|
|
3719
3770
|
switch (_g.label) {
|
|
3720
3771
|
case 0:
|
|
3721
|
-
publicKey =
|
|
3772
|
+
publicKey = this.provider.wallet.publicKey;
|
|
3722
3773
|
payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
|
|
3723
3774
|
if (!payTokenCustodyConfig) {
|
|
3724
3775
|
throw "payTokenCustodyConfig not found";
|
|
@@ -3730,7 +3781,7 @@ var PerpetualsClient = (function () {
|
|
|
3730
3781
|
payToken = poolConfig.getTokenFromSymbol(payTokenSymbol);
|
|
3731
3782
|
_g.label = 1;
|
|
3732
3783
|
case 1:
|
|
3733
|
-
_g.trys.push([1,
|
|
3784
|
+
_g.trys.push([1, 10, , 11]);
|
|
3734
3785
|
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);
|
|
3735
3786
|
lpTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.stakedLpTokenMint, publicKey, true);
|
|
3736
3787
|
custodyAccountMetas = [];
|
|
@@ -3757,20 +3808,24 @@ var PerpetualsClient = (function () {
|
|
|
3757
3808
|
isWritable: false,
|
|
3758
3809
|
});
|
|
3759
3810
|
}
|
|
3760
|
-
|
|
3761
|
-
|
|
3811
|
+
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
|
3812
|
+
case 2:
|
|
3813
|
+
if (!(_g.sent())) {
|
|
3814
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
|
3815
|
+
}
|
|
3816
|
+
if (!(payTokenSymbol == 'SOL')) return [3, 5];
|
|
3762
3817
|
console.log("payTokenSymbol === SOL", payTokenSymbol);
|
|
3763
3818
|
lamports = tokenAmountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
|
3764
|
-
if (!!skipBalanceChecks) return [3,
|
|
3819
|
+
if (!!skipBalanceChecks) return [3, 4];
|
|
3765
3820
|
_e = anchor_1.BN.bind;
|
|
3766
3821
|
return [4, this.provider.connection.getBalance(publicKey)];
|
|
3767
|
-
case
|
|
3822
|
+
case 3:
|
|
3768
3823
|
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
|
3769
3824
|
if (unWrappedSolBalance.lt(lamports)) {
|
|
3770
3825
|
throw "Insufficient SOL Funds";
|
|
3771
3826
|
}
|
|
3772
|
-
_g.label =
|
|
3773
|
-
case
|
|
3827
|
+
_g.label = 4;
|
|
3828
|
+
case 4:
|
|
3774
3829
|
if (!ephemeralSignerPubkey) {
|
|
3775
3830
|
wrappedSolAccount = new web3_js_1.Keypair();
|
|
3776
3831
|
additionalSigners.push(wrappedSolAccount);
|
|
@@ -3788,23 +3843,23 @@ var PerpetualsClient = (function () {
|
|
|
3788
3843
|
postInstructions = [
|
|
3789
3844
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3790
3845
|
];
|
|
3791
|
-
return [3,
|
|
3792
|
-
case 4:
|
|
3793
|
-
if (!!skipBalanceChecks) return [3, 7];
|
|
3794
|
-
return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
|
|
3846
|
+
return [3, 8];
|
|
3795
3847
|
case 5:
|
|
3848
|
+
if (!!skipBalanceChecks) return [3, 8];
|
|
3849
|
+
return [4, (0, utils_1.checkIfAccountExists)(userPayingTokenAccount, this.provider.connection)];
|
|
3850
|
+
case 6:
|
|
3796
3851
|
if (!(_g.sent())) {
|
|
3797
3852
|
throw "Insufficient Funds , token Account doesn't exist";
|
|
3798
3853
|
}
|
|
3799
3854
|
_f = anchor_1.BN.bind;
|
|
3800
3855
|
return [4, this.provider.connection.getTokenAccountBalance(userPayingTokenAccount)];
|
|
3801
|
-
case
|
|
3856
|
+
case 7:
|
|
3802
3857
|
tokenAccountBalance = new (_f.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
|
3803
3858
|
if (tokenAccountBalance.lt(tokenAmountIn)) {
|
|
3804
3859
|
throw "Insufficient Funds need more ".concat(tokenAmountIn.sub(tokenAccountBalance), " tokens");
|
|
3805
3860
|
}
|
|
3806
|
-
_g.label =
|
|
3807
|
-
case
|
|
3861
|
+
_g.label = 8;
|
|
3862
|
+
case 8:
|
|
3808
3863
|
whitelistPda = this.findProgramAddress("whitelist", [publicKey]).publicKey;
|
|
3809
3864
|
whitelistMeta = {
|
|
3810
3865
|
pubkey: whitelistPda,
|
|
@@ -3835,15 +3890,15 @@ var PerpetualsClient = (function () {
|
|
|
3835
3890
|
})
|
|
3836
3891
|
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3837
3892
|
.instruction()];
|
|
3838
|
-
case
|
|
3893
|
+
case 9:
|
|
3839
3894
|
instruction = _g.sent();
|
|
3840
3895
|
instructions.push(instruction);
|
|
3841
|
-
return [3,
|
|
3842
|
-
case
|
|
3896
|
+
return [3, 11];
|
|
3897
|
+
case 10:
|
|
3843
3898
|
err_5 = _g.sent();
|
|
3844
3899
|
console.error("perpClient addLiquidity error:: ", err_5);
|
|
3845
3900
|
throw err_5;
|
|
3846
|
-
case
|
|
3901
|
+
case 11: return [2, {
|
|
3847
3902
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
3848
3903
|
additionalSigners: additionalSigners
|
|
3849
3904
|
}];
|
|
@@ -3877,7 +3932,7 @@ var PerpetualsClient = (function () {
|
|
|
3877
3932
|
inputToken = poolConfig.getTokenFromSymbol(inputSymbol);
|
|
3878
3933
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
|
3879
3934
|
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
|
3880
|
-
if (!(inputSymbol == 'SOL')) return [3,
|
|
3935
|
+
if (!(inputSymbol == 'SOL')) return [3, 4];
|
|
3881
3936
|
console.log("inputSymbol === SOL", inputSymbol);
|
|
3882
3937
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
|
3883
3938
|
console.log("lamports:", lamports.toNumber());
|
|
@@ -3890,8 +3945,11 @@ var PerpetualsClient = (function () {
|
|
|
3890
3945
|
throw "Insufficient SOL Funds";
|
|
3891
3946
|
}
|
|
3892
3947
|
_g.label = 2;
|
|
3893
|
-
case 2:
|
|
3894
|
-
|
|
3948
|
+
case 2: return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
|
3949
|
+
case 3:
|
|
3950
|
+
if (!(_g.sent())) {
|
|
3951
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
|
3952
|
+
}
|
|
3895
3953
|
if (!ephemeralSignerPubkey) {
|
|
3896
3954
|
wrappedSolAccount = new web3_js_1.Keypair();
|
|
3897
3955
|
additionalSigners.push(wrappedSolAccount);
|
|
@@ -3909,24 +3967,24 @@ var PerpetualsClient = (function () {
|
|
|
3909
3967
|
postInstructions = [
|
|
3910
3968
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
3911
3969
|
];
|
|
3912
|
-
return [3,
|
|
3913
|
-
case
|
|
3970
|
+
return [3, 7];
|
|
3971
|
+
case 4:
|
|
3914
3972
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(inputCustodyConfig.mintKey, publicKey, true, inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
3915
|
-
if (!!skipBalanceChecks) return [3,
|
|
3973
|
+
if (!!skipBalanceChecks) return [3, 7];
|
|
3916
3974
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
|
3917
|
-
case
|
|
3975
|
+
case 5:
|
|
3918
3976
|
if (!(_g.sent())) {
|
|
3919
3977
|
throw "Insufficient Funds , token Account doesn't exist";
|
|
3920
3978
|
}
|
|
3921
3979
|
_b = anchor_1.BN.bind;
|
|
3922
3980
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
|
3923
|
-
case
|
|
3981
|
+
case 6:
|
|
3924
3982
|
tokenAccountBalance = new (_b.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
|
3925
3983
|
if (tokenAccountBalance.lt(amountIn)) {
|
|
3926
3984
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
|
3927
3985
|
}
|
|
3928
|
-
_g.label =
|
|
3929
|
-
case
|
|
3986
|
+
_g.label = 7;
|
|
3987
|
+
case 7:
|
|
3930
3988
|
custodyAccountMetas = [];
|
|
3931
3989
|
custodyOracleAccountMetas = [];
|
|
3932
3990
|
markets = [];
|
|
@@ -3981,7 +4039,7 @@ var PerpetualsClient = (function () {
|
|
|
3981
4039
|
})
|
|
3982
4040
|
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3983
4041
|
.instruction()];
|
|
3984
|
-
case
|
|
4042
|
+
case 8:
|
|
3985
4043
|
instruction = _g.sent();
|
|
3986
4044
|
instructions.push(instruction);
|
|
3987
4045
|
return [2, {
|
|
@@ -4459,12 +4517,12 @@ var PerpetualsClient = (function () {
|
|
|
4459
4517
|
}
|
|
4460
4518
|
});
|
|
4461
4519
|
}); };
|
|
4462
|
-
this.unstakeRequest = function (unstakeAmount, poolConfig
|
|
4520
|
+
this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
4463
4521
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_13;
|
|
4464
4522
|
return __generator(this, function (_a) {
|
|
4465
4523
|
switch (_a.label) {
|
|
4466
4524
|
case 0:
|
|
4467
|
-
publicKey =
|
|
4525
|
+
publicKey = this.provider.wallet.publicKey;
|
|
4468
4526
|
preInstructions = [];
|
|
4469
4527
|
instructions = [];
|
|
4470
4528
|
postInstructions = [];
|
|
@@ -4581,10 +4639,10 @@ var PerpetualsClient = (function () {
|
|
|
4581
4639
|
args_1[_i - 3] = arguments[_i];
|
|
4582
4640
|
}
|
|
4583
4641
|
return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
|
|
4584
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, tokenStakeAccounts, withdrawStakeInstruction, err_15;
|
|
4642
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_15;
|
|
4585
4643
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4586
|
-
return __generator(this, function (
|
|
4587
|
-
switch (
|
|
4644
|
+
return __generator(this, function (_b) {
|
|
4645
|
+
switch (_b.label) {
|
|
4588
4646
|
case 0:
|
|
4589
4647
|
publicKey = this.provider.wallet.publicKey;
|
|
4590
4648
|
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
|
@@ -4593,13 +4651,22 @@ var PerpetualsClient = (function () {
|
|
|
4593
4651
|
instructions = [];
|
|
4594
4652
|
postInstructions = [];
|
|
4595
4653
|
additionalSigners = [];
|
|
4596
|
-
|
|
4654
|
+
_b.label = 1;
|
|
4597
4655
|
case 1:
|
|
4598
|
-
|
|
4656
|
+
_b.trys.push([1, 5, , 6]);
|
|
4599
4657
|
pool = poolConfig.poolAddress;
|
|
4600
4658
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.program.programId)[0];
|
|
4601
4659
|
receivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rewardCustodyMint, publicKey, true);
|
|
4602
|
-
|
|
4660
|
+
_a = createUserATA;
|
|
4661
|
+
if (!_a) return [3, 3];
|
|
4662
|
+
return [4, (0, utils_1.checkIfAccountExists)(receivingTokenAccount, this.provider.connection)];
|
|
4663
|
+
case 2:
|
|
4664
|
+
_a = !(_b.sent());
|
|
4665
|
+
_b.label = 3;
|
|
4666
|
+
case 3:
|
|
4667
|
+
if (_a) {
|
|
4668
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, receivingTokenAccount, publicKey, rewardCustodyMint));
|
|
4669
|
+
}
|
|
4603
4670
|
tokenStakeAccounts = [];
|
|
4604
4671
|
if (tokenStakeAccount) {
|
|
4605
4672
|
tokenStakeAccounts.push({
|
|
@@ -4627,15 +4694,15 @@ var PerpetualsClient = (function () {
|
|
|
4627
4694
|
})
|
|
4628
4695
|
.remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
|
|
4629
4696
|
.instruction()];
|
|
4630
|
-
case
|
|
4631
|
-
withdrawStakeInstruction =
|
|
4697
|
+
case 4:
|
|
4698
|
+
withdrawStakeInstruction = _b.sent();
|
|
4632
4699
|
instructions.push(withdrawStakeInstruction);
|
|
4633
|
-
return [3,
|
|
4634
|
-
case
|
|
4635
|
-
err_15 =
|
|
4700
|
+
return [3, 6];
|
|
4701
|
+
case 5:
|
|
4702
|
+
err_15 = _b.sent();
|
|
4636
4703
|
console.log("perpClient withdrawStake error:: ", err_15);
|
|
4637
4704
|
throw err_15;
|
|
4638
|
-
case
|
|
4705
|
+
case 6: return [2, {
|
|
4639
4706
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4640
4707
|
additionalSigners: additionalSigners
|
|
4641
4708
|
}];
|
|
@@ -4695,21 +4762,29 @@ var PerpetualsClient = (function () {
|
|
|
4695
4762
|
isWritable: false,
|
|
4696
4763
|
});
|
|
4697
4764
|
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
if (!(
|
|
4765
|
+
return [4, (0, utils_1.checkIfAccountExists)(lpTokenAccount, this.provider.connection)];
|
|
4766
|
+
case 1:
|
|
4767
|
+
if (!(_f.sent())) {
|
|
4768
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, lpTokenAccount, publicKey, poolConfig.stakedLpTokenMint));
|
|
4769
|
+
}
|
|
4770
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoundingTokenAccount, this.provider.connection)];
|
|
4771
|
+
case 2:
|
|
4772
|
+
if (!(_f.sent())) {
|
|
4773
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoundingTokenAccount, publicKey, poolConfig.compoundingTokenMint));
|
|
4774
|
+
}
|
|
4775
|
+
if (!(inTokenSymbol == 'SOL')) return [3, 5];
|
|
4701
4776
|
console.log("inTokenSymbol === SOL", inTokenSymbol);
|
|
4702
4777
|
lamports = amountIn.add(new anchor_1.BN(this.minimumBalanceForRentExemptAccountLamports));
|
|
4703
|
-
if (!!skipBalanceChecks) return [3,
|
|
4778
|
+
if (!!skipBalanceChecks) return [3, 4];
|
|
4704
4779
|
_e = anchor_1.BN.bind;
|
|
4705
4780
|
return [4, this.provider.connection.getBalance(publicKey)];
|
|
4706
|
-
case
|
|
4781
|
+
case 3:
|
|
4707
4782
|
unWrappedSolBalance = new (_e.apply(anchor_1.BN, [void 0, _f.sent()]))();
|
|
4708
4783
|
if (unWrappedSolBalance.lt(lamports)) {
|
|
4709
4784
|
throw "Insufficient SOL Funds";
|
|
4710
4785
|
}
|
|
4711
|
-
_f.label =
|
|
4712
|
-
case
|
|
4786
|
+
_f.label = 4;
|
|
4787
|
+
case 4:
|
|
4713
4788
|
if (!ephemeralSignerPubkey) {
|
|
4714
4789
|
wrappedSolAccount = new web3_js_1.Keypair();
|
|
4715
4790
|
additionalSigners.push(wrappedSolAccount);
|
|
@@ -4727,17 +4802,17 @@ var PerpetualsClient = (function () {
|
|
|
4727
4802
|
postInstructions = [
|
|
4728
4803
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
4729
4804
|
];
|
|
4730
|
-
return [3,
|
|
4731
|
-
case
|
|
4732
|
-
if (!!skipBalanceChecks) return [3,
|
|
4805
|
+
return [3, 7];
|
|
4806
|
+
case 5:
|
|
4807
|
+
if (!!skipBalanceChecks) return [3, 7];
|
|
4733
4808
|
return [4, (0, utils_1.checkIfAccountExists)(fundingAccount, this.provider.connection)];
|
|
4734
|
-
case
|
|
4809
|
+
case 6:
|
|
4735
4810
|
if (!(_f.sent())) {
|
|
4736
4811
|
throw "Insufficient Funds , token Account doesn't exist";
|
|
4737
4812
|
}
|
|
4738
|
-
_f.label =
|
|
4739
|
-
case
|
|
4740
|
-
_f.trys.push([
|
|
4813
|
+
_f.label = 7;
|
|
4814
|
+
case 7:
|
|
4815
|
+
_f.trys.push([7, 9, , 10]);
|
|
4741
4816
|
if (enableHeapSizeIx) {
|
|
4742
4817
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4743
4818
|
bytes: 64 * 1024,
|
|
@@ -4778,15 +4853,15 @@ var PerpetualsClient = (function () {
|
|
|
4778
4853
|
})
|
|
4779
4854
|
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4780
4855
|
.instruction()];
|
|
4781
|
-
case
|
|
4856
|
+
case 8:
|
|
4782
4857
|
addCompoundingLiquidity = _f.sent();
|
|
4783
4858
|
instructions.push(addCompoundingLiquidity);
|
|
4784
|
-
return [3,
|
|
4785
|
-
case
|
|
4859
|
+
return [3, 10];
|
|
4860
|
+
case 9:
|
|
4786
4861
|
err_16 = _f.sent();
|
|
4787
4862
|
console.log("perpClient addCompoundingLiquidity error:: ", err_16);
|
|
4788
|
-
return [3,
|
|
4789
|
-
case
|
|
4863
|
+
return [3, 10];
|
|
4864
|
+
case 10: return [2, {
|
|
4790
4865
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4791
4866
|
additionalSigners: additionalSigners
|
|
4792
4867
|
}];
|
|
@@ -4800,15 +4875,15 @@ var PerpetualsClient = (function () {
|
|
|
4800
4875
|
args_1[_i - 5] = arguments[_i];
|
|
4801
4876
|
}
|
|
4802
4877
|
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, isWhitelistedUser, includeRemainingAccounts) {
|
|
4803
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, custodyAccountMetas, custodyOracleAccountMetas, markets,
|
|
4878
|
+
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, whitelistMeta, removeCompoundingLiquidity, err_17;
|
|
4804
4879
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4805
4880
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4806
4881
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4807
4882
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4808
4883
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4809
4884
|
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
4810
|
-
return __generator(this, function (
|
|
4811
|
-
switch (
|
|
4885
|
+
return __generator(this, function (_f) {
|
|
4886
|
+
switch (_f.label) {
|
|
4812
4887
|
case 0:
|
|
4813
4888
|
publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
|
|
4814
4889
|
preInstructions = [];
|
|
@@ -4819,35 +4894,45 @@ var PerpetualsClient = (function () {
|
|
|
4819
4894
|
outCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outTokenSymbol).mintKey); });
|
|
4820
4895
|
lpTokenMint = poolConfig.stakedLpTokenMint;
|
|
4821
4896
|
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
4822
|
-
if (outCustodyConfig.symbol == 'SOL')
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
}
|
|
4828
|
-
preInstructions = [
|
|
4829
|
-
web3_js_1.SystemProgram.createAccount({
|
|
4830
|
-
fromPubkey: publicKey,
|
|
4831
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
4832
|
-
lamports: lamports,
|
|
4833
|
-
space: 165,
|
|
4834
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4835
|
-
}),
|
|
4836
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
4837
|
-
];
|
|
4838
|
-
postInstructions = [
|
|
4839
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
4840
|
-
];
|
|
4897
|
+
if (!(outCustodyConfig.symbol == 'SOL')) return [3, 1];
|
|
4898
|
+
lamports = this.minimumBalanceForRentExemptAccountLamports;
|
|
4899
|
+
if (!ephemeralSignerPubkey) {
|
|
4900
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
4901
|
+
additionalSigners.push(wrappedSolAccount);
|
|
4841
4902
|
}
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4903
|
+
preInstructions = [
|
|
4904
|
+
web3_js_1.SystemProgram.createAccount({
|
|
4905
|
+
fromPubkey: publicKey,
|
|
4906
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
4907
|
+
lamports: lamports,
|
|
4908
|
+
space: 165,
|
|
4909
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4910
|
+
}),
|
|
4911
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
4912
|
+
];
|
|
4913
|
+
postInstructions = [
|
|
4914
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
4915
|
+
];
|
|
4916
|
+
return [3, 4];
|
|
4917
|
+
case 1:
|
|
4918
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(outCustodyConfig.mintKey, publicKey, true, poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
4919
|
+
_a = createUserATA;
|
|
4920
|
+
if (!_a) return [3, 3];
|
|
4921
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
4922
|
+
case 2:
|
|
4923
|
+
_a = !(_f.sent());
|
|
4924
|
+
_f.label = 3;
|
|
4925
|
+
case 3:
|
|
4926
|
+
if (_a) {
|
|
4927
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, outCustodyConfig.mintKey, poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
4845
4928
|
}
|
|
4929
|
+
_f.label = 4;
|
|
4930
|
+
case 4:
|
|
4846
4931
|
custodyAccountMetas = [];
|
|
4847
4932
|
custodyOracleAccountMetas = [];
|
|
4848
4933
|
markets = [];
|
|
4849
|
-
for (
|
|
4850
|
-
custody = _b
|
|
4934
|
+
for (_b = 0, _c = poolConfig.custodies; _b < _c.length; _b++) {
|
|
4935
|
+
custody = _c[_b];
|
|
4851
4936
|
custodyAccountMetas.push({
|
|
4852
4937
|
pubkey: custody.custodyAccount,
|
|
4853
4938
|
isSigner: false,
|
|
@@ -4859,8 +4944,8 @@ var PerpetualsClient = (function () {
|
|
|
4859
4944
|
isWritable: false,
|
|
4860
4945
|
});
|
|
4861
4946
|
}
|
|
4862
|
-
for (
|
|
4863
|
-
market = _d
|
|
4947
|
+
for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
|
|
4948
|
+
market = _e[_d];
|
|
4864
4949
|
markets.push({
|
|
4865
4950
|
pubkey: market.marketAccount,
|
|
4866
4951
|
isSigner: false,
|
|
@@ -4868,9 +4953,9 @@ var PerpetualsClient = (function () {
|
|
|
4868
4953
|
});
|
|
4869
4954
|
}
|
|
4870
4955
|
compoundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
|
4871
|
-
|
|
4872
|
-
case
|
|
4873
|
-
|
|
4956
|
+
_f.label = 5;
|
|
4957
|
+
case 5:
|
|
4958
|
+
_f.trys.push([5, 7, , 8]);
|
|
4874
4959
|
if (enableHeapSizeIx) {
|
|
4875
4960
|
heapSizeIx = web3_js_1.ComputeBudgetProgram.requestHeapFrame({
|
|
4876
4961
|
bytes: 64 * 1024,
|
|
@@ -4911,15 +4996,15 @@ var PerpetualsClient = (function () {
|
|
|
4911
4996
|
})
|
|
4912
4997
|
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4913
4998
|
.instruction()];
|
|
4914
|
-
case
|
|
4915
|
-
removeCompoundingLiquidity =
|
|
4999
|
+
case 6:
|
|
5000
|
+
removeCompoundingLiquidity = _f.sent();
|
|
4916
5001
|
instructions.push(removeCompoundingLiquidity);
|
|
4917
|
-
return [3,
|
|
4918
|
-
case
|
|
4919
|
-
err_17 =
|
|
5002
|
+
return [3, 8];
|
|
5003
|
+
case 7:
|
|
5004
|
+
err_17 = _f.sent();
|
|
4920
5005
|
console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
|
|
4921
|
-
return [3,
|
|
4922
|
-
case
|
|
5006
|
+
return [3, 8];
|
|
5007
|
+
case 8: return [2, {
|
|
4923
5008
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
4924
5009
|
additionalSigners: additionalSigners
|
|
4925
5010
|
}];
|
|
@@ -4932,13 +5017,13 @@ var PerpetualsClient = (function () {
|
|
|
4932
5017
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
4933
5018
|
args_1[_i - 3] = arguments[_i];
|
|
4934
5019
|
}
|
|
4935
|
-
return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA
|
|
4936
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts,
|
|
5020
|
+
return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
|
5021
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_18;
|
|
4937
5022
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4938
|
-
return __generator(this, function (
|
|
4939
|
-
switch (
|
|
5023
|
+
return __generator(this, function (_g) {
|
|
5024
|
+
switch (_g.label) {
|
|
4940
5025
|
case 0:
|
|
4941
|
-
publicKey =
|
|
5026
|
+
publicKey = this.provider.wallet.publicKey;
|
|
4942
5027
|
preInstructions = [];
|
|
4943
5028
|
instructions = [];
|
|
4944
5029
|
postInstructions = [];
|
|
@@ -4947,18 +5032,27 @@ var PerpetualsClient = (function () {
|
|
|
4947
5032
|
lpTokenMint = poolConfig.stakedLpTokenMint;
|
|
4948
5033
|
compoundingTokenMint = poolConfig.compoundingTokenMint;
|
|
4949
5034
|
compoudingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(compoundingTokenMint, publicKey, true);
|
|
4950
|
-
|
|
4951
|
-
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
|
4952
|
-
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
|
|
4953
|
-
tokenStakeAccounts = [];
|
|
4954
|
-
_a = tokenStakeAccount;
|
|
5035
|
+
_a = createUserATA;
|
|
4955
5036
|
if (!_a) return [3, 2];
|
|
4956
|
-
return [4, (0, utils_1.checkIfAccountExists)(
|
|
5037
|
+
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
|
4957
5038
|
case 1:
|
|
4958
|
-
_a = (
|
|
4959
|
-
|
|
5039
|
+
_a = !(_g.sent());
|
|
5040
|
+
_g.label = 2;
|
|
4960
5041
|
case 2:
|
|
4961
5042
|
if (_a) {
|
|
5043
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
|
5044
|
+
}
|
|
5045
|
+
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
|
5046
|
+
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
|
|
5047
|
+
tokenStakeAccounts = [];
|
|
5048
|
+
_b = tokenStakeAccount;
|
|
5049
|
+
if (!_b) return [3, 4];
|
|
5050
|
+
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
|
5051
|
+
case 3:
|
|
5052
|
+
_b = (_g.sent());
|
|
5053
|
+
_g.label = 4;
|
|
5054
|
+
case 4:
|
|
5055
|
+
if (_b) {
|
|
4962
5056
|
tokenStakeAccounts.push({
|
|
4963
5057
|
pubkey: tokenStakeAccount,
|
|
4964
5058
|
isSigner: false,
|
|
@@ -4969,8 +5063,8 @@ var PerpetualsClient = (function () {
|
|
|
4969
5063
|
custodyAccountMetas = [];
|
|
4970
5064
|
custodyOracleAccountMetas = [];
|
|
4971
5065
|
markets = [];
|
|
4972
|
-
for (
|
|
4973
|
-
custody = _c
|
|
5066
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
|
5067
|
+
custody = _d[_c];
|
|
4974
5068
|
custodyAccountMetas.push({
|
|
4975
5069
|
pubkey: custody.custodyAccount,
|
|
4976
5070
|
isSigner: false,
|
|
@@ -4982,17 +5076,17 @@ var PerpetualsClient = (function () {
|
|
|
4982
5076
|
isWritable: false,
|
|
4983
5077
|
});
|
|
4984
5078
|
}
|
|
4985
|
-
for (
|
|
4986
|
-
market = _e
|
|
5079
|
+
for (_e = 0, _f = poolConfig.markets; _e < _f.length; _e++) {
|
|
5080
|
+
market = _f[_e];
|
|
4987
5081
|
markets.push({
|
|
4988
5082
|
pubkey: market.marketAccount,
|
|
4989
5083
|
isSigner: false,
|
|
4990
5084
|
isWritable: false,
|
|
4991
5085
|
});
|
|
4992
5086
|
}
|
|
4993
|
-
|
|
4994
|
-
case
|
|
4995
|
-
|
|
5087
|
+
_g.label = 5;
|
|
5088
|
+
case 5:
|
|
5089
|
+
_g.trys.push([5, 7, , 8]);
|
|
4996
5090
|
return [4, this.program.methods
|
|
4997
5091
|
.migrateStake({
|
|
4998
5092
|
amount: amount
|
|
@@ -5016,15 +5110,15 @@ var PerpetualsClient = (function () {
|
|
|
5016
5110
|
})
|
|
5017
5111
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
|
|
5018
5112
|
.instruction()];
|
|
5019
|
-
case
|
|
5020
|
-
migrateStake =
|
|
5113
|
+
case 6:
|
|
5114
|
+
migrateStake = _g.sent();
|
|
5021
5115
|
instructions.push(migrateStake);
|
|
5022
|
-
return [3,
|
|
5023
|
-
case
|
|
5024
|
-
err_18 =
|
|
5116
|
+
return [3, 8];
|
|
5117
|
+
case 7:
|
|
5118
|
+
err_18 = _g.sent();
|
|
5025
5119
|
console.log("perpClient migrateStake error:: ", err_18);
|
|
5026
|
-
return [3,
|
|
5027
|
-
case
|
|
5120
|
+
return [3, 8];
|
|
5121
|
+
case 8: return [2, {
|
|
5028
5122
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5029
5123
|
additionalSigners: additionalSigners
|
|
5030
5124
|
}];
|
|
@@ -5032,12 +5126,52 @@ var PerpetualsClient = (function () {
|
|
|
5032
5126
|
});
|
|
5033
5127
|
});
|
|
5034
5128
|
};
|
|
5035
|
-
this.
|
|
5036
|
-
var publicKey,
|
|
5129
|
+
this.migrateTokenStake = function (tokenStakeAccounts) { return __awaiter(_this, void 0, void 0, function () {
|
|
5130
|
+
var publicKey, instructions, additionalSigners, remainingAccounts, migrateTokenStakeIx, err_19;
|
|
5131
|
+
return __generator(this, function (_a) {
|
|
5132
|
+
switch (_a.label) {
|
|
5133
|
+
case 0:
|
|
5134
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5135
|
+
instructions = [];
|
|
5136
|
+
additionalSigners = [];
|
|
5137
|
+
remainingAccounts = tokenStakeAccounts.map(function (pubkey) { return ({
|
|
5138
|
+
pubkey: pubkey,
|
|
5139
|
+
isSigner: false,
|
|
5140
|
+
isWritable: true,
|
|
5141
|
+
}); });
|
|
5142
|
+
_a.label = 1;
|
|
5143
|
+
case 1:
|
|
5144
|
+
_a.trys.push([1, 3, , 4]);
|
|
5145
|
+
return [4, this.program.methods
|
|
5146
|
+
.migrateTokenStake({})
|
|
5147
|
+
.accountsPartial({
|
|
5148
|
+
admin: publicKey,
|
|
5149
|
+
multisig: this.multisig.publicKey,
|
|
5150
|
+
program: this.program.programId,
|
|
5151
|
+
})
|
|
5152
|
+
.remainingAccounts(remainingAccounts)
|
|
5153
|
+
.instruction()];
|
|
5154
|
+
case 2:
|
|
5155
|
+
migrateTokenStakeIx = _a.sent();
|
|
5156
|
+
instructions.push(migrateTokenStakeIx);
|
|
5157
|
+
return [3, 4];
|
|
5158
|
+
case 3:
|
|
5159
|
+
err_19 = _a.sent();
|
|
5160
|
+
console.log("perpClient migrateTokenStake error:: ", err_19);
|
|
5161
|
+
return [3, 4];
|
|
5162
|
+
case 4: return [2, {
|
|
5163
|
+
instructions: instructions,
|
|
5164
|
+
additionalSigners: additionalSigners,
|
|
5165
|
+
}];
|
|
5166
|
+
}
|
|
5167
|
+
});
|
|
5168
|
+
}); };
|
|
5169
|
+
this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5170
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_20;
|
|
5037
5171
|
return __generator(this, function (_d) {
|
|
5038
5172
|
switch (_d.label) {
|
|
5039
5173
|
case 0:
|
|
5040
|
-
publicKey =
|
|
5174
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5041
5175
|
preInstructions = [];
|
|
5042
5176
|
instructions = [];
|
|
5043
5177
|
postInstructions = [];
|
|
@@ -5104,8 +5238,8 @@ var PerpetualsClient = (function () {
|
|
|
5104
5238
|
instructions.push(migrateFlp);
|
|
5105
5239
|
return [3, 4];
|
|
5106
5240
|
case 3:
|
|
5107
|
-
|
|
5108
|
-
console.log("perpClient migrateFlp error:: ",
|
|
5241
|
+
err_20 = _d.sent();
|
|
5242
|
+
console.log("perpClient migrateFlp error:: ", err_20);
|
|
5109
5243
|
return [3, 4];
|
|
5110
5244
|
case 4: return [2, {
|
|
5111
5245
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
@@ -5120,7 +5254,7 @@ var PerpetualsClient = (function () {
|
|
|
5120
5254
|
args_1[_i - 1] = arguments[_i];
|
|
5121
5255
|
}
|
|
5122
5256
|
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
|
|
5123
|
-
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee,
|
|
5257
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_21;
|
|
5124
5258
|
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
|
5125
5259
|
return __generator(this, function (_e) {
|
|
5126
5260
|
switch (_e.label) {
|
|
@@ -5177,8 +5311,8 @@ var PerpetualsClient = (function () {
|
|
|
5177
5311
|
instructions.push(compoundingFee);
|
|
5178
5312
|
return [3, 4];
|
|
5179
5313
|
case 3:
|
|
5180
|
-
|
|
5181
|
-
console.log("perpClient compoundingFee error:: ",
|
|
5314
|
+
err_21 = _e.sent();
|
|
5315
|
+
console.log("perpClient compoundingFee error:: ", err_21);
|
|
5182
5316
|
return [3, 4];
|
|
5183
5317
|
case 4: return [2, {
|
|
5184
5318
|
instructions: __spreadArray([], instructions, true),
|
|
@@ -5189,7 +5323,7 @@ var PerpetualsClient = (function () {
|
|
|
5189
5323
|
});
|
|
5190
5324
|
};
|
|
5191
5325
|
this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5192
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction,
|
|
5326
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_22;
|
|
5193
5327
|
return __generator(this, function (_a) {
|
|
5194
5328
|
switch (_a.label) {
|
|
5195
5329
|
case 0:
|
|
@@ -5199,10 +5333,14 @@ var PerpetualsClient = (function () {
|
|
|
5199
5333
|
additionalSigners = [];
|
|
5200
5334
|
_a.label = 1;
|
|
5201
5335
|
case 1:
|
|
5202
|
-
_a.trys.push([1,
|
|
5336
|
+
_a.trys.push([1, 4, , 5]);
|
|
5203
5337
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5204
5338
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
|
|
5205
|
-
|
|
5339
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5340
|
+
case 2:
|
|
5341
|
+
if (!(_a.sent())) {
|
|
5342
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(feePayer, userTokenAccount, owner, poolConfig.tokenMint));
|
|
5343
|
+
}
|
|
5206
5344
|
return [4, this.program.methods
|
|
5207
5345
|
.depositTokenStake({
|
|
5208
5346
|
depositAmount: depositAmount
|
|
@@ -5220,15 +5358,15 @@ var PerpetualsClient = (function () {
|
|
|
5220
5358
|
tokenMint: poolConfig.tokenMint,
|
|
5221
5359
|
})
|
|
5222
5360
|
.instruction()];
|
|
5223
|
-
case
|
|
5361
|
+
case 3:
|
|
5224
5362
|
depositTokenStakeInstruction = _a.sent();
|
|
5225
5363
|
instructions.push(depositTokenStakeInstruction);
|
|
5226
|
-
return [3,
|
|
5227
|
-
case
|
|
5228
|
-
|
|
5229
|
-
console.log("perpClient depositStakingInstruction error:: ",
|
|
5230
|
-
throw
|
|
5231
|
-
case
|
|
5364
|
+
return [3, 5];
|
|
5365
|
+
case 4:
|
|
5366
|
+
err_22 = _a.sent();
|
|
5367
|
+
console.log("perpClient depositStakingInstruction error:: ", err_22);
|
|
5368
|
+
throw err_22;
|
|
5369
|
+
case 5: return [2, {
|
|
5232
5370
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5233
5371
|
additionalSigners: additionalSigners
|
|
5234
5372
|
}];
|
|
@@ -5236,7 +5374,7 @@ var PerpetualsClient = (function () {
|
|
|
5236
5374
|
});
|
|
5237
5375
|
}); };
|
|
5238
5376
|
this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5239
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction,
|
|
5377
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_23;
|
|
5240
5378
|
return __generator(this, function (_a) {
|
|
5241
5379
|
switch (_a.label) {
|
|
5242
5380
|
case 0:
|
|
@@ -5264,9 +5402,9 @@ var PerpetualsClient = (function () {
|
|
|
5264
5402
|
instructions.push(unstakeTokenRequestInstruction);
|
|
5265
5403
|
return [3, 4];
|
|
5266
5404
|
case 3:
|
|
5267
|
-
|
|
5268
|
-
console.log("perpClient unstakeTokenRequestInstruction error:: ",
|
|
5269
|
-
throw
|
|
5405
|
+
err_23 = _a.sent();
|
|
5406
|
+
console.log("perpClient unstakeTokenRequestInstruction error:: ", err_23);
|
|
5407
|
+
throw err_23;
|
|
5270
5408
|
case 4: return [2, {
|
|
5271
5409
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5272
5410
|
additionalSigners: additionalSigners
|
|
@@ -5275,7 +5413,7 @@ var PerpetualsClient = (function () {
|
|
|
5275
5413
|
});
|
|
5276
5414
|
}); };
|
|
5277
5415
|
this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5278
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction,
|
|
5416
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_24;
|
|
5279
5417
|
return __generator(this, function (_a) {
|
|
5280
5418
|
switch (_a.label) {
|
|
5281
5419
|
case 0:
|
|
@@ -5285,10 +5423,14 @@ var PerpetualsClient = (function () {
|
|
|
5285
5423
|
additionalSigners = [];
|
|
5286
5424
|
_a.label = 1;
|
|
5287
5425
|
case 1:
|
|
5288
|
-
_a.trys.push([1,
|
|
5426
|
+
_a.trys.push([1, 4, , 5]);
|
|
5289
5427
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5290
5428
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
|
|
5291
|
-
|
|
5429
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5430
|
+
case 2:
|
|
5431
|
+
if (!(_a.sent())) {
|
|
5432
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(this.provider.wallet.publicKey, userTokenAccount, owner, poolConfig.tokenMint));
|
|
5433
|
+
}
|
|
5292
5434
|
return [4, this.program.methods
|
|
5293
5435
|
.unstakeTokenInstant({
|
|
5294
5436
|
unstakeAmount: unstakeAmount
|
|
@@ -5305,15 +5447,15 @@ var PerpetualsClient = (function () {
|
|
|
5305
5447
|
tokenMint: poolConfig.tokenMint,
|
|
5306
5448
|
})
|
|
5307
5449
|
.instruction()];
|
|
5308
|
-
case
|
|
5450
|
+
case 3:
|
|
5309
5451
|
unstakeTokenInstantInstruction = _a.sent();
|
|
5310
5452
|
instructions.push(unstakeTokenInstantInstruction);
|
|
5311
|
-
return [3,
|
|
5312
|
-
case
|
|
5313
|
-
|
|
5314
|
-
console.log("perpClient unstakeTokenInstantInstruction error:: ",
|
|
5315
|
-
throw
|
|
5316
|
-
case
|
|
5453
|
+
return [3, 5];
|
|
5454
|
+
case 4:
|
|
5455
|
+
err_24 = _a.sent();
|
|
5456
|
+
console.log("perpClient unstakeTokenInstantInstruction error:: ", err_24);
|
|
5457
|
+
throw err_24;
|
|
5458
|
+
case 5: return [2, {
|
|
5317
5459
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5318
5460
|
additionalSigners: additionalSigners
|
|
5319
5461
|
}];
|
|
@@ -5321,7 +5463,7 @@ var PerpetualsClient = (function () {
|
|
|
5321
5463
|
});
|
|
5322
5464
|
}); };
|
|
5323
5465
|
this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5324
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction,
|
|
5466
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_25;
|
|
5325
5467
|
return __generator(this, function (_a) {
|
|
5326
5468
|
switch (_a.label) {
|
|
5327
5469
|
case 0:
|
|
@@ -5331,10 +5473,14 @@ var PerpetualsClient = (function () {
|
|
|
5331
5473
|
additionalSigners = [];
|
|
5332
5474
|
_a.label = 1;
|
|
5333
5475
|
case 1:
|
|
5334
|
-
_a.trys.push([1,
|
|
5476
|
+
_a.trys.push([1, 4, , 5]);
|
|
5335
5477
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5336
5478
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
|
|
5337
|
-
|
|
5479
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5480
|
+
case 2:
|
|
5481
|
+
if (!(_a.sent())) {
|
|
5482
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(this.provider.wallet.publicKey, userTokenAccount, owner, poolConfig.tokenMint));
|
|
5483
|
+
}
|
|
5338
5484
|
return [4, this.program.methods
|
|
5339
5485
|
.withdrawToken({
|
|
5340
5486
|
withdrawRequestId: withdrawRequestId
|
|
@@ -5351,15 +5497,15 @@ var PerpetualsClient = (function () {
|
|
|
5351
5497
|
tokenMint: poolConfig.tokenMint,
|
|
5352
5498
|
})
|
|
5353
5499
|
.instruction()];
|
|
5354
|
-
case
|
|
5500
|
+
case 3:
|
|
5355
5501
|
withdrawTokenInstruction = _a.sent();
|
|
5356
5502
|
instructions.push(withdrawTokenInstruction);
|
|
5357
|
-
return [3,
|
|
5358
|
-
case
|
|
5359
|
-
|
|
5360
|
-
console.log("perpClient withdrawTokenInstruction error:: ",
|
|
5361
|
-
throw
|
|
5362
|
-
case
|
|
5503
|
+
return [3, 5];
|
|
5504
|
+
case 4:
|
|
5505
|
+
err_25 = _a.sent();
|
|
5506
|
+
console.log("perpClient withdrawTokenInstruction error:: ", err_25);
|
|
5507
|
+
throw err_25;
|
|
5508
|
+
case 5: return [2, {
|
|
5363
5509
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5364
5510
|
additionalSigners: additionalSigners
|
|
5365
5511
|
}];
|
|
@@ -5367,7 +5513,7 @@ var PerpetualsClient = (function () {
|
|
|
5367
5513
|
});
|
|
5368
5514
|
}); };
|
|
5369
5515
|
this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5370
|
-
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction,
|
|
5516
|
+
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_26;
|
|
5371
5517
|
return __generator(this, function (_a) {
|
|
5372
5518
|
switch (_a.label) {
|
|
5373
5519
|
case 0:
|
|
@@ -5395,9 +5541,9 @@ var PerpetualsClient = (function () {
|
|
|
5395
5541
|
instructions.push(cancelUnstakeRequestInstruction);
|
|
5396
5542
|
return [3, 4];
|
|
5397
5543
|
case 3:
|
|
5398
|
-
|
|
5399
|
-
console.log("perpClient cancelUnstakeRequestInstruction error:: ",
|
|
5400
|
-
throw
|
|
5544
|
+
err_26 = _a.sent();
|
|
5545
|
+
console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_26);
|
|
5546
|
+
throw err_26;
|
|
5401
5547
|
case 4: return [2, {
|
|
5402
5548
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5403
5549
|
additionalSigners: additionalSigners
|
|
@@ -5410,23 +5556,32 @@ var PerpetualsClient = (function () {
|
|
|
5410
5556
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
5411
5557
|
args_1[_i - 2] = arguments[_i];
|
|
5412
5558
|
}
|
|
5413
|
-
return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA
|
|
5414
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, collectTokenRewardInstruction,
|
|
5559
|
+
return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
|
|
5560
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_27;
|
|
5415
5561
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5416
|
-
return __generator(this, function (
|
|
5417
|
-
switch (
|
|
5562
|
+
return __generator(this, function (_b) {
|
|
5563
|
+
switch (_b.label) {
|
|
5418
5564
|
case 0:
|
|
5419
|
-
publicKey =
|
|
5565
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5420
5566
|
preInstructions = [];
|
|
5421
5567
|
instructions = [];
|
|
5422
5568
|
postInstructions = [];
|
|
5423
5569
|
additionalSigners = [];
|
|
5424
|
-
|
|
5570
|
+
_b.label = 1;
|
|
5425
5571
|
case 1:
|
|
5426
|
-
|
|
5572
|
+
_b.trys.push([1, 5, , 6]);
|
|
5427
5573
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5428
5574
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
|
|
5429
|
-
|
|
5575
|
+
_a = createUserATA;
|
|
5576
|
+
if (!_a) return [3, 3];
|
|
5577
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5578
|
+
case 2:
|
|
5579
|
+
_a = !(_b.sent());
|
|
5580
|
+
_b.label = 3;
|
|
5581
|
+
case 3:
|
|
5582
|
+
if (_a) {
|
|
5583
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userTokenAccount, publicKey, poolConfig.tokenMint));
|
|
5584
|
+
}
|
|
5430
5585
|
return [4, this.program.methods
|
|
5431
5586
|
.collectTokenReward({})
|
|
5432
5587
|
.accountsPartial({
|
|
@@ -5441,15 +5596,15 @@ var PerpetualsClient = (function () {
|
|
|
5441
5596
|
tokenMint: poolConfig.tokenMint,
|
|
5442
5597
|
})
|
|
5443
5598
|
.instruction()];
|
|
5444
|
-
case
|
|
5445
|
-
collectTokenRewardInstruction =
|
|
5599
|
+
case 4:
|
|
5600
|
+
collectTokenRewardInstruction = _b.sent();
|
|
5446
5601
|
instructions.push(collectTokenRewardInstruction);
|
|
5447
|
-
return [3,
|
|
5448
|
-
case
|
|
5449
|
-
|
|
5450
|
-
console.log("perpClient collectTokenRewardInstruction error:: ",
|
|
5451
|
-
throw
|
|
5452
|
-
case
|
|
5602
|
+
return [3, 6];
|
|
5603
|
+
case 5:
|
|
5604
|
+
err_27 = _b.sent();
|
|
5605
|
+
console.log("perpClient collectTokenRewardInstruction error:: ", err_27);
|
|
5606
|
+
throw err_27;
|
|
5607
|
+
case 6: return [2, {
|
|
5453
5608
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5454
5609
|
additionalSigners: additionalSigners
|
|
5455
5610
|
}];
|
|
@@ -5463,23 +5618,32 @@ var PerpetualsClient = (function () {
|
|
|
5463
5618
|
args_1[_i - 3] = arguments[_i];
|
|
5464
5619
|
}
|
|
5465
5620
|
return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
|
|
5466
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, collectRevenueInstruction,
|
|
5621
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_28;
|
|
5467
5622
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5468
|
-
return __generator(this, function (
|
|
5469
|
-
switch (
|
|
5623
|
+
return __generator(this, function (_b) {
|
|
5624
|
+
switch (_b.label) {
|
|
5470
5625
|
case 0:
|
|
5471
5626
|
publicKey = this.provider.wallet.publicKey;
|
|
5472
5627
|
preInstructions = [];
|
|
5473
5628
|
instructions = [];
|
|
5474
5629
|
postInstructions = [];
|
|
5475
5630
|
additionalSigners = [];
|
|
5476
|
-
|
|
5631
|
+
_b.label = 1;
|
|
5477
5632
|
case 1:
|
|
5478
|
-
|
|
5633
|
+
_b.trys.push([1, 5, , 6]);
|
|
5479
5634
|
rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
|
|
5480
5635
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5481
5636
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rewardCustodyMint, owner, true);
|
|
5482
|
-
|
|
5637
|
+
_a = createUserATA;
|
|
5638
|
+
if (!_a) return [3, 3];
|
|
5639
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5640
|
+
case 2:
|
|
5641
|
+
_a = !(_b.sent());
|
|
5642
|
+
_b.label = 3;
|
|
5643
|
+
case 3:
|
|
5644
|
+
if (_a) {
|
|
5645
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userTokenAccount, publicKey, rewardCustodyMint));
|
|
5646
|
+
}
|
|
5483
5647
|
return [4, this.program.methods
|
|
5484
5648
|
.collectRevenue({})
|
|
5485
5649
|
.accountsPartial({
|
|
@@ -5494,15 +5658,15 @@ var PerpetualsClient = (function () {
|
|
|
5494
5658
|
receivingTokenMint: rewardCustodyMint,
|
|
5495
5659
|
})
|
|
5496
5660
|
.instruction()];
|
|
5497
|
-
case
|
|
5498
|
-
collectRevenueInstruction =
|
|
5661
|
+
case 4:
|
|
5662
|
+
collectRevenueInstruction = _b.sent();
|
|
5499
5663
|
instructions.push(collectRevenueInstruction);
|
|
5500
|
-
return [3,
|
|
5501
|
-
case
|
|
5502
|
-
|
|
5503
|
-
console.log("perpClient collectRevenueInstruction error:: ",
|
|
5504
|
-
throw
|
|
5505
|
-
case
|
|
5664
|
+
return [3, 6];
|
|
5665
|
+
case 5:
|
|
5666
|
+
err_28 = _b.sent();
|
|
5667
|
+
console.log("perpClient collectRevenueInstruction error:: ", err_28);
|
|
5668
|
+
throw err_28;
|
|
5669
|
+
case 6: return [2, {
|
|
5506
5670
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5507
5671
|
additionalSigners: additionalSigners
|
|
5508
5672
|
}];
|
|
@@ -5516,23 +5680,32 @@ var PerpetualsClient = (function () {
|
|
|
5516
5680
|
args_1[_i - 3] = arguments[_i];
|
|
5517
5681
|
}
|
|
5518
5682
|
return __awaiter(_this, __spreadArray([owner_1, rebateSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rebateSymbol, poolConfig, createUserATA) {
|
|
5519
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateMint, tokenStakeAccount, userTokenAccount, collectRebateInstruction,
|
|
5683
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateMint, tokenStakeAccount, userTokenAccount, _a, collectRebateInstruction, err_29;
|
|
5520
5684
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5521
|
-
return __generator(this, function (
|
|
5522
|
-
switch (
|
|
5685
|
+
return __generator(this, function (_b) {
|
|
5686
|
+
switch (_b.label) {
|
|
5523
5687
|
case 0:
|
|
5524
5688
|
publicKey = this.provider.wallet.publicKey;
|
|
5525
5689
|
preInstructions = [];
|
|
5526
5690
|
instructions = [];
|
|
5527
5691
|
postInstructions = [];
|
|
5528
5692
|
additionalSigners = [];
|
|
5529
|
-
|
|
5693
|
+
_b.label = 1;
|
|
5530
5694
|
case 1:
|
|
5531
|
-
|
|
5695
|
+
_b.trys.push([1, 5, , 6]);
|
|
5532
5696
|
rebateMint = poolConfig.getTokenFromSymbol(rebateSymbol).mintKey;
|
|
5533
5697
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
|
5534
5698
|
userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rebateMint, owner, true);
|
|
5535
|
-
|
|
5699
|
+
_a = createUserATA;
|
|
5700
|
+
if (!_a) return [3, 3];
|
|
5701
|
+
return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
|
|
5702
|
+
case 2:
|
|
5703
|
+
_a = !(_b.sent());
|
|
5704
|
+
_b.label = 3;
|
|
5705
|
+
case 3:
|
|
5706
|
+
if (_a) {
|
|
5707
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userTokenAccount, publicKey, rebateMint));
|
|
5708
|
+
}
|
|
5536
5709
|
return [4, this.program.methods
|
|
5537
5710
|
.collectRebate()
|
|
5538
5711
|
.accountsPartial({
|
|
@@ -5547,15 +5720,15 @@ var PerpetualsClient = (function () {
|
|
|
5547
5720
|
receivingTokenMint: rebateMint,
|
|
5548
5721
|
})
|
|
5549
5722
|
.instruction()];
|
|
5550
|
-
case
|
|
5551
|
-
collectRebateInstruction =
|
|
5723
|
+
case 4:
|
|
5724
|
+
collectRebateInstruction = _b.sent();
|
|
5552
5725
|
instructions.push(collectRebateInstruction);
|
|
5553
|
-
return [3,
|
|
5554
|
-
case
|
|
5555
|
-
|
|
5556
|
-
console.log("perpClient collectRebateInstruction error:: ",
|
|
5557
|
-
throw
|
|
5558
|
-
case
|
|
5726
|
+
return [3, 6];
|
|
5727
|
+
case 5:
|
|
5728
|
+
err_29 = _b.sent();
|
|
5729
|
+
console.log("perpClient collectRebateInstruction error:: ", err_29);
|
|
5730
|
+
throw err_29;
|
|
5731
|
+
case 6: return [2, {
|
|
5559
5732
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5560
5733
|
additionalSigners: additionalSigners
|
|
5561
5734
|
}];
|
|
@@ -5564,7 +5737,7 @@ var PerpetualsClient = (function () {
|
|
|
5564
5737
|
});
|
|
5565
5738
|
};
|
|
5566
5739
|
this.settleRebates = function (rebateSymbol, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
5567
|
-
var preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, rebateMint, settleRebatesInstruction,
|
|
5740
|
+
var preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, rebateMint, settleRebatesInstruction, err_30;
|
|
5568
5741
|
return __generator(this, function (_a) {
|
|
5569
5742
|
switch (_a.label) {
|
|
5570
5743
|
case 0:
|
|
@@ -5598,9 +5771,9 @@ var PerpetualsClient = (function () {
|
|
|
5598
5771
|
instructions.push(settleRebatesInstruction);
|
|
5599
5772
|
return [3, 4];
|
|
5600
5773
|
case 3:
|
|
5601
|
-
|
|
5602
|
-
console.log("perpClient settleRebatesInstruction error:: ",
|
|
5603
|
-
throw
|
|
5774
|
+
err_30 = _a.sent();
|
|
5775
|
+
console.log("perpClient settleRebatesInstruction error:: ", err_30);
|
|
5776
|
+
throw err_30;
|
|
5604
5777
|
case 4: return [2, {
|
|
5605
5778
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5606
5779
|
additionalSigners: additionalSigners
|
|
@@ -5613,14 +5786,14 @@ var PerpetualsClient = (function () {
|
|
|
5613
5786
|
for (var _i = 11; _i < arguments.length; _i++) {
|
|
5614
5787
|
args_1[_i - 11] = arguments[_i];
|
|
5615
5788
|
}
|
|
5616
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey
|
|
5617
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder,
|
|
5789
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
|
|
5790
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_31;
|
|
5618
5791
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
5619
5792
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
5620
5793
|
return __generator(this, function (_c) {
|
|
5621
5794
|
switch (_c.label) {
|
|
5622
5795
|
case 0:
|
|
5623
|
-
publicKey =
|
|
5796
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5624
5797
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
5625
5798
|
reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
|
|
5626
5799
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
@@ -5718,9 +5891,9 @@ var PerpetualsClient = (function () {
|
|
|
5718
5891
|
instructions.push(placeLimitOrder);
|
|
5719
5892
|
return [3, 10];
|
|
5720
5893
|
case 9:
|
|
5721
|
-
|
|
5722
|
-
console.log("perpClient placeLimitOrder error:: ",
|
|
5723
|
-
throw
|
|
5894
|
+
err_31 = _c.sent();
|
|
5895
|
+
console.log("perpClient placeLimitOrder error:: ", err_31);
|
|
5896
|
+
throw err_31;
|
|
5724
5897
|
case 10: return [2, {
|
|
5725
5898
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5726
5899
|
additionalSigners: additionalSigners
|
|
@@ -5734,14 +5907,14 @@ var PerpetualsClient = (function () {
|
|
|
5734
5907
|
for (var _i = 11; _i < arguments.length; _i++) {
|
|
5735
5908
|
args_1[_i - 11] = arguments[_i];
|
|
5736
5909
|
}
|
|
5737
|
-
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey
|
|
5738
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, positionAccount, orderAccount, editLimitOrder,
|
|
5910
|
+
return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
|
5911
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_32;
|
|
5739
5912
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
5740
5913
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
5741
|
-
return __generator(this, function (
|
|
5742
|
-
switch (
|
|
5914
|
+
return __generator(this, function (_b) {
|
|
5915
|
+
switch (_b.label) {
|
|
5743
5916
|
case 0:
|
|
5744
|
-
publicKey =
|
|
5917
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5745
5918
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
5746
5919
|
reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
|
|
5747
5920
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
@@ -5751,33 +5924,43 @@ var PerpetualsClient = (function () {
|
|
|
5751
5924
|
instructions = [];
|
|
5752
5925
|
postInstructions = [];
|
|
5753
5926
|
additionalSigners = [];
|
|
5754
|
-
|
|
5927
|
+
_b.label = 1;
|
|
5755
5928
|
case 1:
|
|
5756
|
-
|
|
5757
|
-
if (reserveSymbol == 'SOL')
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
}
|
|
5763
|
-
preInstructions = [
|
|
5764
|
-
web3_js_1.SystemProgram.createAccount({
|
|
5765
|
-
fromPubkey: publicKey,
|
|
5766
|
-
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
5767
|
-
lamports: lamports,
|
|
5768
|
-
space: 165,
|
|
5769
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5770
|
-
}),
|
|
5771
|
-
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
5772
|
-
];
|
|
5773
|
-
postInstructions = [
|
|
5774
|
-
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
5775
|
-
];
|
|
5929
|
+
_b.trys.push([1, 7, , 8]);
|
|
5930
|
+
if (!(reserveSymbol == 'SOL')) return [3, 2];
|
|
5931
|
+
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
|
5932
|
+
if (!ephemeralSignerPubkey) {
|
|
5933
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
|
5934
|
+
additionalSigners.push(wrappedSolAccount);
|
|
5776
5935
|
}
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5936
|
+
preInstructions = [
|
|
5937
|
+
web3_js_1.SystemProgram.createAccount({
|
|
5938
|
+
fromPubkey: publicKey,
|
|
5939
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
|
5940
|
+
lamports: lamports,
|
|
5941
|
+
space: 165,
|
|
5942
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5943
|
+
}),
|
|
5944
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
|
5945
|
+
];
|
|
5946
|
+
postInstructions = [
|
|
5947
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
5948
|
+
];
|
|
5949
|
+
return [3, 5];
|
|
5950
|
+
case 2:
|
|
5951
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(reserveSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
5952
|
+
_a = createUserATA;
|
|
5953
|
+
if (!_a) return [3, 4];
|
|
5954
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
5955
|
+
case 3:
|
|
5956
|
+
_a = !(_b.sent());
|
|
5957
|
+
_b.label = 4;
|
|
5958
|
+
case 4:
|
|
5959
|
+
if (_a) {
|
|
5960
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(reserveSymbol).mintKey, poolConfig.getTokenFromSymbol(reserveSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
5780
5961
|
}
|
|
5962
|
+
_b.label = 5;
|
|
5963
|
+
case 5:
|
|
5781
5964
|
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
|
5782
5965
|
orderAccount = poolConfig.getOrderFromMarketPk(publicKey, marketAccount);
|
|
5783
5966
|
return [4, this.program.methods
|
|
@@ -5809,15 +5992,15 @@ var PerpetualsClient = (function () {
|
|
|
5809
5992
|
receivingMint: poolConfig.getTokenFromSymbol(reserveSymbol).mintKey
|
|
5810
5993
|
})
|
|
5811
5994
|
.instruction()];
|
|
5812
|
-
case
|
|
5813
|
-
editLimitOrder =
|
|
5995
|
+
case 6:
|
|
5996
|
+
editLimitOrder = _b.sent();
|
|
5814
5997
|
instructions.push(editLimitOrder);
|
|
5815
|
-
return [3,
|
|
5816
|
-
case
|
|
5817
|
-
|
|
5818
|
-
console.log("perpClient editLimitOrder error:: ",
|
|
5819
|
-
throw
|
|
5820
|
-
case
|
|
5998
|
+
return [3, 8];
|
|
5999
|
+
case 7:
|
|
6000
|
+
err_32 = _b.sent();
|
|
6001
|
+
console.log("perpClient editLimitOrder error:: ", err_32);
|
|
6002
|
+
throw err_32;
|
|
6003
|
+
case 8: return [2, {
|
|
5821
6004
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5822
6005
|
additionalSigners: additionalSigners
|
|
5823
6006
|
}];
|
|
@@ -5831,7 +6014,7 @@ var PerpetualsClient = (function () {
|
|
|
5831
6014
|
args_1[_i - 7] = arguments[_i];
|
|
5832
6015
|
}
|
|
5833
6016
|
return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount) {
|
|
5834
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder,
|
|
6017
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_33;
|
|
5835
6018
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
5836
6019
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
5837
6020
|
return __generator(this, function (_a) {
|
|
@@ -5881,9 +6064,9 @@ var PerpetualsClient = (function () {
|
|
|
5881
6064
|
instructions.push(executeLimitOrder);
|
|
5882
6065
|
return [3, 4];
|
|
5883
6066
|
case 3:
|
|
5884
|
-
|
|
5885
|
-
console.log("perpClient executeLimitOrder error:: ",
|
|
5886
|
-
throw
|
|
6067
|
+
err_33 = _a.sent();
|
|
6068
|
+
console.log("perpClient executeLimitOrder error:: ", err_33);
|
|
6069
|
+
throw err_33;
|
|
5887
6070
|
case 4: return [2, {
|
|
5888
6071
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5889
6072
|
additionalSigners: additionalSigners
|
|
@@ -5898,7 +6081,7 @@ var PerpetualsClient = (function () {
|
|
|
5898
6081
|
args_1[_i - 8] = arguments[_i];
|
|
5899
6082
|
}
|
|
5900
6083
|
return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount) {
|
|
5901
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap,
|
|
6084
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_34;
|
|
5902
6085
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
5903
6086
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
5904
6087
|
return __generator(this, function (_a) {
|
|
@@ -5951,9 +6134,9 @@ var PerpetualsClient = (function () {
|
|
|
5951
6134
|
instructions.push(executeLimitWithSwap);
|
|
5952
6135
|
return [3, 4];
|
|
5953
6136
|
case 3:
|
|
5954
|
-
|
|
5955
|
-
console.log("perpClient executeLimitWithSwap error:: ",
|
|
5956
|
-
throw
|
|
6137
|
+
err_34 = _a.sent();
|
|
6138
|
+
console.log("perpClient executeLimitWithSwap error:: ", err_34);
|
|
6139
|
+
throw err_34;
|
|
5957
6140
|
case 4: return [2, {
|
|
5958
6141
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
5959
6142
|
additionalSigners: additionalSigners
|
|
@@ -5962,12 +6145,12 @@ var PerpetualsClient = (function () {
|
|
|
5962
6145
|
});
|
|
5963
6146
|
});
|
|
5964
6147
|
};
|
|
5965
|
-
this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig
|
|
5966
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder,
|
|
6148
|
+
this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6149
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_35;
|
|
5967
6150
|
return __generator(this, function (_a) {
|
|
5968
6151
|
switch (_a.label) {
|
|
5969
6152
|
case 0:
|
|
5970
|
-
publicKey =
|
|
6153
|
+
publicKey = this.provider.wallet.publicKey;
|
|
5971
6154
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
5972
6155
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
5973
6156
|
receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receiveSymbol).mintKey); });
|
|
@@ -6009,9 +6192,9 @@ var PerpetualsClient = (function () {
|
|
|
6009
6192
|
instructions.push(placeTriggerOrder);
|
|
6010
6193
|
return [3, 4];
|
|
6011
6194
|
case 3:
|
|
6012
|
-
|
|
6013
|
-
console.log("perpClient placeTriggerOrder error:: ",
|
|
6014
|
-
throw
|
|
6195
|
+
err_35 = _a.sent();
|
|
6196
|
+
console.log("perpClient placeTriggerOrder error:: ", err_35);
|
|
6197
|
+
throw err_35;
|
|
6015
6198
|
case 4: return [2, {
|
|
6016
6199
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6017
6200
|
additionalSigners: additionalSigners
|
|
@@ -6019,12 +6202,12 @@ var PerpetualsClient = (function () {
|
|
|
6019
6202
|
}
|
|
6020
6203
|
});
|
|
6021
6204
|
}); };
|
|
6022
|
-
this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig
|
|
6023
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder,
|
|
6205
|
+
this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6206
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_36;
|
|
6024
6207
|
return __generator(this, function (_a) {
|
|
6025
6208
|
switch (_a.label) {
|
|
6026
6209
|
case 0:
|
|
6027
|
-
publicKey =
|
|
6210
|
+
publicKey = this.provider.wallet.publicKey;
|
|
6028
6211
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
6029
6212
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
6030
6213
|
receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receiveSymbol).mintKey); });
|
|
@@ -6065,9 +6248,9 @@ var PerpetualsClient = (function () {
|
|
|
6065
6248
|
instructions.push(editTriggerOrder);
|
|
6066
6249
|
return [3, 4];
|
|
6067
6250
|
case 3:
|
|
6068
|
-
|
|
6069
|
-
console.log("perpClient editTriggerOrder error:: ",
|
|
6070
|
-
throw
|
|
6251
|
+
err_36 = _a.sent();
|
|
6252
|
+
console.log("perpClient editTriggerOrder error:: ", err_36);
|
|
6253
|
+
throw err_36;
|
|
6071
6254
|
case 4: return [2, {
|
|
6072
6255
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6073
6256
|
additionalSigners: additionalSigners
|
|
@@ -6075,12 +6258,12 @@ var PerpetualsClient = (function () {
|
|
|
6075
6258
|
}
|
|
6076
6259
|
});
|
|
6077
6260
|
}); };
|
|
6078
|
-
this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig
|
|
6079
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder,
|
|
6261
|
+
this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6262
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_37;
|
|
6080
6263
|
return __generator(this, function (_a) {
|
|
6081
6264
|
switch (_a.label) {
|
|
6082
6265
|
case 0:
|
|
6083
|
-
publicKey =
|
|
6266
|
+
publicKey = this.provider.wallet.publicKey;
|
|
6084
6267
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
6085
6268
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
6086
6269
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
@@ -6107,9 +6290,9 @@ var PerpetualsClient = (function () {
|
|
|
6107
6290
|
instructions.push(cancelTriggerOrder);
|
|
6108
6291
|
return [3, 4];
|
|
6109
6292
|
case 3:
|
|
6110
|
-
|
|
6111
|
-
console.log("perpClient cancelTriggerOrder error:: ",
|
|
6112
|
-
throw
|
|
6293
|
+
err_37 = _a.sent();
|
|
6294
|
+
console.log("perpClient cancelTriggerOrder error:: ", err_37);
|
|
6295
|
+
throw err_37;
|
|
6113
6296
|
case 4: return [2, {
|
|
6114
6297
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6115
6298
|
additionalSigners: additionalSigners
|
|
@@ -6117,12 +6300,12 @@ var PerpetualsClient = (function () {
|
|
|
6117
6300
|
}
|
|
6118
6301
|
});
|
|
6119
6302
|
}); };
|
|
6120
|
-
this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig
|
|
6121
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders,
|
|
6303
|
+
this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6304
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_38;
|
|
6122
6305
|
return __generator(this, function (_a) {
|
|
6123
6306
|
switch (_a.label) {
|
|
6124
6307
|
case 0:
|
|
6125
|
-
publicKey =
|
|
6308
|
+
publicKey = this.provider.wallet.publicKey;
|
|
6126
6309
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
6127
6310
|
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
|
6128
6311
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
@@ -6147,9 +6330,9 @@ var PerpetualsClient = (function () {
|
|
|
6147
6330
|
instructions.push(cancelAllTriggerOrders);
|
|
6148
6331
|
return [3, 4];
|
|
6149
6332
|
case 3:
|
|
6150
|
-
|
|
6151
|
-
console.log("perpClient cancelAllTriggerOrders error:: ",
|
|
6152
|
-
throw
|
|
6333
|
+
err_38 = _a.sent();
|
|
6334
|
+
console.log("perpClient cancelAllTriggerOrders error:: ", err_38);
|
|
6335
|
+
throw err_38;
|
|
6153
6336
|
case 4: return [2, {
|
|
6154
6337
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6155
6338
|
additionalSigners: additionalSigners
|
|
@@ -6163,13 +6346,13 @@ var PerpetualsClient = (function () {
|
|
|
6163
6346
|
args_1[_i - 9] = arguments[_i];
|
|
6164
6347
|
}
|
|
6165
6348
|
return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount) {
|
|
6166
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas,
|
|
6349
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_39;
|
|
6167
6350
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6168
6351
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
6169
6352
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
6170
6353
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
6171
|
-
return __generator(this, function (
|
|
6172
|
-
switch (
|
|
6354
|
+
return __generator(this, function (_e) {
|
|
6355
|
+
switch (_e.label) {
|
|
6173
6356
|
case 0:
|
|
6174
6357
|
payerPubkey = this.provider.wallet.publicKey;
|
|
6175
6358
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
@@ -6182,23 +6365,42 @@ var PerpetualsClient = (function () {
|
|
|
6182
6365
|
additionalSigners = [];
|
|
6183
6366
|
collateralToken = poolConfig.getTokenFromSymbol(collateralSymbol);
|
|
6184
6367
|
receivingToken = poolConfig.getTokenFromSymbol(receivingSymbol);
|
|
6185
|
-
|
|
6368
|
+
_e.label = 1;
|
|
6186
6369
|
case 1:
|
|
6187
|
-
|
|
6188
|
-
if (false)
|
|
6370
|
+
_e.trys.push([1, 9, , 10]);
|
|
6371
|
+
if (!false) return [3, 2];
|
|
6372
|
+
return [3, 7];
|
|
6373
|
+
case 2:
|
|
6374
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey, owner, true, receivingToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
6375
|
+
_a = createUserATA;
|
|
6376
|
+
if (!_a) return [3, 4];
|
|
6377
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
6378
|
+
case 3:
|
|
6379
|
+
_a = !(_e.sent());
|
|
6380
|
+
_e.label = 4;
|
|
6381
|
+
case 4:
|
|
6382
|
+
if (_a) {
|
|
6383
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
|
6189
6384
|
}
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6385
|
+
userReceivingTokenAccountCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, owner, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
6386
|
+
_b = createUserATA;
|
|
6387
|
+
if (!_b) return [3, 6];
|
|
6388
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
|
6389
|
+
case 5:
|
|
6390
|
+
_b = !(_e.sent());
|
|
6391
|
+
_e.label = 6;
|
|
6392
|
+
case 6:
|
|
6393
|
+
if (_b) {
|
|
6394
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
|
6195
6395
|
}
|
|
6396
|
+
_e.label = 7;
|
|
6397
|
+
case 7:
|
|
6196
6398
|
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
|
6197
6399
|
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
|
6198
6400
|
custodyAccountMetas = [];
|
|
6199
6401
|
custodyOracleAccountMetas = [];
|
|
6200
|
-
for (
|
|
6201
|
-
custody =
|
|
6402
|
+
for (_c = 0, _d = poolConfig.custodies; _c < _d.length; _c++) {
|
|
6403
|
+
custody = _d[_c];
|
|
6202
6404
|
custodyAccountMetas.push({
|
|
6203
6405
|
pubkey: custody.custodyAccount,
|
|
6204
6406
|
isSigner: false,
|
|
@@ -6243,15 +6445,15 @@ var PerpetualsClient = (function () {
|
|
|
6243
6445
|
})
|
|
6244
6446
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, privilege), true))
|
|
6245
6447
|
.instruction()];
|
|
6246
|
-
case
|
|
6247
|
-
executeTriggerWithSwap =
|
|
6448
|
+
case 8:
|
|
6449
|
+
executeTriggerWithSwap = _e.sent();
|
|
6248
6450
|
instructions.push(executeTriggerWithSwap);
|
|
6249
|
-
return [3,
|
|
6250
|
-
case
|
|
6251
|
-
|
|
6252
|
-
console.log("perpClient executeTriggerWithSwap error:: ",
|
|
6253
|
-
throw
|
|
6254
|
-
case
|
|
6451
|
+
return [3, 10];
|
|
6452
|
+
case 9:
|
|
6453
|
+
err_39 = _e.sent();
|
|
6454
|
+
console.log("perpClient executeTriggerWithSwap error:: ", err_39);
|
|
6455
|
+
throw err_39;
|
|
6456
|
+
case 10: return [2, {
|
|
6255
6457
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6256
6458
|
additionalSigners: additionalSigners
|
|
6257
6459
|
}];
|
|
@@ -6265,13 +6467,13 @@ var PerpetualsClient = (function () {
|
|
|
6265
6467
|
args_1[_i - 8] = arguments[_i];
|
|
6266
6468
|
}
|
|
6267
6469
|
return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount) {
|
|
6268
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeTriggerOrder,
|
|
6470
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_40;
|
|
6269
6471
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6270
6472
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
6271
6473
|
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
|
6272
6474
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
|
6273
|
-
return __generator(this, function (
|
|
6274
|
-
switch (
|
|
6475
|
+
return __generator(this, function (_b) {
|
|
6476
|
+
switch (_b.label) {
|
|
6275
6477
|
case 0:
|
|
6276
6478
|
payerPubkey = this.provider.wallet.publicKey;
|
|
6277
6479
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
|
@@ -6281,15 +6483,25 @@ var PerpetualsClient = (function () {
|
|
|
6281
6483
|
instructions = [];
|
|
6282
6484
|
postInstructions = [];
|
|
6283
6485
|
additionalSigners = [];
|
|
6284
|
-
|
|
6486
|
+
_b.label = 1;
|
|
6285
6487
|
case 1:
|
|
6286
|
-
|
|
6287
|
-
if (false)
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6488
|
+
_b.trys.push([1, 7, , 8]);
|
|
6489
|
+
if (!false) return [3, 2];
|
|
6490
|
+
return [3, 5];
|
|
6491
|
+
case 2:
|
|
6492
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, owner, true, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
6493
|
+
_a = createUserATA;
|
|
6494
|
+
if (!_a) return [3, 4];
|
|
6495
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
|
6496
|
+
case 3:
|
|
6497
|
+
_a = !(_b.sent());
|
|
6498
|
+
_b.label = 4;
|
|
6499
|
+
case 4:
|
|
6500
|
+
if (_a) {
|
|
6501
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
6292
6502
|
}
|
|
6503
|
+
_b.label = 5;
|
|
6504
|
+
case 5:
|
|
6293
6505
|
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
|
6294
6506
|
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
|
6295
6507
|
return [4, this.program.methods
|
|
@@ -6319,15 +6531,15 @@ var PerpetualsClient = (function () {
|
|
|
6319
6531
|
})
|
|
6320
6532
|
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, privilege), true))
|
|
6321
6533
|
.instruction()];
|
|
6322
|
-
case
|
|
6323
|
-
executeTriggerOrder =
|
|
6534
|
+
case 6:
|
|
6535
|
+
executeTriggerOrder = _b.sent();
|
|
6324
6536
|
instructions.push(executeTriggerOrder);
|
|
6325
|
-
return [3,
|
|
6326
|
-
case
|
|
6327
|
-
|
|
6328
|
-
console.log("perpClient executeTriggerOrder error:: ",
|
|
6329
|
-
throw
|
|
6330
|
-
case
|
|
6537
|
+
return [3, 8];
|
|
6538
|
+
case 7:
|
|
6539
|
+
err_40 = _b.sent();
|
|
6540
|
+
console.log("perpClient executeTriggerOrder error:: ", err_40);
|
|
6541
|
+
throw err_40;
|
|
6542
|
+
case 8: return [2, {
|
|
6331
6543
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6332
6544
|
additionalSigners: additionalSigners
|
|
6333
6545
|
}];
|
|
@@ -6340,16 +6552,16 @@ var PerpetualsClient = (function () {
|
|
|
6340
6552
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
6341
6553
|
args_1[_i - 5] = arguments[_i];
|
|
6342
6554
|
}
|
|
6343
|
-
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, isWhitelistedUser
|
|
6344
|
-
var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, custodyAccountMetas, custodyOracleAccountMetas,
|
|
6555
|
+
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, isWhitelistedUser) {
|
|
6556
|
+
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, whitelistMeta, params, inx, closeWsolATAIns, err_41;
|
|
6345
6557
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
|
6346
6558
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
6347
6559
|
if (unWrapSol === void 0) { unWrapSol = false; }
|
|
6348
6560
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
6349
6561
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
6350
6562
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
6351
|
-
return __generator(this, function (
|
|
6352
|
-
switch (
|
|
6563
|
+
return __generator(this, function (_g) {
|
|
6564
|
+
switch (_g.label) {
|
|
6353
6565
|
case 0:
|
|
6354
6566
|
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
|
6355
6567
|
if (!userInputCustodyConfig) {
|
|
@@ -6359,26 +6571,31 @@ var PerpetualsClient = (function () {
|
|
|
6359
6571
|
if (!userOutputCustodyConfig) {
|
|
6360
6572
|
throw "userOutputCustodyConfig not found";
|
|
6361
6573
|
}
|
|
6362
|
-
publicKey =
|
|
6574
|
+
publicKey = this.provider.wallet.publicKey;
|
|
6363
6575
|
preInstructions = [];
|
|
6364
6576
|
instructions = [];
|
|
6365
6577
|
postInstructions = [];
|
|
6366
6578
|
additionalSigners = [];
|
|
6367
|
-
if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3,
|
|
6579
|
+
if (!(userInputTokenSymbol == 'SOL' && userOutputTokenSymbol == 'WSOL')) return [3, 5];
|
|
6368
6580
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey, true)];
|
|
6369
6581
|
case 1:
|
|
6370
|
-
wsolAssociatedTokenAccount =
|
|
6371
|
-
|
|
6372
|
-
|
|
6582
|
+
wsolAssociatedTokenAccount = _g.sent();
|
|
6583
|
+
return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
|
|
6584
|
+
case 2:
|
|
6585
|
+
wsolATAExist = _g.sent();
|
|
6586
|
+
if (!wsolATAExist) {
|
|
6587
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
|
|
6588
|
+
}
|
|
6589
|
+
if (!!skipBalanceChecks) return [3, 4];
|
|
6373
6590
|
_a = anchor_1.BN.bind;
|
|
6374
6591
|
return [4, this.provider.connection.getBalance(publicKey)];
|
|
6375
|
-
case
|
|
6376
|
-
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0,
|
|
6592
|
+
case 3:
|
|
6593
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
|
6377
6594
|
if (unWrappedSolBalance.lt(amountIn)) {
|
|
6378
6595
|
throw "Insufficient SOL Funds";
|
|
6379
6596
|
}
|
|
6380
|
-
|
|
6381
|
-
case
|
|
6597
|
+
_g.label = 4;
|
|
6598
|
+
case 4:
|
|
6382
6599
|
instructions.push(web3_js_1.SystemProgram.transfer({
|
|
6383
6600
|
fromPubkey: publicKey,
|
|
6384
6601
|
toPubkey: wsolAssociatedTokenAccount,
|
|
@@ -6388,7 +6605,7 @@ var PerpetualsClient = (function () {
|
|
|
6388
6605
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6389
6606
|
additionalSigners: additionalSigners
|
|
6390
6607
|
}];
|
|
6391
|
-
case
|
|
6608
|
+
case 5:
|
|
6392
6609
|
if (userInputTokenSymbol == 'WSOL' && userOutputTokenSymbol == 'SOL') {
|
|
6393
6610
|
console.log("WSOL=> SOL : NOTE : ONLY WAY IS TO CLOSE THE WSOL ATA and GET ALL SOL ");
|
|
6394
6611
|
wsolAssociatedTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, publicKey, true);
|
|
@@ -6399,20 +6616,20 @@ var PerpetualsClient = (function () {
|
|
|
6399
6616
|
additionalSigners: additionalSigners
|
|
6400
6617
|
}];
|
|
6401
6618
|
}
|
|
6402
|
-
|
|
6403
|
-
case
|
|
6404
|
-
|
|
6405
|
-
if (!(userInputTokenSymbol == 'SOL')) return [3,
|
|
6619
|
+
_g.label = 6;
|
|
6620
|
+
case 6:
|
|
6621
|
+
_g.trys.push([6, 19, , 20]);
|
|
6622
|
+
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
|
6406
6623
|
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
|
6407
6624
|
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
|
6408
|
-
case
|
|
6409
|
-
accCreationLamports = (
|
|
6625
|
+
case 7:
|
|
6626
|
+
accCreationLamports = (_g.sent());
|
|
6410
6627
|
console.log("accCreationLamports:", accCreationLamports);
|
|
6411
6628
|
lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
|
|
6412
6629
|
_b = anchor_1.BN.bind;
|
|
6413
6630
|
return [4, this.provider.connection.getBalance(publicKey)];
|
|
6414
|
-
case
|
|
6415
|
-
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0,
|
|
6631
|
+
case 8:
|
|
6632
|
+
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _g.sent()]))();
|
|
6416
6633
|
if (unWrappedSolBalance.lt(amountIn)) {
|
|
6417
6634
|
throw "Insufficient SOL Funds";
|
|
6418
6635
|
}
|
|
@@ -6434,25 +6651,25 @@ var PerpetualsClient = (function () {
|
|
|
6434
6651
|
postInstructions = [
|
|
6435
6652
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
6436
6653
|
];
|
|
6437
|
-
return [3,
|
|
6438
|
-
case
|
|
6654
|
+
return [3, 12];
|
|
6655
|
+
case 9:
|
|
6439
6656
|
userInputTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
6440
6657
|
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
|
6441
|
-
case
|
|
6442
|
-
if (!(
|
|
6658
|
+
case 10:
|
|
6659
|
+
if (!(_g.sent())) {
|
|
6443
6660
|
throw "Insufficient Funds , Token Account doesn't exist";
|
|
6444
6661
|
}
|
|
6445
|
-
if (!!skipBalanceChecks) return [3,
|
|
6662
|
+
if (!!skipBalanceChecks) return [3, 12];
|
|
6446
6663
|
_c = anchor_1.BN.bind;
|
|
6447
6664
|
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
|
6448
|
-
case
|
|
6449
|
-
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (
|
|
6665
|
+
case 11:
|
|
6666
|
+
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_g.sent()).value.amount]))();
|
|
6450
6667
|
if (tokenAccountBalance.lt(amountIn)) {
|
|
6451
6668
|
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
|
6452
6669
|
}
|
|
6453
|
-
|
|
6454
|
-
case
|
|
6455
|
-
if (!(userOutputTokenSymbol == 'SOL')) return [3,
|
|
6670
|
+
_g.label = 12;
|
|
6671
|
+
case 12:
|
|
6672
|
+
if (!(userOutputTokenSymbol == 'SOL')) return [3, 13];
|
|
6456
6673
|
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
|
6457
6674
|
if (!ephemeralSignerPubkey) {
|
|
6458
6675
|
wrappedSolAccount = new web3_js_1.Keypair();
|
|
@@ -6472,17 +6689,26 @@ var PerpetualsClient = (function () {
|
|
|
6472
6689
|
postInstructions = [
|
|
6473
6690
|
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
|
6474
6691
|
];
|
|
6475
|
-
return [3,
|
|
6476
|
-
case
|
|
6477
|
-
case 13:
|
|
6478
|
-
userOutputTokenAccount = _f.sent();
|
|
6479
|
-
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
6480
|
-
_f.label = 14;
|
|
6692
|
+
return [3, 17];
|
|
6693
|
+
case 13: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID)];
|
|
6481
6694
|
case 14:
|
|
6695
|
+
userOutputTokenAccount = _g.sent();
|
|
6696
|
+
_d = createUserATA;
|
|
6697
|
+
if (!_d) return [3, 16];
|
|
6698
|
+
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
|
6699
|
+
case 15:
|
|
6700
|
+
_d = !(_g.sent());
|
|
6701
|
+
_g.label = 16;
|
|
6702
|
+
case 16:
|
|
6703
|
+
if (_d) {
|
|
6704
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
|
|
6705
|
+
}
|
|
6706
|
+
_g.label = 17;
|
|
6707
|
+
case 17:
|
|
6482
6708
|
custodyAccountMetas = [];
|
|
6483
6709
|
custodyOracleAccountMetas = [];
|
|
6484
|
-
for (
|
|
6485
|
-
custody = _e
|
|
6710
|
+
for (_e = 0, _f = poolConfig.custodies; _e < _f.length; _e++) {
|
|
6711
|
+
custody = _f[_e];
|
|
6486
6712
|
custodyAccountMetas.push({
|
|
6487
6713
|
pubkey: custody.custodyAccount,
|
|
6488
6714
|
isSigner: false,
|
|
@@ -6529,19 +6755,19 @@ var PerpetualsClient = (function () {
|
|
|
6529
6755
|
})
|
|
6530
6756
|
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
6531
6757
|
.instruction()];
|
|
6532
|
-
case
|
|
6533
|
-
inx =
|
|
6758
|
+
case 18:
|
|
6759
|
+
inx = _g.sent();
|
|
6534
6760
|
instructions.push(inx);
|
|
6535
6761
|
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
|
6536
6762
|
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
|
6537
6763
|
instructions.push(closeWsolATAIns);
|
|
6538
6764
|
}
|
|
6539
|
-
return [3,
|
|
6540
|
-
case
|
|
6541
|
-
|
|
6542
|
-
console.error("perpClient Swap error:: ",
|
|
6543
|
-
throw
|
|
6544
|
-
case
|
|
6765
|
+
return [3, 20];
|
|
6766
|
+
case 19:
|
|
6767
|
+
err_41 = _g.sent();
|
|
6768
|
+
console.error("perpClient Swap error:: ", err_41);
|
|
6769
|
+
throw err_41;
|
|
6770
|
+
case 20: return [2, {
|
|
6545
6771
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6546
6772
|
additionalSigners: additionalSigners
|
|
6547
6773
|
}];
|
|
@@ -6550,7 +6776,7 @@ var PerpetualsClient = (function () {
|
|
|
6550
6776
|
});
|
|
6551
6777
|
};
|
|
6552
6778
|
this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6553
|
-
var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx,
|
|
6779
|
+
var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_42;
|
|
6554
6780
|
return __generator(this, function (_b) {
|
|
6555
6781
|
switch (_b.label) {
|
|
6556
6782
|
case 0:
|
|
@@ -6604,9 +6830,9 @@ var PerpetualsClient = (function () {
|
|
|
6604
6830
|
instructions.push(inx);
|
|
6605
6831
|
return [3, 4];
|
|
6606
6832
|
case 3:
|
|
6607
|
-
|
|
6608
|
-
console.error("perpClient Swap error:: ",
|
|
6609
|
-
throw
|
|
6833
|
+
err_42 = _b.sent();
|
|
6834
|
+
console.error("perpClient Swap error:: ", err_42);
|
|
6835
|
+
throw err_42;
|
|
6610
6836
|
case 4: return [2, {
|
|
6611
6837
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
6612
6838
|
additionalSigners: additionalSigners
|
|
@@ -6615,7 +6841,7 @@ var PerpetualsClient = (function () {
|
|
|
6615
6841
|
});
|
|
6616
6842
|
}); };
|
|
6617
6843
|
this.setLpTokenPrice = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6618
|
-
var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction,
|
|
6844
|
+
var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction, err_43;
|
|
6619
6845
|
return __generator(this, function (_d) {
|
|
6620
6846
|
switch (_d.label) {
|
|
6621
6847
|
case 0:
|
|
@@ -6663,9 +6889,9 @@ var PerpetualsClient = (function () {
|
|
|
6663
6889
|
instructions.push(setLpTokenPriceInstruction);
|
|
6664
6890
|
return [3, 4];
|
|
6665
6891
|
case 3:
|
|
6666
|
-
|
|
6667
|
-
console.log("perpClient setLpTokenPriceInstruction error:: ",
|
|
6668
|
-
throw
|
|
6892
|
+
err_43 = _d.sent();
|
|
6893
|
+
console.log("perpClient setLpTokenPriceInstruction error:: ", err_43);
|
|
6894
|
+
throw err_43;
|
|
6669
6895
|
case 4: return [2, {
|
|
6670
6896
|
instructions: __spreadArray([], instructions, true),
|
|
6671
6897
|
additionalSigners: additionalSigners
|
|
@@ -6713,7 +6939,7 @@ var PerpetualsClient = (function () {
|
|
|
6713
6939
|
});
|
|
6714
6940
|
}); };
|
|
6715
6941
|
this.setAdminSigners = function (admins, minSignatures) { return __awaiter(_this, void 0, void 0, function () {
|
|
6716
|
-
var adminMetas, _i, admins_2, admin,
|
|
6942
|
+
var adminMetas, _i, admins_2, admin, err_44;
|
|
6717
6943
|
return __generator(this, function (_a) {
|
|
6718
6944
|
switch (_a.label) {
|
|
6719
6945
|
case 0:
|
|
@@ -6743,11 +6969,11 @@ var PerpetualsClient = (function () {
|
|
|
6743
6969
|
_a.sent();
|
|
6744
6970
|
return [3, 4];
|
|
6745
6971
|
case 3:
|
|
6746
|
-
|
|
6972
|
+
err_44 = _a.sent();
|
|
6747
6973
|
if (this.printErrors) {
|
|
6748
|
-
console.error("setAdminSigners err:",
|
|
6974
|
+
console.error("setAdminSigners err:", err_44);
|
|
6749
6975
|
}
|
|
6750
|
-
throw
|
|
6976
|
+
throw err_44;
|
|
6751
6977
|
case 4: return [2];
|
|
6752
6978
|
}
|
|
6753
6979
|
});
|
|
@@ -6944,7 +7170,7 @@ var PerpetualsClient = (function () {
|
|
|
6944
7170
|
});
|
|
6945
7171
|
}); };
|
|
6946
7172
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6947
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
|
7173
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_45;
|
|
6948
7174
|
return __generator(this, function (_a) {
|
|
6949
7175
|
switch (_a.label) {
|
|
6950
7176
|
case 0:
|
|
@@ -6977,9 +7203,9 @@ var PerpetualsClient = (function () {
|
|
|
6977
7203
|
instructions.push(withdrawFeesIx);
|
|
6978
7204
|
return [3, 5];
|
|
6979
7205
|
case 4:
|
|
6980
|
-
|
|
6981
|
-
console.log("perpClient setPool error:: ",
|
|
6982
|
-
throw
|
|
7206
|
+
err_45 = _a.sent();
|
|
7207
|
+
console.log("perpClient setPool error:: ", err_45);
|
|
7208
|
+
throw err_45;
|
|
6983
7209
|
case 5: return [2, {
|
|
6984
7210
|
instructions: __spreadArray([], instructions, true),
|
|
6985
7211
|
additionalSigners: additionalSigners
|
|
@@ -6988,7 +7214,7 @@ var PerpetualsClient = (function () {
|
|
|
6988
7214
|
});
|
|
6989
7215
|
}); };
|
|
6990
7216
|
this.moveProtocolFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
6991
|
-
var publicKey, rewardCustodyConfig, instructions, additionalSigners, moveProtocolFeesIx,
|
|
7217
|
+
var publicKey, rewardCustodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_46;
|
|
6992
7218
|
return __generator(this, function (_a) {
|
|
6993
7219
|
switch (_a.label) {
|
|
6994
7220
|
case 0:
|
|
@@ -7021,9 +7247,9 @@ var PerpetualsClient = (function () {
|
|
|
7021
7247
|
instructions.push(moveProtocolFeesIx);
|
|
7022
7248
|
return [3, 4];
|
|
7023
7249
|
case 3:
|
|
7024
|
-
|
|
7025
|
-
console.log("perpClient setPool error:: ",
|
|
7026
|
-
throw
|
|
7250
|
+
err_46 = _a.sent();
|
|
7251
|
+
console.log("perpClient setPool error:: ", err_46);
|
|
7252
|
+
throw err_46;
|
|
7027
7253
|
case 4: return [2, {
|
|
7028
7254
|
instructions: __spreadArray([], instructions, true),
|
|
7029
7255
|
additionalSigners: additionalSigners
|
|
@@ -7032,7 +7258,7 @@ var PerpetualsClient = (function () {
|
|
|
7032
7258
|
});
|
|
7033
7259
|
}); };
|
|
7034
7260
|
this.setProtocolFeeShareBps = function (feeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7035
|
-
var publicKey, setProtocolFeeShareBpsIx,
|
|
7261
|
+
var publicKey, setProtocolFeeShareBpsIx, err_47;
|
|
7036
7262
|
return __generator(this, function (_a) {
|
|
7037
7263
|
switch (_a.label) {
|
|
7038
7264
|
case 0:
|
|
@@ -7052,15 +7278,15 @@ var PerpetualsClient = (function () {
|
|
|
7052
7278
|
setProtocolFeeShareBpsIx = _a.sent();
|
|
7053
7279
|
return [2, setProtocolFeeShareBpsIx];
|
|
7054
7280
|
case 2:
|
|
7055
|
-
|
|
7056
|
-
console.log("perpClient setProtocolFeeShareBpsIx error:: ",
|
|
7057
|
-
throw
|
|
7281
|
+
err_47 = _a.sent();
|
|
7282
|
+
console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_47);
|
|
7283
|
+
throw err_47;
|
|
7058
7284
|
case 3: return [2];
|
|
7059
7285
|
}
|
|
7060
7286
|
});
|
|
7061
7287
|
}); };
|
|
7062
7288
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
|
7063
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
|
7289
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_48;
|
|
7064
7290
|
return __generator(this, function (_a) {
|
|
7065
7291
|
switch (_a.label) {
|
|
7066
7292
|
case 0:
|
|
@@ -7087,9 +7313,9 @@ var PerpetualsClient = (function () {
|
|
|
7087
7313
|
instructions.push(setPermissionsInstruction);
|
|
7088
7314
|
return [3, 4];
|
|
7089
7315
|
case 3:
|
|
7090
|
-
|
|
7091
|
-
console.log("perpClient setPool error:: ",
|
|
7092
|
-
throw
|
|
7316
|
+
err_48 = _a.sent();
|
|
7317
|
+
console.log("perpClient setPool error:: ", err_48);
|
|
7318
|
+
throw err_48;
|
|
7093
7319
|
case 4: return [2, {
|
|
7094
7320
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7095
7321
|
additionalSigners: additionalSigners
|
|
@@ -7098,7 +7324,7 @@ var PerpetualsClient = (function () {
|
|
|
7098
7324
|
});
|
|
7099
7325
|
}); };
|
|
7100
7326
|
this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7101
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e,
|
|
7327
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_49;
|
|
7102
7328
|
var _f;
|
|
7103
7329
|
return __generator(this, function (_g) {
|
|
7104
7330
|
switch (_g.label) {
|
|
@@ -7159,9 +7385,9 @@ var PerpetualsClient = (function () {
|
|
|
7159
7385
|
instructions.push(reimburse);
|
|
7160
7386
|
return [3, 5];
|
|
7161
7387
|
case 4:
|
|
7162
|
-
|
|
7163
|
-
console.log("perpClient setPool error:: ",
|
|
7164
|
-
throw
|
|
7388
|
+
err_49 = _g.sent();
|
|
7389
|
+
console.log("perpClient setPool error:: ", err_49);
|
|
7390
|
+
throw err_49;
|
|
7165
7391
|
case 5: return [2, {
|
|
7166
7392
|
instructions: __spreadArray([], instructions, true),
|
|
7167
7393
|
additionalSigners: additionalSigners
|
|
@@ -7169,44 +7395,51 @@ var PerpetualsClient = (function () {
|
|
|
7169
7395
|
}
|
|
7170
7396
|
});
|
|
7171
7397
|
}); };
|
|
7172
|
-
this.
|
|
7173
|
-
var instructions, additionalSigners,
|
|
7398
|
+
this.setInternalOraclePriceBatch = function (useCurrentTime, tokenMintList, tokenInternalPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
|
|
7399
|
+
var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_50;
|
|
7174
7400
|
return __generator(this, function (_a) {
|
|
7175
7401
|
switch (_a.label) {
|
|
7176
7402
|
case 0:
|
|
7403
|
+
if (tokenMintList.length !== tokenInternalPrices.length) {
|
|
7404
|
+
throw new Error("tokenMintList and tokenInternalPrices length mismatch");
|
|
7405
|
+
}
|
|
7406
|
+
ALL_CUSTODY_CONFIGS = POOL_CONFIGS.map(function (f) { return f.custodies; }).flat();
|
|
7407
|
+
accountMetas = [];
|
|
7408
|
+
_loop_1 = function (tokenMint) {
|
|
7409
|
+
var custody = ALL_CUSTODY_CONFIGS.find(function (i) { return i.mintKey.equals(tokenMint); });
|
|
7410
|
+
accountMetas.push({
|
|
7411
|
+
pubkey: custody.intOracleAccount,
|
|
7412
|
+
isSigner: false,
|
|
7413
|
+
isWritable: true,
|
|
7414
|
+
});
|
|
7415
|
+
};
|
|
7416
|
+
for (_i = 0, tokenMintList_1 = tokenMintList; _i < tokenMintList_1.length; _i++) {
|
|
7417
|
+
tokenMint = tokenMintList_1[_i];
|
|
7418
|
+
_loop_1(tokenMint);
|
|
7419
|
+
}
|
|
7177
7420
|
instructions = [];
|
|
7178
7421
|
additionalSigners = [];
|
|
7179
|
-
custodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(tokenMint); });
|
|
7180
7422
|
_a.label = 1;
|
|
7181
7423
|
case 1:
|
|
7182
7424
|
_a.trys.push([1, 3, , 4]);
|
|
7183
7425
|
return [4, this.program.methods
|
|
7184
|
-
.
|
|
7426
|
+
.setInternalCurrentPrice({
|
|
7185
7427
|
useCurrentTime: useCurrentTime,
|
|
7186
|
-
|
|
7187
|
-
expo: expo,
|
|
7188
|
-
conf: conf,
|
|
7189
|
-
ema: ema,
|
|
7190
|
-
publishTime: publishTime,
|
|
7428
|
+
prices: tokenInternalPrices
|
|
7191
7429
|
})
|
|
7192
7430
|
.accountsPartial({
|
|
7193
|
-
authority:
|
|
7194
|
-
perpetuals: poolConfig.perpetuals,
|
|
7195
|
-
pool: poolConfig.poolAddress,
|
|
7196
|
-
custody: custodyConfig.custodyAccount,
|
|
7197
|
-
intOracleAccount: custodyConfig.intOracleAccount,
|
|
7198
|
-
extOracleAccount: custodyConfig.extOracleAccount,
|
|
7199
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
7431
|
+
authority: POOL_CONFIGS[0].backupOracle,
|
|
7200
7432
|
})
|
|
7433
|
+
.remainingAccounts(__spreadArray([], accountMetas, true))
|
|
7201
7434
|
.instruction()];
|
|
7202
7435
|
case 2:
|
|
7203
7436
|
setInternalOraclePrice = _a.sent();
|
|
7204
7437
|
instructions.push(setInternalOraclePrice);
|
|
7205
7438
|
return [3, 4];
|
|
7206
7439
|
case 3:
|
|
7207
|
-
|
|
7208
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
|
7209
|
-
throw
|
|
7440
|
+
err_50 = _a.sent();
|
|
7441
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_50);
|
|
7442
|
+
throw err_50;
|
|
7210
7443
|
case 4: return [2, {
|
|
7211
7444
|
instructions: __spreadArray([], instructions, true),
|
|
7212
7445
|
additionalSigners: additionalSigners
|
|
@@ -7214,32 +7447,24 @@ var PerpetualsClient = (function () {
|
|
|
7214
7447
|
}
|
|
7215
7448
|
});
|
|
7216
7449
|
}); };
|
|
7217
|
-
this.
|
|
7218
|
-
var ALL_CUSTODY_CONFIGS, accountMetas,
|
|
7450
|
+
this.setInternalLazerPriceBatch = function (messageData, tokenMintList, pythStorage, pythTreasury, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
|
|
7451
|
+
var ALL_CUSTODY_CONFIGS, accountMetas, _loop_2, _i, tokenMintList_2, tokenMint, instructions, additionalSigners, setInternalLazerPrice, err_51;
|
|
7219
7452
|
return __generator(this, function (_a) {
|
|
7220
7453
|
switch (_a.label) {
|
|
7221
7454
|
case 0:
|
|
7222
|
-
if (tokenMintList.length !== tokenInternalPrices.length) {
|
|
7223
|
-
throw new Error("tokenMintList and tokenInternalPrices length mismatch");
|
|
7224
|
-
}
|
|
7225
7455
|
ALL_CUSTODY_CONFIGS = POOL_CONFIGS.map(function (f) { return f.custodies; }).flat();
|
|
7226
7456
|
accountMetas = [];
|
|
7227
|
-
|
|
7457
|
+
_loop_2 = function (tokenMint) {
|
|
7228
7458
|
var custody = ALL_CUSTODY_CONFIGS.find(function (i) { return i.mintKey.equals(tokenMint); });
|
|
7229
7459
|
accountMetas.push({
|
|
7230
7460
|
pubkey: custody.intOracleAccount,
|
|
7231
7461
|
isSigner: false,
|
|
7232
7462
|
isWritable: true,
|
|
7233
7463
|
});
|
|
7234
|
-
accountMetas.push({
|
|
7235
|
-
pubkey: custody.extOracleAccount,
|
|
7236
|
-
isSigner: false,
|
|
7237
|
-
isWritable: false,
|
|
7238
|
-
});
|
|
7239
7464
|
};
|
|
7240
|
-
for (_i = 0,
|
|
7241
|
-
tokenMint =
|
|
7242
|
-
|
|
7465
|
+
for (_i = 0, tokenMintList_2 = tokenMintList; _i < tokenMintList_2.length; _i++) {
|
|
7466
|
+
tokenMint = tokenMintList_2[_i];
|
|
7467
|
+
_loop_2(tokenMint);
|
|
7243
7468
|
}
|
|
7244
7469
|
instructions = [];
|
|
7245
7470
|
additionalSigners = [];
|
|
@@ -7247,23 +7472,26 @@ var PerpetualsClient = (function () {
|
|
|
7247
7472
|
case 1:
|
|
7248
7473
|
_a.trys.push([1, 3, , 4]);
|
|
7249
7474
|
return [4, this.program.methods
|
|
7250
|
-
.
|
|
7251
|
-
|
|
7252
|
-
prices: tokenInternalPrices
|
|
7475
|
+
.setInternalLazerPrice({
|
|
7476
|
+
messageData: messageData
|
|
7253
7477
|
})
|
|
7254
7478
|
.accountsPartial({
|
|
7255
|
-
|
|
7479
|
+
payer: this.provider.wallet.publicKey,
|
|
7480
|
+
pythStorage: pythStorage,
|
|
7481
|
+
pythTreasury: pythTreasury,
|
|
7482
|
+
pythLazerProgram: constants_1.PYTH_LAZER_PROGRAM_ID,
|
|
7483
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
7256
7484
|
})
|
|
7257
7485
|
.remainingAccounts(__spreadArray([], accountMetas, true))
|
|
7258
7486
|
.instruction()];
|
|
7259
7487
|
case 2:
|
|
7260
|
-
|
|
7261
|
-
instructions.push(
|
|
7488
|
+
setInternalLazerPrice = _a.sent();
|
|
7489
|
+
instructions.push(setInternalLazerPrice);
|
|
7262
7490
|
return [3, 4];
|
|
7263
7491
|
case 3:
|
|
7264
|
-
|
|
7265
|
-
console.log("perpClient
|
|
7266
|
-
throw
|
|
7492
|
+
err_51 = _a.sent();
|
|
7493
|
+
console.log("perpClient setInternalLazerPriceBatch error:: ", err_51);
|
|
7494
|
+
throw err_51;
|
|
7267
7495
|
case 4: return [2, {
|
|
7268
7496
|
instructions: __spreadArray([], instructions, true),
|
|
7269
7497
|
additionalSigners: additionalSigners
|
|
@@ -7272,7 +7500,7 @@ var PerpetualsClient = (function () {
|
|
|
7272
7500
|
});
|
|
7273
7501
|
}); };
|
|
7274
7502
|
this.setInternalOracleEmaPriceBatch = function (tokenMintList, tokenInternalEmaPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
|
|
7275
|
-
var ALL_CUSTODY_CONFIGS, accountMetas,
|
|
7503
|
+
var ALL_CUSTODY_CONFIGS, accountMetas, _loop_3, _i, tokenMintList_3, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_52;
|
|
7276
7504
|
return __generator(this, function (_a) {
|
|
7277
7505
|
switch (_a.label) {
|
|
7278
7506
|
case 0:
|
|
@@ -7281,7 +7509,7 @@ var PerpetualsClient = (function () {
|
|
|
7281
7509
|
}
|
|
7282
7510
|
ALL_CUSTODY_CONFIGS = POOL_CONFIGS.map(function (f) { return f.custodies; }).flat();
|
|
7283
7511
|
accountMetas = [];
|
|
7284
|
-
|
|
7512
|
+
_loop_3 = function (tokenMint) {
|
|
7285
7513
|
var custody = ALL_CUSTODY_CONFIGS.find(function (i) { return i.mintKey.equals(tokenMint); });
|
|
7286
7514
|
accountMetas.push({
|
|
7287
7515
|
pubkey: custody.intOracleAccount,
|
|
@@ -7289,9 +7517,9 @@ var PerpetualsClient = (function () {
|
|
|
7289
7517
|
isWritable: true,
|
|
7290
7518
|
});
|
|
7291
7519
|
};
|
|
7292
|
-
for (_i = 0,
|
|
7293
|
-
tokenMint =
|
|
7294
|
-
|
|
7520
|
+
for (_i = 0, tokenMintList_3 = tokenMintList; _i < tokenMintList_3.length; _i++) {
|
|
7521
|
+
tokenMint = tokenMintList_3[_i];
|
|
7522
|
+
_loop_3(tokenMint);
|
|
7295
7523
|
}
|
|
7296
7524
|
instructions = [];
|
|
7297
7525
|
additionalSigners = [];
|
|
@@ -7312,9 +7540,9 @@ var PerpetualsClient = (function () {
|
|
|
7312
7540
|
instructions.push(setInternalOraclePrice);
|
|
7313
7541
|
return [3, 4];
|
|
7314
7542
|
case 3:
|
|
7315
|
-
|
|
7316
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
|
7317
|
-
throw
|
|
7543
|
+
err_52 = _a.sent();
|
|
7544
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_52);
|
|
7545
|
+
throw err_52;
|
|
7318
7546
|
case 4: return [2, {
|
|
7319
7547
|
instructions: __spreadArray([], instructions, true),
|
|
7320
7548
|
additionalSigners: additionalSigners
|
|
@@ -7323,7 +7551,7 @@ var PerpetualsClient = (function () {
|
|
|
7323
7551
|
});
|
|
7324
7552
|
}); };
|
|
7325
7553
|
this.setPositionPriceImpact = function (positionPubkey, priceImpactUsd, penaltyAuthority) { return __awaiter(_this, void 0, void 0, function () {
|
|
7326
|
-
var instructions, additionalSigners, setPositionPriceImpactIx,
|
|
7554
|
+
var instructions, additionalSigners, setPositionPriceImpactIx, err_53;
|
|
7327
7555
|
return __generator(this, function (_a) {
|
|
7328
7556
|
switch (_a.label) {
|
|
7329
7557
|
case 0:
|
|
@@ -7347,9 +7575,9 @@ var PerpetualsClient = (function () {
|
|
|
7347
7575
|
instructions.push(setPositionPriceImpactIx);
|
|
7348
7576
|
return [3, 4];
|
|
7349
7577
|
case 3:
|
|
7350
|
-
|
|
7351
|
-
console.log("perpClient setPositionPriceImpact error:: ",
|
|
7352
|
-
throw
|
|
7578
|
+
err_53 = _a.sent();
|
|
7579
|
+
console.log("perpClient setPositionPriceImpact error:: ", err_53);
|
|
7580
|
+
throw err_53;
|
|
7353
7581
|
case 4: return [2, {
|
|
7354
7582
|
instructions: __spreadArray([], instructions, true),
|
|
7355
7583
|
additionalSigners: additionalSigners
|
|
@@ -7358,7 +7586,7 @@ var PerpetualsClient = (function () {
|
|
|
7358
7586
|
});
|
|
7359
7587
|
}); };
|
|
7360
7588
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7361
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
|
7589
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_54;
|
|
7362
7590
|
return __generator(this, function (_a) {
|
|
7363
7591
|
switch (_a.label) {
|
|
7364
7592
|
case 0:
|
|
@@ -7396,8 +7624,8 @@ var PerpetualsClient = (function () {
|
|
|
7396
7624
|
instructions.push(renameFlp);
|
|
7397
7625
|
return [3, 4];
|
|
7398
7626
|
case 3:
|
|
7399
|
-
|
|
7400
|
-
console.log("perpClient renameFlp error:: ",
|
|
7627
|
+
err_54 = _a.sent();
|
|
7628
|
+
console.log("perpClient renameFlp error:: ", err_54);
|
|
7401
7629
|
return [3, 4];
|
|
7402
7630
|
case 4: return [2, {
|
|
7403
7631
|
instructions: __spreadArray([], instructions, true),
|
|
@@ -7407,7 +7635,7 @@ var PerpetualsClient = (function () {
|
|
|
7407
7635
|
});
|
|
7408
7636
|
}); };
|
|
7409
7637
|
this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7410
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction,
|
|
7638
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_55;
|
|
7411
7639
|
return __generator(this, function (_a) {
|
|
7412
7640
|
switch (_a.label) {
|
|
7413
7641
|
case 0:
|
|
@@ -7445,9 +7673,9 @@ var PerpetualsClient = (function () {
|
|
|
7445
7673
|
instructions.push(initStakeInstruction);
|
|
7446
7674
|
return [3, 4];
|
|
7447
7675
|
case 3:
|
|
7448
|
-
|
|
7449
|
-
console.log("perpClient InitStaking error:: ",
|
|
7450
|
-
throw
|
|
7676
|
+
err_55 = _a.sent();
|
|
7677
|
+
console.log("perpClient InitStaking error:: ", err_55);
|
|
7678
|
+
throw err_55;
|
|
7451
7679
|
case 4: return [2, {
|
|
7452
7680
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7453
7681
|
additionalSigners: additionalSigners
|
|
@@ -7456,7 +7684,7 @@ var PerpetualsClient = (function () {
|
|
|
7456
7684
|
});
|
|
7457
7685
|
}); };
|
|
7458
7686
|
this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7459
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction,
|
|
7687
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_56;
|
|
7460
7688
|
return __generator(this, function (_a) {
|
|
7461
7689
|
switch (_a.label) {
|
|
7462
7690
|
case 0:
|
|
@@ -7500,9 +7728,9 @@ var PerpetualsClient = (function () {
|
|
|
7500
7728
|
instructions.push(initCompoundingInstruction);
|
|
7501
7729
|
return [3, 4];
|
|
7502
7730
|
case 3:
|
|
7503
|
-
|
|
7504
|
-
console.log("perpClient initCompounding error:: ",
|
|
7505
|
-
throw
|
|
7731
|
+
err_56 = _a.sent();
|
|
7732
|
+
console.log("perpClient initCompounding error:: ", err_56);
|
|
7733
|
+
throw err_56;
|
|
7506
7734
|
case 4: return [2, {
|
|
7507
7735
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7508
7736
|
additionalSigners: additionalSigners
|
|
@@ -7511,7 +7739,7 @@ var PerpetualsClient = (function () {
|
|
|
7511
7739
|
});
|
|
7512
7740
|
}); };
|
|
7513
7741
|
this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7514
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction,
|
|
7742
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_57;
|
|
7515
7743
|
return __generator(this, function (_a) {
|
|
7516
7744
|
switch (_a.label) {
|
|
7517
7745
|
case 0:
|
|
@@ -7552,9 +7780,9 @@ var PerpetualsClient = (function () {
|
|
|
7552
7780
|
instructions.push(initTokenVaultInstruction);
|
|
7553
7781
|
return [3, 4];
|
|
7554
7782
|
case 3:
|
|
7555
|
-
|
|
7556
|
-
console.log("perpClient InitTokenVaultInstruction error:: ",
|
|
7557
|
-
throw
|
|
7783
|
+
err_57 = _a.sent();
|
|
7784
|
+
console.log("perpClient InitTokenVaultInstruction error:: ", err_57);
|
|
7785
|
+
throw err_57;
|
|
7558
7786
|
case 4: return [2, {
|
|
7559
7787
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7560
7788
|
additionalSigners: additionalSigners
|
|
@@ -7563,7 +7791,7 @@ var PerpetualsClient = (function () {
|
|
|
7563
7791
|
});
|
|
7564
7792
|
}); };
|
|
7565
7793
|
this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7566
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction,
|
|
7794
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_58;
|
|
7567
7795
|
return __generator(this, function (_a) {
|
|
7568
7796
|
switch (_a.label) {
|
|
7569
7797
|
case 0:
|
|
@@ -7594,9 +7822,9 @@ var PerpetualsClient = (function () {
|
|
|
7594
7822
|
instructions.push(setTokenVaultConfigInstruction);
|
|
7595
7823
|
return [3, 4];
|
|
7596
7824
|
case 3:
|
|
7597
|
-
|
|
7598
|
-
console.log("perpClient setTokenVaultConfigInstruction error:: ",
|
|
7599
|
-
throw
|
|
7825
|
+
err_58 = _a.sent();
|
|
7826
|
+
console.log("perpClient setTokenVaultConfigInstruction error:: ", err_58);
|
|
7827
|
+
throw err_58;
|
|
7600
7828
|
case 4: return [2, {
|
|
7601
7829
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7602
7830
|
additionalSigners: additionalSigners
|
|
@@ -7605,7 +7833,7 @@ var PerpetualsClient = (function () {
|
|
|
7605
7833
|
});
|
|
7606
7834
|
}); };
|
|
7607
7835
|
this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7608
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction,
|
|
7836
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_59;
|
|
7609
7837
|
return __generator(this, function (_a) {
|
|
7610
7838
|
switch (_a.label) {
|
|
7611
7839
|
case 0:
|
|
@@ -7616,11 +7844,15 @@ var PerpetualsClient = (function () {
|
|
|
7616
7844
|
additionalSigners = [];
|
|
7617
7845
|
_a.label = 1;
|
|
7618
7846
|
case 1:
|
|
7619
|
-
_a.trys.push([1,
|
|
7847
|
+
_a.trys.push([1, 5, , 6]);
|
|
7620
7848
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.tokenMint, publicKey, true)];
|
|
7621
7849
|
case 2:
|
|
7622
7850
|
receivingTokenAccount = _a.sent();
|
|
7623
|
-
|
|
7851
|
+
return [4, (0, utils_1.checkIfAccountExists)(receivingTokenAccount, this.provider.connection)];
|
|
7852
|
+
case 3:
|
|
7853
|
+
if (!(_a.sent())) {
|
|
7854
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, receivingTokenAccount, publicKey, poolConfig.tokenMint));
|
|
7855
|
+
}
|
|
7624
7856
|
return [4, this.program.methods
|
|
7625
7857
|
.withdrawInstantFees({})
|
|
7626
7858
|
.accountsPartial({
|
|
@@ -7635,15 +7867,15 @@ var PerpetualsClient = (function () {
|
|
|
7635
7867
|
receivingTokenMint: poolConfig.tokenMint,
|
|
7636
7868
|
})
|
|
7637
7869
|
.instruction()];
|
|
7638
|
-
case
|
|
7870
|
+
case 4:
|
|
7639
7871
|
withdrawInstantFeeInstruction = _a.sent();
|
|
7640
7872
|
instructions.push(withdrawInstantFeeInstruction);
|
|
7641
|
-
return [3,
|
|
7642
|
-
case
|
|
7643
|
-
|
|
7644
|
-
console.log("perpClient withdrawInstantFeeInstruction error:: ",
|
|
7645
|
-
throw
|
|
7646
|
-
case
|
|
7873
|
+
return [3, 6];
|
|
7874
|
+
case 5:
|
|
7875
|
+
err_59 = _a.sent();
|
|
7876
|
+
console.log("perpClient withdrawInstantFeeInstruction error:: ", err_59);
|
|
7877
|
+
throw err_59;
|
|
7878
|
+
case 6: return [2, {
|
|
7647
7879
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7648
7880
|
additionalSigners: additionalSigners
|
|
7649
7881
|
}];
|
|
@@ -7651,7 +7883,7 @@ var PerpetualsClient = (function () {
|
|
|
7651
7883
|
});
|
|
7652
7884
|
}); };
|
|
7653
7885
|
this.withdrawUnclaimedTokens = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7654
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction,
|
|
7886
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_60;
|
|
7655
7887
|
return __generator(this, function (_a) {
|
|
7656
7888
|
switch (_a.label) {
|
|
7657
7889
|
case 0:
|
|
@@ -7662,11 +7894,15 @@ var PerpetualsClient = (function () {
|
|
|
7662
7894
|
additionalSigners = [];
|
|
7663
7895
|
_a.label = 1;
|
|
7664
7896
|
case 1:
|
|
7665
|
-
_a.trys.push([1,
|
|
7897
|
+
_a.trys.push([1, 5, , 6]);
|
|
7666
7898
|
return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.tokenMint, publicKey, true)];
|
|
7667
7899
|
case 2:
|
|
7668
7900
|
receivingTokenAccount = _a.sent();
|
|
7669
|
-
|
|
7901
|
+
return [4, (0, utils_1.checkIfAccountExists)(receivingTokenAccount, this.provider.connection)];
|
|
7902
|
+
case 3:
|
|
7903
|
+
if (!(_a.sent())) {
|
|
7904
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, receivingTokenAccount, publicKey, poolConfig.tokenMint));
|
|
7905
|
+
}
|
|
7670
7906
|
return [4, this.program.methods
|
|
7671
7907
|
.withdrawUnclaimedTokens({})
|
|
7672
7908
|
.accountsPartial({
|
|
@@ -7681,15 +7917,15 @@ var PerpetualsClient = (function () {
|
|
|
7681
7917
|
receivingTokenMint: poolConfig.tokenMint,
|
|
7682
7918
|
})
|
|
7683
7919
|
.instruction()];
|
|
7684
|
-
case
|
|
7920
|
+
case 4:
|
|
7685
7921
|
withdrawUnclaimedTokensInstruction = _a.sent();
|
|
7686
7922
|
instructions.push(withdrawUnclaimedTokensInstruction);
|
|
7687
|
-
return [3,
|
|
7688
|
-
case
|
|
7689
|
-
|
|
7690
|
-
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ",
|
|
7691
|
-
throw
|
|
7692
|
-
case
|
|
7923
|
+
return [3, 6];
|
|
7924
|
+
case 5:
|
|
7925
|
+
err_60 = _a.sent();
|
|
7926
|
+
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_60);
|
|
7927
|
+
throw err_60;
|
|
7928
|
+
case 6: return [2, {
|
|
7693
7929
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7694
7930
|
additionalSigners: additionalSigners
|
|
7695
7931
|
}];
|
|
@@ -7697,7 +7933,7 @@ var PerpetualsClient = (function () {
|
|
|
7697
7933
|
});
|
|
7698
7934
|
}); };
|
|
7699
7935
|
this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7700
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction,
|
|
7936
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_61;
|
|
7701
7937
|
return __generator(this, function (_a) {
|
|
7702
7938
|
switch (_a.label) {
|
|
7703
7939
|
case 0:
|
|
@@ -7734,9 +7970,9 @@ var PerpetualsClient = (function () {
|
|
|
7734
7970
|
instructions.push(initRevenueTokenAccountInstruction);
|
|
7735
7971
|
return [3, 4];
|
|
7736
7972
|
case 3:
|
|
7737
|
-
|
|
7738
|
-
console.log("perpClient initRevenueTokenAccountInstruction error:: ",
|
|
7739
|
-
throw
|
|
7973
|
+
err_61 = _a.sent();
|
|
7974
|
+
console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_61);
|
|
7975
|
+
throw err_61;
|
|
7740
7976
|
case 4: return [2, {
|
|
7741
7977
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7742
7978
|
additionalSigners: additionalSigners
|
|
@@ -7745,7 +7981,7 @@ var PerpetualsClient = (function () {
|
|
|
7745
7981
|
});
|
|
7746
7982
|
}); };
|
|
7747
7983
|
this.initRebateVault = function (allowRebatePayout, rebateSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7748
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction,
|
|
7984
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_62;
|
|
7749
7985
|
return __generator(this, function (_a) {
|
|
7750
7986
|
switch (_a.label) {
|
|
7751
7987
|
case 0:
|
|
@@ -7780,9 +8016,9 @@ var PerpetualsClient = (function () {
|
|
|
7780
8016
|
instructions.push(initRebateVaultInstruction);
|
|
7781
8017
|
return [3, 4];
|
|
7782
8018
|
case 3:
|
|
7783
|
-
|
|
7784
|
-
console.log("perpClient initRebateVaultInstruction error:: ",
|
|
7785
|
-
throw
|
|
8019
|
+
err_62 = _a.sent();
|
|
8020
|
+
console.log("perpClient initRebateVaultInstruction error:: ", err_62);
|
|
8021
|
+
throw err_62;
|
|
7786
8022
|
case 4: return [2, {
|
|
7787
8023
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7788
8024
|
additionalSigners: additionalSigners
|
|
@@ -7791,7 +8027,7 @@ var PerpetualsClient = (function () {
|
|
|
7791
8027
|
});
|
|
7792
8028
|
}); };
|
|
7793
8029
|
this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7794
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction,
|
|
8030
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_63;
|
|
7795
8031
|
return __generator(this, function (_a) {
|
|
7796
8032
|
switch (_a.label) {
|
|
7797
8033
|
case 0:
|
|
@@ -7828,9 +8064,9 @@ var PerpetualsClient = (function () {
|
|
|
7828
8064
|
instructions.push(distributeTokenRewardInstruction);
|
|
7829
8065
|
return [3, 4];
|
|
7830
8066
|
case 3:
|
|
7831
|
-
|
|
7832
|
-
console.log("perpClient distributeTokenRewardInstruction error:: ",
|
|
7833
|
-
throw
|
|
8067
|
+
err_63 = _a.sent();
|
|
8068
|
+
console.log("perpClient distributeTokenRewardInstruction error:: ", err_63);
|
|
8069
|
+
throw err_63;
|
|
7834
8070
|
case 4: return [2, {
|
|
7835
8071
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7836
8072
|
additionalSigners: additionalSigners
|
|
@@ -7839,7 +8075,7 @@ var PerpetualsClient = (function () {
|
|
|
7839
8075
|
});
|
|
7840
8076
|
}); };
|
|
7841
8077
|
this.setTokenStakeLevel = function (owner, stakeLevel, isInitialized) { return __awaiter(_this, void 0, void 0, function () {
|
|
7842
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction,
|
|
8078
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_64;
|
|
7843
8079
|
return __generator(this, function (_a) {
|
|
7844
8080
|
switch (_a.label) {
|
|
7845
8081
|
case 0:
|
|
@@ -7868,9 +8104,9 @@ var PerpetualsClient = (function () {
|
|
|
7868
8104
|
instructions.push(setTokenStakeLevelInstruction);
|
|
7869
8105
|
return [3, 4];
|
|
7870
8106
|
case 3:
|
|
7871
|
-
|
|
7872
|
-
console.log("perpClient setTokenStakeLevelInstruction error:: ",
|
|
7873
|
-
throw
|
|
8107
|
+
err_64 = _a.sent();
|
|
8108
|
+
console.log("perpClient setTokenStakeLevelInstruction error:: ", err_64);
|
|
8109
|
+
throw err_64;
|
|
7874
8110
|
case 4: return [2, {
|
|
7875
8111
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7876
8112
|
additionalSigners: additionalSigners
|
|
@@ -7879,7 +8115,7 @@ var PerpetualsClient = (function () {
|
|
|
7879
8115
|
});
|
|
7880
8116
|
}); };
|
|
7881
8117
|
this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7882
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction,
|
|
8118
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_65;
|
|
7883
8119
|
return __generator(this, function (_a) {
|
|
7884
8120
|
switch (_a.label) {
|
|
7885
8121
|
case 0:
|
|
@@ -7910,9 +8146,9 @@ var PerpetualsClient = (function () {
|
|
|
7910
8146
|
instructions.push(setTokenRewardInstruction);
|
|
7911
8147
|
return [3, 4];
|
|
7912
8148
|
case 3:
|
|
7913
|
-
|
|
7914
|
-
console.log("perpClient setTokenRewardInstruction error:: ",
|
|
7915
|
-
throw
|
|
8149
|
+
err_65 = _a.sent();
|
|
8150
|
+
console.log("perpClient setTokenRewardInstruction error:: ", err_65);
|
|
8151
|
+
throw err_65;
|
|
7916
8152
|
case 4: return [2, {
|
|
7917
8153
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7918
8154
|
additionalSigners: additionalSigners
|
|
@@ -7920,8 +8156,8 @@ var PerpetualsClient = (function () {
|
|
|
7920
8156
|
}
|
|
7921
8157
|
});
|
|
7922
8158
|
}); };
|
|
7923
|
-
this.resizeInternalOracle = function (
|
|
7924
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction,
|
|
8159
|
+
this.resizeInternalOracle = function (lazerFeedId, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
|
|
8160
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_66;
|
|
7925
8161
|
return __generator(this, function (_a) {
|
|
7926
8162
|
switch (_a.label) {
|
|
7927
8163
|
case 0:
|
|
@@ -7935,7 +8171,7 @@ var PerpetualsClient = (function () {
|
|
|
7935
8171
|
_a.trys.push([1, 3, , 4]);
|
|
7936
8172
|
return [4, this.program.methods
|
|
7937
8173
|
.resizeInternalOracle({
|
|
7938
|
-
|
|
8174
|
+
lazerFeedId: lazerFeedId,
|
|
7939
8175
|
})
|
|
7940
8176
|
.accountsPartial({
|
|
7941
8177
|
admin: publicKey,
|
|
@@ -7950,9 +8186,9 @@ var PerpetualsClient = (function () {
|
|
|
7950
8186
|
instructions.push(resizeInternalOracleInstruction);
|
|
7951
8187
|
return [3, 4];
|
|
7952
8188
|
case 3:
|
|
7953
|
-
|
|
7954
|
-
console.log("perpClient resizeInternalOracleInstruction error:: ",
|
|
7955
|
-
throw
|
|
8189
|
+
err_66 = _a.sent();
|
|
8190
|
+
console.log("perpClient resizeInternalOracleInstruction error:: ", err_66);
|
|
8191
|
+
throw err_66;
|
|
7956
8192
|
case 4: return [2, {
|
|
7957
8193
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7958
8194
|
additionalSigners: additionalSigners
|
|
@@ -7961,7 +8197,7 @@ var PerpetualsClient = (function () {
|
|
|
7961
8197
|
});
|
|
7962
8198
|
}); };
|
|
7963
8199
|
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
7964
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction,
|
|
8200
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_67;
|
|
7965
8201
|
return __generator(this, function (_a) {
|
|
7966
8202
|
switch (_a.label) {
|
|
7967
8203
|
case 0:
|
|
@@ -7994,9 +8230,9 @@ var PerpetualsClient = (function () {
|
|
|
7994
8230
|
instructions.push(createWhitelistInstruction);
|
|
7995
8231
|
return [3, 4];
|
|
7996
8232
|
case 3:
|
|
7997
|
-
|
|
7998
|
-
console.log("perpClient createWhitelistInstruction error:: ",
|
|
7999
|
-
throw
|
|
8233
|
+
err_67 = _a.sent();
|
|
8234
|
+
console.log("perpClient createWhitelistInstruction error:: ", err_67);
|
|
8235
|
+
throw err_67;
|
|
8000
8236
|
case 4: return [2, {
|
|
8001
8237
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8002
8238
|
additionalSigners: additionalSigners
|
|
@@ -8005,7 +8241,7 @@ var PerpetualsClient = (function () {
|
|
|
8005
8241
|
});
|
|
8006
8242
|
}); };
|
|
8007
8243
|
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8008
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction,
|
|
8244
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_68;
|
|
8009
8245
|
return __generator(this, function (_a) {
|
|
8010
8246
|
switch (_a.label) {
|
|
8011
8247
|
case 0:
|
|
@@ -8038,9 +8274,9 @@ var PerpetualsClient = (function () {
|
|
|
8038
8274
|
instructions.push(setWhitelistConfigInstruction);
|
|
8039
8275
|
return [3, 4];
|
|
8040
8276
|
case 3:
|
|
8041
|
-
|
|
8042
|
-
console.log("perpClient setWhitelistConfigInstruction error:: ",
|
|
8043
|
-
throw
|
|
8277
|
+
err_68 = _a.sent();
|
|
8278
|
+
console.log("perpClient setWhitelistConfigInstruction error:: ", err_68);
|
|
8279
|
+
throw err_68;
|
|
8044
8280
|
case 4: return [2, {
|
|
8045
8281
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8046
8282
|
additionalSigners: additionalSigners
|
|
@@ -8049,7 +8285,7 @@ var PerpetualsClient = (function () {
|
|
|
8049
8285
|
});
|
|
8050
8286
|
}); };
|
|
8051
8287
|
this.setPerpetualsConfig = function (allowUngatedTrading, voltageMultiplier, tradingDiscount, referralRebate, defaultRebate, tradeLimit, triggerOrderLimit, rebateLimitUsd) { return __awaiter(_this, void 0, void 0, function () {
|
|
8052
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPerpetualsConfigInstruction,
|
|
8288
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPerpetualsConfigInstruction, err_69;
|
|
8053
8289
|
return __generator(this, function (_a) {
|
|
8054
8290
|
switch (_a.label) {
|
|
8055
8291
|
case 0:
|
|
@@ -8083,9 +8319,9 @@ var PerpetualsClient = (function () {
|
|
|
8083
8319
|
instructions.push(setPerpetualsConfigInstruction);
|
|
8084
8320
|
return [3, 4];
|
|
8085
8321
|
case 3:
|
|
8086
|
-
|
|
8087
|
-
console.log("perpClient setPerpetualsConfigInstruction error:: ",
|
|
8088
|
-
throw
|
|
8322
|
+
err_69 = _a.sent();
|
|
8323
|
+
console.log("perpClient setPerpetualsConfigInstruction error:: ", err_69);
|
|
8324
|
+
throw err_69;
|
|
8089
8325
|
case 4: return [2, {
|
|
8090
8326
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8091
8327
|
additionalSigners: additionalSigners
|
|
@@ -8094,7 +8330,7 @@ var PerpetualsClient = (function () {
|
|
|
8094
8330
|
});
|
|
8095
8331
|
}); };
|
|
8096
8332
|
this.setPoolConfig = function (name, permissions, maxAumUsd, oracleAuthority, stakingFeeShareBps, vpVolumeFactor, stakingFeeBoostBps, minLpPriceUsd, maxLpPriceUsd, thresholdUsd) { return __awaiter(_this, void 0, void 0, function () {
|
|
8097
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPoolConfigInstruction,
|
|
8333
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPoolConfigInstruction, err_70;
|
|
8098
8334
|
return __generator(this, function (_a) {
|
|
8099
8335
|
switch (_a.label) {
|
|
8100
8336
|
case 0:
|
|
@@ -8122,9 +8358,9 @@ var PerpetualsClient = (function () {
|
|
|
8122
8358
|
instructions.push(setPoolConfigInstruction);
|
|
8123
8359
|
return [3, 4];
|
|
8124
8360
|
case 3:
|
|
8125
|
-
|
|
8126
|
-
console.log("perpClient setPoolConfigInstruction error:: ",
|
|
8127
|
-
throw
|
|
8361
|
+
err_70 = _a.sent();
|
|
8362
|
+
console.log("perpClient setPoolConfigInstruction error:: ", err_70);
|
|
8363
|
+
throw err_70;
|
|
8128
8364
|
case 4: return [2, {
|
|
8129
8365
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8130
8366
|
additionalSigners: additionalSigners
|
|
@@ -8133,7 +8369,7 @@ var PerpetualsClient = (function () {
|
|
|
8133
8369
|
});
|
|
8134
8370
|
}); };
|
|
8135
8371
|
this.addCustodyToken22 = function (poolName, tokenMint, tokenAccountSpace, token22) { return __awaiter(_this, void 0, void 0, function () {
|
|
8136
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addCustodyToken22Instruction,
|
|
8372
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addCustodyToken22Instruction, err_71;
|
|
8137
8373
|
return __generator(this, function (_a) {
|
|
8138
8374
|
switch (_a.label) {
|
|
8139
8375
|
case 0:
|
|
@@ -8167,9 +8403,9 @@ var PerpetualsClient = (function () {
|
|
|
8167
8403
|
instructions.push(addCustodyToken22Instruction);
|
|
8168
8404
|
return [3, 4];
|
|
8169
8405
|
case 3:
|
|
8170
|
-
|
|
8171
|
-
console.log("perpClient addCustodyToken22Instruction error:: ",
|
|
8172
|
-
throw
|
|
8406
|
+
err_71 = _a.sent();
|
|
8407
|
+
console.log("perpClient addCustodyToken22Instruction error:: ", err_71);
|
|
8408
|
+
throw err_71;
|
|
8173
8409
|
case 4: return [2, {
|
|
8174
8410
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8175
8411
|
additionalSigners: additionalSigners
|
|
@@ -8178,7 +8414,7 @@ var PerpetualsClient = (function () {
|
|
|
8178
8414
|
});
|
|
8179
8415
|
}); };
|
|
8180
8416
|
this.addMarket = function (poolName, targetCustody, collateralCustody, side, correlation, maxPayoffBps, permissions) { return __awaiter(_this, void 0, void 0, function () {
|
|
8181
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, market, addMarketInstruction,
|
|
8417
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, market, addMarketInstruction, err_72;
|
|
8182
8418
|
return __generator(this, function (_a) {
|
|
8183
8419
|
switch (_a.label) {
|
|
8184
8420
|
case 0:
|
|
@@ -8221,9 +8457,9 @@ var PerpetualsClient = (function () {
|
|
|
8221
8457
|
instructions.push(addMarketInstruction);
|
|
8222
8458
|
return [3, 4];
|
|
8223
8459
|
case 3:
|
|
8224
|
-
|
|
8225
|
-
console.log("perpClient addMarketInstruction error:: ",
|
|
8226
|
-
throw
|
|
8460
|
+
err_72 = _a.sent();
|
|
8461
|
+
console.log("perpClient addMarketInstruction error:: ", err_72);
|
|
8462
|
+
throw err_72;
|
|
8227
8463
|
case 4: return [2, {
|
|
8228
8464
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8229
8465
|
additionalSigners: additionalSigners
|
|
@@ -8232,7 +8468,7 @@ var PerpetualsClient = (function () {
|
|
|
8232
8468
|
});
|
|
8233
8469
|
}); };
|
|
8234
8470
|
this.setCustody = function (poolName, tokenMint, depegAdjustment, inversePrice, oracle, pricingConfig, permissions, fees, borrowRate, ratios, rewardThreshold, minReserveUsd, limitPriceBufferBps, token22) { return __awaiter(_this, void 0, void 0, function () {
|
|
8235
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setCustodyConfigInstruction,
|
|
8471
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setCustodyConfigInstruction, err_73;
|
|
8236
8472
|
return __generator(this, function (_a) {
|
|
8237
8473
|
switch (_a.label) {
|
|
8238
8474
|
case 0:
|
|
@@ -8271,9 +8507,9 @@ var PerpetualsClient = (function () {
|
|
|
8271
8507
|
instructions.push(setCustodyConfigInstruction);
|
|
8272
8508
|
return [3, 4];
|
|
8273
8509
|
case 3:
|
|
8274
|
-
|
|
8275
|
-
console.log("perpClient setCustodyConfigInstruction error:: ",
|
|
8276
|
-
throw
|
|
8510
|
+
err_73 = _a.sent();
|
|
8511
|
+
console.log("perpClient setCustodyConfigInstruction error:: ", err_73);
|
|
8512
|
+
throw err_73;
|
|
8277
8513
|
case 4: return [2, {
|
|
8278
8514
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8279
8515
|
additionalSigners: additionalSigners
|
|
@@ -8281,12 +8517,11 @@ var PerpetualsClient = (function () {
|
|
|
8281
8517
|
}
|
|
8282
8518
|
});
|
|
8283
8519
|
}); };
|
|
8284
|
-
this.addInternalOracle = function (exponent, tokenMint, intOracleAccount
|
|
8285
|
-
var
|
|
8520
|
+
this.addInternalOracle = function (exponent, lazerFeedId, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
|
|
8521
|
+
var preInstructions, instructions, postInstructions, additionalSigners, addInternalOracleInstruction, err_74;
|
|
8286
8522
|
return __generator(this, function (_a) {
|
|
8287
8523
|
switch (_a.label) {
|
|
8288
8524
|
case 0:
|
|
8289
|
-
publicKey = this.provider.wallet.publicKey;
|
|
8290
8525
|
preInstructions = [];
|
|
8291
8526
|
instructions = [];
|
|
8292
8527
|
postInstructions = [];
|
|
@@ -8297,7 +8532,7 @@ var PerpetualsClient = (function () {
|
|
|
8297
8532
|
return [4, this.program.methods
|
|
8298
8533
|
.addInternalOracle({
|
|
8299
8534
|
expo: exponent,
|
|
8300
|
-
|
|
8535
|
+
lazerFeedId: lazerFeedId
|
|
8301
8536
|
})
|
|
8302
8537
|
.accountsPartial({
|
|
8303
8538
|
admin: this.admin,
|
|
@@ -8313,9 +8548,9 @@ var PerpetualsClient = (function () {
|
|
|
8313
8548
|
instructions.push(addInternalOracleInstruction);
|
|
8314
8549
|
return [3, 4];
|
|
8315
8550
|
case 3:
|
|
8316
|
-
|
|
8317
|
-
console.log("perpClient setCustodyConfigInstruction error:: ",
|
|
8318
|
-
throw
|
|
8551
|
+
err_74 = _a.sent();
|
|
8552
|
+
console.log("perpClient setCustodyConfigInstruction error:: ", err_74);
|
|
8553
|
+
throw err_74;
|
|
8319
8554
|
case 4: return [2, {
|
|
8320
8555
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8321
8556
|
additionalSigners: additionalSigners
|
|
@@ -8324,7 +8559,7 @@ var PerpetualsClient = (function () {
|
|
|
8324
8559
|
});
|
|
8325
8560
|
}); };
|
|
8326
8561
|
this.setMarket = function (poolName, targetCustody, collateralCustody, marketAccount, maxPayoffBps, permissions, correlation) { return __awaiter(_this, void 0, void 0, function () {
|
|
8327
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setMarketConfigInstruction,
|
|
8562
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setMarketConfigInstruction, err_75;
|
|
8328
8563
|
return __generator(this, function (_a) {
|
|
8329
8564
|
switch (_a.label) {
|
|
8330
8565
|
case 0:
|
|
@@ -8355,9 +8590,9 @@ var PerpetualsClient = (function () {
|
|
|
8355
8590
|
instructions.push(setMarketConfigInstruction);
|
|
8356
8591
|
return [3, 4];
|
|
8357
8592
|
case 3:
|
|
8358
|
-
|
|
8359
|
-
console.log("perpClient setCustodyConfigInstruction error:: ",
|
|
8360
|
-
throw
|
|
8593
|
+
err_75 = _a.sent();
|
|
8594
|
+
console.log("perpClient setCustodyConfigInstruction error:: ", err_75);
|
|
8595
|
+
throw err_75;
|
|
8361
8596
|
case 4: return [2, {
|
|
8362
8597
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8363
8598
|
additionalSigners: additionalSigners
|
|
@@ -8366,7 +8601,7 @@ var PerpetualsClient = (function () {
|
|
|
8366
8601
|
});
|
|
8367
8602
|
}); };
|
|
8368
8603
|
this.removeMarket = function (poolName, market, targetMint, collateralMint) { return __awaiter(_this, void 0, void 0, function () {
|
|
8369
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, removeMarketInstruction,
|
|
8604
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, removeMarketInstruction, err_76;
|
|
8370
8605
|
return __generator(this, function (_a) {
|
|
8371
8606
|
switch (_a.label) {
|
|
8372
8607
|
case 0:
|
|
@@ -8398,9 +8633,9 @@ var PerpetualsClient = (function () {
|
|
|
8398
8633
|
instructions.push(removeMarketInstruction);
|
|
8399
8634
|
return [3, 4];
|
|
8400
8635
|
case 3:
|
|
8401
|
-
|
|
8402
|
-
console.log("perpClient setCustodyConfigInstruction error:: ",
|
|
8403
|
-
throw
|
|
8636
|
+
err_76 = _a.sent();
|
|
8637
|
+
console.log("perpClient setCustodyConfigInstruction error:: ", err_76);
|
|
8638
|
+
throw err_76;
|
|
8404
8639
|
case 4: return [2, {
|
|
8405
8640
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8406
8641
|
additionalSigners: additionalSigners
|