flash-sdk 2.45.5 → 2.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +21 -13
- package/dist/PerpetualsClient.js +244 -130
- package/dist/idl/perpetuals.d.ts +101 -1
- package/dist/idl/perpetuals.js +101 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
@@ -4757,21 +4757,37 @@ var PerpetualsClient = (function () {
|
|
4757
4757
|
});
|
4758
4758
|
}); };
|
4759
4759
|
this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
4760
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, unstakeInstantInstruction, err_16;
|
4761
|
-
return __generator(this, function (
|
4762
|
-
switch (
|
4760
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_16;
|
4761
|
+
return __generator(this, function (_b) {
|
4762
|
+
switch (_b.label) {
|
4763
4763
|
case 0:
|
4764
4764
|
publicKey = this.provider.wallet.publicKey;
|
4765
4765
|
preInstructions = [];
|
4766
4766
|
instructions = [];
|
4767
4767
|
postInstructions = [];
|
4768
4768
|
additionalSigners = [];
|
4769
|
-
|
4769
|
+
_b.label = 1;
|
4770
4770
|
case 1:
|
4771
|
-
|
4771
|
+
_b.trys.push([1, 5, , 6]);
|
4772
4772
|
rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
|
4773
4773
|
pool = poolConfig.poolAddress;
|
4774
4774
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.programId)[0];
|
4775
|
+
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
|
4776
|
+
tokenStakeAccounts = [];
|
4777
|
+
_a = tokenStakeAccount;
|
4778
|
+
if (!_a) return [3, 3];
|
4779
|
+
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
4780
|
+
case 2:
|
4781
|
+
_a = (_b.sent());
|
4782
|
+
_b.label = 3;
|
4783
|
+
case 3:
|
4784
|
+
if (_a) {
|
4785
|
+
tokenStakeAccounts.push({
|
4786
|
+
pubkey: tokenStakeAccount,
|
4787
|
+
isSigner: false,
|
4788
|
+
isWritable: false,
|
4789
|
+
});
|
4790
|
+
}
|
4775
4791
|
return [4, this.program.methods
|
4776
4792
|
.unstakeInstant({
|
4777
4793
|
unstakeAmount: unstakeAmount
|
@@ -4785,16 +4801,17 @@ var PerpetualsClient = (function () {
|
|
4785
4801
|
eventAuthority: this.eventAuthority.publicKey,
|
4786
4802
|
program: this.program.programId,
|
4787
4803
|
})
|
4804
|
+
.remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
|
4788
4805
|
.instruction()];
|
4789
|
-
case
|
4790
|
-
unstakeInstantInstruction =
|
4806
|
+
case 4:
|
4807
|
+
unstakeInstantInstruction = _b.sent();
|
4791
4808
|
instructions.push(unstakeInstantInstruction);
|
4792
|
-
return [3,
|
4793
|
-
case
|
4794
|
-
err_16 =
|
4809
|
+
return [3, 6];
|
4810
|
+
case 5:
|
4811
|
+
err_16 = _b.sent();
|
4795
4812
|
console.log("perpClient unstakeInstant error:: ", err_16);
|
4796
4813
|
throw err_16;
|
4797
|
-
case
|
4814
|
+
case 6: return [2, {
|
4798
4815
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
4799
4816
|
additionalSigners: additionalSigners
|
4800
4817
|
}];
|
@@ -5699,8 +5716,47 @@ var PerpetualsClient = (function () {
|
|
5699
5716
|
});
|
5700
5717
|
});
|
5701
5718
|
};
|
5719
|
+
this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
|
5720
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_34;
|
5721
|
+
return __generator(this, function (_a) {
|
5722
|
+
switch (_a.label) {
|
5723
|
+
case 0:
|
5724
|
+
publicKey = this.provider.wallet.publicKey;
|
5725
|
+
preInstructions = [];
|
5726
|
+
instructions = [];
|
5727
|
+
postInstructions = [];
|
5728
|
+
additionalSigners = [];
|
5729
|
+
_a.label = 1;
|
5730
|
+
case 1:
|
5731
|
+
_a.trys.push([1, 3, , 4]);
|
5732
|
+
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
|
5733
|
+
return [4, this.program.methods
|
5734
|
+
.setTokenStakeLevel({
|
5735
|
+
level: stakeLevel,
|
5736
|
+
})
|
5737
|
+
.accounts({
|
5738
|
+
admin: publicKey,
|
5739
|
+
multisig: this.multisig.publicKey,
|
5740
|
+
tokenStakeAccount: tokenStakeAccount,
|
5741
|
+
})
|
5742
|
+
.instruction()];
|
5743
|
+
case 2:
|
5744
|
+
setTokenStakeLevelInstruction = _a.sent();
|
5745
|
+
instructions.push(setTokenStakeLevelInstruction);
|
5746
|
+
return [3, 4];
|
5747
|
+
case 3:
|
5748
|
+
err_34 = _a.sent();
|
5749
|
+
console.log("perpClient setTokenStakeLevelInstruction error:: ", err_34);
|
5750
|
+
throw err_34;
|
5751
|
+
case 4: return [2, {
|
5752
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5753
|
+
additionalSigners: additionalSigners
|
5754
|
+
}];
|
5755
|
+
}
|
5756
|
+
});
|
5757
|
+
}); };
|
5702
5758
|
this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5703
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault,
|
5759
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_35;
|
5704
5760
|
return __generator(this, function (_a) {
|
5705
5761
|
switch (_a.label) {
|
5706
5762
|
case 0:
|
@@ -5737,9 +5793,9 @@ var PerpetualsClient = (function () {
|
|
5737
5793
|
instructions.push(initRewardVault);
|
5738
5794
|
return [3, 4];
|
5739
5795
|
case 3:
|
5740
|
-
|
5741
|
-
console.log("perpClient InitRewardVault error:: ",
|
5742
|
-
throw
|
5796
|
+
err_35 = _a.sent();
|
5797
|
+
console.log("perpClient InitRewardVault error:: ", err_35);
|
5798
|
+
throw err_35;
|
5743
5799
|
case 4: return [2, {
|
5744
5800
|
instructions: __spreadArray([], instructions, true),
|
5745
5801
|
additionalSigners: additionalSigners
|
@@ -5748,7 +5804,7 @@ var PerpetualsClient = (function () {
|
|
5748
5804
|
});
|
5749
5805
|
}); };
|
5750
5806
|
this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5751
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward,
|
5807
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_36;
|
5752
5808
|
return __generator(this, function (_a) {
|
5753
5809
|
switch (_a.label) {
|
5754
5810
|
case 0:
|
@@ -5779,9 +5835,9 @@ var PerpetualsClient = (function () {
|
|
5779
5835
|
instructions.push(distributeReward);
|
5780
5836
|
return [3, 4];
|
5781
5837
|
case 3:
|
5782
|
-
|
5783
|
-
console.log("perpClient distributeReward error:: ",
|
5784
|
-
throw
|
5838
|
+
err_36 = _a.sent();
|
5839
|
+
console.log("perpClient distributeReward error:: ", err_36);
|
5840
|
+
throw err_36;
|
5785
5841
|
case 4: return [2, {
|
5786
5842
|
instructions: __spreadArray([], instructions, true),
|
5787
5843
|
additionalSigners: additionalSigners
|
@@ -5792,7 +5848,7 @@ var PerpetualsClient = (function () {
|
|
5792
5848
|
this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
|
5793
5849
|
if (createUserATA === void 0) { createUserATA = true; }
|
5794
5850
|
return __awaiter(_this, void 0, void 0, function () {
|
5795
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward,
|
5851
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_37;
|
5796
5852
|
return __generator(this, function (_b) {
|
5797
5853
|
switch (_b.label) {
|
5798
5854
|
case 0:
|
@@ -5842,8 +5898,8 @@ var PerpetualsClient = (function () {
|
|
5842
5898
|
instructions.push(collectNftReward);
|
5843
5899
|
return [3, 6];
|
5844
5900
|
case 5:
|
5845
|
-
|
5846
|
-
throw
|
5901
|
+
err_37 = _b.sent();
|
5902
|
+
throw err_37;
|
5847
5903
|
case 6: return [2, {
|
5848
5904
|
instructions: __spreadArray([], instructions, true),
|
5849
5905
|
additionalSigners: additionalSigners
|
@@ -5855,7 +5911,7 @@ var PerpetualsClient = (function () {
|
|
5855
5911
|
this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
|
5856
5912
|
if (createUserATA === void 0) { createUserATA = true; }
|
5857
5913
|
return __awaiter(_this, void 0, void 0, function () {
|
5858
|
-
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction,
|
5914
|
+
var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_38;
|
5859
5915
|
return __generator(this, function (_b) {
|
5860
5916
|
switch (_b.label) {
|
5861
5917
|
case 0:
|
@@ -5919,9 +5975,9 @@ var PerpetualsClient = (function () {
|
|
5919
5975
|
instructions.push(withdrawStakeInstruction);
|
5920
5976
|
return [3, 6];
|
5921
5977
|
case 5:
|
5922
|
-
|
5923
|
-
console.log("perpClient withdrawStake error:: ",
|
5924
|
-
throw
|
5978
|
+
err_38 = _b.sent();
|
5979
|
+
console.log("perpClient withdrawStake error:: ", err_38);
|
5980
|
+
throw err_38;
|
5925
5981
|
case 6: return [2, {
|
5926
5982
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5927
5983
|
additionalSigners: additionalSigners
|
@@ -5931,7 +5987,7 @@ var PerpetualsClient = (function () {
|
|
5931
5987
|
});
|
5932
5988
|
};
|
5933
5989
|
this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5934
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice,
|
5990
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_39;
|
5935
5991
|
return __generator(this, function (_a) {
|
5936
5992
|
switch (_a.label) {
|
5937
5993
|
case 0:
|
@@ -5970,9 +6026,9 @@ var PerpetualsClient = (function () {
|
|
5970
6026
|
instructions.push(setTriggerPrice);
|
5971
6027
|
return [3, 4];
|
5972
6028
|
case 3:
|
5973
|
-
|
5974
|
-
console.log("perpClient setTriggerPrice error:: ",
|
5975
|
-
throw
|
6029
|
+
err_39 = _a.sent();
|
6030
|
+
console.log("perpClient setTriggerPrice error:: ", err_39);
|
6031
|
+
throw err_39;
|
5976
6032
|
case 4: return [2, {
|
5977
6033
|
instructions: __spreadArray([], instructions, true),
|
5978
6034
|
additionalSigners: additionalSigners
|
@@ -5985,7 +6041,7 @@ var PerpetualsClient = (function () {
|
|
5985
6041
|
if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
|
5986
6042
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5987
6043
|
return __awaiter(_this, void 0, void 0, function () {
|
5988
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns,
|
6044
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_40;
|
5989
6045
|
return __generator(this, function (_b) {
|
5990
6046
|
switch (_b.label) {
|
5991
6047
|
case 0:
|
@@ -6046,9 +6102,9 @@ var PerpetualsClient = (function () {
|
|
6046
6102
|
}
|
6047
6103
|
return [3, 7];
|
6048
6104
|
case 6:
|
6049
|
-
|
6050
|
-
console.log("perpClient forceClosePosition error:: ",
|
6051
|
-
throw
|
6105
|
+
err_40 = _b.sent();
|
6106
|
+
console.log("perpClient forceClosePosition error:: ", err_40);
|
6107
|
+
throw err_40;
|
6052
6108
|
case 7: return [2, {
|
6053
6109
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6054
6110
|
additionalSigners: additionalSigners
|
@@ -6061,7 +6117,7 @@ var PerpetualsClient = (function () {
|
|
6061
6117
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6062
6118
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6063
6119
|
return __awaiter(_this, void 0, void 0, function () {
|
6064
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder,
|
6120
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_41;
|
6065
6121
|
return __generator(this, function (_c) {
|
6066
6122
|
switch (_c.label) {
|
6067
6123
|
case 0:
|
@@ -6166,9 +6222,9 @@ var PerpetualsClient = (function () {
|
|
6166
6222
|
instructions.push(placeLimitOrder);
|
6167
6223
|
return [3, 11];
|
6168
6224
|
case 10:
|
6169
|
-
|
6170
|
-
console.log("perpClient placeLimitOrder error:: ",
|
6171
|
-
throw
|
6225
|
+
err_41 = _c.sent();
|
6226
|
+
console.log("perpClient placeLimitOrder error:: ", err_41);
|
6227
|
+
throw err_41;
|
6172
6228
|
case 11: return [2, {
|
6173
6229
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6174
6230
|
additionalSigners: additionalSigners
|
@@ -6181,7 +6237,7 @@ var PerpetualsClient = (function () {
|
|
6181
6237
|
if (createUserATA === void 0) { createUserATA = true; }
|
6182
6238
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6183
6239
|
return __awaiter(_this, void 0, void 0, function () {
|
6184
|
-
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder,
|
6240
|
+
var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_42;
|
6185
6241
|
return __generator(this, function (_b) {
|
6186
6242
|
switch (_b.label) {
|
6187
6243
|
case 0:
|
@@ -6269,9 +6325,9 @@ var PerpetualsClient = (function () {
|
|
6269
6325
|
instructions.push(editLimitOrder);
|
6270
6326
|
return [3, 8];
|
6271
6327
|
case 7:
|
6272
|
-
|
6273
|
-
console.log("perpClient editLimitOrder error:: ",
|
6274
|
-
throw
|
6328
|
+
err_42 = _b.sent();
|
6329
|
+
console.log("perpClient editLimitOrder error:: ", err_42);
|
6330
|
+
throw err_42;
|
6275
6331
|
case 8: return [2, {
|
6276
6332
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6277
6333
|
additionalSigners: additionalSigners
|
@@ -6285,7 +6341,7 @@ var PerpetualsClient = (function () {
|
|
6285
6341
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6286
6342
|
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6287
6343
|
return __awaiter(_this, void 0, void 0, function () {
|
6288
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder,
|
6344
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_43;
|
6289
6345
|
return __generator(this, function (_a) {
|
6290
6346
|
switch (_a.label) {
|
6291
6347
|
case 0:
|
@@ -6334,9 +6390,9 @@ var PerpetualsClient = (function () {
|
|
6334
6390
|
instructions.push(executeLimitOrder);
|
6335
6391
|
return [3, 4];
|
6336
6392
|
case 3:
|
6337
|
-
|
6338
|
-
console.log("perpClient executeLimitOrder error:: ",
|
6339
|
-
throw
|
6393
|
+
err_43 = _a.sent();
|
6394
|
+
console.log("perpClient executeLimitOrder error:: ", err_43);
|
6395
|
+
throw err_43;
|
6340
6396
|
case 4: return [2, {
|
6341
6397
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6342
6398
|
additionalSigners: additionalSigners
|
@@ -6350,7 +6406,7 @@ var PerpetualsClient = (function () {
|
|
6350
6406
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6351
6407
|
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6352
6408
|
return __awaiter(_this, void 0, void 0, function () {
|
6353
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap,
|
6409
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_44;
|
6354
6410
|
return __generator(this, function (_a) {
|
6355
6411
|
switch (_a.label) {
|
6356
6412
|
case 0:
|
@@ -6402,9 +6458,9 @@ var PerpetualsClient = (function () {
|
|
6402
6458
|
instructions.push(executeLimitWithSwap);
|
6403
6459
|
return [3, 4];
|
6404
6460
|
case 3:
|
6405
|
-
|
6406
|
-
console.log("perpClient executeLimitWithSwap error:: ",
|
6407
|
-
throw
|
6461
|
+
err_44 = _a.sent();
|
6462
|
+
console.log("perpClient executeLimitWithSwap error:: ", err_44);
|
6463
|
+
throw err_44;
|
6408
6464
|
case 4: return [2, {
|
6409
6465
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6410
6466
|
additionalSigners: additionalSigners
|
@@ -6414,7 +6470,7 @@ var PerpetualsClient = (function () {
|
|
6414
6470
|
});
|
6415
6471
|
};
|
6416
6472
|
this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6417
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder,
|
6473
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_45;
|
6418
6474
|
return __generator(this, function (_a) {
|
6419
6475
|
switch (_a.label) {
|
6420
6476
|
case 0:
|
@@ -6462,9 +6518,9 @@ var PerpetualsClient = (function () {
|
|
6462
6518
|
instructions.push(placeTriggerOrder);
|
6463
6519
|
return [3, 4];
|
6464
6520
|
case 3:
|
6465
|
-
|
6466
|
-
console.log("perpClient placeTriggerOrder error:: ",
|
6467
|
-
throw
|
6521
|
+
err_45 = _a.sent();
|
6522
|
+
console.log("perpClient placeTriggerOrder error:: ", err_45);
|
6523
|
+
throw err_45;
|
6468
6524
|
case 4: return [2, {
|
6469
6525
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6470
6526
|
additionalSigners: additionalSigners
|
@@ -6473,7 +6529,7 @@ var PerpetualsClient = (function () {
|
|
6473
6529
|
});
|
6474
6530
|
}); };
|
6475
6531
|
this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6476
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder,
|
6532
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_46;
|
6477
6533
|
return __generator(this, function (_a) {
|
6478
6534
|
switch (_a.label) {
|
6479
6535
|
case 0:
|
@@ -6520,9 +6576,9 @@ var PerpetualsClient = (function () {
|
|
6520
6576
|
instructions.push(editTriggerOrder);
|
6521
6577
|
return [3, 4];
|
6522
6578
|
case 3:
|
6523
|
-
|
6524
|
-
console.log("perpClient editTriggerOrder error:: ",
|
6525
|
-
throw
|
6579
|
+
err_46 = _a.sent();
|
6580
|
+
console.log("perpClient editTriggerOrder error:: ", err_46);
|
6581
|
+
throw err_46;
|
6526
6582
|
case 4: return [2, {
|
6527
6583
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6528
6584
|
additionalSigners: additionalSigners
|
@@ -6531,7 +6587,7 @@ var PerpetualsClient = (function () {
|
|
6531
6587
|
});
|
6532
6588
|
}); };
|
6533
6589
|
this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6534
|
-
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder,
|
6590
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_47;
|
6535
6591
|
return __generator(this, function (_a) {
|
6536
6592
|
switch (_a.label) {
|
6537
6593
|
case 0:
|
@@ -6564,9 +6620,51 @@ var PerpetualsClient = (function () {
|
|
6564
6620
|
instructions.push(cancelTriggerOrder);
|
6565
6621
|
return [3, 4];
|
6566
6622
|
case 3:
|
6567
|
-
|
6568
|
-
console.log("perpClient cancelTriggerOrder error:: ",
|
6569
|
-
throw
|
6623
|
+
err_47 = _a.sent();
|
6624
|
+
console.log("perpClient cancelTriggerOrder error:: ", err_47);
|
6625
|
+
throw err_47;
|
6626
|
+
case 4: return [2, {
|
6627
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6628
|
+
additionalSigners: additionalSigners
|
6629
|
+
}];
|
6630
|
+
}
|
6631
|
+
});
|
6632
|
+
}); };
|
6633
|
+
this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6634
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_48;
|
6635
|
+
return __generator(this, function (_a) {
|
6636
|
+
switch (_a.label) {
|
6637
|
+
case 0:
|
6638
|
+
publicKey = this.provider.wallet.publicKey;
|
6639
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
6640
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
6641
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
6642
|
+
preInstructions = [];
|
6643
|
+
instructions = [];
|
6644
|
+
postInstructions = [];
|
6645
|
+
additionalSigners = [];
|
6646
|
+
_a.label = 1;
|
6647
|
+
case 1:
|
6648
|
+
_a.trys.push([1, 3, , 4]);
|
6649
|
+
orderAccount = poolConfig.getOrderFromMarketPk(publicKey, marketAccount);
|
6650
|
+
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
6651
|
+
return [4, this.program.methods
|
6652
|
+
.cancelAllTriggerOrders()
|
6653
|
+
.accounts({
|
6654
|
+
position: positionAccount,
|
6655
|
+
order: orderAccount,
|
6656
|
+
eventAuthority: this.eventAuthority.publicKey,
|
6657
|
+
program: this.programId,
|
6658
|
+
})
|
6659
|
+
.instruction()];
|
6660
|
+
case 2:
|
6661
|
+
cancelAllTriggerOrders = _a.sent();
|
6662
|
+
instructions.push(cancelAllTriggerOrders);
|
6663
|
+
return [3, 4];
|
6664
|
+
case 3:
|
6665
|
+
err_48 = _a.sent();
|
6666
|
+
console.log("perpClient cancelAllTriggerOrders error:: ", err_48);
|
6667
|
+
throw err_48;
|
6570
6668
|
case 4: return [2, {
|
6571
6669
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6572
6670
|
additionalSigners: additionalSigners
|
@@ -6581,7 +6679,7 @@ var PerpetualsClient = (function () {
|
|
6581
6679
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6582
6680
|
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6583
6681
|
return __awaiter(_this, void 0, void 0, function () {
|
6584
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap,
|
6682
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_49;
|
6585
6683
|
return __generator(this, function (_d) {
|
6586
6684
|
switch (_d.label) {
|
6587
6685
|
case 0:
|
@@ -6678,9 +6776,9 @@ var PerpetualsClient = (function () {
|
|
6678
6776
|
instructions.push(executeTriggerWithSwap);
|
6679
6777
|
return [3, 10];
|
6680
6778
|
case 9:
|
6681
|
-
|
6682
|
-
console.log("perpClient executeTriggerWithSwap error:: ",
|
6683
|
-
throw
|
6779
|
+
err_49 = _d.sent();
|
6780
|
+
console.log("perpClient executeTriggerWithSwap error:: ", err_49);
|
6781
|
+
throw err_49;
|
6684
6782
|
case 10: return [2, {
|
6685
6783
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6686
6784
|
additionalSigners: additionalSigners
|
@@ -6696,7 +6794,7 @@ var PerpetualsClient = (function () {
|
|
6696
6794
|
if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
|
6697
6795
|
if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
|
6698
6796
|
return __awaiter(_this, void 0, void 0, function () {
|
6699
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder,
|
6797
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_50;
|
6700
6798
|
return __generator(this, function (_b) {
|
6701
6799
|
switch (_b.label) {
|
6702
6800
|
case 0:
|
@@ -6762,9 +6860,9 @@ var PerpetualsClient = (function () {
|
|
6762
6860
|
instructions.push(executeTriggerOrder);
|
6763
6861
|
return [3, 8];
|
6764
6862
|
case 7:
|
6765
|
-
|
6766
|
-
console.log("perpClient executeTriggerOrder error:: ",
|
6767
|
-
throw
|
6863
|
+
err_50 = _b.sent();
|
6864
|
+
console.log("perpClient executeTriggerOrder error:: ", err_50);
|
6865
|
+
throw err_50;
|
6768
6866
|
case 8: return [2, {
|
6769
6867
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6770
6868
|
additionalSigners: additionalSigners
|
@@ -6774,7 +6872,7 @@ var PerpetualsClient = (function () {
|
|
6774
6872
|
});
|
6775
6873
|
};
|
6776
6874
|
this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6777
|
-
var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder,
|
6875
|
+
var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_51;
|
6778
6876
|
return __generator(this, function (_a) {
|
6779
6877
|
switch (_a.label) {
|
6780
6878
|
case 0:
|
@@ -6804,9 +6902,9 @@ var PerpetualsClient = (function () {
|
|
6804
6902
|
instructions.push(migrateTriggerOrder);
|
6805
6903
|
return [3, 4];
|
6806
6904
|
case 3:
|
6807
|
-
|
6808
|
-
console.log("perpClient migrateTriggerOrder error:: ",
|
6809
|
-
throw
|
6905
|
+
err_51 = _a.sent();
|
6906
|
+
console.log("perpClient migrateTriggerOrder error:: ", err_51);
|
6907
|
+
throw err_51;
|
6810
6908
|
case 4: return [2, {
|
6811
6909
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6812
6910
|
additionalSigners: additionalSigners
|
@@ -6815,7 +6913,7 @@ var PerpetualsClient = (function () {
|
|
6815
6913
|
});
|
6816
6914
|
}); };
|
6817
6915
|
this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6818
|
-
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData,
|
6916
|
+
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_52;
|
6819
6917
|
return __generator(this, function (_a) {
|
6820
6918
|
switch (_a.label) {
|
6821
6919
|
case 0:
|
@@ -6844,15 +6942,15 @@ var PerpetualsClient = (function () {
|
|
6844
6942
|
console.log(getPositionData);
|
6845
6943
|
return [2, getPositionData];
|
6846
6944
|
case 3:
|
6847
|
-
|
6848
|
-
console.log("perpClient setPool error:: ",
|
6849
|
-
throw
|
6945
|
+
err_52 = _a.sent();
|
6946
|
+
console.log("perpClient setPool error:: ", err_52);
|
6947
|
+
throw err_52;
|
6850
6948
|
case 4: return [2];
|
6851
6949
|
}
|
6852
6950
|
});
|
6853
6951
|
}); };
|
6854
6952
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6855
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
6953
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_53;
|
6856
6954
|
return __generator(this, function (_a) {
|
6857
6955
|
switch (_a.label) {
|
6858
6956
|
case 0:
|
@@ -6885,9 +6983,9 @@ var PerpetualsClient = (function () {
|
|
6885
6983
|
instructions.push(withdrawFeesIx);
|
6886
6984
|
return [3, 5];
|
6887
6985
|
case 4:
|
6888
|
-
|
6889
|
-
console.log("perpClient setPool error:: ",
|
6890
|
-
throw
|
6986
|
+
err_53 = _a.sent();
|
6987
|
+
console.log("perpClient setPool error:: ", err_53);
|
6988
|
+
throw err_53;
|
6891
6989
|
case 5: return [2, {
|
6892
6990
|
instructions: __spreadArray([], instructions, true),
|
6893
6991
|
additionalSigners: additionalSigners
|
@@ -6896,7 +6994,7 @@ var PerpetualsClient = (function () {
|
|
6896
6994
|
});
|
6897
6995
|
}); };
|
6898
6996
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
6899
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
6997
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_54;
|
6900
6998
|
return __generator(this, function (_a) {
|
6901
6999
|
switch (_a.label) {
|
6902
7000
|
case 0:
|
@@ -6923,9 +7021,9 @@ var PerpetualsClient = (function () {
|
|
6923
7021
|
instructions.push(setPermissionsInstruction);
|
6924
7022
|
return [3, 4];
|
6925
7023
|
case 3:
|
6926
|
-
|
6927
|
-
console.log("perpClient setPool error:: ",
|
6928
|
-
throw
|
7024
|
+
err_54 = _a.sent();
|
7025
|
+
console.log("perpClient setPool error:: ", err_54);
|
7026
|
+
throw err_54;
|
6929
7027
|
case 4: return [2, {
|
6930
7028
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
6931
7029
|
additionalSigners: additionalSigners
|
@@ -6934,7 +7032,7 @@ var PerpetualsClient = (function () {
|
|
6934
7032
|
});
|
6935
7033
|
}); };
|
6936
7034
|
this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6937
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e,
|
7035
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_55;
|
6938
7036
|
var _f;
|
6939
7037
|
return __generator(this, function (_g) {
|
6940
7038
|
switch (_g.label) {
|
@@ -6994,9 +7092,9 @@ var PerpetualsClient = (function () {
|
|
6994
7092
|
instructions.push(reimburse);
|
6995
7093
|
return [3, 5];
|
6996
7094
|
case 4:
|
6997
|
-
|
6998
|
-
console.log("perpClient setPool error:: ",
|
6999
|
-
throw
|
7095
|
+
err_55 = _g.sent();
|
7096
|
+
console.log("perpClient setPool error:: ", err_55);
|
7097
|
+
throw err_55;
|
7000
7098
|
case 5: return [2, {
|
7001
7099
|
instructions: __spreadArray([], instructions, true),
|
7002
7100
|
additionalSigners: additionalSigners
|
@@ -7005,7 +7103,7 @@ var PerpetualsClient = (function () {
|
|
7005
7103
|
});
|
7006
7104
|
}); };
|
7007
7105
|
this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7008
|
-
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice,
|
7106
|
+
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_56;
|
7009
7107
|
return __generator(this, function (_a) {
|
7010
7108
|
switch (_a.label) {
|
7011
7109
|
case 0:
|
@@ -7038,9 +7136,9 @@ var PerpetualsClient = (function () {
|
|
7038
7136
|
instructions.push(setInternalOraclePrice);
|
7039
7137
|
return [3, 4];
|
7040
7138
|
case 3:
|
7041
|
-
|
7042
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
7043
|
-
throw
|
7139
|
+
err_56 = _a.sent();
|
7140
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_56);
|
7141
|
+
throw err_56;
|
7044
7142
|
case 4: return [2, {
|
7045
7143
|
instructions: __spreadArray([], instructions, true),
|
7046
7144
|
additionalSigners: additionalSigners
|
@@ -7052,7 +7150,7 @@ var PerpetualsClient = (function () {
|
|
7052
7150
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
7053
7151
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7054
7152
|
return __awaiter(_this, void 0, void 0, function () {
|
7055
|
-
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,
|
7153
|
+
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_57;
|
7056
7154
|
return __generator(this, function (_e) {
|
7057
7155
|
switch (_e.label) {
|
7058
7156
|
case 0:
|
@@ -7175,8 +7273,8 @@ var PerpetualsClient = (function () {
|
|
7175
7273
|
instructions.push(addCompoundingLiquidity);
|
7176
7274
|
return [3, 10];
|
7177
7275
|
case 9:
|
7178
|
-
|
7179
|
-
console.log("perpClient addCompoundingLiquidity error:: ",
|
7276
|
+
err_57 = _e.sent();
|
7277
|
+
console.log("perpClient addCompoundingLiquidity error:: ", err_57);
|
7180
7278
|
return [3, 10];
|
7181
7279
|
case 10: return [2, {
|
7182
7280
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7190,7 +7288,7 @@ var PerpetualsClient = (function () {
|
|
7190
7288
|
if (createUserATA === void 0) { createUserATA = true; }
|
7191
7289
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
7192
7290
|
return __awaiter(_this, void 0, void 0, function () {
|
7193
|
-
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,
|
7291
|
+
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_58;
|
7194
7292
|
return __generator(this, function (_e) {
|
7195
7293
|
switch (_e.label) {
|
7196
7294
|
case 0:
|
@@ -7297,8 +7395,8 @@ var PerpetualsClient = (function () {
|
|
7297
7395
|
instructions.push(removeCompoundingLiquidity);
|
7298
7396
|
return [3, 8];
|
7299
7397
|
case 7:
|
7300
|
-
|
7301
|
-
console.log("perpClient removeCompoundingLiquidity error:: ",
|
7398
|
+
err_58 = _e.sent();
|
7399
|
+
console.log("perpClient removeCompoundingLiquidity error:: ", err_58);
|
7302
7400
|
return [3, 8];
|
7303
7401
|
case 8: return [2, {
|
7304
7402
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7311,9 +7409,9 @@ var PerpetualsClient = (function () {
|
|
7311
7409
|
this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
7312
7410
|
if (createUserATA === void 0) { createUserATA = true; }
|
7313
7411
|
return __awaiter(_this, void 0, void 0, function () {
|
7314
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i,
|
7315
|
-
return __generator(this, function (
|
7316
|
-
switch (
|
7412
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, migrateStake, err_59;
|
7413
|
+
return __generator(this, function (_f) {
|
7414
|
+
switch (_f.label) {
|
7317
7415
|
case 0:
|
7318
7416
|
publicKey = this.provider.wallet.publicKey;
|
7319
7417
|
preInstructions = [];
|
@@ -7328,19 +7426,35 @@ var PerpetualsClient = (function () {
|
|
7328
7426
|
if (!_a) return [3, 2];
|
7329
7427
|
return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
|
7330
7428
|
case 1:
|
7331
|
-
_a = !(
|
7332
|
-
|
7429
|
+
_a = !(_f.sent());
|
7430
|
+
_f.label = 2;
|
7333
7431
|
case 2:
|
7334
7432
|
if (_a) {
|
7335
7433
|
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
|
7336
7434
|
}
|
7337
7435
|
flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
|
7436
|
+
tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
|
7437
|
+
tokenStakeAccounts = [];
|
7438
|
+
_b = tokenStakeAccount;
|
7439
|
+
if (!_b) return [3, 4];
|
7440
|
+
return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
|
7441
|
+
case 3:
|
7442
|
+
_b = (_f.sent());
|
7443
|
+
_f.label = 4;
|
7444
|
+
case 4:
|
7445
|
+
if (_b) {
|
7446
|
+
tokenStakeAccounts.push({
|
7447
|
+
pubkey: tokenStakeAccount,
|
7448
|
+
isSigner: false,
|
7449
|
+
isWritable: true,
|
7450
|
+
});
|
7451
|
+
}
|
7338
7452
|
poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
|
7339
7453
|
custodyAccountMetas = [];
|
7340
7454
|
custodyOracleAccountMetas = [];
|
7341
7455
|
markets = [];
|
7342
|
-
for (_i = 0,
|
7343
|
-
custody =
|
7456
|
+
for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
|
7457
|
+
custody = _c[_i];
|
7344
7458
|
custodyAccountMetas.push({
|
7345
7459
|
pubkey: custody.custodyAccount,
|
7346
7460
|
isSigner: false,
|
@@ -7352,17 +7466,17 @@ var PerpetualsClient = (function () {
|
|
7352
7466
|
isWritable: false,
|
7353
7467
|
});
|
7354
7468
|
}
|
7355
|
-
for (
|
7356
|
-
market = _d
|
7469
|
+
for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
|
7470
|
+
market = _e[_d];
|
7357
7471
|
markets.push({
|
7358
7472
|
pubkey: market.marketAccount,
|
7359
7473
|
isSigner: false,
|
7360
7474
|
isWritable: false,
|
7361
7475
|
});
|
7362
7476
|
}
|
7363
|
-
|
7364
|
-
case
|
7365
|
-
|
7477
|
+
_f.label = 5;
|
7478
|
+
case 5:
|
7479
|
+
_f.trys.push([5, 7, , 8]);
|
7366
7480
|
return [4, this.program.methods
|
7367
7481
|
.migrateStake({
|
7368
7482
|
amount: amount
|
@@ -7385,17 +7499,17 @@ var PerpetualsClient = (function () {
|
|
7385
7499
|
program: this.program.programId,
|
7386
7500
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
7387
7501
|
})
|
7388
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
7502
|
+
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
|
7389
7503
|
.instruction()];
|
7390
|
-
case
|
7391
|
-
migrateStake =
|
7504
|
+
case 6:
|
7505
|
+
migrateStake = _f.sent();
|
7392
7506
|
instructions.push(migrateStake);
|
7393
|
-
return [3,
|
7394
|
-
case
|
7395
|
-
|
7396
|
-
console.log("perpClient migrateStake error:: ",
|
7397
|
-
return [3,
|
7398
|
-
case
|
7507
|
+
return [3, 8];
|
7508
|
+
case 7:
|
7509
|
+
err_59 = _f.sent();
|
7510
|
+
console.log("perpClient migrateStake error:: ", err_59);
|
7511
|
+
return [3, 8];
|
7512
|
+
case 8: return [2, {
|
7399
7513
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
7400
7514
|
additionalSigners: additionalSigners
|
7401
7515
|
}];
|
@@ -7404,7 +7518,7 @@ var PerpetualsClient = (function () {
|
|
7404
7518
|
});
|
7405
7519
|
};
|
7406
7520
|
this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7407
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp,
|
7521
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_60;
|
7408
7522
|
return __generator(this, function (_d) {
|
7409
7523
|
switch (_d.label) {
|
7410
7524
|
case 0:
|
@@ -7476,8 +7590,8 @@ var PerpetualsClient = (function () {
|
|
7476
7590
|
instructions.push(migrateFlp);
|
7477
7591
|
return [3, 4];
|
7478
7592
|
case 3:
|
7479
|
-
|
7480
|
-
console.log("perpClient migrateFlp error:: ",
|
7593
|
+
err_60 = _d.sent();
|
7594
|
+
console.log("perpClient migrateFlp error:: ", err_60);
|
7481
7595
|
return [3, 4];
|
7482
7596
|
case 4: return [2, {
|
7483
7597
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -7489,7 +7603,7 @@ var PerpetualsClient = (function () {
|
|
7489
7603
|
this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
|
7490
7604
|
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
7491
7605
|
return __awaiter(_this, void 0, void 0, function () {
|
7492
|
-
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee,
|
7606
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_61;
|
7493
7607
|
return __generator(this, function (_d) {
|
7494
7608
|
switch (_d.label) {
|
7495
7609
|
case 0:
|
@@ -7546,8 +7660,8 @@ var PerpetualsClient = (function () {
|
|
7546
7660
|
instructions.push(compoundingFee);
|
7547
7661
|
return [3, 4];
|
7548
7662
|
case 3:
|
7549
|
-
|
7550
|
-
console.log("perpClient compoundingFee error:: ",
|
7663
|
+
err_61 = _d.sent();
|
7664
|
+
console.log("perpClient compoundingFee error:: ", err_61);
|
7551
7665
|
return [3, 4];
|
7552
7666
|
case 4: return [2, {
|
7553
7667
|
instructions: __spreadArray([], instructions, true),
|
@@ -7558,7 +7672,7 @@ var PerpetualsClient = (function () {
|
|
7558
7672
|
});
|
7559
7673
|
};
|
7560
7674
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
7561
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
7675
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_62;
|
7562
7676
|
return __generator(this, function (_a) {
|
7563
7677
|
switch (_a.label) {
|
7564
7678
|
case 0:
|
@@ -7596,8 +7710,8 @@ var PerpetualsClient = (function () {
|
|
7596
7710
|
instructions.push(renameFlp);
|
7597
7711
|
return [3, 4];
|
7598
7712
|
case 3:
|
7599
|
-
|
7600
|
-
console.log("perpClient renameFlp error:: ",
|
7713
|
+
err_62 = _a.sent();
|
7714
|
+
console.log("perpClient renameFlp error:: ", err_62);
|
7601
7715
|
return [3, 4];
|
7602
7716
|
case 4: return [2, {
|
7603
7717
|
instructions: __spreadArray([], instructions, true),
|