flash-sdk 2.40.9 → 2.40.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +51 -51
- package/dist/PerpetualsClient.js +73 -72
- package/dist/idl/perpetuals.d.ts +393 -11
- package/dist/idl/perpetuals.js +393 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +11 -2
- package/dist/types/index.js +1 -1
- package/dist/utils/alt.d.ts +1 -0
- package/dist/utils/getReferralAccounts.d.ts +7 -0
- package/dist/utils/getReferralAccounts.js +33 -0
- package/package.json +1 -1
- package/dist/utils/getNftAccounts.d.ts +0 -7
- package/dist/utils/getNftAccounts.js +0 -33
package/dist/PerpetualsClient.js
CHANGED
@@ -77,7 +77,7 @@ var utils_1 = require("./utils");
|
|
77
77
|
var constants_1 = require("./constants");
|
78
78
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
79
79
|
var backupOracle_1 = require("./backupOracle");
|
80
|
-
var
|
80
|
+
var getReferralAccounts_1 = require("./utils/getReferralAccounts");
|
81
81
|
var ViewHelper_1 = require("./ViewHelper");
|
82
82
|
var PerpetualsClient = (function () {
|
83
83
|
function PerpetualsClient(provider, programId, composabilityProgramId, fbNftRewardProgramId, rewardDistributionProgramId, opts, useExtOracleAccount) {
|
@@ -2567,10 +2567,10 @@ var PerpetualsClient = (function () {
|
|
2567
2567
|
}
|
2568
2568
|
});
|
2569
2569
|
}); };
|
2570
|
-
this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege,
|
2571
|
-
if (
|
2572
|
-
if (
|
2573
|
-
if (
|
2570
|
+
this.openPosition = function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
2571
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2572
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2573
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2574
2574
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2575
2575
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2576
2576
|
return __awaiter(_this, void 0, void 0, function () {
|
@@ -2665,7 +2665,7 @@ var PerpetualsClient = (function () {
|
|
2665
2665
|
transferAuthority: this.authority.publicKey,
|
2666
2666
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
2667
2667
|
})
|
2668
|
-
.remainingAccounts(__spreadArray([], (0,
|
2668
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
2669
2669
|
.instruction()];
|
2670
2670
|
case 8:
|
2671
2671
|
instruction = _c.sent();
|
@@ -2678,10 +2678,10 @@ var PerpetualsClient = (function () {
|
|
2678
2678
|
});
|
2679
2679
|
});
|
2680
2680
|
};
|
2681
|
-
this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege,
|
2682
|
-
if (
|
2683
|
-
if (
|
2684
|
-
if (
|
2681
|
+
this.closePosition = function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
|
2682
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2683
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2684
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2685
2685
|
if (createUserATA === void 0) { createUserATA = true; }
|
2686
2686
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
2687
2687
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
@@ -2761,7 +2761,7 @@ var PerpetualsClient = (function () {
|
|
2761
2761
|
program: this.programId,
|
2762
2762
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
2763
2763
|
})
|
2764
|
-
.remainingAccounts(__spreadArray([], (0,
|
2764
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
2765
2765
|
.instruction()];
|
2766
2766
|
case 6:
|
2767
2767
|
instruction = _b.sent();
|
@@ -2783,10 +2783,10 @@ var PerpetualsClient = (function () {
|
|
2783
2783
|
});
|
2784
2784
|
});
|
2785
2785
|
};
|
2786
|
-
this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege,
|
2787
|
-
if (
|
2788
|
-
if (
|
2789
|
-
if (
|
2786
|
+
this.swapAndOpen = function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, minCollateralAmountOut, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, skipBalanceChecks, ephemeralSignerPubkey) {
|
2787
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2788
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2789
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2790
2790
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
2791
2791
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2792
2792
|
return __awaiter(_this, void 0, void 0, function () {
|
@@ -2904,7 +2904,7 @@ var PerpetualsClient = (function () {
|
|
2904
2904
|
program: this.programId,
|
2905
2905
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
2906
2906
|
})
|
2907
|
-
.remainingAccounts(__spreadArray([], (0,
|
2907
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
2908
2908
|
.instruction()];
|
2909
2909
|
case 9:
|
2910
2910
|
inx = _c.sent();
|
@@ -2922,10 +2922,10 @@ var PerpetualsClient = (function () {
|
|
2922
2922
|
});
|
2923
2923
|
});
|
2924
2924
|
};
|
2925
|
-
this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege,
|
2926
|
-
if (
|
2927
|
-
if (
|
2928
|
-
if (
|
2925
|
+
this.closeAndSwap = function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, minSwapAmountOut, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount, ephemeralSignerPubkey) {
|
2926
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
2927
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
2928
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
2929
2929
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
2930
2930
|
return __awaiter(_this, void 0, void 0, function () {
|
2931
2931
|
var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, inx, err_3;
|
@@ -3024,7 +3024,7 @@ var PerpetualsClient = (function () {
|
|
3024
3024
|
program: this.programId,
|
3025
3025
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
3026
3026
|
})
|
3027
|
-
.remainingAccounts(__spreadArray([], (0,
|
3027
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
3028
3028
|
.instruction()];
|
3029
3029
|
case 7:
|
3030
3030
|
inx = _a.sent();
|
@@ -3743,10 +3743,10 @@ var PerpetualsClient = (function () {
|
|
3743
3743
|
});
|
3744
3744
|
});
|
3745
3745
|
};
|
3746
|
-
this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege,
|
3747
|
-
if (
|
3748
|
-
if (
|
3749
|
-
if (
|
3746
|
+
this.increaseSize = function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
3747
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3748
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3749
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3750
3750
|
return __awaiter(_this, void 0, void 0, function () {
|
3751
3751
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3752
3752
|
return __generator(this, function (_a) {
|
@@ -3790,7 +3790,7 @@ var PerpetualsClient = (function () {
|
|
3790
3790
|
program: this.programId,
|
3791
3791
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
3792
3792
|
})
|
3793
|
-
.remainingAccounts(__spreadArray([], (0,
|
3793
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
3794
3794
|
.instruction()];
|
3795
3795
|
case 1:
|
3796
3796
|
instruction = _a.sent();
|
@@ -3803,10 +3803,10 @@ var PerpetualsClient = (function () {
|
|
3803
3803
|
});
|
3804
3804
|
});
|
3805
3805
|
};
|
3806
|
-
this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege,
|
3807
|
-
if (
|
3808
|
-
if (
|
3809
|
-
if (
|
3806
|
+
this.decreaseSize = function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
3807
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
3808
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
3809
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
3810
3810
|
return __awaiter(_this, void 0, void 0, function () {
|
3811
3811
|
var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
|
3812
3812
|
return __generator(this, function (_a) {
|
@@ -3850,7 +3850,7 @@ var PerpetualsClient = (function () {
|
|
3850
3850
|
program: this.programId,
|
3851
3851
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
3852
3852
|
})
|
3853
|
-
.remainingAccounts(__spreadArray([], (0,
|
3853
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
3854
3854
|
.instruction()];
|
3855
3855
|
case 1:
|
3856
3856
|
instruction = _a.sent();
|
@@ -5409,7 +5409,7 @@ var PerpetualsClient = (function () {
|
|
5409
5409
|
}
|
5410
5410
|
});
|
5411
5411
|
}); };
|
5412
|
-
this.withdrawToken = function (owner,
|
5412
|
+
this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5413
5413
|
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_29;
|
5414
5414
|
return __generator(this, function (_a) {
|
5415
5415
|
switch (_a.label) {
|
@@ -5430,7 +5430,7 @@ var PerpetualsClient = (function () {
|
|
5430
5430
|
}
|
5431
5431
|
return [4, this.program.methods
|
5432
5432
|
.withdrawToken({
|
5433
|
-
|
5433
|
+
withdrawRequestId: withdrawRequestId
|
5434
5434
|
})
|
5435
5435
|
.accounts({
|
5436
5436
|
owner: owner,
|
@@ -5460,7 +5460,7 @@ var PerpetualsClient = (function () {
|
|
5460
5460
|
}
|
5461
5461
|
});
|
5462
5462
|
}); };
|
5463
|
-
this.cancelUnstakeRequest = function (owner,
|
5463
|
+
this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5464
5464
|
var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_30;
|
5465
5465
|
return __generator(this, function (_a) {
|
5466
5466
|
switch (_a.label) {
|
@@ -5475,7 +5475,7 @@ var PerpetualsClient = (function () {
|
|
5475
5475
|
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
5476
5476
|
return [4, this.program.methods
|
5477
5477
|
.cancelUnstakeTokenRequest({
|
5478
|
-
|
5478
|
+
withdrawRequestId: withdrawRequestId
|
5479
5479
|
})
|
5480
5480
|
.accounts({
|
5481
5481
|
owner: owner,
|
@@ -6079,10 +6079,10 @@ var PerpetualsClient = (function () {
|
|
6079
6079
|
});
|
6080
6080
|
});
|
6081
6081
|
};
|
6082
|
-
this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege,
|
6083
|
-
if (
|
6084
|
-
if (
|
6085
|
-
if (
|
6082
|
+
this.executeLimitOrder = function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6083
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6084
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6085
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6086
6086
|
return __awaiter(_this, void 0, void 0, function () {
|
6087
6087
|
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_39;
|
6088
6088
|
return __generator(this, function (_a) {
|
@@ -6107,7 +6107,9 @@ var PerpetualsClient = (function () {
|
|
6107
6107
|
privilege: privilege
|
6108
6108
|
})
|
6109
6109
|
.accounts({
|
6110
|
+
positionOwner: userPubkey,
|
6110
6111
|
feePayer: publicKey,
|
6112
|
+
transferAuthority: poolConfig.transferAuthority,
|
6111
6113
|
perpetuals: poolConfig.perpetuals,
|
6112
6114
|
pool: poolConfig.poolAddress,
|
6113
6115
|
position: positionAccount,
|
@@ -6117,13 +6119,14 @@ var PerpetualsClient = (function () {
|
|
6117
6119
|
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
6118
6120
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
6119
6121
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
6122
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
6120
6123
|
systemProgram: web3_js_1.SystemProgram.programId,
|
6121
6124
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
6122
6125
|
eventAuthority: this.eventAuthority.publicKey,
|
6123
6126
|
program: this.programId,
|
6124
6127
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6125
6128
|
})
|
6126
|
-
.remainingAccounts(__spreadArray([], (0,
|
6129
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6127
6130
|
.instruction()];
|
6128
6131
|
case 2:
|
6129
6132
|
executeLimitOrder = _a.sent();
|
@@ -6141,14 +6144,14 @@ var PerpetualsClient = (function () {
|
|
6141
6144
|
});
|
6142
6145
|
});
|
6143
6146
|
};
|
6144
|
-
this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege,
|
6145
|
-
if (
|
6146
|
-
if (
|
6147
|
-
if (
|
6147
|
+
this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6148
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6149
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6150
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6148
6151
|
return __awaiter(_this, void 0, void 0, function () {
|
6149
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners,
|
6150
|
-
return __generator(this, function (
|
6151
|
-
switch (
|
6152
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_40;
|
6153
|
+
return __generator(this, function (_a) {
|
6154
|
+
switch (_a.label) {
|
6152
6155
|
case 0:
|
6153
6156
|
publicKey = this.provider.wallet.publicKey;
|
6154
6157
|
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
@@ -6159,24 +6162,9 @@ var PerpetualsClient = (function () {
|
|
6159
6162
|
instructions = [];
|
6160
6163
|
postInstructions = [];
|
6161
6164
|
additionalSigners = [];
|
6162
|
-
|
6163
|
-
custodyOracleAccountMetas = [];
|
6164
|
-
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
6165
|
-
custody = _a[_i];
|
6166
|
-
custodyAccountMetas.push({
|
6167
|
-
pubkey: custody.custodyAccount,
|
6168
|
-
isSigner: false,
|
6169
|
-
isWritable: false,
|
6170
|
-
});
|
6171
|
-
custodyOracleAccountMetas.push({
|
6172
|
-
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
6173
|
-
isSigner: false,
|
6174
|
-
isWritable: false,
|
6175
|
-
});
|
6176
|
-
}
|
6177
|
-
_b.label = 1;
|
6165
|
+
_a.label = 1;
|
6178
6166
|
case 1:
|
6179
|
-
|
6167
|
+
_a.trys.push([1, 3, , 4]);
|
6180
6168
|
positionAccount = poolConfig.getPositionFromMarketPk(userPubkey, marketAccount);
|
6181
6169
|
orderAccount = poolConfig.getOrderFromMarketPk(userPubkey, marketAccount);
|
6182
6170
|
return [4, this.program.methods
|
@@ -6185,7 +6173,9 @@ var PerpetualsClient = (function () {
|
|
6185
6173
|
privilege: privilege
|
6186
6174
|
})
|
6187
6175
|
.accounts({
|
6176
|
+
positionOwner: userPubkey,
|
6188
6177
|
feePayer: publicKey,
|
6178
|
+
transferAuthority: poolConfig.transferAuthority,
|
6189
6179
|
perpetuals: poolConfig.perpetuals,
|
6190
6180
|
pool: poolConfig.poolAddress,
|
6191
6181
|
reserveCustody: reserveCustodyConfig.custodyAccount,
|
@@ -6197,20 +6187,21 @@ var PerpetualsClient = (function () {
|
|
6197
6187
|
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
6198
6188
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
6199
6189
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
6190
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
6200
6191
|
systemProgram: web3_js_1.SystemProgram.programId,
|
6201
6192
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
6202
6193
|
eventAuthority: this.eventAuthority.publicKey,
|
6203
6194
|
program: this.programId,
|
6204
6195
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6205
6196
|
})
|
6206
|
-
.remainingAccounts(__spreadArray(
|
6197
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6207
6198
|
.instruction()];
|
6208
6199
|
case 2:
|
6209
|
-
executeLimitWithSwap =
|
6200
|
+
executeLimitWithSwap = _a.sent();
|
6210
6201
|
instructions.push(executeLimitWithSwap);
|
6211
6202
|
return [3, 4];
|
6212
6203
|
case 3:
|
6213
|
-
err_40 =
|
6204
|
+
err_40 = _a.sent();
|
6214
6205
|
console.log("perpClient executeLimitWithSwap error:: ", err_40);
|
6215
6206
|
throw err_40;
|
6216
6207
|
case 4: return [2, {
|
@@ -6379,9 +6370,12 @@ var PerpetualsClient = (function () {
|
|
6379
6370
|
}
|
6380
6371
|
});
|
6381
6372
|
}); };
|
6382
|
-
this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
6373
|
+
this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6383
6374
|
if (createUserATA === void 0) { createUserATA = true; }
|
6384
6375
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6376
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6377
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6378
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6385
6379
|
return __awaiter(_this, void 0, void 0, function () {
|
6386
6380
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_44;
|
6387
6381
|
return __generator(this, function (_d) {
|
@@ -6446,9 +6440,11 @@ var PerpetualsClient = (function () {
|
|
6446
6440
|
return [4, this.program.methods
|
6447
6441
|
.executeTriggerWithSwap({
|
6448
6442
|
isStopLoss: isStopLoss,
|
6449
|
-
orderId: orderId
|
6443
|
+
orderId: orderId,
|
6444
|
+
privilege: privilege
|
6450
6445
|
})
|
6451
6446
|
.accounts({
|
6447
|
+
positionOwner: owner,
|
6452
6448
|
feePayer: payerPubkey,
|
6453
6449
|
receivingAccount: userReceivingTokenAccount,
|
6454
6450
|
collateralAccount: userReceivingTokenAccountCollateral,
|
@@ -6471,7 +6467,7 @@ var PerpetualsClient = (function () {
|
|
6471
6467
|
program: this.programId,
|
6472
6468
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6473
6469
|
})
|
6474
|
-
.remainingAccounts(__spreadArray(
|
6470
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6475
6471
|
.instruction()];
|
6476
6472
|
case 8:
|
6477
6473
|
executeTriggerWithSwap = _d.sent();
|
@@ -6489,9 +6485,12 @@ var PerpetualsClient = (function () {
|
|
6489
6485
|
});
|
6490
6486
|
});
|
6491
6487
|
};
|
6492
|
-
this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
6488
|
+
this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
|
6493
6489
|
if (createUserATA === void 0) { createUserATA = true; }
|
6494
6490
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6491
|
+
if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
|
6492
|
+
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6493
|
+
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6495
6494
|
return __awaiter(_this, void 0, void 0, function () {
|
6496
6495
|
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_45;
|
6497
6496
|
return __generator(this, function (_b) {
|
@@ -6529,7 +6528,8 @@ var PerpetualsClient = (function () {
|
|
6529
6528
|
return [4, this.program.methods
|
6530
6529
|
.executeTriggerOrder({
|
6531
6530
|
isStopLoss: isStopLoss,
|
6532
|
-
orderId: orderId
|
6531
|
+
orderId: orderId,
|
6532
|
+
privilege: privilege
|
6533
6533
|
})
|
6534
6534
|
.accounts({
|
6535
6535
|
feePayer: payerPubkey,
|
@@ -6550,6 +6550,7 @@ var PerpetualsClient = (function () {
|
|
6550
6550
|
program: this.programId,
|
6551
6551
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
6552
6552
|
})
|
6553
|
+
.remainingAccounts(__spreadArray([], (0, getReferralAccounts_1.getReferralAccounts)(tokenStakeAccount, userReferralAccount, rebateTokenAccount, privilege), true))
|
6553
6554
|
.instruction()];
|
6554
6555
|
case 6:
|
6555
6556
|
executeTriggerOrder = _b.sent();
|