@drift-labs/sdk 2.130.0-beta.8 → 2.130.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.
Files changed (103) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +1 -0
  3. package/lib/browser/accounts/grpcAccountSubscriber.js +16 -12
  4. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +1 -0
  5. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +16 -12
  6. package/lib/browser/accounts/types.d.ts +5 -0
  7. package/lib/browser/adminClient.d.ts +2 -2
  8. package/lib/browser/adminClient.js +14 -14
  9. package/lib/browser/dlob/DLOB.d.ts +3 -3
  10. package/lib/browser/dlob/DLOB.js +14 -8
  11. package/lib/browser/dlob/DLOBNode.d.ts +5 -3
  12. package/lib/browser/dlob/DLOBNode.js +12 -11
  13. package/lib/browser/dlob/DLOBSubscriber.js +1 -1
  14. package/lib/browser/dlob/NodeList.d.ts +3 -1
  15. package/lib/browser/dlob/NodeList.js +2 -2
  16. package/lib/browser/dlob/orderBookLevels.d.ts +6 -0
  17. package/lib/browser/dlob/orderBookLevels.js +5 -2
  18. package/lib/browser/driftClient.js +15 -2
  19. package/lib/browser/idl/drift.json +82 -11
  20. package/lib/browser/math/amm.d.ts +4 -0
  21. package/lib/browser/math/amm.js +25 -9
  22. package/lib/browser/math/market.d.ts +10 -0
  23. package/lib/browser/math/market.js +76 -1
  24. package/lib/browser/math/orders.d.ts +1 -0
  25. package/lib/browser/math/orders.js +13 -1
  26. package/lib/browser/math/state.d.ts +1 -0
  27. package/lib/browser/math/state.js +6 -1
  28. package/lib/browser/oracles/types.d.ts +1 -0
  29. package/lib/browser/oracles/utils.js +1 -3
  30. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
  31. package/lib/browser/orderSubscriber/OrderSubscriber.js +10 -3
  32. package/lib/browser/types.d.ts +7 -0
  33. package/lib/browser/types.js +6 -1
  34. package/lib/node/accounts/grpcAccountSubscriber.d.ts +1 -0
  35. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  36. package/lib/node/accounts/grpcAccountSubscriber.js +16 -12
  37. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +1 -0
  38. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  39. package/lib/node/accounts/grpcProgramAccountSubscriber.js +16 -12
  40. package/lib/node/accounts/types.d.ts +5 -0
  41. package/lib/node/accounts/types.d.ts.map +1 -1
  42. package/lib/node/adminClient.d.ts +2 -2
  43. package/lib/node/adminClient.d.ts.map +1 -1
  44. package/lib/node/adminClient.js +14 -14
  45. package/lib/node/dlob/DLOB.d.ts +3 -3
  46. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  47. package/lib/node/dlob/DLOB.js +14 -8
  48. package/lib/node/dlob/DLOBNode.d.ts +5 -3
  49. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  50. package/lib/node/dlob/DLOBNode.js +12 -11
  51. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  52. package/lib/node/dlob/DLOBSubscriber.js +1 -1
  53. package/lib/node/dlob/NodeList.d.ts +3 -1
  54. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  55. package/lib/node/dlob/NodeList.js +2 -2
  56. package/lib/node/dlob/orderBookLevels.d.ts +6 -0
  57. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  58. package/lib/node/dlob/orderBookLevels.js +5 -2
  59. package/lib/node/driftClient.d.ts.map +1 -1
  60. package/lib/node/driftClient.js +15 -2
  61. package/lib/node/idl/drift.json +82 -11
  62. package/lib/node/math/amm.d.ts +4 -0
  63. package/lib/node/math/amm.d.ts.map +1 -1
  64. package/lib/node/math/amm.js +25 -9
  65. package/lib/node/math/market.d.ts +10 -0
  66. package/lib/node/math/market.d.ts.map +1 -1
  67. package/lib/node/math/market.js +76 -1
  68. package/lib/node/math/orders.d.ts +1 -0
  69. package/lib/node/math/orders.d.ts.map +1 -1
  70. package/lib/node/math/orders.js +13 -1
  71. package/lib/node/math/state.d.ts +1 -0
  72. package/lib/node/math/state.d.ts.map +1 -1
  73. package/lib/node/math/state.js +6 -1
  74. package/lib/node/oracles/types.d.ts +1 -0
  75. package/lib/node/oracles/types.d.ts.map +1 -1
  76. package/lib/node/oracles/utils.d.ts.map +1 -1
  77. package/lib/node/oracles/utils.js +1 -3
  78. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
  79. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  80. package/lib/node/orderSubscriber/OrderSubscriber.js +10 -3
  81. package/lib/node/types.d.ts +7 -0
  82. package/lib/node/types.d.ts.map +1 -1
  83. package/lib/node/types.js +6 -1
  84. package/package.json +1 -1
  85. package/src/accounts/grpcAccountSubscriber.ts +24 -11
  86. package/src/accounts/grpcProgramAccountSubscriber.ts +26 -11
  87. package/src/accounts/types.ts +5 -0
  88. package/src/adminClient.ts +29 -27
  89. package/src/dlob/DLOB.ts +30 -6
  90. package/src/dlob/DLOBNode.ts +21 -10
  91. package/src/dlob/DLOBSubscriber.ts +2 -1
  92. package/src/dlob/NodeList.ts +5 -2
  93. package/src/dlob/orderBookLevels.ts +8 -2
  94. package/src/driftClient.ts +18 -4
  95. package/src/idl/drift.json +83 -12
  96. package/src/math/amm.ts +49 -10
  97. package/src/math/market.ts +105 -0
  98. package/src/math/orders.ts +18 -0
  99. package/src/math/state.ts +7 -1
  100. package/src/oracles/types.ts +1 -0
  101. package/src/oracles/utils.ts +1 -3
  102. package/src/orderSubscriber/OrderSubscriber.ts +16 -2
  103. package/src/types.ts +9 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.129.0",
2
+ "version": "2.130.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -2099,7 +2099,12 @@
2099
2099
  "isSigner": false
2100
2100
  }
2101
2101
  ],
2102
- "args": []
2102
+ "args": [
2103
+ {
2104
+ "name": "disableMaintenance",
2105
+ "type": "bool"
2106
+ }
2107
+ ]
2103
2108
  },
2104
2109
  {
2105
2110
  "name": "updateUserFuelBonus",
@@ -7531,7 +7536,7 @@
7531
7536
  ]
7532
7537
  },
7533
7538
  {
7534
- "name": "updateDisableBitflagsMmOracle",
7539
+ "name": "updateFeatureBitFlagsMmOracle",
7535
7540
  "accounts": [
7536
7541
  {
7537
7542
  "name": "admin",
@@ -7546,7 +7551,7 @@
7546
7551
  ],
7547
7552
  "args": [
7548
7553
  {
7549
- "name": "disable",
7554
+ "name": "enable",
7550
7555
  "type": "bool"
7551
7556
  }
7552
7557
  ]
@@ -7795,11 +7800,24 @@
7795
7800
  "type": "u8"
7796
7801
  },
7797
7802
  {
7798
- "name": "padding",
7803
+ "name": "padding1",
7799
7804
  "type": {
7800
7805
  "array": [
7801
7806
  "u8",
7802
- 31
7807
+ 3
7808
+ ]
7809
+ }
7810
+ },
7811
+ {
7812
+ "name": "currentMaintenanceUsers",
7813
+ "type": "u32"
7814
+ },
7815
+ {
7816
+ "name": "padding2",
7817
+ "type": {
7818
+ "array": [
7819
+ "u8",
7820
+ 24
7803
7821
  ]
7804
7822
  }
7805
7823
  }
@@ -8324,12 +8342,20 @@
8324
8342
  "name": "protectedMakerDynamicDivisor",
8325
8343
  "type": "u8"
8326
8344
  },
8345
+ {
8346
+ "name": "padding1",
8347
+ "type": "u32"
8348
+ },
8349
+ {
8350
+ "name": "lastFillPrice",
8351
+ "type": "u64"
8352
+ },
8327
8353
  {
8328
8354
  "name": "padding",
8329
8355
  "type": {
8330
8356
  "array": [
8331
8357
  "u8",
8332
- 36
8358
+ 24
8333
8359
  ]
8334
8360
  }
8335
8361
  }
@@ -9060,7 +9086,7 @@
9060
9086
  "type": "u16"
9061
9087
  },
9062
9088
  {
9063
- "name": "disableBitFlags",
9089
+ "name": "featureBitFlags",
9064
9090
  "type": "u8"
9065
9091
  },
9066
9092
  {
@@ -10640,7 +10666,7 @@
10640
10666
  "name": "lastFundingRate",
10641
10667
  "docs": [
10642
10668
  "last funding rate in this perp market (unit is quote per base)",
10643
- "precision: QUOTE_PRECISION"
10669
+ "precision: FUNDING_RATE_PRECISION"
10644
10670
  ],
10645
10671
  "type": "i64"
10646
10672
  },
@@ -10648,7 +10674,7 @@
10648
10674
  "name": "lastFundingRateLong",
10649
10675
  "docs": [
10650
10676
  "last funding rate for longs in this perp market (unit is quote per base)",
10651
- "precision: QUOTE_PRECISION"
10677
+ "precision: FUNDING_RATE_PRECISION"
10652
10678
  ],
10653
10679
  "type": "i64"
10654
10680
  },
@@ -11078,9 +11104,13 @@
11078
11104
  "type": {
11079
11105
  "array": [
11080
11106
  "u8",
11081
- 11
11107
+ 3
11082
11108
  ]
11083
11109
  }
11110
+ },
11111
+ {
11112
+ "name": "lastFundingOracleTwap",
11113
+ "type": "i64"
11084
11114
  }
11085
11115
  ]
11086
11116
  }
@@ -12002,6 +12032,26 @@
12002
12032
  ]
12003
12033
  }
12004
12034
  },
12035
+ {
12036
+ "name": "LogMode",
12037
+ "type": {
12038
+ "kind": "enum",
12039
+ "variants": [
12040
+ {
12041
+ "name": "None"
12042
+ },
12043
+ {
12044
+ "name": "ExchangeOracle"
12045
+ },
12046
+ {
12047
+ "name": "MMOracle"
12048
+ },
12049
+ {
12050
+ "name": "SafeMMOracle"
12051
+ }
12052
+ ]
12053
+ }
12054
+ },
12005
12055
  {
12006
12056
  "name": "PositionUpdateType",
12007
12057
  "type": {
@@ -12751,6 +12801,20 @@
12751
12801
  ]
12752
12802
  }
12753
12803
  },
12804
+ {
12805
+ "name": "FeatureBitFlags",
12806
+ "type": {
12807
+ "kind": "enum",
12808
+ "variants": [
12809
+ {
12810
+ "name": "MmOracleUpdate"
12811
+ },
12812
+ {
12813
+ "name": "EnableMedianTriggerPrice"
12814
+ }
12815
+ ]
12816
+ }
12817
+ },
12754
12818
  {
12755
12819
  "name": "UserStatus",
12756
12820
  "type": {
@@ -13674,6 +13738,13 @@
13674
13738
  "option": "u64"
13675
13739
  },
13676
13740
  "index": false
13741
+ },
13742
+ {
13743
+ "name": "triggerPrice",
13744
+ "type": {
13745
+ "option": "u64"
13746
+ },
13747
+ "index": false
13677
13748
  }
13678
13749
  ]
13679
13750
  },
@@ -12,6 +12,10 @@ export declare function calculateUpdatedAMMSpreadReserves(amm: AMM, direction: P
12
12
  sqrtK: BN;
13
13
  newPeg: BN;
14
14
  };
15
+ export declare function calculateAMMBidAskPrice(amm: AMM, oraclePriceData: OraclePriceData, withUpdate?: boolean, isPrediction?: boolean): [BN, BN];
16
+ /**
17
+ * @deprecated Use calculateAMMBidAskPrice instead
18
+ */
15
19
  export declare function calculateBidAskPrice(amm: AMM, oraclePriceData: OraclePriceData, withUpdate?: boolean, isPrediction?: boolean): [BN, BN];
16
20
  /**
17
21
  * Calculates a price given an arbitrary base and quote amount (they must have the same precision)
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateMaxBaseAssetAmountFillable = exports.calculateQuoteAssetAmountSwapped = exports.calculateMaxBaseAssetAmountToTrade = exports.calculateTerminalPrice = exports.getSwapDirection = exports.calculateSwapOutput = exports.calculateSpreadReserves = exports.getQuoteAssetReservePredictionMarketBounds = exports.calculateSpread = exports.calculateSpreadBN = exports.calculateVolSpreadBN = exports.calculateMaxSpread = exports.calculateEffectiveLeverage = exports.calculateReferencePriceOffset = exports.calculateInventoryScale = exports.calculateInventoryLiquidityRatio = exports.calculateMarketOpenBidAsk = exports.calculateAmmReservesAfterSwap = exports.calculatePrice = exports.calculateBidAskPrice = exports.calculateUpdatedAMMSpreadReserves = exports.calculateUpdatedAMM = exports.calculateNewAmm = exports.calculateOptimalPegAndBudget = exports.calculatePegFromTargetPrice = void 0;
3
+ exports.calculateMaxBaseAssetAmountFillable = exports.calculateQuoteAssetAmountSwapped = exports.calculateMaxBaseAssetAmountToTrade = exports.calculateTerminalPrice = exports.getSwapDirection = exports.calculateSwapOutput = exports.calculateSpreadReserves = exports.getQuoteAssetReservePredictionMarketBounds = exports.calculateSpread = exports.calculateSpreadBN = exports.calculateVolSpreadBN = exports.calculateMaxSpread = exports.calculateEffectiveLeverage = exports.calculateReferencePriceOffset = exports.calculateInventoryScale = exports.calculateInventoryLiquidityRatio = exports.calculateMarketOpenBidAsk = exports.calculateAmmReservesAfterSwap = exports.calculatePrice = exports.calculateBidAskPrice = exports.calculateAMMBidAskPrice = exports.calculateUpdatedAMMSpreadReserves = exports.calculateUpdatedAMM = exports.calculateNewAmm = exports.calculateOptimalPegAndBudget = exports.calculatePegFromTargetPrice = void 0;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
5
  const numericConstants_1 = require("../constants/numericConstants");
6
6
  const types_1 = require("../types");
@@ -82,9 +82,6 @@ function calculateNewAmm(amm, oraclePriceData) {
82
82
  }
83
83
  exports.calculateNewAmm = calculateNewAmm;
84
84
  function calculateUpdatedAMM(amm, oraclePriceData) {
85
- if (!(oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.fetchedWithMMOracle)) {
86
- console.log('Use driftClient method getMMOracleDataForPerpMarket for accurate MM pricing');
87
- }
88
85
  if (amm.curveUpdateIntensity == 0 || oraclePriceData === undefined) {
89
86
  return amm;
90
87
  }
@@ -108,8 +105,9 @@ function calculateUpdatedAMM(amm, oraclePriceData) {
108
105
  }
109
106
  exports.calculateUpdatedAMM = calculateUpdatedAMM;
110
107
  function calculateUpdatedAMMSpreadReserves(amm, direction, oraclePriceData, isPrediction = false) {
111
- if (!(oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.fetchedWithMMOracle)) {
112
- console.log('Use driftClient method getMMOracleDataForPerpMarket for accurate MM pricing');
108
+ if (!(oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.fetchedWithMMOracle) &&
109
+ (oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.isMMOracleActive)) {
110
+ console.log('Use driftClient method getMMOracleDataForPerpMarket for accurate updated AMM in calculateUpdatedAMMSpreadReserves');
113
111
  }
114
112
  const newAmm = calculateUpdatedAMM(amm, oraclePriceData);
115
113
  const [shortReserves, longReserves] = calculateSpreadReserves(newAmm, oraclePriceData, undefined, isPrediction);
@@ -125,10 +123,28 @@ function calculateUpdatedAMMSpreadReserves(amm, direction, oraclePriceData, isPr
125
123
  return result;
126
124
  }
127
125
  exports.calculateUpdatedAMMSpreadReserves = calculateUpdatedAMMSpreadReserves;
128
- function calculateBidAskPrice(amm, oraclePriceData, withUpdate = true, isPrediction = false) {
129
- if (!(oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.fetchedWithMMOracle)) {
130
- console.log('Use driftClient method getMMOracleDataForPerpMarket for accurate MM pricing');
126
+ function calculateAMMBidAskPrice(amm, oraclePriceData, withUpdate = true, isPrediction = false) {
127
+ if (!(oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.fetchedWithMMOracle) &&
128
+ (oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.isMMOracleActive)) {
129
+ console.log('Use driftClient method getMMOracleDataForPerpMarket for accurate MM pricing in calculateAMMBidAskPrice');
130
+ }
131
+ let newAmm;
132
+ if (withUpdate) {
133
+ newAmm = calculateUpdatedAMM(amm, oraclePriceData);
134
+ }
135
+ else {
136
+ newAmm = amm;
131
137
  }
138
+ const [bidReserves, askReserves] = calculateSpreadReserves(newAmm, oraclePriceData, undefined, isPrediction);
139
+ const askPrice = calculatePrice(askReserves.baseAssetReserve, askReserves.quoteAssetReserve, newAmm.pegMultiplier);
140
+ const bidPrice = calculatePrice(bidReserves.baseAssetReserve, bidReserves.quoteAssetReserve, newAmm.pegMultiplier);
141
+ return [bidPrice, askPrice];
142
+ }
143
+ exports.calculateAMMBidAskPrice = calculateAMMBidAskPrice;
144
+ /**
145
+ * @deprecated Use calculateAMMBidAskPrice instead
146
+ */
147
+ function calculateBidAskPrice(amm, oraclePriceData, withUpdate = true, isPrediction = false) {
132
148
  let newAmm;
133
149
  if (withUpdate) {
134
150
  newAmm = calculateUpdatedAMM(amm, oraclePriceData);
@@ -38,3 +38,13 @@ export declare function calculateAvailablePerpLiquidity(market: PerpMarketAccoun
38
38
  asks: BN;
39
39
  };
40
40
  export declare function calculatePerpMarketBaseLiquidatorFee(market: PerpMarketAccount, userHighLeverageMode: boolean): number;
41
+ /**
42
+ * Calculates trigger price for a perp market based on oracle price and current time
43
+ * Implements the same logic as the Rust get_trigger_price function
44
+ *
45
+ * @param market - The perp market account
46
+ * @param oraclePrice - Current oracle price (precision: PRICE_PRECISION)
47
+ * @param now - Current timestamp in seconds
48
+ * @returns trigger price (precision: PRICE_PRECISION)
49
+ */
50
+ export declare function getTriggerPrice(market: PerpMarketAccount, oraclePrice: BN, now: BN, useMedianPrice: boolean): BN;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculatePerpMarketBaseLiquidatorFee = exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
3
+ exports.getTriggerPrice = exports.calculatePerpMarketBaseLiquidatorFee = exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
5
  const types_1 = require("../types");
6
6
  const amm_1 = require("./amm");
@@ -172,3 +172,78 @@ function calculatePerpMarketBaseLiquidatorFee(market, userHighLeverageMode) {
172
172
  }
173
173
  }
174
174
  exports.calculatePerpMarketBaseLiquidatorFee = calculatePerpMarketBaseLiquidatorFee;
175
+ /**
176
+ * Calculates trigger price for a perp market based on oracle price and current time
177
+ * Implements the same logic as the Rust get_trigger_price function
178
+ *
179
+ * @param market - The perp market account
180
+ * @param oraclePrice - Current oracle price (precision: PRICE_PRECISION)
181
+ * @param now - Current timestamp in seconds
182
+ * @returns trigger price (precision: PRICE_PRECISION)
183
+ */
184
+ function getTriggerPrice(market, oraclePrice, now, useMedianPrice) {
185
+ if (!useMedianPrice) {
186
+ return oraclePrice.abs();
187
+ }
188
+ const lastFillPrice = market.lastFillPrice;
189
+ // Calculate 5-minute basis
190
+ const markPrice5minTwap = market.amm.lastMarkPriceTwap5Min;
191
+ const lastOraclePriceTwap5min = market.amm.historicalOracleData.lastOraclePriceTwap5Min;
192
+ const basis5min = markPrice5minTwap.sub(lastOraclePriceTwap5min);
193
+ const oraclePlusBasis5min = oraclePrice.add(basis5min);
194
+ // Calculate funding basis
195
+ const lastFundingBasis = getLastFundingBasis(market, oraclePrice, now);
196
+ const oraclePlusFundingBasis = oraclePrice.add(lastFundingBasis);
197
+ const prices = [
198
+ lastFillPrice.gt(numericConstants_1.ZERO) ? lastFillPrice : oraclePrice,
199
+ oraclePlusFundingBasis,
200
+ oraclePlusBasis5min,
201
+ ].sort((a, b) => a.cmp(b));
202
+ const medianPrice = prices[1];
203
+ return clampTriggerPrice(market, oraclePrice.abs(), medianPrice);
204
+ }
205
+ exports.getTriggerPrice = getTriggerPrice;
206
+ /**
207
+ * Calculates the last funding basis for trigger price calculation
208
+ * Implements the same logic as the Rust get_last_funding_basis function
209
+ */
210
+ function getLastFundingBasis(market, oraclePrice, now) {
211
+ if (market.amm.lastFundingOracleTwap.gt(numericConstants_1.ZERO)) {
212
+ const lastFundingRate = market.amm.lastFundingRate
213
+ .mul(numericConstants_1.PRICE_PRECISION)
214
+ .div(market.amm.lastFundingOracleTwap)
215
+ .muln(24);
216
+ const lastFundingRatePreAdj = lastFundingRate.sub(numericConstants_1.FUNDING_RATE_PRECISION.div(new anchor_1.BN(5000)) // FUNDING_RATE_OFFSET_PERCENTAGE
217
+ );
218
+ const timeLeftUntilFundingUpdate = anchor_1.BN.min(anchor_1.BN.max(now.sub(market.amm.lastFundingRateTs), numericConstants_1.ZERO), market.amm.fundingPeriod);
219
+ const lastFundingBasis = oraclePrice
220
+ .mul(lastFundingRatePreAdj)
221
+ .div(numericConstants_1.PERCENTAGE_PRECISION)
222
+ .mul(market.amm.fundingPeriod.sub(timeLeftUntilFundingUpdate))
223
+ .div(market.amm.fundingPeriod)
224
+ .div(new anchor_1.BN(1000)); // FUNDING_RATE_BUFFER
225
+ return lastFundingBasis;
226
+ }
227
+ else {
228
+ return numericConstants_1.ZERO;
229
+ }
230
+ }
231
+ /**
232
+ * Clamps trigger price based on contract tier
233
+ * Implements the same logic as the Rust clamp_trigger_price function
234
+ */
235
+ function clampTriggerPrice(market, oraclePrice, medianPrice) {
236
+ let maxBpsDiff;
237
+ const tier = market.contractTier;
238
+ if ((0, types_1.isVariant)(tier, 'a') || (0, types_1.isVariant)(tier, 'b')) {
239
+ maxBpsDiff = new anchor_1.BN(500); // 20 BPS
240
+ }
241
+ else if ((0, types_1.isVariant)(tier, 'c')) {
242
+ maxBpsDiff = new anchor_1.BN(100); // 100 BPS
243
+ }
244
+ else {
245
+ maxBpsDiff = new anchor_1.BN(40); // 250 BPS
246
+ }
247
+ const maxOracleDiff = oraclePrice.div(maxBpsDiff);
248
+ return anchor_1.BN.min(anchor_1.BN.max(medianPrice, oraclePrice.sub(maxOracleDiff)), oraclePrice.add(maxOracleDiff));
249
+ }
@@ -23,3 +23,4 @@ export declare function isTriggered(order: Order): boolean;
23
23
  export declare function isRestingLimitOrder(order: Order, slot: number): boolean;
24
24
  export declare function isTakingOrder(order: Order, slot: number): boolean;
25
25
  export declare function isSignedMsgOrder(order: Order): boolean;
26
+ export declare function calculateOrderBaseAssetAmount(order: Order, existingBaseAssetAmount: BN): BN;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSignedMsgOrder = exports.isTakingOrder = exports.isRestingLimitOrder = exports.isTriggered = exports.mustBeTriggered = exports.isLimitOrder = exports.isMarketOrder = exports.isOrderExpired = exports.calculateBaseAssetAmountToFillUpToLimitPrice = exports.calculateBaseAssetAmountForAmmToFulfill = exports.isFillableByVAMM = exports.hasAuctionPrice = exports.hasLimitPrice = exports.applyProtectedMakerParams = exports.getLimitPrice = exports.standardizePrice = exports.standardizeBaseAssetAmount = exports.isOrderReduceOnly = exports.isOrderRiskIncreasingInSameDirection = exports.isOrderRiskIncreasing = void 0;
3
+ exports.calculateOrderBaseAssetAmount = exports.isSignedMsgOrder = exports.isTakingOrder = exports.isRestingLimitOrder = exports.isTriggered = exports.mustBeTriggered = exports.isLimitOrder = exports.isMarketOrder = exports.isOrderExpired = exports.calculateBaseAssetAmountToFillUpToLimitPrice = exports.calculateBaseAssetAmountForAmmToFulfill = exports.isFillableByVAMM = exports.hasAuctionPrice = exports.hasLimitPrice = exports.applyProtectedMakerParams = exports.getLimitPrice = exports.standardizePrice = exports.standardizeBaseAssetAmount = exports.isOrderReduceOnly = exports.isOrderRiskIncreasingInSameDirection = exports.isOrderRiskIncreasing = void 0;
4
4
  const types_1 = require("../types");
5
5
  const numericConstants_1 = require("../constants/numericConstants");
6
6
  const anchor_1 = require("@coral-xyz/anchor");
@@ -240,3 +240,15 @@ function isSignedMsgOrder(order) {
240
240
  return (order.bitFlags & FLAG_IS_SIGNED_MSG) !== 0;
241
241
  }
242
242
  exports.isSignedMsgOrder = isSignedMsgOrder;
243
+ function calculateOrderBaseAssetAmount(order, existingBaseAssetAmount) {
244
+ if (!order.reduceOnly) {
245
+ return order.baseAssetAmount;
246
+ }
247
+ if ((0, types_1.isVariant)(order.direction, 'long')) {
248
+ return anchor_1.BN.min(anchor_1.BN.min(existingBaseAssetAmount, numericConstants_1.ZERO).abs(), order.baseAssetAmount);
249
+ }
250
+ else {
251
+ return anchor_1.BN.min(anchor_1.BN.max(existingBaseAssetAmount, numericConstants_1.ZERO), order.baseAssetAmount);
252
+ }
253
+ }
254
+ exports.calculateOrderBaseAssetAmount = calculateOrderBaseAssetAmount;
@@ -3,3 +3,4 @@ import { BN } from '@coral-xyz/anchor';
3
3
  import { StateAccount } from '../types';
4
4
  export declare function calculateInitUserFee(stateAccount: StateAccount): BN;
5
5
  export declare function getMaxNumberOfSubAccounts(stateAccount: StateAccount): BN;
6
+ export declare function useMedianTriggerPrice(stateAccount: StateAccount): boolean;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMaxNumberOfSubAccounts = exports.calculateInitUserFee = void 0;
3
+ exports.useMedianTriggerPrice = exports.getMaxNumberOfSubAccounts = exports.calculateInitUserFee = void 0;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
5
  const numericConstants_1 = require("../constants/numericConstants");
6
+ const types_1 = require("../types");
6
7
  function calculateInitUserFee(stateAccount) {
7
8
  const maxInitFee = new anchor_1.BN(stateAccount.maxInitializeUserFee)
8
9
  .mul(numericConstants_1.LAMPORTS_PRECISION)
@@ -29,3 +30,7 @@ function getMaxNumberOfSubAccounts(stateAccount) {
29
30
  return new anchor_1.BN(stateAccount.maxNumberOfSubAccounts).muln(100);
30
31
  }
31
32
  exports.getMaxNumberOfSubAccounts = getMaxNumberOfSubAccounts;
33
+ function useMedianTriggerPrice(stateAccount) {
34
+ return ((stateAccount.featureBitFlags & types_1.FeatureBitFlags.MEDIAN_TRIGGER_PRICE) > 0);
35
+ }
36
+ exports.useMedianTriggerPrice = useMedianTriggerPrice;
@@ -18,6 +18,7 @@ export type OraclePriceData = {
18
18
  twapConfidence?: BN;
19
19
  maxPrice?: BN;
20
20
  fetchedWithMMOracle?: boolean;
21
+ isMMOracleActive?: boolean;
21
22
  };
22
23
  export type OracleInfo = {
23
24
  publicKey: PublicKey;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOracleConfidenceFromMMOracleData = void 0;
4
- const numericConstants_1 = require("../constants/numericConstants");
5
4
  function getOracleConfidenceFromMMOracleData(mmOracleData) {
6
5
  const mmOracleDiffPremium = mmOracleData.mmOraclePrice
7
6
  .sub(mmOracleData.oraclePriceData.price)
8
- .abs()
9
- .div(numericConstants_1.FIVE);
7
+ .abs();
10
8
  return mmOracleData.oraclePriceData.confidence.add(mmOracleDiffPremium);
11
9
  }
12
10
  exports.getOracleConfidenceFromMMOracleData = getOracleConfidenceFromMMOracleData;
@@ -11,7 +11,7 @@ import { PollingSubscription } from './PollingSubscription';
11
11
  import { WebsocketSubscription } from './WebsocketSubscription';
12
12
  import StrictEventEmitter from 'strict-event-emitter-types';
13
13
  import { EventEmitter } from 'events';
14
- import { ProtectMakerParamsMap } from '../index';
14
+ import { ProtectMakerParamsMap } from '../dlob/types';
15
15
  import { grpcSubscription } from './grpcSubscription';
16
16
  export declare class OrderSubscriber {
17
17
  driftClient: DriftClient;
@@ -9,6 +9,7 @@ const PollingSubscription_1 = require("./PollingSubscription");
9
9
  const WebsocketSubscription_1 = require("./WebsocketSubscription");
10
10
  const events_1 = require("events");
11
11
  const index_1 = require("../index");
12
+ const anchor_1 = require("@coral-xyz/anchor");
12
13
  const user_1 = require("../decode/user");
13
14
  const grpcSubscription_1 = require("./grpcSubscription");
14
15
  const userStatus_1 = require("../math/userStatus");
@@ -115,7 +116,7 @@ class OrderSubscriber {
115
116
  if (dataType === 'raw') {
116
117
  // @ts-ignore
117
118
  const buffer = buffer_1.Buffer.from(data[0], data[1]);
118
- const newLastActiveSlot = new index_1.BN(buffer.subarray(4328, 4328 + 8), undefined, 'le');
119
+ const newLastActiveSlot = new anchor_1.BN(buffer.subarray(4328, 4328 + 8), undefined, 'le');
119
120
  if (slotAndUserAccount &&
120
121
  slotAndUserAccount.userAccount.lastActiveSlot.gt(newLastActiveSlot)) {
121
122
  return;
@@ -124,7 +125,7 @@ class OrderSubscriber {
124
125
  }
125
126
  else if (dataType === 'buffer') {
126
127
  const buffer = data;
127
- const newLastActiveSlot = new index_1.BN(buffer.subarray(4328, 4328 + 8), undefined, 'le');
128
+ const newLastActiveSlot = new anchor_1.BN(buffer.subarray(4328, 4328 + 8), undefined, 'le');
128
129
  if (slotAndUserAccount &&
129
130
  slotAndUserAccount.userAccount.lastActiveSlot.gt(newLastActiveSlot)) {
130
131
  return;
@@ -155,11 +156,17 @@ class OrderSubscriber {
155
156
  return new DLOB_1.DLOB(protectedMakerParamsMap);
156
157
  }
157
158
  async getDLOB(slot, protectedMakerParamsMap) {
159
+ var _a;
158
160
  const dlob = this.createDLOB(protectedMakerParamsMap);
159
161
  for (const [key, { userAccount }] of this.usersAccounts.entries()) {
160
162
  const protectedMaker = (0, userStatus_1.isUserProtectedMaker)(userAccount);
161
163
  for (const order of userAccount.orders) {
162
- dlob.insertOrder(order, key, slot, protectedMaker);
164
+ let baseAssetAmount = order.baseAssetAmount;
165
+ if (order.reduceOnly) {
166
+ const existingBaseAmount = ((_a = userAccount.perpPositions.find((pos) => pos.marketIndex === order.marketIndex && pos.openOrders > 0)) === null || _a === void 0 ? void 0 : _a.baseAssetAmount) || index_1.ZERO;
167
+ baseAssetAmount = (0, index_1.calculateOrderBaseAssetAmount)(order, existingBaseAmount);
168
+ }
169
+ dlob.insertOrder(order, key, slot, protectedMaker, baseAssetAmount);
163
170
  }
164
171
  }
165
172
  return dlob;
@@ -18,6 +18,10 @@ export declare enum ExchangeStatus {
18
18
  AMM_IMMEDIATE_FILL_PAUSED = 128,
19
19
  PAUSED = 255
20
20
  }
21
+ export declare enum FeatureBitFlags {
22
+ MM_ORACLE_UPDATE = 1,
23
+ MEDIAN_TRIGGER_PRICE = 2
24
+ }
21
25
  export declare class MarketStatus {
22
26
  static readonly INITIALIZED: {
23
27
  initialized: {};
@@ -860,6 +864,7 @@ export type StateAccount = {
860
864
  initialPctToLiquidate: number;
861
865
  liquidationDuration: number;
862
866
  maxInitializeUserFee: number;
867
+ featureBitFlags: number;
863
868
  };
864
869
  export type PerpMarketAccount = {
865
870
  status: MarketStatus;
@@ -903,6 +908,7 @@ export type PerpMarketAccount = {
903
908
  highLeverageMarginRatioMaintenance: number;
904
909
  protectedMakerLimitPriceDivisor: number;
905
910
  protectedMakerDynamicDivisor: number;
911
+ lastFillPrice: BN;
906
912
  };
907
913
  export type HistoricalOracleData = {
908
914
  lastOraclePrice: BN;
@@ -1081,6 +1087,7 @@ export type AMM = {
1081
1087
  takerSpeedBumpOverride: number;
1082
1088
  ammSpreadAdjustment: number;
1083
1089
  ammInventorySpreadAdjustment: number;
1090
+ lastFundingOracleTwap: BN;
1084
1091
  };
1085
1092
  export type PerpPosition = {
1086
1093
  baseAssetAmount: BN;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwapReduceOnly = exports.PlaceAndTakeOrderSuccessCondition = exports.FuelOverflowStatus = exports.ReferrerStatus = exports.DefaultOrderParams = exports.ModifyOrderPolicy = exports.OrderParamsBitFlag = exports.PostOnlyParams = exports.LiquidationType = exports.LPAction = exports.TradeSide = exports.getVariant = exports.isOneOfVariant = exports.isVariant = exports.SettlePnlMode = exports.StakeAction = exports.SpotFulfillmentConfigStatus = exports.SettlePnlExplanation = exports.DepositExplanation = exports.SpotFulfillmentStatus = exports.SpotFulfillmentType = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderBitFlag = exports.OrderStatus = exports.MarketType = exports.OrderType = exports.OracleSourceNum = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.SpotBalanceType = exports.SwapDirection = exports.TokenProgramFlag = exports.AssetTier = exports.ContractTier = exports.ContractType = exports.MarginMode = exports.UserStatus = exports.InsuranceFundOperation = exports.SpotOperation = exports.PerpOperation = exports.MarketStatus = exports.ExchangeStatus = void 0;
3
+ exports.SwapReduceOnly = exports.PlaceAndTakeOrderSuccessCondition = exports.FuelOverflowStatus = exports.ReferrerStatus = exports.DefaultOrderParams = exports.ModifyOrderPolicy = exports.OrderParamsBitFlag = exports.PostOnlyParams = exports.LiquidationType = exports.LPAction = exports.TradeSide = exports.getVariant = exports.isOneOfVariant = exports.isVariant = exports.SettlePnlMode = exports.StakeAction = exports.SpotFulfillmentConfigStatus = exports.SettlePnlExplanation = exports.DepositExplanation = exports.SpotFulfillmentStatus = exports.SpotFulfillmentType = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderBitFlag = exports.OrderStatus = exports.MarketType = exports.OrderType = exports.OracleSourceNum = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.SpotBalanceType = exports.SwapDirection = exports.TokenProgramFlag = exports.AssetTier = exports.ContractTier = exports.ContractType = exports.MarginMode = exports.UserStatus = exports.InsuranceFundOperation = exports.SpotOperation = exports.PerpOperation = exports.MarketStatus = exports.FeatureBitFlags = exports.ExchangeStatus = void 0;
4
4
  const numericConstants_1 = require("./constants/numericConstants");
5
5
  // # Utility Types / Enums / Constants
6
6
  var ExchangeStatus;
@@ -16,6 +16,11 @@ var ExchangeStatus;
16
16
  ExchangeStatus[ExchangeStatus["AMM_IMMEDIATE_FILL_PAUSED"] = 128] = "AMM_IMMEDIATE_FILL_PAUSED";
17
17
  ExchangeStatus[ExchangeStatus["PAUSED"] = 255] = "PAUSED";
18
18
  })(ExchangeStatus || (exports.ExchangeStatus = ExchangeStatus = {}));
19
+ var FeatureBitFlags;
20
+ (function (FeatureBitFlags) {
21
+ FeatureBitFlags[FeatureBitFlags["MM_ORACLE_UPDATE"] = 1] = "MM_ORACLE_UPDATE";
22
+ FeatureBitFlags[FeatureBitFlags["MEDIAN_TRIGGER_PRICE"] = 2] = "MEDIAN_TRIGGER_PRICE";
23
+ })(FeatureBitFlags || (exports.FeatureBitFlags = FeatureBitFlags = {}));
19
24
  class MarketStatus {
20
25
  }
21
26
  exports.MarketStatus = MarketStatus;
@@ -9,6 +9,7 @@ export declare class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber
9
9
  private stream;
10
10
  private commitmentLevel;
11
11
  listenerId?: number;
12
+ private enableReconnect;
12
13
  private constructor();
13
14
  static create<U>(grpcConfigs: GrpcConfigs, accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => U, resubOpts?: ResubOpts): Promise<grpcAccountSubscriber<U>>;
14
15
  subscribe(onChange: (data: T) => void): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"grpcAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAU1E,qBAAa,qBAAqB,CAAC,CAAC,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO;WAca,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,SAAS,EAC3B,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAqBrB,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA6FrD,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC1D"}
1
+ {"version":3,"file":"grpcAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAU1E,qBAAa,qBAAqB,CAAC,CAAC,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,eAAe,CAAU;IAEjC,OAAO;WAgBa,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,SAAS,EAC3B,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAsBrB,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAsGrD,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC1D"}
@@ -29,10 +29,11 @@ const Buffer = __importStar(require("buffer"));
29
29
  const webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
30
30
  const grpc_1 = require("../isomorphic/grpc");
31
31
  class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccountSubscriber {
32
- constructor(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts) {
32
+ constructor(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts, enableReconnect = false) {
33
33
  super(accountName, program, accountPublicKey, decodeBuffer, resubOpts);
34
34
  this.client = client;
35
35
  this.commitmentLevel = commitmentLevel;
36
+ this.enableReconnect = enableReconnect;
36
37
  }
37
38
  static async create(grpcConfigs, accountName, program, accountPublicKey, decodeBuffer, resubOpts) {
38
39
  var _a, _b;
@@ -40,7 +41,7 @@ class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccoun
40
41
  const commitmentLevel =
41
42
  // @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
42
43
  (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
43
- return new grpcAccountSubscriber(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts);
44
+ return new grpcAccountSubscriber(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts, grpcConfigs.enableReconnect);
44
45
  }
45
46
  async subscribe(onChange) {
46
47
  if (this.listenerId != null || this.isUnsubscribing) {
@@ -70,16 +71,19 @@ class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccoun
70
71
  entry: {},
71
72
  transactionsStatus: {},
72
73
  };
73
- this.stream.on('error', (error) => {
74
- // @ts-ignore
75
- if (error.code === 1) {
76
- // expected: 1 CANCELLED: Cancelled on client
77
- return;
78
- }
79
- else {
80
- console.error('GRPC unexpected error caught:', error);
81
- }
82
- });
74
+ if (this.enableReconnect) {
75
+ this.stream.on('error', (error) => {
76
+ // @ts-ignore
77
+ if (error.code === 1) {
78
+ // expected: 1 CANCELLED: Cancelled on client
79
+ console.error('GRPC (grpcAccountSubscriber) Cancelled on client caught:', error);
80
+ return;
81
+ }
82
+ else {
83
+ console.error('GRPC (grpcAccountSubscriber) unexpected error caught:', error);
84
+ }
85
+ });
86
+ }
83
87
  this.stream.on('data', (chunk) => {
84
88
  var _a;
85
89
  if (!chunk.account) {
@@ -9,6 +9,7 @@ export declare class grpcProgramAccountSubscriber<T> extends WebSocketProgramAcc
9
9
  private stream;
10
10
  private commitmentLevel;
11
11
  listenerId?: number;
12
+ private enableReconnect;
12
13
  private constructor();
13
14
  static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
14
15
  filters: MemcmpFilter[];
@@ -1 +1 @@
1
- {"version":3,"file":"grpcProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcProgramAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAUxF,qBAAa,4BAA4B,CACxC,CAAC,CACA,SAAQ,iCAAiC,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO;WAwBa,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC,EACtD,OAAO,GAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAA;KAEjC,EACD,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;IAsBrC,SAAS,CACd,QAAQ,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,KACV,IAAI,GACP,OAAO,CAAC,IAAI,CAAC;IAsGH,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCxD"}
1
+ {"version":3,"file":"grpcProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcProgramAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAUxF,qBAAa,4BAA4B,CACxC,CAAC,CACA,SAAQ,iCAAiC,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,eAAe,CAAU;IAEjC,OAAO;WA0Ba,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC,EACtD,OAAO,GAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAA;KAEjC,EACD,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;IAuBrC,SAAS,CACd,QAAQ,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,KACV,IAAI,GACP,OAAO,CAAC,IAAI,CAAC;IAiHH,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCxD"}