flash-sdk 15.1.2 → 15.1.4
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 +5 -1
- package/dist/PerpetualsClient.js +95 -51
- package/dist/PoolConfig.json +4 -4
- package/dist/idl/perpetuals.d.ts +59 -59
- package/dist/idl/perpetuals.json +59 -59
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -778,7 +778,7 @@ export declare class PerpetualsClient {
|
|
|
778
778
|
setAdminSigners: (admins: PublicKey[], minSignatures: number) => Promise<void>;
|
|
779
779
|
addPool: (name: string, maxAumUsd: BN, permissions: Permissions, metadataSymbol: string, metadataTitle: string, metadataUri: string, stakingFeeShareBps: BN, vpVolumeFactor: number, stakingFeeBoostBps: BN[], minLpPriceUsd: BN, maxLpPriceUsd: BN, thresholdUsd: BN) => Promise<void>;
|
|
780
780
|
removePool: (name: string) => Promise<void>;
|
|
781
|
-
addCustody: (poolName: string, tokenMint: PublicKey,
|
|
781
|
+
addCustody: (poolName: string, tokenMint: PublicKey, isToken22: boolean, isStable: boolean, isVirtual: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[], depegAdjustment: boolean, rewardThreshold: BN, minReserveUsd: BN, limitPriceBufferBps: BN, inversePrice: boolean) => Promise<void>;
|
|
782
782
|
editCustody: (poolName: string, tokenMint: PublicKey, isStable: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[]) => Promise<void>;
|
|
783
783
|
removeCustody: (poolName: string, tokenMint: PublicKey, ratios: TokenRatios[], poolConfig: PoolConfig) => Promise<void>;
|
|
784
784
|
protocolWithdrawFees: (rewardSymbol: string, poolConfig: PoolConfig) => Promise<{
|
|
@@ -910,6 +910,10 @@ export declare class PerpetualsClient {
|
|
|
910
910
|
instructions: TransactionInstruction[];
|
|
911
911
|
additionalSigners: Signer[];
|
|
912
912
|
}>;
|
|
913
|
+
refreshOrdersStatus: (orderAccounts: PublicKey[]) => Promise<{
|
|
914
|
+
instructions: TransactionInstruction[];
|
|
915
|
+
additionalSigners: Signer[];
|
|
916
|
+
}>;
|
|
913
917
|
migrateMarketPosition: (poolName: string, oldMarket: PublicKey, newMarket: PublicKey, oldCollateralCustody: PublicKey, newCollateralCustody: PublicKey, owner: PublicKey) => Promise<{
|
|
914
918
|
instructions: TransactionInstruction[];
|
|
915
919
|
additionalSigners: Signer[];
|
package/dist/PerpetualsClient.js
CHANGED
|
@@ -7028,7 +7028,7 @@ var PerpetualsClient = (function () {
|
|
|
7028
7028
|
}
|
|
7029
7029
|
});
|
|
7030
7030
|
}); };
|
|
7031
|
-
this.addCustody = function (poolName, tokenMint,
|
|
7031
|
+
this.addCustody = function (poolName, tokenMint, isToken22, isStable, isVirtual, oracle, pricing, permissions, fees, borrowRate, ratios, depegAdjustment, rewardThreshold, minReserveUsd, limitPriceBufferBps, inversePrice) { return __awaiter(_this, void 0, void 0, function () {
|
|
7032
7032
|
var trx_id, error_3;
|
|
7033
7033
|
return __generator(this, function (_a) {
|
|
7034
7034
|
switch (_a.label) {
|
|
@@ -7040,7 +7040,7 @@ var PerpetualsClient = (function () {
|
|
|
7040
7040
|
depegAdjustment: depegAdjustment,
|
|
7041
7041
|
isVirtual: isVirtual,
|
|
7042
7042
|
inversePrice: inversePrice,
|
|
7043
|
-
token22:
|
|
7043
|
+
token22: isToken22,
|
|
7044
7044
|
oracle: oracle,
|
|
7045
7045
|
pricing: pricing,
|
|
7046
7046
|
permissions: permissions,
|
|
@@ -8672,8 +8672,46 @@ var PerpetualsClient = (function () {
|
|
|
8672
8672
|
}
|
|
8673
8673
|
});
|
|
8674
8674
|
}); };
|
|
8675
|
+
this.refreshOrdersStatus = function (orderAccounts) { return __awaiter(_this, void 0, void 0, function () {
|
|
8676
|
+
var instructions, additionalSigners, remainingAccounts, refreshInstruction, err_77;
|
|
8677
|
+
return __generator(this, function (_a) {
|
|
8678
|
+
switch (_a.label) {
|
|
8679
|
+
case 0:
|
|
8680
|
+
instructions = [];
|
|
8681
|
+
additionalSigners = [];
|
|
8682
|
+
_a.label = 1;
|
|
8683
|
+
case 1:
|
|
8684
|
+
_a.trys.push([1, 3, , 4]);
|
|
8685
|
+
remainingAccounts = orderAccounts.map(function (pubkey) { return ({
|
|
8686
|
+
pubkey: pubkey,
|
|
8687
|
+
isSigner: false,
|
|
8688
|
+
isWritable: true,
|
|
8689
|
+
}); });
|
|
8690
|
+
return [4, this.program.methods
|
|
8691
|
+
.refreshOrdersStatus({})
|
|
8692
|
+
.accountsPartial({
|
|
8693
|
+
admin: this.provider.wallet.publicKey,
|
|
8694
|
+
multisig: this.multisig.publicKey,
|
|
8695
|
+
})
|
|
8696
|
+
.remainingAccounts(remainingAccounts)
|
|
8697
|
+
.instruction()];
|
|
8698
|
+
case 2:
|
|
8699
|
+
refreshInstruction = _a.sent();
|
|
8700
|
+
instructions.push(refreshInstruction);
|
|
8701
|
+
return [3, 4];
|
|
8702
|
+
case 3:
|
|
8703
|
+
err_77 = _a.sent();
|
|
8704
|
+
console.log("perpClient refreshOrdersStatus error:: ", err_77);
|
|
8705
|
+
throw err_77;
|
|
8706
|
+
case 4: return [2, {
|
|
8707
|
+
instructions: __spreadArray([], instructions, true),
|
|
8708
|
+
additionalSigners: additionalSigners
|
|
8709
|
+
}];
|
|
8710
|
+
}
|
|
8711
|
+
});
|
|
8712
|
+
}); };
|
|
8675
8713
|
this.migrateMarketPosition = function (poolName, oldMarket, newMarket, oldCollateralCustody, newCollateralCustody, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8676
|
-
var preInstructions, instructions, postInstructions, additionalSigners, oldPosition, newPosition, oldCollateralCustodyAccount, newCollateralCustodyAccount, migrateMarketPositionInstruction,
|
|
8714
|
+
var preInstructions, instructions, postInstructions, additionalSigners, oldPosition, newPosition, oldCollateralCustodyAccount, newCollateralCustodyAccount, migrateMarketPositionInstruction, err_78;
|
|
8677
8715
|
return __generator(this, function (_a) {
|
|
8678
8716
|
switch (_a.label) {
|
|
8679
8717
|
case 0:
|
|
@@ -8723,9 +8761,9 @@ var PerpetualsClient = (function () {
|
|
|
8723
8761
|
instructions.push(migrateMarketPositionInstruction);
|
|
8724
8762
|
return [3, 6];
|
|
8725
8763
|
case 5:
|
|
8726
|
-
|
|
8727
|
-
console.log("perpClient migrateMarketPosition error:: ",
|
|
8728
|
-
throw
|
|
8764
|
+
err_78 = _a.sent();
|
|
8765
|
+
console.log("perpClient migrateMarketPosition error:: ", err_78);
|
|
8766
|
+
throw err_78;
|
|
8729
8767
|
case 6: return [2, {
|
|
8730
8768
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8731
8769
|
additionalSigners: additionalSigners
|
|
@@ -8739,7 +8777,7 @@ var PerpetualsClient = (function () {
|
|
|
8739
8777
|
args_1[_i - 5] = arguments[_i];
|
|
8740
8778
|
}
|
|
8741
8779
|
return __awaiter(_this, __spreadArray([poolName_1, oldMarket_1, newMarket_1, oldCollateralCustody_1, newCollateralCustody_1], args_1, true), void 0, function (poolName, oldMarket, newMarket, oldCollateralCustody, newCollateralCustody, owner) {
|
|
8742
|
-
var preInstructions, instructions, postInstructions, additionalSigners, oldOrder, newOrder, migrateMarketOrderInstruction,
|
|
8780
|
+
var preInstructions, instructions, postInstructions, additionalSigners, oldOrder, newOrder, migrateMarketOrderInstruction, err_79;
|
|
8743
8781
|
if (owner === void 0) { owner = this.provider.wallet.publicKey; }
|
|
8744
8782
|
return __generator(this, function (_a) {
|
|
8745
8783
|
switch (_a.label) {
|
|
@@ -8780,9 +8818,9 @@ var PerpetualsClient = (function () {
|
|
|
8780
8818
|
instructions.push(migrateMarketOrderInstruction);
|
|
8781
8819
|
return [3, 4];
|
|
8782
8820
|
case 3:
|
|
8783
|
-
|
|
8784
|
-
console.log("perpClient migrateMarketOrder error:: ",
|
|
8785
|
-
throw
|
|
8821
|
+
err_79 = _a.sent();
|
|
8822
|
+
console.log("perpClient migrateMarketOrder error:: ", err_79);
|
|
8823
|
+
throw err_79;
|
|
8786
8824
|
case 4: return [2, {
|
|
8787
8825
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8788
8826
|
additionalSigners: additionalSigners
|
|
@@ -8792,7 +8830,7 @@ var PerpetualsClient = (function () {
|
|
|
8792
8830
|
});
|
|
8793
8831
|
};
|
|
8794
8832
|
this.forceSettlePosition = function (market, owner, receivingAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8795
|
-
var instructions, additionalSigners, marketAccount, targetCustody_1, collateralCustody_1, targetCustodyConfig, collateralCustodyConfig, positionAccount, orderAccount, remainingAccounts, orderAccountInfo, forceSettlePositionIx,
|
|
8833
|
+
var instructions, additionalSigners, marketAccount, targetCustody_1, collateralCustody_1, targetCustodyConfig, collateralCustodyConfig, positionAccount, orderAccount, remainingAccounts, orderAccountInfo, forceSettlePositionIx, err_80;
|
|
8796
8834
|
return __generator(this, function (_a) {
|
|
8797
8835
|
switch (_a.label) {
|
|
8798
8836
|
case 0:
|
|
@@ -8856,9 +8894,9 @@ var PerpetualsClient = (function () {
|
|
|
8856
8894
|
instructions.push(forceSettlePositionIx);
|
|
8857
8895
|
return [3, 6];
|
|
8858
8896
|
case 5:
|
|
8859
|
-
|
|
8860
|
-
console.log("perpClient forceSettlePosition error:: ",
|
|
8861
|
-
throw
|
|
8897
|
+
err_80 = _a.sent();
|
|
8898
|
+
console.log("perpClient forceSettlePosition error:: ", err_80);
|
|
8899
|
+
throw err_80;
|
|
8862
8900
|
case 6: return [2, {
|
|
8863
8901
|
instructions: __spreadArray([], instructions, true),
|
|
8864
8902
|
additionalSigners: additionalSigners
|
|
@@ -8867,18 +8905,18 @@ var PerpetualsClient = (function () {
|
|
|
8867
8905
|
});
|
|
8868
8906
|
}); };
|
|
8869
8907
|
this.forceSettleOrder = function (market, owner, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8870
|
-
var instructions, additionalSigners, marketAccount, targetCustody, orderKey, orderAccount, uidToCustodyConfig, _i, _a, custodyConfig, custody, activeLimitOrders, uniqueUids,
|
|
8871
|
-
return __generator(this, function (
|
|
8872
|
-
switch (
|
|
8908
|
+
var instructions, additionalSigners, marketAccount, targetCustody, orderKey, orderAccount, uidToCustodyConfig, _i, _a, custodyConfig, custody, _b, activeLimitOrders, uniqueUids, _c, uniqueUids_1, uid, reserveCustodyConfig, isToken2022, receivingAccount, forceSettleOrderIx, reserveCustodyConfig, isToken2022, receivingAccount, forceSettleOrderIx, err_81;
|
|
8909
|
+
return __generator(this, function (_d) {
|
|
8910
|
+
switch (_d.label) {
|
|
8873
8911
|
case 0:
|
|
8874
8912
|
instructions = [];
|
|
8875
8913
|
additionalSigners = [];
|
|
8876
|
-
|
|
8914
|
+
_d.label = 1;
|
|
8877
8915
|
case 1:
|
|
8878
|
-
|
|
8916
|
+
_d.trys.push([1, 16, , 17]);
|
|
8879
8917
|
return [4, this.program.account.market.fetch(market)];
|
|
8880
8918
|
case 2:
|
|
8881
|
-
marketAccount =
|
|
8919
|
+
marketAccount = _d.sent();
|
|
8882
8920
|
targetCustody = marketAccount.targetCustody;
|
|
8883
8921
|
orderKey = this.findProgramAddress("order", [
|
|
8884
8922
|
owner,
|
|
@@ -8886,32 +8924,38 @@ var PerpetualsClient = (function () {
|
|
|
8886
8924
|
]).publicKey;
|
|
8887
8925
|
return [4, this.program.account.order.fetch(orderKey)];
|
|
8888
8926
|
case 3:
|
|
8889
|
-
orderAccount =
|
|
8927
|
+
orderAccount = _d.sent();
|
|
8890
8928
|
uidToCustodyConfig = new Map();
|
|
8891
8929
|
_i = 0, _a = poolConfig.custodies;
|
|
8892
|
-
|
|
8930
|
+
_d.label = 4;
|
|
8893
8931
|
case 4:
|
|
8894
|
-
if (!(_i < _a.length)) return [3,
|
|
8932
|
+
if (!(_i < _a.length)) return [3, 9];
|
|
8895
8933
|
custodyConfig = _a[_i];
|
|
8896
|
-
|
|
8934
|
+
_d.label = 5;
|
|
8897
8935
|
case 5:
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
_c.label = 6;
|
|
8936
|
+
_d.trys.push([5, 7, , 8]);
|
|
8937
|
+
return [4, this.program.account.custody.fetch(custodyConfig.custodyAccount)];
|
|
8901
8938
|
case 6:
|
|
8939
|
+
custody = _d.sent();
|
|
8940
|
+
uidToCustodyConfig.set(custody.uid, custodyConfig);
|
|
8941
|
+
return [3, 8];
|
|
8942
|
+
case 7:
|
|
8943
|
+
_b = _d.sent();
|
|
8944
|
+
return [3, 8];
|
|
8945
|
+
case 8:
|
|
8902
8946
|
_i++;
|
|
8903
8947
|
return [3, 4];
|
|
8904
|
-
case
|
|
8948
|
+
case 9:
|
|
8905
8949
|
activeLimitOrders = orderAccount.limitOrders.slice(0, orderAccount.activeOrders);
|
|
8906
8950
|
uniqueUids = Array.from(new Set(activeLimitOrders.map(function (o) { return o.reserveCustodyUid; })));
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
case
|
|
8910
|
-
if (!(
|
|
8911
|
-
uid = uniqueUids_1[
|
|
8951
|
+
_c = 0, uniqueUids_1 = uniqueUids;
|
|
8952
|
+
_d.label = 10;
|
|
8953
|
+
case 10:
|
|
8954
|
+
if (!(_c < uniqueUids_1.length)) return [3, 13];
|
|
8955
|
+
uid = uniqueUids_1[_c];
|
|
8912
8956
|
reserveCustodyConfig = uidToCustodyConfig.get(uid);
|
|
8913
8957
|
if (!reserveCustodyConfig)
|
|
8914
|
-
return [3,
|
|
8958
|
+
return [3, 12];
|
|
8915
8959
|
isToken2022 = poolConfig.getTokenFromMintPk(reserveCustodyConfig.mintKey).isToken2022;
|
|
8916
8960
|
receivingAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(reserveCustodyConfig.mintKey, owner, true, isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
8917
8961
|
return [4, this.program.methods
|
|
@@ -8935,15 +8979,15 @@ var PerpetualsClient = (function () {
|
|
|
8935
8979
|
reserveMint: reserveCustodyConfig.mintKey,
|
|
8936
8980
|
})
|
|
8937
8981
|
.instruction()];
|
|
8938
|
-
case 9:
|
|
8939
|
-
forceSettleOrderIx = _c.sent();
|
|
8940
|
-
instructions.push(forceSettleOrderIx);
|
|
8941
|
-
_c.label = 10;
|
|
8942
|
-
case 10:
|
|
8943
|
-
_b++;
|
|
8944
|
-
return [3, 8];
|
|
8945
8982
|
case 11:
|
|
8946
|
-
|
|
8983
|
+
forceSettleOrderIx = _d.sent();
|
|
8984
|
+
instructions.push(forceSettleOrderIx);
|
|
8985
|
+
_d.label = 12;
|
|
8986
|
+
case 12:
|
|
8987
|
+
_c++;
|
|
8988
|
+
return [3, 10];
|
|
8989
|
+
case 13:
|
|
8990
|
+
if (!(uniqueUids.length === 0 && (orderAccount.openTp > 0 || orderAccount.openSl > 0))) return [3, 15];
|
|
8947
8991
|
reserveCustodyConfig = poolConfig.custodies[0];
|
|
8948
8992
|
isToken2022 = poolConfig.getTokenFromMintPk(reserveCustodyConfig.mintKey).isToken2022;
|
|
8949
8993
|
receivingAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(reserveCustodyConfig.mintKey, owner, true, isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
|
|
@@ -8968,16 +9012,16 @@ var PerpetualsClient = (function () {
|
|
|
8968
9012
|
reserveMint: reserveCustodyConfig.mintKey,
|
|
8969
9013
|
})
|
|
8970
9014
|
.instruction()];
|
|
8971
|
-
case 12:
|
|
8972
|
-
forceSettleOrderIx = _c.sent();
|
|
8973
|
-
instructions.push(forceSettleOrderIx);
|
|
8974
|
-
_c.label = 13;
|
|
8975
|
-
case 13: return [3, 15];
|
|
8976
9015
|
case 14:
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
case 15: return [
|
|
9016
|
+
forceSettleOrderIx = _d.sent();
|
|
9017
|
+
instructions.push(forceSettleOrderIx);
|
|
9018
|
+
_d.label = 15;
|
|
9019
|
+
case 15: return [3, 17];
|
|
9020
|
+
case 16:
|
|
9021
|
+
err_81 = _d.sent();
|
|
9022
|
+
console.log("perpClient forceSettleOrder error:: ", err_81);
|
|
9023
|
+
throw err_81;
|
|
9024
|
+
case 17: return [2, {
|
|
8981
9025
|
instructions: __spreadArray([], instructions, true),
|
|
8982
9026
|
additionalSigners: additionalSigners
|
|
8983
9027
|
}];
|
package/dist/PoolConfig.json
CHANGED
|
@@ -1509,9 +1509,9 @@
|
|
|
1509
1509
|
"targetCustody": "AC5Uash5GPiHmST2dbqszJezVf2QVHseAi79zch9ANYo",
|
|
1510
1510
|
"collateralCustody": "AC5Uash5GPiHmST2dbqszJezVf2QVHseAi79zch9ANYo",
|
|
1511
1511
|
"side": "long",
|
|
1512
|
-
"maxLev":
|
|
1512
|
+
"maxLev": 20,
|
|
1513
1513
|
"degenMinLev": 1,
|
|
1514
|
-
"degenMaxLev":
|
|
1514
|
+
"degenMaxLev": 20,
|
|
1515
1515
|
"targetCustodyId": 9,
|
|
1516
1516
|
"collateralCustodyId": 9,
|
|
1517
1517
|
"targetMint": "98sMhvDwXj1RQi5c5Mndm3vPe9cBqPrbLaufMXFNMh5g",
|
|
@@ -1525,9 +1525,9 @@
|
|
|
1525
1525
|
"targetCustody": "AC5Uash5GPiHmST2dbqszJezVf2QVHseAi79zch9ANYo",
|
|
1526
1526
|
"collateralCustody": "6fiadNoZVTha5NdaktZgJ3PHm7bncZpiqGvFbCsrUv72",
|
|
1527
1527
|
"side": "short",
|
|
1528
|
-
"maxLev":
|
|
1528
|
+
"maxLev": 20,
|
|
1529
1529
|
"degenMinLev": 1,
|
|
1530
|
-
"degenMaxLev":
|
|
1530
|
+
"degenMaxLev": 20,
|
|
1531
1531
|
"targetCustodyId": 9,
|
|
1532
1532
|
"collateralCustodyId": 0,
|
|
1533
1533
|
"targetMint": "98sMhvDwXj1RQi5c5Mndm3vPe9cBqPrbLaufMXFNMh5g",
|