flash-sdk 2.18.2 → 2.19.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/PerpetualsClient.d.ts +8 -0
- package/dist/PerpetualsClient.js +247 -73
- package/dist/idl/perpetuals.d.ts +491 -1
- package/dist/idl/perpetuals.js +491 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/utils/alt.d.ts +1 -0
- package/package.json +1 -1
@@ -4106,6 +4106,10 @@ export declare class PerpetualsClient {
|
|
4106
4106
|
instructions: TransactionInstruction[];
|
4107
4107
|
additionalSigners: Signer[];
|
4108
4108
|
}>;
|
4109
|
+
executeLimitWithSwap: (userPubkey: PublicKey, targetSymbol: string, collateralSymbol: string, reserveSymbol: string, side: Side, orderId: number, poolConfig: PoolConfig, privilege: Privilege, nftTradingAccount?: PublicKey, nftReferralAccount?: PublicKey, nftRebateTokenAccount?: PublicKey) => Promise<{
|
4110
|
+
instructions: TransactionInstruction[];
|
4111
|
+
additionalSigners: Signer[];
|
4112
|
+
}>;
|
4109
4113
|
placeTriggerOrder: (targetSymbol: string, collateralSymbol: string, side: Side, triggerPrice: ContractOraclePrice, deltaSizeAmount: BN, isStopLoss: boolean, receiveCustodyId: number, poolConfig: PoolConfig) => Promise<{
|
4110
4114
|
instructions: TransactionInstruction[];
|
4111
4115
|
additionalSigners: Signer[];
|
@@ -4118,6 +4122,10 @@ export declare class PerpetualsClient {
|
|
4118
4122
|
instructions: TransactionInstruction[];
|
4119
4123
|
additionalSigners: Signer[];
|
4120
4124
|
}>;
|
4125
|
+
executeTriggerWithSwap: (owner: PublicKey, targetSymbol: string, collateralSymbol: string, receivingSymbol: string, side: Side, orderId: number, isStopLoss: boolean, poolConfig: PoolConfig, createUserATA?: boolean, ephemeralSignerPubkey?: any) => Promise<{
|
4126
|
+
instructions: TransactionInstruction[];
|
4127
|
+
additionalSigners: Signer[];
|
4128
|
+
}>;
|
4121
4129
|
executeTriggerOrder: (owner: PublicKey, targetSymbol: string, collateralSymbol: string, side: Side, orderId: number, isStopLoss: boolean, poolConfig: PoolConfig, createUserATA?: boolean, ephemeralSignerPubkey?: any) => Promise<{
|
4122
4130
|
instructions: TransactionInstruction[];
|
4123
4131
|
additionalSigners: Signer[];
|
package/dist/PerpetualsClient.js
CHANGED
@@ -5583,8 +5583,72 @@ var PerpetualsClient = (function () {
|
|
5583
5583
|
});
|
5584
5584
|
});
|
5585
5585
|
};
|
5586
|
+
this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
|
5587
|
+
if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
|
5588
|
+
if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
|
5589
|
+
if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
|
5590
|
+
return __awaiter(_this, void 0, void 0, function () {
|
5591
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_28;
|
5592
|
+
return __generator(this, function (_a) {
|
5593
|
+
switch (_a.label) {
|
5594
|
+
case 0:
|
5595
|
+
publicKey = this.provider.wallet.publicKey;
|
5596
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
5597
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
5598
|
+
reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
|
5599
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
5600
|
+
preInstructions = [];
|
5601
|
+
instructions = [];
|
5602
|
+
postInstructions = [];
|
5603
|
+
additionalSigners = [];
|
5604
|
+
_a.label = 1;
|
5605
|
+
case 1:
|
5606
|
+
_a.trys.push([1, 3, , 4]);
|
5607
|
+
positionAccount = poolConfig.getPositionFromMarketPk(userPubkey, marketAccount);
|
5608
|
+
orderAccount = poolConfig.getOrderFromMarketPk(userPubkey, marketAccount);
|
5609
|
+
return [4, this.program.methods
|
5610
|
+
.executeLimitWithSwap({
|
5611
|
+
orderId: orderId,
|
5612
|
+
privilege: privilege
|
5613
|
+
})
|
5614
|
+
.accounts({
|
5615
|
+
feePayer: publicKey,
|
5616
|
+
perpetuals: poolConfig.perpetuals,
|
5617
|
+
pool: poolConfig.poolAddress,
|
5618
|
+
reserveCustody: reserveCustodyConfig.custodyAccount,
|
5619
|
+
reserveCustodyOracleAccount: this.useExtOracleAccount ? reserveCustodyConfig.extOracleAccount : reserveCustodyConfig.intOracleAccount,
|
5620
|
+
position: positionAccount,
|
5621
|
+
order: orderAccount,
|
5622
|
+
market: marketAccount,
|
5623
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
5624
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
5625
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
5626
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
5627
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
5628
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5629
|
+
eventAuthority: this.eventAuthority.publicKey,
|
5630
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
5631
|
+
})
|
5632
|
+
.remainingAccounts(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true))
|
5633
|
+
.instruction()];
|
5634
|
+
case 2:
|
5635
|
+
executeLimitWithSwap = _a.sent();
|
5636
|
+
instructions.push(executeLimitWithSwap);
|
5637
|
+
return [3, 4];
|
5638
|
+
case 3:
|
5639
|
+
err_28 = _a.sent();
|
5640
|
+
console.log("perpClient executeLimitWithSwap error:: ", err_28);
|
5641
|
+
throw err_28;
|
5642
|
+
case 4: return [2, {
|
5643
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5644
|
+
additionalSigners: additionalSigners
|
5645
|
+
}];
|
5646
|
+
}
|
5647
|
+
});
|
5648
|
+
});
|
5649
|
+
};
|
5586
5650
|
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,
|
5651
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_29;
|
5588
5652
|
return __generator(this, function (_a) {
|
5589
5653
|
switch (_a.label) {
|
5590
5654
|
case 0:
|
@@ -5631,9 +5695,9 @@ var PerpetualsClient = (function () {
|
|
5631
5695
|
instructions.push(placeTriggerOrder);
|
5632
5696
|
return [3, 4];
|
5633
5697
|
case 3:
|
5634
|
-
|
5635
|
-
console.log("perpClient placeTriggerOrder error:: ",
|
5636
|
-
throw
|
5698
|
+
err_29 = _a.sent();
|
5699
|
+
console.log("perpClient placeTriggerOrder error:: ", err_29);
|
5700
|
+
throw err_29;
|
5637
5701
|
case 4: return [2, {
|
5638
5702
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5639
5703
|
additionalSigners: additionalSigners
|
@@ -5642,7 +5706,7 @@ var PerpetualsClient = (function () {
|
|
5642
5706
|
});
|
5643
5707
|
}); };
|
5644
5708
|
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,
|
5709
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_30;
|
5646
5710
|
return __generator(this, function (_a) {
|
5647
5711
|
switch (_a.label) {
|
5648
5712
|
case 0:
|
@@ -5687,9 +5751,9 @@ var PerpetualsClient = (function () {
|
|
5687
5751
|
instructions.push(editTriggerOrder);
|
5688
5752
|
return [3, 4];
|
5689
5753
|
case 3:
|
5690
|
-
|
5691
|
-
console.log("perpClient editTriggerOrder error:: ",
|
5692
|
-
throw
|
5754
|
+
err_30 = _a.sent();
|
5755
|
+
console.log("perpClient editTriggerOrder error:: ", err_30);
|
5756
|
+
throw err_30;
|
5693
5757
|
case 4: return [2, {
|
5694
5758
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5695
5759
|
additionalSigners: additionalSigners
|
@@ -5698,7 +5762,7 @@ var PerpetualsClient = (function () {
|
|
5698
5762
|
});
|
5699
5763
|
}); };
|
5700
5764
|
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,
|
5765
|
+
var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_31;
|
5702
5766
|
return __generator(this, function (_a) {
|
5703
5767
|
switch (_a.label) {
|
5704
5768
|
case 0:
|
@@ -5731,9 +5795,9 @@ var PerpetualsClient = (function () {
|
|
5731
5795
|
instructions.push(cancelTriggerOrder);
|
5732
5796
|
return [3, 4];
|
5733
5797
|
case 3:
|
5734
|
-
|
5735
|
-
console.log("perpClient cancelTriggerOrder error:: ",
|
5736
|
-
throw
|
5798
|
+
err_31 = _a.sent();
|
5799
|
+
console.log("perpClient cancelTriggerOrder error:: ", err_31);
|
5800
|
+
throw err_31;
|
5737
5801
|
case 4: return [2, {
|
5738
5802
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5739
5803
|
additionalSigners: additionalSigners
|
@@ -5741,11 +5805,121 @@ var PerpetualsClient = (function () {
|
|
5741
5805
|
}
|
5742
5806
|
});
|
5743
5807
|
}); };
|
5808
|
+
this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
5809
|
+
if (createUserATA === void 0) { createUserATA = true; }
|
5810
|
+
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5811
|
+
return __awaiter(_this, void 0, void 0, function () {
|
5812
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_32;
|
5813
|
+
return __generator(this, function (_d) {
|
5814
|
+
switch (_d.label) {
|
5815
|
+
case 0:
|
5816
|
+
payerPubkey = this.provider.wallet.publicKey;
|
5817
|
+
targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
|
5818
|
+
collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
|
5819
|
+
receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey); });
|
5820
|
+
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
5821
|
+
preInstructions = [];
|
5822
|
+
instructions = [];
|
5823
|
+
postInstructions = [];
|
5824
|
+
additionalSigners = [];
|
5825
|
+
_d.label = 1;
|
5826
|
+
case 1:
|
5827
|
+
_d.trys.push([1, 9, , 10]);
|
5828
|
+
if (!false) return [3, 2];
|
5829
|
+
return [3, 7];
|
5830
|
+
case 2:
|
5831
|
+
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey, owner, true);
|
5832
|
+
_a = createUserATA;
|
5833
|
+
if (!_a) return [3, 4];
|
5834
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
|
5835
|
+
case 3:
|
5836
|
+
_a = !(_d.sent());
|
5837
|
+
_d.label = 4;
|
5838
|
+
case 4:
|
5839
|
+
if (_a) {
|
5840
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
|
5841
|
+
}
|
5842
|
+
userReceivingTokenAccountCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, owner, true);
|
5843
|
+
_b = createUserATA;
|
5844
|
+
if (!_b) return [3, 6];
|
5845
|
+
return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
|
5846
|
+
case 5:
|
5847
|
+
_b = !(_d.sent());
|
5848
|
+
_d.label = 6;
|
5849
|
+
case 6:
|
5850
|
+
if (_b) {
|
5851
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
|
5852
|
+
}
|
5853
|
+
_d.label = 7;
|
5854
|
+
case 7:
|
5855
|
+
positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
|
5856
|
+
orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
|
5857
|
+
custodyAccountMetas = [];
|
5858
|
+
custodyOracleAccountMetas = [];
|
5859
|
+
for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
|
5860
|
+
custody = _c[_i];
|
5861
|
+
custodyAccountMetas.push({
|
5862
|
+
pubkey: custody.custodyAccount,
|
5863
|
+
isSigner: false,
|
5864
|
+
isWritable: false,
|
5865
|
+
});
|
5866
|
+
custodyOracleAccountMetas.push({
|
5867
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
5868
|
+
isSigner: false,
|
5869
|
+
isWritable: false,
|
5870
|
+
});
|
5871
|
+
}
|
5872
|
+
return [4, this.program.methods
|
5873
|
+
.executeTriggerWithSwap({
|
5874
|
+
isStopLoss: isStopLoss,
|
5875
|
+
orderId: orderId
|
5876
|
+
})
|
5877
|
+
.accounts({
|
5878
|
+
feePayer: payerPubkey,
|
5879
|
+
receivingAccount: userReceivingTokenAccount,
|
5880
|
+
receivingAccountCollateral: userReceivingTokenAccountCollateral,
|
5881
|
+
transferAuthority: poolConfig.transferAuthority,
|
5882
|
+
perpetuals: poolConfig.perpetuals,
|
5883
|
+
pool: poolConfig.poolAddress,
|
5884
|
+
position: positionAccount,
|
5885
|
+
order: orderAccount,
|
5886
|
+
market: marketAccount,
|
5887
|
+
targetCustody: targetCustodyConfig.custodyAccount,
|
5888
|
+
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
5889
|
+
collateralCustody: collateralCustodyConfig.custodyAccount,
|
5890
|
+
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
5891
|
+
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
5892
|
+
receivingCustody: receivingCustodyConfig.custodyAccount,
|
5893
|
+
receivingOracleAccount: this.useExtOracleAccount ? receivingCustodyConfig.extOracleAccount : receivingCustodyConfig.intOracleAccount,
|
5894
|
+
receivingCustodyTokenAccount: receivingCustodyConfig.tokenAccount,
|
5895
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
5896
|
+
eventAuthority: this.eventAuthority.publicKey,
|
5897
|
+
program: this.programId,
|
5898
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
5899
|
+
})
|
5900
|
+
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
5901
|
+
.instruction()];
|
5902
|
+
case 8:
|
5903
|
+
executeTriggerWithSwap = _d.sent();
|
5904
|
+
instructions.push(executeTriggerWithSwap);
|
5905
|
+
return [3, 10];
|
5906
|
+
case 9:
|
5907
|
+
err_32 = _d.sent();
|
5908
|
+
console.log("perpClient executeTriggerWithSwap error:: ", err_32);
|
5909
|
+
throw err_32;
|
5910
|
+
case 10: return [2, {
|
5911
|
+
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5912
|
+
additionalSigners: additionalSigners
|
5913
|
+
}];
|
5914
|
+
}
|
5915
|
+
});
|
5916
|
+
});
|
5917
|
+
};
|
5744
5918
|
this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
|
5745
5919
|
if (createUserATA === void 0) { createUserATA = true; }
|
5746
5920
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
5747
5921
|
return __awaiter(_this, void 0, void 0, function () {
|
5748
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder,
|
5922
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_33;
|
5749
5923
|
return __generator(this, function (_b) {
|
5750
5924
|
switch (_b.label) {
|
5751
5925
|
case 0:
|
@@ -5808,9 +5982,9 @@ var PerpetualsClient = (function () {
|
|
5808
5982
|
instructions.push(executeTriggerOrder);
|
5809
5983
|
return [3, 8];
|
5810
5984
|
case 7:
|
5811
|
-
|
5812
|
-
console.log("perpClient executeTriggerOrder error:: ",
|
5813
|
-
throw
|
5985
|
+
err_33 = _b.sent();
|
5986
|
+
console.log("perpClient executeTriggerOrder error:: ", err_33);
|
5987
|
+
throw err_33;
|
5814
5988
|
case 8: return [2, {
|
5815
5989
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5816
5990
|
additionalSigners: additionalSigners
|
@@ -5820,7 +5994,7 @@ var PerpetualsClient = (function () {
|
|
5820
5994
|
});
|
5821
5995
|
};
|
5822
5996
|
this.migrateTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5823
|
-
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder,
|
5997
|
+
var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_34;
|
5824
5998
|
return __generator(this, function (_a) {
|
5825
5999
|
switch (_a.label) {
|
5826
6000
|
case 0:
|
@@ -5853,9 +6027,9 @@ var PerpetualsClient = (function () {
|
|
5853
6027
|
instructions.push(migrateTriggerOrder);
|
5854
6028
|
return [3, 4];
|
5855
6029
|
case 3:
|
5856
|
-
|
5857
|
-
console.log("perpClient migrateTriggerOrder error:: ",
|
5858
|
-
throw
|
6030
|
+
err_34 = _a.sent();
|
6031
|
+
console.log("perpClient migrateTriggerOrder error:: ", err_34);
|
6032
|
+
throw err_34;
|
5859
6033
|
case 4: return [2, {
|
5860
6034
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5861
6035
|
additionalSigners: additionalSigners
|
@@ -5864,7 +6038,7 @@ var PerpetualsClient = (function () {
|
|
5864
6038
|
});
|
5865
6039
|
}); };
|
5866
6040
|
this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5867
|
-
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData,
|
6041
|
+
var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_35;
|
5868
6042
|
return __generator(this, function (_a) {
|
5869
6043
|
switch (_a.label) {
|
5870
6044
|
case 0:
|
@@ -5893,15 +6067,15 @@ var PerpetualsClient = (function () {
|
|
5893
6067
|
console.log(getPositionData);
|
5894
6068
|
return [2, getPositionData];
|
5895
6069
|
case 3:
|
5896
|
-
|
5897
|
-
console.log("perpClient setPool error:: ",
|
5898
|
-
throw
|
6070
|
+
err_35 = _a.sent();
|
6071
|
+
console.log("perpClient setPool error:: ", err_35);
|
6072
|
+
throw err_35;
|
5899
6073
|
case 4: return [2];
|
5900
6074
|
}
|
5901
6075
|
});
|
5902
6076
|
}); };
|
5903
6077
|
this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
5904
|
-
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx,
|
6078
|
+
var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_36;
|
5905
6079
|
return __generator(this, function (_a) {
|
5906
6080
|
switch (_a.label) {
|
5907
6081
|
case 0:
|
@@ -5934,9 +6108,9 @@ var PerpetualsClient = (function () {
|
|
5934
6108
|
instructions.push(withdrawFeesIx);
|
5935
6109
|
return [3, 5];
|
5936
6110
|
case 4:
|
5937
|
-
|
5938
|
-
console.log("perpClient setPool error:: ",
|
5939
|
-
throw
|
6111
|
+
err_36 = _a.sent();
|
6112
|
+
console.log("perpClient setPool error:: ", err_36);
|
6113
|
+
throw err_36;
|
5940
6114
|
case 5: return [2, {
|
5941
6115
|
instructions: __spreadArray([], instructions, true),
|
5942
6116
|
additionalSigners: additionalSigners
|
@@ -5945,7 +6119,7 @@ var PerpetualsClient = (function () {
|
|
5945
6119
|
});
|
5946
6120
|
}); };
|
5947
6121
|
this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
|
5948
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction,
|
6122
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_37;
|
5949
6123
|
return __generator(this, function (_a) {
|
5950
6124
|
switch (_a.label) {
|
5951
6125
|
case 0:
|
@@ -5972,9 +6146,9 @@ var PerpetualsClient = (function () {
|
|
5972
6146
|
instructions.push(setPermissionsInstruction);
|
5973
6147
|
return [3, 4];
|
5974
6148
|
case 3:
|
5975
|
-
|
5976
|
-
console.log("perpClient setPool error:: ",
|
5977
|
-
throw
|
6149
|
+
err_37 = _a.sent();
|
6150
|
+
console.log("perpClient setPool error:: ", err_37);
|
6151
|
+
throw err_37;
|
5978
6152
|
case 4: return [2, {
|
5979
6153
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
5980
6154
|
additionalSigners: additionalSigners
|
@@ -5983,7 +6157,7 @@ var PerpetualsClient = (function () {
|
|
5983
6157
|
});
|
5984
6158
|
}); };
|
5985
6159
|
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,
|
6160
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_38;
|
5987
6161
|
var _f;
|
5988
6162
|
return __generator(this, function (_g) {
|
5989
6163
|
switch (_g.label) {
|
@@ -6043,9 +6217,9 @@ var PerpetualsClient = (function () {
|
|
6043
6217
|
instructions.push(reimburse);
|
6044
6218
|
return [3, 5];
|
6045
6219
|
case 4:
|
6046
|
-
|
6047
|
-
console.log("perpClient setPool error:: ",
|
6048
|
-
throw
|
6220
|
+
err_38 = _g.sent();
|
6221
|
+
console.log("perpClient setPool error:: ", err_38);
|
6222
|
+
throw err_38;
|
6049
6223
|
case 5: return [2, {
|
6050
6224
|
instructions: __spreadArray([], instructions, true),
|
6051
6225
|
additionalSigners: additionalSigners
|
@@ -6054,7 +6228,7 @@ var PerpetualsClient = (function () {
|
|
6054
6228
|
});
|
6055
6229
|
}); };
|
6056
6230
|
this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6057
|
-
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice,
|
6231
|
+
var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_39;
|
6058
6232
|
return __generator(this, function (_a) {
|
6059
6233
|
switch (_a.label) {
|
6060
6234
|
case 0:
|
@@ -6087,9 +6261,9 @@ var PerpetualsClient = (function () {
|
|
6087
6261
|
instructions.push(setInternalOraclePrice);
|
6088
6262
|
return [3, 4];
|
6089
6263
|
case 3:
|
6090
|
-
|
6091
|
-
console.log("perpClient setInternalOracleAccount error:: ",
|
6092
|
-
throw
|
6264
|
+
err_39 = _a.sent();
|
6265
|
+
console.log("perpClient setInternalOracleAccount error:: ", err_39);
|
6266
|
+
throw err_39;
|
6093
6267
|
case 4: return [2, {
|
6094
6268
|
instructions: __spreadArray([], instructions, true),
|
6095
6269
|
additionalSigners: additionalSigners
|
@@ -6101,7 +6275,7 @@ var PerpetualsClient = (function () {
|
|
6101
6275
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
6102
6276
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6103
6277
|
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,
|
6278
|
+
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_40;
|
6105
6279
|
return __generator(this, function (_e) {
|
6106
6280
|
switch (_e.label) {
|
6107
6281
|
case 0:
|
@@ -6224,8 +6398,8 @@ var PerpetualsClient = (function () {
|
|
6224
6398
|
instructions.push(addCompoundingLiquidity);
|
6225
6399
|
return [3, 10];
|
6226
6400
|
case 9:
|
6227
|
-
|
6228
|
-
console.log("perpClient addCompoundingLiquidity error:: ",
|
6401
|
+
err_40 = _e.sent();
|
6402
|
+
console.log("perpClient addCompoundingLiquidity error:: ", err_40);
|
6229
6403
|
return [3, 10];
|
6230
6404
|
case 10: return [2, {
|
6231
6405
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6239,7 +6413,7 @@ var PerpetualsClient = (function () {
|
|
6239
6413
|
if (createUserATA === void 0) { createUserATA = true; }
|
6240
6414
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
6241
6415
|
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,
|
6416
|
+
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_41;
|
6243
6417
|
return __generator(this, function (_e) {
|
6244
6418
|
switch (_e.label) {
|
6245
6419
|
case 0:
|
@@ -6346,8 +6520,8 @@ var PerpetualsClient = (function () {
|
|
6346
6520
|
instructions.push(removeCompoundingLiquidity);
|
6347
6521
|
return [3, 8];
|
6348
6522
|
case 7:
|
6349
|
-
|
6350
|
-
console.log("perpClient removeCompoundingLiquidity error:: ",
|
6523
|
+
err_41 = _e.sent();
|
6524
|
+
console.log("perpClient removeCompoundingLiquidity error:: ", err_41);
|
6351
6525
|
return [3, 8];
|
6352
6526
|
case 8: return [2, {
|
6353
6527
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6360,7 +6534,7 @@ var PerpetualsClient = (function () {
|
|
6360
6534
|
this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
|
6361
6535
|
if (createUserATA === void 0) { createUserATA = true; }
|
6362
6536
|
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,
|
6537
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_42;
|
6364
6538
|
return __generator(this, function (_e) {
|
6365
6539
|
switch (_e.label) {
|
6366
6540
|
case 0:
|
@@ -6441,8 +6615,8 @@ var PerpetualsClient = (function () {
|
|
6441
6615
|
instructions.push(migrateStake);
|
6442
6616
|
return [3, 6];
|
6443
6617
|
case 5:
|
6444
|
-
|
6445
|
-
console.log("perpClient migrateStake error:: ",
|
6618
|
+
err_42 = _e.sent();
|
6619
|
+
console.log("perpClient migrateStake error:: ", err_42);
|
6446
6620
|
return [3, 6];
|
6447
6621
|
case 6: return [2, {
|
6448
6622
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6453,7 +6627,7 @@ var PerpetualsClient = (function () {
|
|
6453
6627
|
});
|
6454
6628
|
};
|
6455
6629
|
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,
|
6630
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_43;
|
6457
6631
|
return __generator(this, function (_d) {
|
6458
6632
|
switch (_d.label) {
|
6459
6633
|
case 0:
|
@@ -6525,8 +6699,8 @@ var PerpetualsClient = (function () {
|
|
6525
6699
|
instructions.push(migrateFlp);
|
6526
6700
|
return [3, 4];
|
6527
6701
|
case 3:
|
6528
|
-
|
6529
|
-
console.log("perpClient migrateFlp error:: ",
|
6702
|
+
err_43 = _d.sent();
|
6703
|
+
console.log("perpClient migrateFlp error:: ", err_43);
|
6530
6704
|
return [3, 4];
|
6531
6705
|
case 4: return [2, {
|
6532
6706
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
@@ -6538,7 +6712,7 @@ var PerpetualsClient = (function () {
|
|
6538
6712
|
this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
|
6539
6713
|
if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
|
6540
6714
|
return __awaiter(_this, void 0, void 0, function () {
|
6541
|
-
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee,
|
6715
|
+
var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_44;
|
6542
6716
|
return __generator(this, function (_d) {
|
6543
6717
|
switch (_d.label) {
|
6544
6718
|
case 0:
|
@@ -6595,8 +6769,8 @@ var PerpetualsClient = (function () {
|
|
6595
6769
|
instructions.push(compoundingFee);
|
6596
6770
|
return [3, 4];
|
6597
6771
|
case 3:
|
6598
|
-
|
6599
|
-
console.log("perpClient compoundingFee error:: ",
|
6772
|
+
err_44 = _d.sent();
|
6773
|
+
console.log("perpClient compoundingFee error:: ", err_44);
|
6600
6774
|
return [3, 4];
|
6601
6775
|
case 4: return [2, {
|
6602
6776
|
instructions: __spreadArray([], instructions, true),
|
@@ -6607,7 +6781,7 @@ var PerpetualsClient = (function () {
|
|
6607
6781
|
});
|
6608
6782
|
};
|
6609
6783
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6610
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
6784
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_45;
|
6611
6785
|
return __generator(this, function (_a) {
|
6612
6786
|
switch (_a.label) {
|
6613
6787
|
case 0:
|
@@ -6645,8 +6819,8 @@ var PerpetualsClient = (function () {
|
|
6645
6819
|
instructions.push(renameFlp);
|
6646
6820
|
return [3, 4];
|
6647
6821
|
case 3:
|
6648
|
-
|
6649
|
-
console.log("perpClient renameFlp error:: ",
|
6822
|
+
err_45 = _a.sent();
|
6823
|
+
console.log("perpClient renameFlp error:: ", err_45);
|
6650
6824
|
return [3, 4];
|
6651
6825
|
case 4: return [2, {
|
6652
6826
|
instructions: __spreadArray([], instructions, true),
|
@@ -6656,7 +6830,7 @@ var PerpetualsClient = (function () {
|
|
6656
6830
|
});
|
6657
6831
|
}); };
|
6658
6832
|
this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
6659
|
-
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault,
|
6833
|
+
var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_46;
|
6660
6834
|
return __generator(this, function (_a) {
|
6661
6835
|
switch (_a.label) {
|
6662
6836
|
case 0:
|
@@ -6690,9 +6864,9 @@ var PerpetualsClient = (function () {
|
|
6690
6864
|
instructions.push(initRewardVault);
|
6691
6865
|
return [3, 4];
|
6692
6866
|
case 3:
|
6693
|
-
|
6694
|
-
console.log("rewardDistribution InitRewardVault error:: ",
|
6695
|
-
throw
|
6867
|
+
err_46 = _a.sent();
|
6868
|
+
console.log("rewardDistribution InitRewardVault error:: ", err_46);
|
6869
|
+
throw err_46;
|
6696
6870
|
case 4: return [2, {
|
6697
6871
|
instructions: __spreadArray([], instructions, true),
|
6698
6872
|
additionalSigners: additionalSigners
|
@@ -6701,7 +6875,7 @@ var PerpetualsClient = (function () {
|
|
6701
6875
|
});
|
6702
6876
|
}); };
|
6703
6877
|
this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
|
6704
|
-
var publicKey, instructions, additionalSigners, rewardVault, updateCounter,
|
6878
|
+
var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_47;
|
6705
6879
|
return __generator(this, function (_a) {
|
6706
6880
|
switch (_a.label) {
|
6707
6881
|
case 0:
|
@@ -6724,9 +6898,9 @@ var PerpetualsClient = (function () {
|
|
6724
6898
|
instructions.push(updateCounter);
|
6725
6899
|
return [3, 4];
|
6726
6900
|
case 3:
|
6727
|
-
|
6728
|
-
console.log("rewardDistribution updateCounter error:: ",
|
6729
|
-
throw
|
6901
|
+
err_47 = _a.sent();
|
6902
|
+
console.log("rewardDistribution updateCounter error:: ", err_47);
|
6903
|
+
throw err_47;
|
6730
6904
|
case 4: return [2, {
|
6731
6905
|
instructions: __spreadArray([], instructions, true),
|
6732
6906
|
additionalSigners: additionalSigners
|
@@ -6735,7 +6909,7 @@ var PerpetualsClient = (function () {
|
|
6735
6909
|
});
|
6736
6910
|
}); };
|
6737
6911
|
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,
|
6912
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_48;
|
6739
6913
|
return __generator(this, function (_a) {
|
6740
6914
|
switch (_a.label) {
|
6741
6915
|
case 0:
|
@@ -6774,9 +6948,9 @@ var PerpetualsClient = (function () {
|
|
6774
6948
|
instructions.push(distributeReward);
|
6775
6949
|
return [3, 4];
|
6776
6950
|
case 3:
|
6777
|
-
|
6778
|
-
console.log("rewardDistribution distributeReward error:: ",
|
6779
|
-
throw
|
6951
|
+
err_48 = _a.sent();
|
6952
|
+
console.log("rewardDistribution distributeReward error:: ", err_48);
|
6953
|
+
throw err_48;
|
6780
6954
|
case 4: return [2, {
|
6781
6955
|
instructions: __spreadArray([], instructions, true),
|
6782
6956
|
additionalSigners: additionalSigners
|
@@ -6787,7 +6961,7 @@ var PerpetualsClient = (function () {
|
|
6787
6961
|
this.collectReward = function (counter, owner, rewardSymbol, poolConfig, createUserATA) {
|
6788
6962
|
if (createUserATA === void 0) { createUserATA = true; }
|
6789
6963
|
return __awaiter(_this, void 0, void 0, function () {
|
6790
|
-
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward,
|
6964
|
+
var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward, err_49;
|
6791
6965
|
return __generator(this, function (_b) {
|
6792
6966
|
switch (_b.label) {
|
6793
6967
|
case 0:
|
@@ -6835,8 +7009,8 @@ var PerpetualsClient = (function () {
|
|
6835
7009
|
instructions.push(collectRaffleReward);
|
6836
7010
|
return [3, 6];
|
6837
7011
|
case 5:
|
6838
|
-
|
6839
|
-
throw
|
7012
|
+
err_49 = _b.sent();
|
7013
|
+
throw err_49;
|
6840
7014
|
case 6: return [2, {
|
6841
7015
|
instructions: __spreadArray([], instructions, true),
|
6842
7016
|
additionalSigners: additionalSigners
|