flash-sdk 15.1.1 → 15.1.3

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.
@@ -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, isToken222: 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>;
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[];
@@ -7028,7 +7028,7 @@ var PerpetualsClient = (function () {
7028
7028
  }
7029
7029
  });
7030
7030
  }); };
7031
- this.addCustody = function (poolName, tokenMint, isToken222, isStable, isVirtual, oracle, pricing, permissions, fees, borrowRate, ratios, depegAdjustment, rewardThreshold, minReserveUsd, limitPriceBufferBps, inversePrice) { return __awaiter(_this, void 0, void 0, function () {
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: isToken222,
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, err_77;
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
- err_77 = _a.sent();
8727
- console.log("perpClient migrateMarketPosition error:: ", err_77);
8728
- throw err_77;
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, err_78;
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
- err_78 = _a.sent();
8784
- console.log("perpClient migrateMarketOrder error:: ", err_78);
8785
- throw err_78;
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, err_79;
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
- err_79 = _a.sent();
8860
- console.log("perpClient forceSettlePosition error:: ", err_79);
8861
- throw err_79;
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, _b, uniqueUids_1, uid, reserveCustodyConfig, isToken2022, receivingAccount, forceSettleOrderIx, reserveCustodyConfig, isToken2022, receivingAccount, forceSettleOrderIx, err_80;
8871
- return __generator(this, function (_c) {
8872
- switch (_c.label) {
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
- _c.label = 1;
8914
+ _d.label = 1;
8877
8915
  case 1:
8878
- _c.trys.push([1, 14, , 15]);
8916
+ _d.trys.push([1, 16, , 17]);
8879
8917
  return [4, this.program.account.market.fetch(market)];
8880
8918
  case 2:
8881
- marketAccount = _c.sent();
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 = _c.sent();
8927
+ orderAccount = _d.sent();
8890
8928
  uidToCustodyConfig = new Map();
8891
8929
  _i = 0, _a = poolConfig.custodies;
8892
- _c.label = 4;
8930
+ _d.label = 4;
8893
8931
  case 4:
8894
- if (!(_i < _a.length)) return [3, 7];
8932
+ if (!(_i < _a.length)) return [3, 9];
8895
8933
  custodyConfig = _a[_i];
8896
- return [4, this.program.account.custody.fetch(custodyConfig.custodyAccount)];
8934
+ _d.label = 5;
8897
8935
  case 5:
8898
- custody = _c.sent();
8899
- uidToCustodyConfig.set(custody.uid, custodyConfig);
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 7:
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
- _b = 0, uniqueUids_1 = uniqueUids;
8908
- _c.label = 8;
8909
- case 8:
8910
- if (!(_b < uniqueUids_1.length)) return [3, 11];
8911
- uid = uniqueUids_1[_b];
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, 10];
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
- if (!(uniqueUids.length === 0 && (orderAccount.openTp > 0 || orderAccount.openSl > 0))) return [3, 13];
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
- err_80 = _c.sent();
8978
- console.log("perpClient forceSettleOrder error:: ", err_80);
8979
- throw err_80;
8980
- case 15: return [2, {
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
  }];
@@ -564,9 +564,9 @@
564
564
  "tokenPrecision": 4,
565
565
  "isStable": false,
566
566
  "isVirtual": true,
567
- "lazerId": 2692,
568
- "pythTicker": "Commodities.WTIH6/USD",
569
- "pythPriceId": "0x0058c6f03fd28b18083d00fcdc3baaed2f11edef8b981f6b74130b85be474b17",
567
+ "lazerId": 2693,
568
+ "pythTicker": "Commodities.WTIJ6/USD",
569
+ "pythPriceId": "0x6a60b0d1ea6809b47dbe599f24a71c8bda335aa5c77e503e7260cde5ba2f4694",
570
570
  "isToken2022": false
571
571
  },
572
572
  {
@@ -707,10 +707,10 @@
707
707
  "isStable": false,
708
708
  "isVirtual": true,
709
709
  "intOracleAddress": "5qLQ3BT7JCf4fUxoAH1xZwHCca9fZuuTWTgTsNxLNcoZ",
710
- "extOracleAddress": "Gf9Cg2NS2xfsxLXixjsfAsQkeH1UxN2WVA7dRzKoacYk",
711
- "lazerId": 2692,
712
- "pythTicker": "Commodities.WTIH6/USD",
713
- "pythPriceId": "0x0058c6f03fd28b18083d00fcdc3baaed2f11edef8b981f6b74130b85be474b17"
710
+ "extOracleAddress": "5cuRJhJacGmNJWXqFMWebJReaCktd4Huj2eY7VxF2Rkr",
711
+ "lazerId": 2693,
712
+ "pythTicker": "Commodities.WTIJ6/USD",
713
+ "pythPriceId": "0x6a60b0d1ea6809b47dbe599f24a71c8bda335aa5c77e503e7260cde5ba2f4694"
714
714
  },
715
715
  {
716
716
  "custodyId": 7,
@@ -3189,9 +3189,9 @@
3189
3189
  "tokenPrecision": 4,
3190
3190
  "isStable": false,
3191
3191
  "isVirtual": true,
3192
- "lazerId": 2692,
3193
- "pythTicker": "Commodities.WTIH6/USD",
3194
- "pythPriceId": "0x0058c6f03fd28b18083d00fcdc3baaed2f11edef8b981f6b74130b85be474b17",
3192
+ "lazerId": 2693,
3193
+ "pythTicker": "Commodities.WTIJ6/USD",
3194
+ "pythPriceId": "0x6a60b0d1ea6809b47dbe599f24a71c8bda335aa5c77e503e7260cde5ba2f4694",
3195
3195
  "isToken2022": false
3196
3196
  },
3197
3197
  {
@@ -3332,10 +3332,10 @@
3332
3332
  "isStable": false,
3333
3333
  "isVirtual": true,
3334
3334
  "intOracleAddress": "BeqYMCytDcEJrpikXhz8ZLaBb9ACGDVvmp9ekwbgBgma",
3335
- "extOracleAddress": "Gf9Cg2NS2xfsxLXixjsfAsQkeH1UxN2WVA7dRzKoacYk",
3336
- "lazerId": 2692,
3337
- "pythTicker": "Commodities.WTIH6/USD",
3338
- "pythPriceId": "0x0058c6f03fd28b18083d00fcdc3baaed2f11edef8b981f6b74130b85be474b17"
3335
+ "extOracleAddress": "5cuRJhJacGmNJWXqFMWebJReaCktd4Huj2eY7VxF2Rkr",
3336
+ "lazerId": 2693,
3337
+ "pythTicker": "Commodities.WTIJ6/USD",
3338
+ "pythPriceId": "0x6a60b0d1ea6809b47dbe599f24a71c8bda335aa5c77e503e7260cde5ba2f4694"
3339
3339
  },
3340
3340
  {
3341
3341
  "custodyId": 7,