flash-sdk 2.23.1 → 2.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/PerpetualsClient.d.ts +18 -2
- package/dist/PerpetualsClient.js +737 -186
- package/dist/idl/perpetuals.d.ts +1524 -218
- package/dist/idl/perpetuals.js +1524 -218
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
@@ -2954,6 +2954,369 @@ var PerpetualsClient = (function () {
|
|
2954
2954
|
});
|
2955
2955
|
});
|
2956
2956
|
};
|
2957
|
+
this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, createUserATA, unWrapSol, skipBalanceChecks) {
|
2958
|
+
if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
|
2959
|
+
if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
|
2960
|
+
if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
|
2961
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
2962
|
+
if (unWrapSol === void 0) { unWrapSol = false; }
|
2963
|
+
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2964
|
+
return __awaiter(_this, void 0, void 0, function () {
|
2965
|
+
var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, params, inx, closeWsolATAIns, err_2;
|
2966
|
+
return __generator(this, function (_e) {
|
2967
|
+
switch (_e.label) {
|
2968
|
+
case 0:
|
2969
|
+
publicKey = this.provider.wallet.publicKey;
|
2970
|
+
userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
|
2971
|
+
if (!userInputCustodyConfig) {
|
2972
|
+
throw "userInputCustodyConfig not found";
|
2973
|
+
}
|
2974
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey); });
|
2975
|
+
if (!collateralCustodyConfig) {
|
2976
|
+
throw "collateralCustodyConfig not found";
|
2977
|
+
}
|
2978
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetTokenSymbol).mintKey); });
|
2979
|
+
if (!targetCustodyConfig) {
|
2980
|
+
throw "targetCustodyConfig not found";
|
2981
|
+
}
|
2982
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
2983
|
+
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
2984
|
+
preInstructions = [];
|
2985
|
+
instructions = [];
|
2986
|
+
postInstructions = [];
|
2987
|
+
additionalSigners = [];
|
2988
|
+
if (!(userInputTokenSymbol == 'SOL' && collateralTokenSymbol == 'WSOL')) return [3, 4];
|
2989
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey)];
|
2990
|
+
case 1:
|
2991
|
+
wsolAssociatedTokenAccount = _e.sent();
|
2992
|
+
return [4, (0, utils_1.checkIfAccountExists)(wsolAssociatedTokenAccount, this.provider.connection)];
|
2993
|
+
case 2:
|
2994
|
+
wsolATAExist = _e.sent();
|
2995
|
+
if (!wsolATAExist) {
|
2996
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, wsolAssociatedTokenAccount, publicKey, spl_token_1.NATIVE_MINT));
|
2997
|
+
}
|
2998
|
+
_a = anchor_1.BN.bind;
|
2999
|
+
return [4, this.provider.connection.getBalance(publicKey)];
|
3000
|
+
case 3:
|
3001
|
+
unWrappedSolBalance = new (_a.apply(anchor_1.BN, [void 0, _e.sent()]))();
|
3002
|
+
if (unWrappedSolBalance.lt(amountIn)) {
|
3003
|
+
throw "Insufficient SOL Funds";
|
3004
|
+
}
|
3005
|
+
instructions.push(web3_js_1.SystemProgram.transfer({
|
3006
|
+
fromPubkey: publicKey,
|
3007
|
+
toPubkey: wsolAssociatedTokenAccount,
|
3008
|
+
lamports: amountIn.toNumber(),
|
3009
|
+
}), (0, spl_token_1.createSyncNativeInstruction)(wsolAssociatedTokenAccount));
|
3010
|
+
return [2, {
|
3011
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3012
|
+
additionalSigners: additionalSigners
|
3013
|
+
}];
|
3014
|
+
case 4:
|
3015
|
+
if (!(userInputTokenSymbol == 'WSOL' && collateralTokenSymbol == 'SOL')) return [3, 6];
|
3016
|
+
console.log("WSOL=> SOL : NOTE : ONLY WAY IS TO CLOSE THE WSOL ATA and GET ALL SOL ");
|
3017
|
+
return [4, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, publicKey)];
|
3018
|
+
case 5:
|
3019
|
+
wsolAssociatedTokenAccount = _e.sent();
|
3020
|
+
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(wsolAssociatedTokenAccount, publicKey, publicKey);
|
3021
|
+
instructions.push(closeWsolATAIns);
|
3022
|
+
return [2, {
|
3023
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3024
|
+
additionalSigners: additionalSigners
|
3025
|
+
}];
|
3026
|
+
case 6:
|
3027
|
+
_e.trys.push([6, 21, , 22]);
|
3028
|
+
if (!(userInputTokenSymbol == 'SOL')) return [3, 9];
|
3029
|
+
console.log("userInputTokenSymbol === sol", userInputTokenSymbol);
|
3030
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
3031
|
+
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
3032
|
+
case 7:
|
3033
|
+
accCreationLamports = (_e.sent());
|
3034
|
+
console.log("accCreationLamports:", accCreationLamports);
|
3035
|
+
lamports = amountIn.add(new anchor_1.BN(accCreationLamports));
|
3036
|
+
_b = anchor_1.BN.bind;
|
3037
|
+
return [4, this.provider.connection.getBalance(publicKey)];
|
3038
|
+
case 8:
|
3039
|
+
unWrappedSolBalance = new (_b.apply(anchor_1.BN, [void 0, _e.sent()]))();
|
3040
|
+
if (unWrappedSolBalance.lt(amountIn)) {
|
3041
|
+
throw "Insufficient SOL Funds";
|
3042
|
+
}
|
3043
|
+
preInstructions = [
|
3044
|
+
web3_js_1.SystemProgram.createAccount({
|
3045
|
+
fromPubkey: publicKey,
|
3046
|
+
newAccountPubkey: wrappedSolAccount.publicKey,
|
3047
|
+
lamports: lamports.toNumber(),
|
3048
|
+
space: 165,
|
3049
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
3050
|
+
}),
|
3051
|
+
(0, spl_token_1.createInitializeAccount3Instruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, publicKey),
|
3052
|
+
];
|
3053
|
+
postInstructions = [
|
3054
|
+
(0, spl_token_1.createCloseAccountInstruction)(wrappedSolAccount.publicKey, publicKey, publicKey),
|
3055
|
+
];
|
3056
|
+
additionalSigners.push(wrappedSolAccount);
|
3057
|
+
return [3, 13];
|
3058
|
+
case 9: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey, publicKey)];
|
3059
|
+
case 10:
|
3060
|
+
userInputTokenAccount = _e.sent();
|
3061
|
+
return [4, (0, utils_1.checkIfAccountExists)(userInputTokenAccount, this.provider.connection)];
|
3062
|
+
case 11:
|
3063
|
+
if (!(_e.sent())) {
|
3064
|
+
throw "Insufficient Funds , Token Account doesn't exist";
|
3065
|
+
}
|
3066
|
+
if (!!skipBalanceChecks) return [3, 13];
|
3067
|
+
_c = anchor_1.BN.bind;
|
3068
|
+
return [4, this.provider.connection.getTokenAccountBalance(userInputTokenAccount)];
|
3069
|
+
case 12:
|
3070
|
+
tokenAccountBalance = new (_c.apply(anchor_1.BN, [void 0, (_e.sent()).value.amount]))();
|
3071
|
+
if (tokenAccountBalance.lt(amountIn)) {
|
3072
|
+
throw "Insufficient Funds need more ".concat(amountIn.sub(tokenAccountBalance), " tokens");
|
3073
|
+
}
|
3074
|
+
_e.label = 13;
|
3075
|
+
case 13:
|
3076
|
+
if (!(collateralTokenSymbol == 'SOL')) return [3, 15];
|
3077
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
3078
|
+
return [4, (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(this.provider.connection)];
|
3079
|
+
case 14:
|
3080
|
+
lamports = (_e.sent());
|
3081
|
+
preInstructions = [
|
3082
|
+
web3_js_1.SystemProgram.createAccount({
|
3083
|
+
fromPubkey: publicKey,
|
3084
|
+
newAccountPubkey: wrappedSolAccount.publicKey,
|
3085
|
+
lamports: lamports,
|
3086
|
+
space: 165,
|
3087
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
3088
|
+
}),
|
3089
|
+
(0, spl_token_1.createInitializeAccount3Instruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, publicKey),
|
3090
|
+
];
|
3091
|
+
postInstructions = [
|
3092
|
+
(0, spl_token_1.createCloseAccountInstruction)(wrappedSolAccount.publicKey, publicKey, publicKey),
|
3093
|
+
];
|
3094
|
+
additionalSigners.push(wrappedSolAccount);
|
3095
|
+
return [3, 19];
|
3096
|
+
case 15: return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey, publicKey)];
|
3097
|
+
case 16:
|
3098
|
+
userOutputTokenAccount = _e.sent();
|
3099
|
+
_d = createUserATA;
|
3100
|
+
if (!_d) return [3, 18];
|
3101
|
+
return [4, (0, utils_1.checkIfAccountExists)(userOutputTokenAccount, this.provider.connection)];
|
3102
|
+
case 17:
|
3103
|
+
_d = !(_e.sent());
|
3104
|
+
_e.label = 18;
|
3105
|
+
case 18:
|
3106
|
+
if (_d) {
|
3107
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userOutputTokenAccount, publicKey, poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey));
|
3108
|
+
}
|
3109
|
+
_e.label = 19;
|
3110
|
+
case 19:
|
3111
|
+
params = {
|
3112
|
+
amountIn: amountIn,
|
3113
|
+
minCollateralAmountOut: minCollateralAmountOut,
|
3114
|
+
priceWithSlippage: priceWithSlippage,
|
3115
|
+
sizeAmount: sizeAmount,
|
3116
|
+
privilege: privilege
|
3117
|
+
};
|
3118
|
+
return [4, this.program.methods
|
3119
|
+
.swapAndOpen(params)
|
3120
|
+
.accounts({
|
3121
|
+
owner: publicKey,
|
3122
|
+
feePayer: publicKey,
|
3123
|
+
fundingAccount: userInputTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userInputTokenAccount,
|
3124
|
+
transferAuthority: poolConfig.transferAuthority,
|
3125
|
+
perpetuals: poolConfig.perpetuals,
|
3126
|
+
pool: poolConfig.poolAddress,
|
3127
|
+
receivingCustody: userInputCustodyConfig.custodyAccount,
|
3128
|
+
receivingCustodyOracleAccount: this.useExtOracleAccount ? userInputCustodyConfig.extOracleAccount : userInputCustodyConfig.intOracleAccount,
|
3129
|
+
receivingCustodyTokenAccount: userInputCustodyConfig.tokenAccount,
|
3130
|
+
position: positionAccount,
|
3131
|
+
market: marketAccount,
|
3132
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
3133
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
3134
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
3135
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
3136
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
3137
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
3138
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3139
|
+
eventAuthority: this.eventAuthority.publicKey,
|
3140
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
3141
|
+
})
|
3142
|
+
.remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
|
3143
|
+
.instruction()];
|
3144
|
+
case 20:
|
3145
|
+
inx = _e.sent();
|
3146
|
+
instructions.push(inx);
|
3147
|
+
if (collateralTokenSymbol == 'SOL' && unWrapSol) {
|
3148
|
+
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userOutputTokenAccount, publicKey, publicKey);
|
3149
|
+
instructions.push(closeWsolATAIns);
|
3150
|
+
}
|
3151
|
+
return [3, 22];
|
3152
|
+
case 21:
|
3153
|
+
err_2 = _e.sent();
|
3154
|
+
console.error("perpClient SwapAndOpen error:: ", err_2);
|
3155
|
+
throw err_2;
|
3156
|
+
case 22: return [2, {
|
3157
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3158
|
+
additionalSigners: additionalSigners
|
3159
|
+
}];
|
3160
|
+
}
|
3161
|
+
});
|
3162
|
+
});
|
3163
|
+
};
|
3164
|
+
this.closeAndSwap = function (targetTokenSymbol, collateralTokenSymbol, userOutputTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, createUserATA, unWrapSol, ephemeralSignerPubkey) {
|
3165
|
+
if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
|
3166
|
+
if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
|
3167
|
+
if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
|
3168
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
3169
|
+
if (unWrapSol === void 0) { unWrapSol = false; }
|
3170
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3171
|
+
return __awaiter(_this, void 0, void 0, function () {
|
3172
|
+
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, userReceivingTokenAccountCollateral, lamports, _a, lamports, _b, inx, closeWsolATAIns, closeWsolATAIns, err_3;
|
3173
|
+
return __generator(this, function (_c) {
|
3174
|
+
switch (_c.label) {
|
3175
|
+
case 0:
|
3176
|
+
publicKey = this.provider.wallet.publicKey;
|
3177
|
+
userOutputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey); });
|
3178
|
+
if (!userOutputCustodyConfig) {
|
3179
|
+
throw "userOutputCustodyConfig not found";
|
3180
|
+
}
|
3181
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey); });
|
3182
|
+
if (!collateralCustodyConfig) {
|
3183
|
+
throw "collateralCustodyConfig not found";
|
3184
|
+
}
|
3185
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetTokenSymbol).mintKey); });
|
3186
|
+
if (!targetCustodyConfig) {
|
3187
|
+
throw "targetCustodyConfig not found";
|
3188
|
+
}
|
3189
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
3190
|
+
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
3191
|
+
preInstructions = [];
|
3192
|
+
instructions = [];
|
3193
|
+
postInstructions = [];
|
3194
|
+
additionalSigners = [];
|
3195
|
+
_c.label = 1;
|
3196
|
+
case 1:
|
3197
|
+
_c.trys.push([1, 11, , 12]);
|
3198
|
+
if (!(collateralTokenSymbol == 'SOL')) return [3, 2];
|
3199
|
+
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
3200
|
+
if (!ephemeralSignerPubkey) {
|
3201
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
3202
|
+
additionalSigners.push(wrappedSolAccount);
|
3203
|
+
}
|
3204
|
+
preInstructions = [
|
3205
|
+
web3_js_1.SystemProgram.createAccount({
|
3206
|
+
fromPubkey: publicKey,
|
3207
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
3208
|
+
lamports: lamports,
|
3209
|
+
space: 165,
|
3210
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
3211
|
+
}),
|
3212
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
3213
|
+
];
|
3214
|
+
postInstructions = [
|
3215
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
3216
|
+
];
|
3217
|
+
return [3, 5];
|
3218
|
+
case 2:
|
3219
|
+
userReceivingTokenAccountCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey, publicKey, true);
|
3220
|
+
_a = createUserATA;
|
3221
|
+
if (!_a) return [3, 4];
|
3222
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
3223
|
+
case 3:
|
3224
|
+
_a = !(_c.sent());
|
3225
|
+
_c.label = 4;
|
3226
|
+
case 4:
|
3227
|
+
if (_a) {
|
3228
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccountCollateral, publicKey, poolConfig.getTokenFromSymbol(collateralTokenSymbol).mintKey));
|
3229
|
+
}
|
3230
|
+
_c.label = 5;
|
3231
|
+
case 5:
|
3232
|
+
if (!(userOutputTokenSymbol == 'SOL')) return [3, 6];
|
3233
|
+
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
3234
|
+
if (!ephemeralSignerPubkey) {
|
3235
|
+
wrappedSolAccount = new web3_js_1.Keypair();
|
3236
|
+
additionalSigners.push(wrappedSolAccount);
|
3237
|
+
}
|
3238
|
+
preInstructions = [
|
3239
|
+
web3_js_1.SystemProgram.createAccount({
|
3240
|
+
fromPubkey: publicKey,
|
3241
|
+
newAccountPubkey: (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey),
|
3242
|
+
lamports: lamports,
|
3243
|
+
space: 165,
|
3244
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
3245
|
+
}),
|
3246
|
+
(0, spl_token_1.createInitializeAccount3Instruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), spl_token_1.NATIVE_MINT, publicKey),
|
3247
|
+
];
|
3248
|
+
postInstructions = [
|
3249
|
+
(0, spl_token_1.createCloseAccountInstruction)((ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey), publicKey, publicKey),
|
3250
|
+
];
|
3251
|
+
return [3, 9];
|
3252
|
+
case 6:
|
3253
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey, publicKey, true);
|
3254
|
+
_b = createUserATA;
|
3255
|
+
if (!_b) return [3, 8];
|
3256
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
3257
|
+
case 7:
|
3258
|
+
_b = !(_c.sent());
|
3259
|
+
_c.label = 8;
|
3260
|
+
case 8:
|
3261
|
+
if (_b) {
|
3262
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey));
|
3263
|
+
}
|
3264
|
+
_c.label = 9;
|
3265
|
+
case 9: return [4, this.program.methods
|
3266
|
+
.closeAndSwap({
|
3267
|
+
priceWithSlippage: priceWithSlippage,
|
3268
|
+
minSwapAmountOut: minSwapAmountOut,
|
3269
|
+
privilege: privilege
|
3270
|
+
})
|
3271
|
+
.accounts({
|
3272
|
+
owner: publicKey,
|
3273
|
+
feePayer: publicKey,
|
3274
|
+
receivingAccount: userReceivingTokenAccount,
|
3275
|
+
collateralAccount: userReceivingTokenAccountCollateral,
|
3276
|
+
transferAuthority: poolConfig.transferAuthority,
|
3277
|
+
perpetuals: poolConfig.perpetuals,
|
3278
|
+
pool: poolConfig.poolAddress,
|
3279
|
+
position: positionAccount,
|
3280
|
+
market: marketAccount,
|
3281
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
3282
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
3283
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
3284
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
3285
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
3286
|
+
dispensingCustody: userOutputCustodyConfig.custodyAccount,
|
3287
|
+
dispensingOracleAccount: this.useExtOracleAccount ? userOutputCustodyConfig.extOracleAccount : userOutputCustodyConfig.intOracleAccount,
|
3288
|
+
dispensingCustodyTokenAccount: userOutputCustodyConfig.tokenAccount,
|
3289
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
3290
|
+
eventAuthority: this.eventAuthority.publicKey,
|
3291
|
+
program: this.programId,
|
3292
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
3293
|
+
})
|
3294
|
+
.remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
|
3295
|
+
.instruction()];
|
3296
|
+
case 10:
|
3297
|
+
inx = _c.sent();
|
3298
|
+
instructions.push(inx);
|
3299
|
+
if (collateralTokenSymbol == 'SOL' && unWrapSol) {
|
3300
|
+
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccountCollateral, publicKey, publicKey);
|
3301
|
+
instructions.push(closeWsolATAIns);
|
3302
|
+
}
|
3303
|
+
if (userOutputTokenSymbol == 'SOL' && unWrapSol) {
|
3304
|
+
closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, publicKey, publicKey);
|
3305
|
+
instructions.push(closeWsolATAIns);
|
3306
|
+
}
|
3307
|
+
return [3, 12];
|
3308
|
+
case 11:
|
3309
|
+
err_3 = _c.sent();
|
3310
|
+
console.error("perpClient CloseAndSwap error:: ", err_3);
|
3311
|
+
throw err_3;
|
3312
|
+
case 12: return [2, {
|
3313
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3314
|
+
additionalSigners: additionalSigners
|
3315
|
+
}];
|
3316
|
+
}
|
3317
|
+
});
|
3318
|
+
});
|
3319
|
+
};
|
2957
3320
|
this.swap = function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
|
2958
3321
|
if (useFeesPool === void 0) { useFeesPool = false; }
|
2959
3322
|
if (createUserATA === void 0) { createUserATA = true; }
|
@@ -2961,7 +3324,7 @@ var PerpetualsClient = (function () {
|
|
2961
3324
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2962
3325
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2963
3326
|
return __awaiter(_this, void 0, void 0, function () {
|
2964
|
-
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, _i, _e, custody, params, inx, closeWsolATAIns,
|
3327
|
+
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, _i, _e, custody, params, inx, closeWsolATAIns, err_4;
|
2965
3328
|
return __generator(this, function (_f) {
|
2966
3329
|
switch (_f.label) {
|
2967
3330
|
case 0:
|
@@ -3158,9 +3521,9 @@ var PerpetualsClient = (function () {
|
|
3158
3521
|
}
|
3159
3522
|
return [3, 20];
|
3160
3523
|
case 19:
|
3161
|
-
|
3162
|
-
console.error("perpClient Swap error:: ",
|
3163
|
-
throw
|
3524
|
+
err_4 = _f.sent();
|
3525
|
+
console.error("perpClient Swap error:: ", err_4);
|
3526
|
+
throw err_4;
|
3164
3527
|
case 20: return [2, {
|
3165
3528
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3166
3529
|
additionalSigners: additionalSigners
|
@@ -3170,7 +3533,7 @@ var PerpetualsClient = (function () {
|
|
3170
3533
|
});
|
3171
3534
|
};
|
3172
3535
|
this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
3173
|
-
var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx,
|
3536
|
+
var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_5;
|
3174
3537
|
return __generator(this, function (_b) {
|
3175
3538
|
switch (_b.label) {
|
3176
3539
|
case 0:
|
@@ -3230,9 +3593,9 @@ var PerpetualsClient = (function () {
|
|
3230
3593
|
instructions.push(inx);
|
3231
3594
|
return [3, 4];
|
3232
3595
|
case 3:
|
3233
|
-
|
3234
|
-
console.error("perpClient Swap error:: ",
|
3235
|
-
throw
|
3596
|
+
err_5 = _b.sent();
|
3597
|
+
console.error("perpClient Swap error:: ", err_5);
|
3598
|
+
throw err_5;
|
3236
3599
|
case 4: return [2, {
|
3237
3600
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3238
3601
|
additionalSigners: additionalSigners
|
@@ -3820,7 +4183,7 @@ var PerpetualsClient = (function () {
|
|
3820
4183
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
3821
4184
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
3822
4185
|
return __awaiter(_this, void 0, void 0, function () {
|
3823
|
-
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, tokenAccountBalance, _e, instruction,
|
4186
|
+
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, tokenAccountBalance, _e, instruction, err_6;
|
3824
4187
|
return __generator(this, function (_f) {
|
3825
4188
|
switch (_f.label) {
|
3826
4189
|
case 0:
|
@@ -3941,9 +4304,9 @@ var PerpetualsClient = (function () {
|
|
3941
4304
|
instructions.push(instruction);
|
3942
4305
|
return [3, 11];
|
3943
4306
|
case 10:
|
3944
|
-
|
3945
|
-
console.error("perpClient addLiquidity error:: ",
|
3946
|
-
throw
|
4307
|
+
err_6 = _f.sent();
|
4308
|
+
console.error("perpClient addLiquidity error:: ", err_6);
|
4309
|
+
throw err_6;
|
3947
4310
|
case 11: return [2, {
|
3948
4311
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
3949
4312
|
additionalSigners: additionalSigners
|
@@ -4088,7 +4451,7 @@ var PerpetualsClient = (function () {
|
|
4088
4451
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
4089
4452
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
4090
4453
|
return __awaiter(_this, void 0, void 0, function () {
|
4091
|
-
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns,
|
4454
|
+
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, _d, removeLiquidityTx, closeInx, closeWsolATAIns, err_7;
|
4092
4455
|
return __generator(this, function (_e) {
|
4093
4456
|
switch (_e.label) {
|
4094
4457
|
case 0:
|
@@ -4198,9 +4561,9 @@ var PerpetualsClient = (function () {
|
|
4198
4561
|
}
|
4199
4562
|
return [3, 8];
|
4200
4563
|
case 7:
|
4201
|
-
|
4202
|
-
console.log("perpClient removeLiquidity error:: ",
|
4203
|
-
throw
|
4564
|
+
err_7 = _e.sent();
|
4565
|
+
console.log("perpClient removeLiquidity error:: ", err_7);
|
4566
|
+
throw err_7;
|
4204
4567
|
case 8: return [2, {
|
4205
4568
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4206
4569
|
additionalSigners: additionalSigners
|
@@ -4210,7 +4573,7 @@ var PerpetualsClient = (function () {
|
|
4210
4573
|
});
|
4211
4574
|
};
|
4212
4575
|
this.addReferral = function (nftTradingAccount, nftReferralAccount) { return __awaiter(_this, void 0, void 0, function () {
|
4213
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction,
|
4576
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, addReferralInstruction, err_8;
|
4214
4577
|
return __generator(this, function (_a) {
|
4215
4578
|
switch (_a.label) {
|
4216
4579
|
case 0:
|
@@ -4237,9 +4600,9 @@ var PerpetualsClient = (function () {
|
|
4237
4600
|
instructions.push(addReferralInstruction);
|
4238
4601
|
return [3, 4];
|
4239
4602
|
case 3:
|
4240
|
-
|
4241
|
-
console.log("perpClient addReferral error:: ",
|
4242
|
-
throw
|
4603
|
+
err_8 = _a.sent();
|
4604
|
+
console.log("perpClient addReferral error:: ", err_8);
|
4605
|
+
throw err_8;
|
4243
4606
|
case 4: return [2, {
|
4244
4607
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4245
4608
|
additionalSigners: additionalSigners
|
@@ -4248,7 +4611,7 @@ var PerpetualsClient = (function () {
|
|
4248
4611
|
});
|
4249
4612
|
}); };
|
4250
4613
|
this.createNftTradingAccount = function (nftMint, owner, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4251
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, nftTokenAccount, createNftTradingAccountInstruction,
|
4614
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, nftTokenAccount, createNftTradingAccountInstruction, err_9;
|
4252
4615
|
return __generator(this, function (_a) {
|
4253
4616
|
switch (_a.label) {
|
4254
4617
|
case 0:
|
@@ -4286,9 +4649,9 @@ var PerpetualsClient = (function () {
|
|
4286
4649
|
instructions.push(createNftTradingAccountInstruction);
|
4287
4650
|
return [3, 4];
|
4288
4651
|
case 3:
|
4289
|
-
|
4290
|
-
console.log("perpClient createNftAccount error:: ",
|
4291
|
-
throw
|
4652
|
+
err_9 = _a.sent();
|
4653
|
+
console.log("perpClient createNftAccount error:: ", err_9);
|
4654
|
+
throw err_9;
|
4292
4655
|
case 4: return [2, {
|
4293
4656
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4294
4657
|
additionalSigners: additionalSigners
|
@@ -4297,7 +4660,7 @@ var PerpetualsClient = (function () {
|
|
4297
4660
|
});
|
4298
4661
|
}); };
|
4299
4662
|
this.updateNftAccount = function (nftMint, updateReferer, updateBooster, flpStakeAccounts) { return __awaiter(_this, void 0, void 0, function () {
|
4300
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction,
|
4663
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction, err_10;
|
4301
4664
|
return __generator(this, function (_a) {
|
4302
4665
|
switch (_a.label) {
|
4303
4666
|
case 0:
|
@@ -4347,9 +4710,9 @@ var PerpetualsClient = (function () {
|
|
4347
4710
|
instructions.push(updateNftTradingAccountInstruction);
|
4348
4711
|
return [3, 5];
|
4349
4712
|
case 4:
|
4350
|
-
|
4351
|
-
console.log("perpClient updateNftAccount error:: ",
|
4352
|
-
throw
|
4713
|
+
err_10 = _a.sent();
|
4714
|
+
console.log("perpClient updateNftAccount error:: ", err_10);
|
4715
|
+
throw err_10;
|
4353
4716
|
case 5: return [2, {
|
4354
4717
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4355
4718
|
additionalSigners: additionalSigners
|
@@ -4358,7 +4721,7 @@ var PerpetualsClient = (function () {
|
|
4358
4721
|
});
|
4359
4722
|
}); };
|
4360
4723
|
this.levelUp = function (poolConfig, nftMint, authorizationRulesAccount) { return __awaiter(_this, void 0, void 0, function () {
|
4361
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction,
|
4724
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction, err_11;
|
4362
4725
|
return __generator(this, function (_a) {
|
4363
4726
|
switch (_a.label) {
|
4364
4727
|
case 0:
|
@@ -4397,9 +4760,9 @@ var PerpetualsClient = (function () {
|
|
4397
4760
|
instructions.push(levelUpInstruction);
|
4398
4761
|
return [3, 4];
|
4399
4762
|
case 3:
|
4400
|
-
|
4401
|
-
console.log("perpClient levelUp error:: ",
|
4402
|
-
throw
|
4763
|
+
err_11 = _a.sent();
|
4764
|
+
console.log("perpClient levelUp error:: ", err_11);
|
4765
|
+
throw err_11;
|
4403
4766
|
case 4: return [2, {
|
4404
4767
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4405
4768
|
additionalSigners: additionalSigners
|
@@ -4408,7 +4771,7 @@ var PerpetualsClient = (function () {
|
|
4408
4771
|
});
|
4409
4772
|
}); };
|
4410
4773
|
this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4411
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction,
|
4774
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_12;
|
4412
4775
|
return __generator(this, function (_a) {
|
4413
4776
|
switch (_a.label) {
|
4414
4777
|
case 0:
|
@@ -4446,9 +4809,9 @@ var PerpetualsClient = (function () {
|
|
4446
4809
|
instructions.push(initStakeInstruction);
|
4447
4810
|
return [3, 4];
|
4448
4811
|
case 3:
|
4449
|
-
|
4450
|
-
console.log("perpClient InitStaking error:: ",
|
4451
|
-
throw
|
4812
|
+
err_12 = _a.sent();
|
4813
|
+
console.log("perpClient InitStaking error:: ", err_12);
|
4814
|
+
throw err_12;
|
4452
4815
|
case 4: return [2, {
|
4453
4816
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4454
4817
|
additionalSigners: additionalSigners
|
@@ -4457,7 +4820,7 @@ var PerpetualsClient = (function () {
|
|
4457
4820
|
});
|
4458
4821
|
}); };
|
4459
4822
|
this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4460
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction,
|
4823
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_13;
|
4461
4824
|
return __generator(this, function (_a) {
|
4462
4825
|
switch (_a.label) {
|
4463
4826
|
case 0:
|
@@ -4502,9 +4865,9 @@ var PerpetualsClient = (function () {
|
|
4502
4865
|
instructions.push(initCompoundingInstruction);
|
4503
4866
|
return [3, 4];
|
4504
4867
|
case 3:
|
4505
|
-
|
4506
|
-
console.log("perpClient initCompounding error:: ",
|
4507
|
-
throw
|
4868
|
+
err_13 = _a.sent();
|
4869
|
+
console.log("perpClient initCompounding error:: ", err_13);
|
4870
|
+
throw err_13;
|
4508
4871
|
case 4: return [2, {
|
4509
4872
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4510
4873
|
additionalSigners: additionalSigners
|
@@ -4513,7 +4876,7 @@ var PerpetualsClient = (function () {
|
|
4513
4876
|
});
|
4514
4877
|
}); };
|
4515
4878
|
this.depositStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4516
|
-
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction,
|
4879
|
+
var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_14;
|
4517
4880
|
return __generator(this, function (_a) {
|
4518
4881
|
switch (_a.label) {
|
4519
4882
|
case 0:
|
@@ -4554,9 +4917,9 @@ var PerpetualsClient = (function () {
|
|
4554
4917
|
instructions.push(depositStakeInstruction);
|
4555
4918
|
return [3, 5];
|
4556
4919
|
case 4:
|
4557
|
-
|
4558
|
-
console.log("perpClient depositStaking error:: ",
|
4559
|
-
throw
|
4920
|
+
err_14 = _a.sent();
|
4921
|
+
console.log("perpClient depositStaking error:: ", err_14);
|
4922
|
+
throw err_14;
|
4560
4923
|
case 5: return [2, {
|
4561
4924
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4562
4925
|
additionalSigners: additionalSigners
|
@@ -4599,7 +4962,7 @@ var PerpetualsClient = (function () {
|
|
4599
4962
|
});
|
4600
4963
|
}); };
|
4601
4964
|
this.refreshStake = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
4602
|
-
var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction,
|
4965
|
+
var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_15;
|
4603
4966
|
return __generator(this, function (_c) {
|
4604
4967
|
switch (_c.label) {
|
4605
4968
|
case 0:
|
@@ -4646,15 +5009,15 @@ var PerpetualsClient = (function () {
|
|
4646
5009
|
refreshStakeInstruction = _c.sent();
|
4647
5010
|
return [2, refreshStakeInstruction];
|
4648
5011
|
case 2:
|
4649
|
-
|
4650
|
-
console.log("perpClient refreshStaking error:: ",
|
4651
|
-
throw
|
5012
|
+
err_15 = _c.sent();
|
5013
|
+
console.log("perpClient refreshStaking error:: ", err_15);
|
5014
|
+
throw err_15;
|
4652
5015
|
case 3: return [2];
|
4653
5016
|
}
|
4654
5017
|
});
|
4655
5018
|
}); };
|
4656
5019
|
this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4657
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, unstakeInstantInstruction,
|
5020
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, unstakeInstantInstruction, err_16;
|
4658
5021
|
return __generator(this, function (_a) {
|
4659
5022
|
switch (_a.label) {
|
4660
5023
|
case 0:
|
@@ -4688,9 +5051,9 @@ var PerpetualsClient = (function () {
|
|
4688
5051
|
instructions.push(unstakeInstantInstruction);
|
4689
5052
|
return [3, 4];
|
4690
5053
|
case 3:
|
4691
|
-
|
4692
|
-
console.log("perpClient unstakeInstant error:: ",
|
4693
|
-
throw
|
5054
|
+
err_16 = _a.sent();
|
5055
|
+
console.log("perpClient unstakeInstant error:: ", err_16);
|
5056
|
+
throw err_16;
|
4694
5057
|
case 4: return [2, {
|
4695
5058
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4696
5059
|
additionalSigners: additionalSigners
|
@@ -4699,7 +5062,7 @@ var PerpetualsClient = (function () {
|
|
4699
5062
|
});
|
4700
5063
|
}); };
|
4701
5064
|
this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
|
4702
|
-
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction,
|
5065
|
+
var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_17;
|
4703
5066
|
return __generator(this, function (_c) {
|
4704
5067
|
switch (_c.label) {
|
4705
5068
|
case 0:
|
@@ -4743,15 +5106,15 @@ var PerpetualsClient = (function () {
|
|
4743
5106
|
refreshStakeInstruction = _c.sent();
|
4744
5107
|
return [2, refreshStakeInstruction];
|
4745
5108
|
case 2:
|
4746
|
-
|
4747
|
-
console.log("perpClient refreshStaking error:: ",
|
4748
|
-
throw
|
5109
|
+
err_17 = _c.sent();
|
5110
|
+
console.log("perpClient refreshStaking error:: ", err_17);
|
5111
|
+
throw err_17;
|
4749
5112
|
case 3: return [2];
|
4750
5113
|
}
|
4751
5114
|
});
|
4752
5115
|
}); };
|
4753
5116
|
this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4754
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction,
|
5117
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_18;
|
4755
5118
|
return __generator(this, function (_a) {
|
4756
5119
|
switch (_a.label) {
|
4757
5120
|
case 0:
|
@@ -4785,9 +5148,9 @@ var PerpetualsClient = (function () {
|
|
4785
5148
|
instructions.push(unstakeRequestInstruction);
|
4786
5149
|
return [3, 4];
|
4787
5150
|
case 3:
|
4788
|
-
|
4789
|
-
console.log("perpClient unstakeRequest error:: ",
|
4790
|
-
throw
|
5151
|
+
err_18 = _a.sent();
|
5152
|
+
console.log("perpClient unstakeRequest error:: ", err_18);
|
5153
|
+
throw err_18;
|
4791
5154
|
case 4: return [2, {
|
4792
5155
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4793
5156
|
additionalSigners: additionalSigners
|
@@ -4800,7 +5163,7 @@ var PerpetualsClient = (function () {
|
|
4800
5163
|
if (deactivated === void 0) { deactivated = true; }
|
4801
5164
|
if (createUserLPTA === void 0) { createUserLPTA = true; }
|
4802
5165
|
return __awaiter(_this, void 0, void 0, function () {
|
4803
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction,
|
5166
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_19;
|
4804
5167
|
return __generator(this, function (_b) {
|
4805
5168
|
switch (_b.label) {
|
4806
5169
|
case 0:
|
@@ -4851,9 +5214,9 @@ var PerpetualsClient = (function () {
|
|
4851
5214
|
instructions.push(withdrawStakeInstruction);
|
4852
5215
|
return [3, 6];
|
4853
5216
|
case 5:
|
4854
|
-
|
4855
|
-
console.log("perpClient withdrawStake error:: ",
|
4856
|
-
throw
|
5217
|
+
err_19 = _b.sent();
|
5218
|
+
console.log("perpClient withdrawStake error:: ", err_19);
|
5219
|
+
throw err_19;
|
4857
5220
|
case 6: return [2, {
|
4858
5221
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4859
5222
|
additionalSigners: additionalSigners
|
@@ -4865,7 +5228,7 @@ var PerpetualsClient = (function () {
|
|
4865
5228
|
this.collectStakeFees = function (rewardSymbol, poolConfig, nftTradingAccount, nftBoostingAccount, createUserATA) {
|
4866
5229
|
if (createUserATA === void 0) { createUserATA = true; }
|
4867
5230
|
return __awaiter(_this, void 0, void 0, function () {
|
4868
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, boostingAccount, withdrawStakeInstruction,
|
5231
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, boostingAccount, withdrawStakeInstruction, err_20;
|
4869
5232
|
return __generator(this, function (_b) {
|
4870
5233
|
switch (_b.label) {
|
4871
5234
|
case 0:
|
@@ -4932,9 +5295,9 @@ var PerpetualsClient = (function () {
|
|
4932
5295
|
instructions.push(withdrawStakeInstruction);
|
4933
5296
|
return [3, 6];
|
4934
5297
|
case 5:
|
4935
|
-
|
4936
|
-
console.log("perpClient withdrawStake error:: ",
|
4937
|
-
throw
|
5298
|
+
err_20 = _b.sent();
|
5299
|
+
console.log("perpClient withdrawStake error:: ", err_20);
|
5300
|
+
throw err_20;
|
4938
5301
|
case 6: return [2, {
|
4939
5302
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4940
5303
|
additionalSigners: additionalSigners
|
@@ -4944,7 +5307,7 @@ var PerpetualsClient = (function () {
|
|
4944
5307
|
});
|
4945
5308
|
};
|
4946
5309
|
this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4947
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault,
|
5310
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_21;
|
4948
5311
|
return __generator(this, function (_a) {
|
4949
5312
|
switch (_a.label) {
|
4950
5313
|
case 0:
|
@@ -4981,9 +5344,9 @@ var PerpetualsClient = (function () {
|
|
4981
5344
|
instructions.push(initRewardVault);
|
4982
5345
|
return [3, 4];
|
4983
5346
|
case 3:
|
4984
|
-
|
4985
|
-
console.log("perpClient InitRewardVault error:: ",
|
4986
|
-
throw
|
5347
|
+
err_21 = _a.sent();
|
5348
|
+
console.log("perpClient InitRewardVault error:: ", err_21);
|
5349
|
+
throw err_21;
|
4987
5350
|
case 4: return [2, {
|
4988
5351
|
instructions: __spreadArray([], instructions, true),
|
4989
5352
|
additionalSigners: additionalSigners
|
@@ -4992,7 +5355,7 @@ var PerpetualsClient = (function () {
|
|
4992
5355
|
});
|
4993
5356
|
}); };
|
4994
5357
|
this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4995
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward,
|
5358
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_22;
|
4996
5359
|
return __generator(this, function (_a) {
|
4997
5360
|
switch (_a.label) {
|
4998
5361
|
case 0:
|
@@ -5023,9 +5386,9 @@ var PerpetualsClient = (function () {
|
|
5023
5386
|
instructions.push(distributeReward);
|
5024
5387
|
return [3, 4];
|
5025
5388
|
case 3:
|
5026
|
-
|
5027
|
-
console.log("perpClient distributeReward error:: ",
|
5028
|
-
throw
|
5389
|
+
err_22 = _a.sent();
|
5390
|
+
console.log("perpClient distributeReward error:: ", err_22);
|
5391
|
+
throw err_22;
|
5029
5392
|
case 4: return [2, {
|
5030
5393
|
instructions: __spreadArray([], instructions, true),
|
5031
5394
|
additionalSigners: additionalSigners
|
@@ -5036,7 +5399,7 @@ var PerpetualsClient = (function () {
|
|
5036
5399
|
this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
5037
5400
|
if (createUserATA === void 0) { createUserATA = true; }
|
5038
5401
|
return __awaiter(_this, void 0, void 0, function () {
|
5039
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward,
|
5402
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_23;
|
5040
5403
|
return __generator(this, function (_b) {
|
5041
5404
|
switch (_b.label) {
|
5042
5405
|
case 0:
|
@@ -5086,8 +5449,8 @@ var PerpetualsClient = (function () {
|
|
5086
5449
|
instructions.push(collectNftReward);
|
5087
5450
|
return [3, 6];
|
5088
5451
|
case 5:
|
5089
|
-
|
5090
|
-
throw
|
5452
|
+
err_23 = _b.sent();
|
5453
|
+
throw err_23;
|
5091
5454
|
case 6: return [2, {
|
5092
5455
|
instructions: __spreadArray([], instructions, true),
|
5093
5456
|
additionalSigners: additionalSigners
|
@@ -5099,7 +5462,7 @@ var PerpetualsClient = (function () {
|
|
5099
5462
|
this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
5100
5463
|
if (createUserATA === void 0) { createUserATA = true; }
|
5101
5464
|
return __awaiter(_this, void 0, void 0, function () {
|
5102
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction,
|
5465
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_24;
|
5103
5466
|
return __generator(this, function (_b) {
|
5104
5467
|
switch (_b.label) {
|
5105
5468
|
case 0:
|
@@ -5163,9 +5526,9 @@ var PerpetualsClient = (function () {
|
|
5163
5526
|
instructions.push(withdrawStakeInstruction);
|
5164
5527
|
return [3, 6];
|
5165
5528
|
case 5:
|
5166
|
-
|
5167
|
-
console.log("perpClient withdrawStake error:: ",
|
5168
|
-
throw
|
5529
|
+
err_24 = _b.sent();
|
5530
|
+
console.log("perpClient withdrawStake error:: ", err_24);
|
5531
|
+
throw err_24;
|
5169
5532
|
case 6: return [2, {
|
5170
5533
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5171
5534
|
additionalSigners: additionalSigners
|
@@ -5175,7 +5538,7 @@ var PerpetualsClient = (function () {
|
|
5175
5538
|
});
|
5176
5539
|
};
|
5177
5540
|
this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5178
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice,
|
5541
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_25;
|
5179
5542
|
return __generator(this, function (_a) {
|
5180
5543
|
switch (_a.label) {
|
5181
5544
|
case 0:
|
@@ -5214,9 +5577,9 @@ var PerpetualsClient = (function () {
|
|
5214
5577
|
instructions.push(setTriggerPrice);
|
5215
5578
|
return [3, 4];
|
5216
5579
|
case 3:
|
5217
|
-
|
5218
|
-
console.log("perpClient setTriggerPrice error:: ",
|
5219
|
-
throw
|
5580
|
+
err_25 = _a.sent();
|
5581
|
+
console.log("perpClient setTriggerPrice error:: ", err_25);
|
5582
|
+
throw err_25;
|
5220
5583
|
case 4: return [2, {
|
5221
5584
|
instructions: __spreadArray([], instructions, true),
|
5222
5585
|
additionalSigners: additionalSigners
|
@@ -5229,7 +5592,7 @@ var PerpetualsClient = (function () {
|
|
5229
5592
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
5230
5593
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5231
5594
|
return __awaiter(_this, void 0, void 0, function () {
|
5232
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns,
|
5595
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_26;
|
5233
5596
|
return __generator(this, function (_b) {
|
5234
5597
|
switch (_b.label) {
|
5235
5598
|
case 0:
|
@@ -5290,9 +5653,9 @@ var PerpetualsClient = (function () {
|
|
5290
5653
|
}
|
5291
5654
|
return [3, 7];
|
5292
5655
|
case 6:
|
5293
|
-
|
5294
|
-
console.log("perpClient forceClosePosition error:: ",
|
5295
|
-
throw
|
5656
|
+
err_26 = _b.sent();
|
5657
|
+
console.log("perpClient forceClosePosition error:: ", err_26);
|
5658
|
+
throw err_26;
|
5296
5659
|
case 7: return [2, {
|
5297
5660
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5298
5661
|
additionalSigners: additionalSigners
|
@@ -5305,7 +5668,7 @@ var PerpetualsClient = (function () {
|
|
5305
5668
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
5306
5669
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5307
5670
|
return __awaiter(_this, void 0, void 0, function () {
|
5308
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder,
|
5671
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_27;
|
5309
5672
|
return __generator(this, function (_c) {
|
5310
5673
|
switch (_c.label) {
|
5311
5674
|
case 0:
|
@@ -5409,9 +5772,9 @@ var PerpetualsClient = (function () {
|
|
5409
5772
|
instructions.push(placeLimitOrder);
|
5410
5773
|
return [3, 11];
|
5411
5774
|
case 10:
|
5412
|
-
|
5413
|
-
console.log("perpClient placeLimitOrder error:: ",
|
5414
|
-
throw
|
5775
|
+
err_27 = _c.sent();
|
5776
|
+
console.log("perpClient placeLimitOrder error:: ", err_27);
|
5777
|
+
throw err_27;
|
5415
5778
|
case 11: return [2, {
|
5416
5779
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5417
5780
|
additionalSigners: additionalSigners
|
@@ -5420,11 +5783,11 @@ var PerpetualsClient = (function () {
|
|
5420
5783
|
});
|
5421
5784
|
});
|
5422
5785
|
};
|
5423
|
-
this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
5786
|
+
this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, receiveCustodyId, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
5424
5787
|
if (createUserATA === void 0) { createUserATA = true; }
|
5425
5788
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5426
5789
|
return __awaiter(_this, void 0, void 0, function () {
|
5427
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder,
|
5790
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_28;
|
5428
5791
|
return __generator(this, function (_b) {
|
5429
5792
|
switch (_b.label) {
|
5430
5793
|
case 0:
|
@@ -5440,7 +5803,7 @@ var PerpetualsClient = (function () {
|
|
5440
5803
|
_b.label = 1;
|
5441
5804
|
case 1:
|
5442
5805
|
_b.trys.push([1, 7, , 8]);
|
5443
|
-
if (!(
|
5806
|
+
if (!(reserveSymbol == 'SOL')) return [3, 2];
|
5444
5807
|
lamports = (this.minimumBalanceForRentExemptAccountLamports);
|
5445
5808
|
if (!ephemeralSignerPubkey) {
|
5446
5809
|
wrappedSolAccount = new web3_js_1.Keypair();
|
@@ -5461,7 +5824,7 @@ var PerpetualsClient = (function () {
|
|
5461
5824
|
];
|
5462
5825
|
return [3, 5];
|
5463
5826
|
case 2:
|
5464
|
-
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(
|
5827
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey, publicKey, true);
|
5465
5828
|
_a = createUserATA;
|
5466
5829
|
if (!_a) return [3, 4];
|
5467
5830
|
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
@@ -5470,7 +5833,7 @@ var PerpetualsClient = (function () {
|
|
5470
5833
|
_b.label = 4;
|
5471
5834
|
case 4:
|
5472
5835
|
if (_a) {
|
5473
|
-
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(
|
5836
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(reserveSymbol).mintKey));
|
5474
5837
|
}
|
5475
5838
|
_b.label = 5;
|
5476
5839
|
case 5:
|
@@ -5482,7 +5845,8 @@ var PerpetualsClient = (function () {
|
|
5482
5845
|
limitPrice: limitPrice,
|
5483
5846
|
sizeAmount: sizeAmount,
|
5484
5847
|
stopLossPrice: stopLossPrice,
|
5485
|
-
takeProfitPrice: takeProfitPrice
|
5848
|
+
takeProfitPrice: takeProfitPrice,
|
5849
|
+
receiveCustodyId: receiveCustodyId
|
5486
5850
|
})
|
5487
5851
|
.accounts({
|
5488
5852
|
owner: publicKey,
|
@@ -5498,7 +5862,7 @@ var PerpetualsClient = (function () {
|
|
5498
5862
|
reserveCustody: reserveCustodyConfig.custodyAccount,
|
5499
5863
|
reserveOracleAccount: this.useExtOracleAccount ? reserveCustodyConfig.extOracleAccount : reserveCustodyConfig.intOracleAccount,
|
5500
5864
|
reserveCustodyTokenAccount: reserveCustodyConfig.tokenAccount,
|
5501
|
-
receivingAccount:
|
5865
|
+
receivingAccount: reserveSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
5502
5866
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5503
5867
|
eventAuthority: this.eventAuthority.publicKey,
|
5504
5868
|
program: this.programId,
|
@@ -5510,9 +5874,9 @@ var PerpetualsClient = (function () {
|
|
5510
5874
|
instructions.push(editLimitOrder);
|
5511
5875
|
return [3, 8];
|
5512
5876
|
case 7:
|
5513
|
-
|
5514
|
-
console.log("perpClient editLimitOrder error:: ",
|
5515
|
-
throw
|
5877
|
+
err_28 = _b.sent();
|
5878
|
+
console.log("perpClient editLimitOrder error:: ", err_28);
|
5879
|
+
throw err_28;
|
5516
5880
|
case 8: return [2, {
|
5517
5881
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5518
5882
|
additionalSigners: additionalSigners
|
@@ -5526,7 +5890,7 @@ var PerpetualsClient = (function () {
|
|
5526
5890
|
if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
|
5527
5891
|
if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
|
5528
5892
|
return __awaiter(_this, void 0, void 0, function () {
|
5529
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder,
|
5893
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_29;
|
5530
5894
|
return __generator(this, function (_a) {
|
5531
5895
|
switch (_a.label) {
|
5532
5896
|
case 0:
|
@@ -5572,9 +5936,89 @@ var PerpetualsClient = (function () {
|
|
5572
5936
|
instructions.push(executeLimitOrder);
|
5573
5937
|
return [3, 4];
|
5574
5938
|
case 3:
|
5575
|
-
|
5576
|
-
console.log("perpClient executeLimitOrder error:: ",
|
5577
|
-
throw
|
5939
|
+
err_29 = _a.sent();
|
5940
|
+
console.log("perpClient executeLimitOrder error:: ", err_29);
|
5941
|
+
throw err_29;
|
5942
|
+
case 4: return [2, {
|
5943
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5944
|
+
additionalSigners: additionalSigners
|
5945
|
+
}];
|
5946
|
+
}
|
5947
|
+
});
|
5948
|
+
});
|
5949
|
+
};
|
5950
|
+
this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
|
5951
|
+
if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
|
5952
|
+
if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
|
5953
|
+
if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
|
5954
|
+
return __awaiter(_this, void 0, void 0, function () {
|
5955
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody, positionAccount, orderAccount, executeLimitWithSwap, err_30;
|
5956
|
+
return __generator(this, function (_b) {
|
5957
|
+
switch (_b.label) {
|
5958
|
+
case 0:
|
5959
|
+
publicKey = this.provider.wallet.publicKey;
|
5960
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
5961
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
5962
|
+
reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
|
5963
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
5964
|
+
preInstructions = [];
|
5965
|
+
instructions = [];
|
5966
|
+
postInstructions = [];
|
5967
|
+
additionalSigners = [];
|
5968
|
+
custodyAccountMetas = [];
|
5969
|
+
custodyOracleAccountMetas = [];
|
5970
|
+
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
5971
|
+
custody = _a[_i];
|
5972
|
+
custodyAccountMetas.push({
|
5973
|
+
pubkey: custody.custodyAccount,
|
5974
|
+
isSigner: false,
|
5975
|
+
isWritable: false,
|
5976
|
+
});
|
5977
|
+
custodyOracleAccountMetas.push({
|
5978
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
5979
|
+
isSigner: false,
|
5980
|
+
isWritable: false,
|
5981
|
+
});
|
5982
|
+
}
|
5983
|
+
_b.label = 1;
|
5984
|
+
case 1:
|
5985
|
+
_b.trys.push([1, 3, , 4]);
|
5986
|
+
positionAccount = poolConfig.getPositionFromMarketPk(userPubkey, marketAccount);
|
5987
|
+
orderAccount = poolConfig.getOrderFromMarketPk(userPubkey, marketAccount);
|
5988
|
+
return [4, this.program.methods
|
5989
|
+
.executeLimitWithSwap({
|
5990
|
+
orderId: orderId,
|
5991
|
+
privilege: privilege
|
5992
|
+
})
|
5993
|
+
.accounts({
|
5994
|
+
feePayer: publicKey,
|
5995
|
+
perpetuals: poolConfig.perpetuals,
|
5996
|
+
pool: poolConfig.poolAddress,
|
5997
|
+
reserveCustody: reserveCustodyConfig.custodyAccount,
|
5998
|
+
reserveCustodyOracleAccount: this.useExtOracleAccount ? reserveCustodyConfig.extOracleAccount : reserveCustodyConfig.intOracleAccount,
|
5999
|
+
position: positionAccount,
|
6000
|
+
order: orderAccount,
|
6001
|
+
market: marketAccount,
|
6002
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
6003
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
6004
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
6005
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
6006
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
6007
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
6008
|
+
eventAuthority: this.eventAuthority.publicKey,
|
6009
|
+
program: this.programId,
|
6010
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6011
|
+
})
|
6012
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true), custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
6013
|
+
.instruction()];
|
6014
|
+
case 2:
|
6015
|
+
executeLimitWithSwap = _b.sent();
|
6016
|
+
instructions.push(executeLimitWithSwap);
|
6017
|
+
return [3, 4];
|
6018
|
+
case 3:
|
6019
|
+
err_30 = _b.sent();
|
6020
|
+
console.log("perpClient executeLimitWithSwap error:: ", err_30);
|
6021
|
+
throw err_30;
|
5578
6022
|
case 4: return [2, {
|
5579
6023
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5580
6024
|
additionalSigners: additionalSigners
|
@@ -5584,7 +6028,7 @@ var PerpetualsClient = (function () {
|
|
5584
6028
|
});
|
5585
6029
|
};
|
5586
6030
|
this.placeTriggerOrder = function (targetSymbol, collateralSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, receiveCustodyId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5587
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder,
|
6031
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_31;
|
5588
6032
|
return __generator(this, function (_a) {
|
5589
6033
|
switch (_a.label) {
|
5590
6034
|
case 0:
|
@@ -5631,9 +6075,9 @@ var PerpetualsClient = (function () {
|
|
5631
6075
|
instructions.push(placeTriggerOrder);
|
5632
6076
|
return [3, 4];
|
5633
6077
|
case 3:
|
5634
|
-
|
5635
|
-
console.log("perpClient placeTriggerOrder error:: ",
|
5636
|
-
throw
|
6078
|
+
err_31 = _a.sent();
|
6079
|
+
console.log("perpClient placeTriggerOrder error:: ", err_31);
|
6080
|
+
throw err_31;
|
5637
6081
|
case 4: return [2, {
|
5638
6082
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5639
6083
|
additionalSigners: additionalSigners
|
@@ -5642,7 +6086,7 @@ var PerpetualsClient = (function () {
|
|
5642
6086
|
});
|
5643
6087
|
}); };
|
5644
6088
|
this.editTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5645
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder,
|
6089
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_32;
|
5646
6090
|
return __generator(this, function (_a) {
|
5647
6091
|
switch (_a.label) {
|
5648
6092
|
case 0:
|
@@ -5687,9 +6131,9 @@ var PerpetualsClient = (function () {
|
|
5687
6131
|
instructions.push(editTriggerOrder);
|
5688
6132
|
return [3, 4];
|
5689
6133
|
case 3:
|
5690
|
-
|
5691
|
-
console.log("perpClient editTriggerOrder error:: ",
|
5692
|
-
throw
|
6134
|
+
err_32 = _a.sent();
|
6135
|
+
console.log("perpClient editTriggerOrder error:: ", err_32);
|
6136
|
+
throw err_32;
|
5693
6137
|
case 4: return [2, {
|
5694
6138
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5695
6139
|
additionalSigners: additionalSigners
|
@@ -5698,7 +6142,7 @@ var PerpetualsClient = (function () {
|
|
5698
6142
|
});
|
5699
6143
|
}); };
|
5700
6144
|
this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5701
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder,
|
6145
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_33;
|
5702
6146
|
return __generator(this, function (_a) {
|
5703
6147
|
switch (_a.label) {
|
5704
6148
|
case 0:
|
@@ -5731,9 +6175,9 @@ var PerpetualsClient = (function () {
|
|
5731
6175
|
instructions.push(cancelTriggerOrder);
|
5732
6176
|
return [3, 4];
|
5733
6177
|
case 3:
|
5734
|
-
|
5735
|
-
console.log("perpClient cancelTriggerOrder error:: ",
|
5736
|
-
throw
|
6178
|
+
err_33 = _a.sent();
|
6179
|
+
console.log("perpClient cancelTriggerOrder error:: ", err_33);
|
6180
|
+
throw err_33;
|
5737
6181
|
case 4: return [2, {
|
5738
6182
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5739
6183
|
additionalSigners: additionalSigners
|
@@ -5741,11 +6185,121 @@ var PerpetualsClient = (function () {
|
|
5741
6185
|
}
|
5742
6186
|
});
|
5743
6187
|
}); };
|
6188
|
+
this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
6189
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
6190
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6191
|
+
return __awaiter(_this, void 0, void 0, function () {
|
6192
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_34;
|
6193
|
+
return __generator(this, function (_d) {
|
6194
|
+
switch (_d.label) {
|
6195
|
+
case 0:
|
6196
|
+
payerPubkey = this.provider.wallet.publicKey;
|
6197
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
6198
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
6199
|
+
receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey); });
|
6200
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
6201
|
+
preInstructions = [];
|
6202
|
+
instructions = [];
|
6203
|
+
postInstructions = [];
|
6204
|
+
additionalSigners = [];
|
6205
|
+
_d.label = 1;
|
6206
|
+
case 1:
|
6207
|
+
_d.trys.push([1, 9, , 10]);
|
6208
|
+
if (!false) return [3, 2];
|
6209
|
+
return [3, 7];
|
6210
|
+
case 2:
|
6211
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey, owner, true);
|
6212
|
+
_a = createUserATA;
|
6213
|
+
if (!_a) return [3, 4];
|
6214
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
6215
|
+
case 3:
|
6216
|
+
_a = !(_d.sent());
|
6217
|
+
_d.label = 4;
|
6218
|
+
case 4:
|
6219
|
+
if (_a) {
|
6220
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
6221
|
+
}
|
6222
|
+
userReceivingTokenAccountCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, owner, true);
|
6223
|
+
_b = createUserATA;
|
6224
|
+
if (!_b) return [3, 6];
|
6225
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
6226
|
+
case 5:
|
6227
|
+
_b = !(_d.sent());
|
6228
|
+
_d.label = 6;
|
6229
|
+
case 6:
|
6230
|
+
if (_b) {
|
6231
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
6232
|
+
}
|
6233
|
+
_d.label = 7;
|
6234
|
+
case 7:
|
6235
|
+
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
6236
|
+
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
6237
|
+
custodyAccountMetas = [];
|
6238
|
+
custodyOracleAccountMetas = [];
|
6239
|
+
for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
|
6240
|
+
custody = _c[_i];
|
6241
|
+
custodyAccountMetas.push({
|
6242
|
+
pubkey: custody.custodyAccount,
|
6243
|
+
isSigner: false,
|
6244
|
+
isWritable: false,
|
6245
|
+
});
|
6246
|
+
custodyOracleAccountMetas.push({
|
6247
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
6248
|
+
isSigner: false,
|
6249
|
+
isWritable: false,
|
6250
|
+
});
|
6251
|
+
}
|
6252
|
+
return [4, this.program.methods
|
6253
|
+
.executeTriggerWithSwap({
|
6254
|
+
isStopLoss: isStopLoss,
|
6255
|
+
orderId: orderId
|
6256
|
+
})
|
6257
|
+
.accounts({
|
6258
|
+
feePayer: payerPubkey,
|
6259
|
+
receivingAccount: userReceivingTokenAccount,
|
6260
|
+
collateralAccount: userReceivingTokenAccountCollateral,
|
6261
|
+
transferAuthority: poolConfig.transferAuthority,
|
6262
|
+
perpetuals: poolConfig.perpetuals,
|
6263
|
+
pool: poolConfig.poolAddress,
|
6264
|
+
position: positionAccount,
|
6265
|
+
order: orderAccount,
|
6266
|
+
market: marketAccount,
|
6267
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
6268
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
6269
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
6270
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
6271
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
6272
|
+
dispensingCustody: receivingCustodyConfig.custodyAccount,
|
6273
|
+
dispensingOracleAccount: this.useExtOracleAccount ? receivingCustodyConfig.extOracleAccount : receivingCustodyConfig.intOracleAccount,
|
6274
|
+
dispensingCustodyTokenAccount: receivingCustodyConfig.tokenAccount,
|
6275
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
6276
|
+
eventAuthority: this.eventAuthority.publicKey,
|
6277
|
+
program: this.programId,
|
6278
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6279
|
+
})
|
6280
|
+
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
6281
|
+
.instruction()];
|
6282
|
+
case 8:
|
6283
|
+
executeTriggerWithSwap = _d.sent();
|
6284
|
+
instructions.push(executeTriggerWithSwap);
|
6285
|
+
return [3, 10];
|
6286
|
+
case 9:
|
6287
|
+
err_34 = _d.sent();
|
6288
|
+
console.log("perpClient executeTriggerWithSwap error:: ", err_34);
|
6289
|
+
throw err_34;
|
6290
|
+
case 10: return [2, {
|
6291
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6292
|
+
additionalSigners: additionalSigners
|
6293
|
+
}];
|
6294
|
+
}
|
6295
|
+
});
|
6296
|
+
});
|
6297
|
+
};
|
5744
6298
|
this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
5745
6299
|
if (createUserATA === void 0) { createUserATA = true; }
|
5746
6300
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5747
6301
|
return __awaiter(_this, void 0, void 0, function () {
|
5748
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder,
|
6302
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_35;
|
5749
6303
|
return __generator(this, function (_b) {
|
5750
6304
|
switch (_b.label) {
|
5751
6305
|
case 0:
|
@@ -5808,9 +6362,9 @@ var PerpetualsClient = (function () {
|
|
5808
6362
|
instructions.push(executeTriggerOrder);
|
5809
6363
|
return [3, 8];
|
5810
6364
|
case 7:
|
5811
|
-
|
5812
|
-
console.log("perpClient executeTriggerOrder error:: ",
|
5813
|
-
throw
|
6365
|
+
err_35 = _b.sent();
|
6366
|
+
console.log("perpClient executeTriggerOrder error:: ", err_35);
|
6367
|
+
throw err_35;
|
5814
6368
|
case 8: return [2, {
|
5815
6369
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5816
6370
|
additionalSigners: additionalSigners
|
@@ -5819,15 +6373,12 @@ var PerpetualsClient = (function () {
|
|
5819
6373
|
});
|
5820
6374
|
});
|
5821
6375
|
};
|
5822
|
-
this.migrateTriggerOrder = function (owner,
|
5823
|
-
var payerPubkey,
|
6376
|
+
this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6377
|
+
var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_36;
|
5824
6378
|
return __generator(this, function (_a) {
|
5825
6379
|
switch (_a.label) {
|
5826
6380
|
case 0:
|
5827
6381
|
payerPubkey = this.provider.wallet.publicKey;
|
5828
|
-
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
5829
|
-
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
5830
|
-
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
5831
6382
|
preInstructions = [];
|
5832
6383
|
instructions = [];
|
5833
6384
|
postInstructions = [];
|
@@ -5853,9 +6404,9 @@ var PerpetualsClient = (function () {
|
|
5853
6404
|
instructions.push(migrateTriggerOrder);
|
5854
6405
|
return [3, 4];
|
5855
6406
|
case 3:
|
5856
|
-
|
5857
|
-
console.log("perpClient migrateTriggerOrder error:: ",
|
5858
|
-
throw
|
6407
|
+
err_36 = _a.sent();
|
6408
|
+
console.log("perpClient migrateTriggerOrder error:: ", err_36);
|
6409
|
+
throw err_36;
|
5859
6410
|
case 4: return [2, {
|
5860
6411
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5861
6412
|
additionalSigners: additionalSigners
|
@@ -5864,7 +6415,7 @@ var PerpetualsClient = (function () {
|
|
5864
6415
|
});
|
5865
6416
|
}); };
|
5866
6417
|
this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5867
|
-
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData,
|
6418
|
+
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_37;
|
5868
6419
|
return __generator(this, function (_a) {
|
5869
6420
|
switch (_a.label) {
|
5870
6421
|
case 0:
|
@@ -5893,15 +6444,15 @@ var PerpetualsClient = (function () {
|
|
5893
6444
|
console.log(getPositionData);
|
5894
6445
|
return [2, getPositionData];
|
5895
6446
|
case 3:
|
5896
|
-
|
5897
|
-
console.log("perpClient setPool error:: ",
|
5898
|
-
throw
|
6447
|
+
err_37 = _a.sent();
|
6448
|
+
console.log("perpClient setPool error:: ", err_37);
|
6449
|
+
throw err_37;
|
5899
6450
|
case 4: return [2];
|
5900
6451
|
}
|
5901
6452
|
});
|
5902
6453
|
}); };
|
5903
6454
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5904
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
6455
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_38;
|
5905
6456
|
return __generator(this, function (_a) {
|
5906
6457
|
switch (_a.label) {
|
5907
6458
|
case 0:
|
@@ -5934,9 +6485,9 @@ var PerpetualsClient = (function () {
|
|
5934
6485
|
instructions.push(withdrawFeesIx);
|
5935
6486
|
return [3, 5];
|
5936
6487
|
case 4:
|
5937
|
-
|
5938
|
-
console.log("perpClient setPool error:: ",
|
5939
|
-
throw
|
6488
|
+
err_38 = _a.sent();
|
6489
|
+
console.log("perpClient setPool error:: ", err_38);
|
6490
|
+
throw err_38;
|
5940
6491
|
case 5: return [2, {
|
5941
6492
|
instructions: __spreadArray([], instructions, true),
|
5942
6493
|
additionalSigners: additionalSigners
|
@@ -5945,7 +6496,7 @@ var PerpetualsClient = (function () {
|
|
5945
6496
|
});
|
5946
6497
|
}); };
|
5947
6498
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
5948
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
6499
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_39;
|
5949
6500
|
return __generator(this, function (_a) {
|
5950
6501
|
switch (_a.label) {
|
5951
6502
|
case 0:
|
@@ -5972,9 +6523,9 @@ var PerpetualsClient = (function () {
|
|
5972
6523
|
instructions.push(setPermissionsInstruction);
|
5973
6524
|
return [3, 4];
|
5974
6525
|
case 3:
|
5975
|
-
|
5976
|
-
console.log("perpClient setPool error:: ",
|
5977
|
-
throw
|
6526
|
+
err_39 = _a.sent();
|
6527
|
+
console.log("perpClient setPool error:: ", err_39);
|
6528
|
+
throw err_39;
|
5978
6529
|
case 4: return [2, {
|
5979
6530
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5980
6531
|
additionalSigners: additionalSigners
|
@@ -5983,7 +6534,7 @@ var PerpetualsClient = (function () {
|
|
5983
6534
|
});
|
5984
6535
|
}); };
|
5985
6536
|
this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5986
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e,
|
6537
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_40;
|
5987
6538
|
var _f;
|
5988
6539
|
return __generator(this, function (_g) {
|
5989
6540
|
switch (_g.label) {
|
@@ -6043,9 +6594,9 @@ var PerpetualsClient = (function () {
|
|
6043
6594
|
instructions.push(reimburse);
|
6044
6595
|
return [3, 5];
|
6045
6596
|
case 4:
|
6046
|
-
|
6047
|
-
console.log("perpClient setPool error:: ",
|
6048
|
-
throw
|
6597
|
+
err_40 = _g.sent();
|
6598
|
+
console.log("perpClient setPool error:: ", err_40);
|
6599
|
+
throw err_40;
|
6049
6600
|
case 5: return [2, {
|
6050
6601
|
instructions: __spreadArray([], instructions, true),
|
6051
6602
|
additionalSigners: additionalSigners
|
@@ -6054,7 +6605,7 @@ var PerpetualsClient = (function () {
|
|
6054
6605
|
});
|
6055
6606
|
}); };
|
6056
6607
|
this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6057
|
-
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice,
|
6608
|
+
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_41;
|
6058
6609
|
return __generator(this, function (_a) {
|
6059
6610
|
switch (_a.label) {
|
6060
6611
|
case 0:
|
@@ -6087,9 +6638,9 @@ var PerpetualsClient = (function () {
|
|
6087
6638
|
instructions.push(setInternalOraclePrice);
|
6088
6639
|
return [3, 4];
|
6089
6640
|
case 3:
|
6090
|
-
|
6091
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
6092
|
-
throw
|
6641
|
+
err_41 = _a.sent();
|
6642
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_41);
|
6643
|
+
throw err_41;
|
6093
6644
|
case 4: return [2, {
|
6094
6645
|
instructions: __spreadArray([], instructions, true),
|
6095
6646
|
additionalSigners: additionalSigners
|
@@ -6101,7 +6652,7 @@ var PerpetualsClient = (function () {
|
|
6101
6652
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6102
6653
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6103
6654
|
return __awaiter(_this, void 0, void 0, function () {
|
6104
|
-
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, addCompoundingLiquidity,
|
6655
|
+
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, addCompoundingLiquidity, err_42;
|
6105
6656
|
return __generator(this, function (_e) {
|
6106
6657
|
switch (_e.label) {
|
6107
6658
|
case 0:
|
@@ -6224,8 +6775,8 @@ var PerpetualsClient = (function () {
|
|
6224
6775
|
instructions.push(addCompoundingLiquidity);
|
6225
6776
|
return [3, 10];
|
6226
6777
|
case 9:
|
6227
|
-
|
6228
|
-
console.log("perpClient addCompoundingLiquidity error:: ",
|
6778
|
+
err_42 = _e.sent();
|
6779
|
+
console.log("perpClient addCompoundingLiquidity error:: ", err_42);
|
6229
6780
|
return [3, 10];
|
6230
6781
|
case 10: return [2, {
|
6231
6782
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6239,7 +6790,7 @@ var PerpetualsClient = (function () {
|
|
6239
6790
|
if (createUserATA === void 0) { createUserATA = true; }
|
6240
6791
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6241
6792
|
return __awaiter(_this, void 0, void 0, function () {
|
6242
|
-
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, removeCompoundingLiquidity,
|
6793
|
+
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, removeCompoundingLiquidity, err_43;
|
6243
6794
|
return __generator(this, function (_e) {
|
6244
6795
|
switch (_e.label) {
|
6245
6796
|
case 0:
|
@@ -6346,8 +6897,8 @@ var PerpetualsClient = (function () {
|
|
6346
6897
|
instructions.push(removeCompoundingLiquidity);
|
6347
6898
|
return [3, 8];
|
6348
6899
|
case 7:
|
6349
|
-
|
6350
|
-
console.log("perpClient removeCompoundingLiquidity error:: ",
|
6900
|
+
err_43 = _e.sent();
|
6901
|
+
console.log("perpClient removeCompoundingLiquidity error:: ", err_43);
|
6351
6902
|
return [3, 8];
|
6352
6903
|
case 8: return [2, {
|
6353
6904
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6360,7 +6911,7 @@ var PerpetualsClient = (function () {
|
|
6360
6911
|
this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
6361
6912
|
if (createUserATA === void 0) { createUserATA = true; }
|
6362
6913
|
return __awaiter(_this, void 0, void 0, function () {
|
6363
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake,
|
6914
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_44;
|
6364
6915
|
return __generator(this, function (_e) {
|
6365
6916
|
switch (_e.label) {
|
6366
6917
|
case 0:
|
@@ -6441,8 +6992,8 @@ var PerpetualsClient = (function () {
|
|
6441
6992
|
instructions.push(migrateStake);
|
6442
6993
|
return [3, 6];
|
6443
6994
|
case 5:
|
6444
|
-
|
6445
|
-
console.log("perpClient migrateStake error:: ",
|
6995
|
+
err_44 = _e.sent();
|
6996
|
+
console.log("perpClient migrateStake error:: ", err_44);
|
6446
6997
|
return [3, 6];
|
6447
6998
|
case 6: return [2, {
|
6448
6999
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6453,7 +7004,7 @@ var PerpetualsClient = (function () {
|
|
6453
7004
|
});
|
6454
7005
|
};
|
6455
7006
|
this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6456
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp,
|
7007
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_45;
|
6457
7008
|
return __generator(this, function (_d) {
|
6458
7009
|
switch (_d.label) {
|
6459
7010
|
case 0:
|
@@ -6525,8 +7076,8 @@ var PerpetualsClient = (function () {
|
|
6525
7076
|
instructions.push(migrateFlp);
|
6526
7077
|
return [3, 4];
|
6527
7078
|
case 3:
|
6528
|
-
|
6529
|
-
console.log("perpClient migrateFlp error:: ",
|
7079
|
+
err_45 = _d.sent();
|
7080
|
+
console.log("perpClient migrateFlp error:: ", err_45);
|
6530
7081
|
return [3, 4];
|
6531
7082
|
case 4: return [2, {
|
6532
7083
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6538,7 +7089,7 @@ var PerpetualsClient = (function () {
|
|
6538
7089
|
this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
|
6539
7090
|
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
6540
7091
|
return __awaiter(_this, void 0, void 0, function () {
|
6541
|
-
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee,
|
7092
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_46;
|
6542
7093
|
return __generator(this, function (_d) {
|
6543
7094
|
switch (_d.label) {
|
6544
7095
|
case 0:
|
@@ -6595,8 +7146,8 @@ var PerpetualsClient = (function () {
|
|
6595
7146
|
instructions.push(compoundingFee);
|
6596
7147
|
return [3, 4];
|
6597
7148
|
case 3:
|
6598
|
-
|
6599
|
-
console.log("perpClient compoundingFee error:: ",
|
7149
|
+
err_46 = _d.sent();
|
7150
|
+
console.log("perpClient compoundingFee error:: ", err_46);
|
6600
7151
|
return [3, 4];
|
6601
7152
|
case 4: return [2, {
|
6602
7153
|
instructions: __spreadArray([], instructions, true),
|
@@ -6607,7 +7158,7 @@ var PerpetualsClient = (function () {
|
|
6607
7158
|
});
|
6608
7159
|
};
|
6609
7160
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6610
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
7161
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_47;
|
6611
7162
|
return __generator(this, function (_a) {
|
6612
7163
|
switch (_a.label) {
|
6613
7164
|
case 0:
|
@@ -6645,8 +7196,8 @@ var PerpetualsClient = (function () {
|
|
6645
7196
|
instructions.push(renameFlp);
|
6646
7197
|
return [3, 4];
|
6647
7198
|
case 3:
|
6648
|
-
|
6649
|
-
console.log("perpClient renameFlp error:: ",
|
7199
|
+
err_47 = _a.sent();
|
7200
|
+
console.log("perpClient renameFlp error:: ", err_47);
|
6650
7201
|
return [3, 4];
|
6651
7202
|
case 4: return [2, {
|
6652
7203
|
instructions: __spreadArray([], instructions, true),
|
@@ -6656,7 +7207,7 @@ var PerpetualsClient = (function () {
|
|
6656
7207
|
});
|
6657
7208
|
}); };
|
6658
7209
|
this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6659
|
-
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault,
|
7210
|
+
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_48;
|
6660
7211
|
return __generator(this, function (_a) {
|
6661
7212
|
switch (_a.label) {
|
6662
7213
|
case 0:
|
@@ -6690,9 +7241,9 @@ var PerpetualsClient = (function () {
|
|
6690
7241
|
instructions.push(initRewardVault);
|
6691
7242
|
return [3, 4];
|
6692
7243
|
case 3:
|
6693
|
-
|
6694
|
-
console.log("rewardDistribution InitRewardVault error:: ",
|
6695
|
-
throw
|
7244
|
+
err_48 = _a.sent();
|
7245
|
+
console.log("rewardDistribution InitRewardVault error:: ", err_48);
|
7246
|
+
throw err_48;
|
6696
7247
|
case 4: return [2, {
|
6697
7248
|
instructions: __spreadArray([], instructions, true),
|
6698
7249
|
additionalSigners: additionalSigners
|
@@ -6701,7 +7252,7 @@ var PerpetualsClient = (function () {
|
|
6701
7252
|
});
|
6702
7253
|
}); };
|
6703
7254
|
this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
|
6704
|
-
var publicKey, instructions, additionalSigners, rewardVault, updateCounter,
|
7255
|
+
var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_49;
|
6705
7256
|
return __generator(this, function (_a) {
|
6706
7257
|
switch (_a.label) {
|
6707
7258
|
case 0:
|
@@ -6724,9 +7275,9 @@ var PerpetualsClient = (function () {
|
|
6724
7275
|
instructions.push(updateCounter);
|
6725
7276
|
return [3, 4];
|
6726
7277
|
case 3:
|
6727
|
-
|
6728
|
-
console.log("rewardDistribution updateCounter error:: ",
|
6729
|
-
throw
|
7278
|
+
err_49 = _a.sent();
|
7279
|
+
console.log("rewardDistribution updateCounter error:: ", err_49);
|
7280
|
+
throw err_49;
|
6730
7281
|
case 4: return [2, {
|
6731
7282
|
instructions: __spreadArray([], instructions, true),
|
6732
7283
|
additionalSigners: additionalSigners
|
@@ -6735,7 +7286,7 @@ var PerpetualsClient = (function () {
|
|
6735
7286
|
});
|
6736
7287
|
}); };
|
6737
7288
|
this.rewardDistribution = function (counter, owner, rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6738
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward,
|
7289
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_50;
|
6739
7290
|
return __generator(this, function (_a) {
|
6740
7291
|
switch (_a.label) {
|
6741
7292
|
case 0:
|
@@ -6774,9 +7325,9 @@ var PerpetualsClient = (function () {
|
|
6774
7325
|
instructions.push(distributeReward);
|
6775
7326
|
return [3, 4];
|
6776
7327
|
case 3:
|
6777
|
-
|
6778
|
-
console.log("rewardDistribution distributeReward error:: ",
|
6779
|
-
throw
|
7328
|
+
err_50 = _a.sent();
|
7329
|
+
console.log("rewardDistribution distributeReward error:: ", err_50);
|
7330
|
+
throw err_50;
|
6780
7331
|
case 4: return [2, {
|
6781
7332
|
instructions: __spreadArray([], instructions, true),
|
6782
7333
|
additionalSigners: additionalSigners
|
@@ -6787,7 +7338,7 @@ var PerpetualsClient = (function () {
|
|
6787
7338
|
this.collectReward = function (counter, owner, rewardSymbol, poolConfig, createUserATA) {
|
6788
7339
|
if (createUserATA === void 0) { createUserATA = true; }
|
6789
7340
|
return __awaiter(_this, void 0, void 0, function () {
|
6790
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward,
|
7341
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward, err_51;
|
6791
7342
|
return __generator(this, function (_b) {
|
6792
7343
|
switch (_b.label) {
|
6793
7344
|
case 0:
|
@@ -6835,8 +7386,8 @@ var PerpetualsClient = (function () {
|
|
6835
7386
|
instructions.push(collectRaffleReward);
|
6836
7387
|
return [3, 6];
|
6837
7388
|
case 5:
|
6838
|
-
|
6839
|
-
throw
|
7389
|
+
err_51 = _b.sent();
|
7390
|
+
throw err_51;
|
6840
7391
|
case 6: return [2, {
|
6841
7392
|
instructions: __spreadArray([], instructions, true),
|
6842
7393
|
additionalSigners: additionalSigners
|