@metamask-previews/perps-controller 12.2.0-preview-7cfd8be → 12.2.0-preview-364dd6413

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 (60) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/PerpsController-method-action-types.cjs.map +1 -1
  3. package/dist/PerpsController-method-action-types.d.cts +58 -3
  4. package/dist/PerpsController-method-action-types.d.cts.map +1 -1
  5. package/dist/PerpsController-method-action-types.d.mts +58 -3
  6. package/dist/PerpsController-method-action-types.d.mts.map +1 -1
  7. package/dist/PerpsController-method-action-types.mjs.map +1 -1
  8. package/dist/PerpsController.cjs +108 -7
  9. package/dist/PerpsController.cjs.map +1 -1
  10. package/dist/PerpsController.d.cts +49 -5
  11. package/dist/PerpsController.d.cts.map +1 -1
  12. package/dist/PerpsController.d.mts +49 -5
  13. package/dist/PerpsController.d.mts.map +1 -1
  14. package/dist/PerpsController.mjs +108 -9
  15. package/dist/PerpsController.mjs.map +1 -1
  16. package/dist/constants/chartConfig.cjs +13 -1
  17. package/dist/constants/chartConfig.cjs.map +1 -1
  18. package/dist/constants/chartConfig.d.cts +12 -0
  19. package/dist/constants/chartConfig.d.cts.map +1 -1
  20. package/dist/constants/chartConfig.d.mts +12 -0
  21. package/dist/constants/chartConfig.d.mts.map +1 -1
  22. package/dist/constants/chartConfig.mjs +12 -0
  23. package/dist/constants/chartConfig.mjs.map +1 -1
  24. package/dist/constants/perpsConfig.cjs +14 -1
  25. package/dist/constants/perpsConfig.cjs.map +1 -1
  26. package/dist/constants/perpsConfig.d.cts +24 -0
  27. package/dist/constants/perpsConfig.d.cts.map +1 -1
  28. package/dist/constants/perpsConfig.d.mts +24 -0
  29. package/dist/constants/perpsConfig.d.mts.map +1 -1
  30. package/dist/constants/perpsConfig.mjs +13 -0
  31. package/dist/constants/perpsConfig.mjs.map +1 -1
  32. package/dist/index.cjs +12 -5
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +5 -5
  35. package/dist/index.d.cts.map +1 -1
  36. package/dist/index.d.mts +5 -5
  37. package/dist/index.d.mts.map +1 -1
  38. package/dist/index.mjs +3 -3
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/selectors.cjs +69 -15
  41. package/dist/selectors.cjs.map +1 -1
  42. package/dist/selectors.d.cts +52 -117
  43. package/dist/selectors.d.cts.map +1 -1
  44. package/dist/selectors.d.mts +52 -117
  45. package/dist/selectors.d.mts.map +1 -1
  46. package/dist/selectors.mjs +65 -15
  47. package/dist/selectors.mjs.map +1 -1
  48. package/dist/services/HyperLiquidClientService.cjs +37 -4
  49. package/dist/services/HyperLiquidClientService.cjs.map +1 -1
  50. package/dist/services/HyperLiquidClientService.d.cts.map +1 -1
  51. package/dist/services/HyperLiquidClientService.d.mts.map +1 -1
  52. package/dist/services/HyperLiquidClientService.mjs +37 -4
  53. package/dist/services/HyperLiquidClientService.mjs.map +1 -1
  54. package/dist/types/index.cjs.map +1 -1
  55. package/dist/types/index.d.cts +1 -0
  56. package/dist/types/index.d.cts.map +1 -1
  57. package/dist/types/index.d.mts +1 -0
  58. package/dist/types/index.d.mts.map +1 -1
  59. package/dist/types/index.mjs.map +1 -1
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { SortOptionId } from "./constants/perpsConfig.cjs";
2
- import type { PerpsMode, ProLayoutPreferences } from "./constants/perpsConfig.cjs";
2
+ import type { OrderBookPreferences, PerpsMode, ProLayoutPreferences } from "./constants/perpsConfig.cjs";
3
3
  import type { PerpsControllerState } from "./PerpsController.cjs";
4
4
  import type { OrderType, PerpsSelectedPaymentToken, SortDirection } from "./types/index.cjs";
5
5
  /**
@@ -71,6 +71,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
71
71
  stopLossPrice?: string | undefined;
72
72
  limitPrice?: string | undefined;
73
73
  orderType?: OrderType | undefined;
74
+ reduceOnly?: boolean | undefined;
74
75
  timestamp: number;
75
76
  } | undefined;
76
77
  };
@@ -86,6 +87,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
86
87
  stopLossPrice?: string | undefined;
87
88
  limitPrice?: string | undefined;
88
89
  orderType?: OrderType | undefined;
90
+ reduceOnly?: boolean | undefined;
89
91
  timestamp: number;
90
92
  } | undefined;
91
93
  };
@@ -105,6 +107,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
105
107
  stopLossPrice?: string | undefined;
106
108
  limitPrice?: string | undefined;
107
109
  orderType?: OrderType | undefined;
110
+ reduceOnly?: boolean | undefined;
108
111
  timestamp: number;
109
112
  } | undefined;
110
113
  };
@@ -120,6 +123,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
120
123
  stopLossPrice?: string | undefined;
121
124
  limitPrice?: string | undefined;
122
125
  orderType?: OrderType | undefined;
126
+ reduceOnly?: boolean | undefined;
123
127
  timestamp: number;
124
128
  } | undefined;
125
129
  };
@@ -143,9 +147,28 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
143
147
  memoize: typeof import("reselect").weakMapMemoize;
144
148
  argsMemoize: typeof import("reselect").weakMapMemoize;
145
149
  };
150
+ /**
151
+ * Pending trade configuration as returned to consumers (timestamp stripped).
152
+ */
153
+ type PendingTradeConfiguration = {
154
+ amount?: string;
155
+ leverage?: number;
156
+ takeProfitPrice?: string;
157
+ stopLossPrice?: string;
158
+ limitPrice?: string;
159
+ orderType?: OrderType;
160
+ reduceOnly?: boolean;
161
+ selectedPaymentToken?: PerpsSelectedPaymentToken | null;
162
+ };
146
163
  /**
147
164
  * Select pending trade configuration for a specific market on the current network.
148
- * Returns undefined if config doesn't exist or has expired (more than 5 minutes old).
165
+ * Returns undefined if config doesn't exist or has expired.
166
+ *
167
+ * The underlying data extraction is memoized for stable object references, but
168
+ * the TTL is checked on every call (using `Date.now()`) so expiry stays accurate
169
+ * even when the memoized inputs have not changed. This mirrors
170
+ * `PerpsController.getPendingTradeConfiguration`, which also evaluates time on
171
+ * every call.
149
172
  *
150
173
  * Usage: selectPendingTradeConfiguration(state, coin)
151
174
  *
@@ -153,121 +176,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
153
176
  * @param coin - The market coin symbol.
154
177
  * @returns The pending trade configuration, or undefined if expired or not found.
155
178
  */
156
- export declare const selectPendingTradeConfiguration: ((state: PerpsControllerState, _coin: string) => {
157
- amount?: string | undefined;
158
- leverage?: number | undefined;
159
- takeProfitPrice?: string | undefined;
160
- stopLossPrice?: string | undefined;
161
- limitPrice?: string | undefined;
162
- orderType?: OrderType | undefined;
163
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
164
- } | undefined) & {
165
- clearCache: () => void;
166
- resultsCount: () => number;
167
- resetResultsCount: () => void;
168
- } & {
169
- resultFunc: (resultFuncArgs_0: boolean | undefined, resultFuncArgs_1: {
170
- testnet: {
171
- [marketSymbol: string]: {
172
- leverage?: number | undefined;
173
- orderBookGrouping?: number | undefined;
174
- pendingConfig?: {
175
- amount?: string | undefined;
176
- leverage?: number | undefined;
177
- takeProfitPrice?: string | undefined;
178
- stopLossPrice?: string | undefined;
179
- limitPrice?: string | undefined;
180
- orderType?: OrderType | undefined;
181
- timestamp: number;
182
- } | undefined;
183
- };
184
- };
185
- mainnet: {
186
- [marketSymbol: string]: {
187
- leverage?: number | undefined;
188
- orderBookGrouping?: number | undefined;
189
- pendingConfig?: {
190
- amount?: string | undefined;
191
- leverage?: number | undefined;
192
- takeProfitPrice?: string | undefined;
193
- stopLossPrice?: string | undefined;
194
- limitPrice?: string | undefined;
195
- orderType?: OrderType | undefined;
196
- timestamp: number;
197
- } | undefined;
198
- };
199
- };
200
- } | undefined, resultFuncArgs_2: string) => {
201
- amount?: string | undefined;
202
- leverage?: number | undefined;
203
- takeProfitPrice?: string | undefined;
204
- stopLossPrice?: string | undefined;
205
- limitPrice?: string | undefined;
206
- orderType?: OrderType | undefined;
207
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
208
- } | undefined;
209
- memoizedResultFunc: ((resultFuncArgs_0: boolean | undefined, resultFuncArgs_1: {
210
- testnet: {
211
- [marketSymbol: string]: {
212
- leverage?: number | undefined;
213
- orderBookGrouping?: number | undefined;
214
- pendingConfig?: {
215
- amount?: string | undefined;
216
- leverage?: number | undefined;
217
- takeProfitPrice?: string | undefined;
218
- stopLossPrice?: string | undefined;
219
- limitPrice?: string | undefined;
220
- orderType?: OrderType | undefined;
221
- timestamp: number;
222
- } | undefined;
223
- };
224
- };
225
- mainnet: {
226
- [marketSymbol: string]: {
227
- leverage?: number | undefined;
228
- orderBookGrouping?: number | undefined;
229
- pendingConfig?: {
230
- amount?: string | undefined;
231
- leverage?: number | undefined;
232
- takeProfitPrice?: string | undefined;
233
- stopLossPrice?: string | undefined;
234
- limitPrice?: string | undefined;
235
- orderType?: OrderType | undefined;
236
- timestamp: number;
237
- } | undefined;
238
- };
239
- };
240
- } | undefined, resultFuncArgs_2: string) => {
241
- amount?: string | undefined;
242
- leverage?: number | undefined;
243
- takeProfitPrice?: string | undefined;
244
- stopLossPrice?: string | undefined;
245
- limitPrice?: string | undefined;
246
- orderType?: OrderType | undefined;
247
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
248
- } | undefined) & {
249
- clearCache: () => void;
250
- resultsCount: () => number;
251
- resetResultsCount: () => void;
252
- };
253
- lastResult: () => {
254
- amount?: string | undefined;
255
- leverage?: number | undefined;
256
- takeProfitPrice?: string | undefined;
257
- stopLossPrice?: string | undefined;
258
- limitPrice?: string | undefined;
259
- orderType?: OrderType | undefined;
260
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
261
- } | undefined;
262
- dependencies: [(state: PerpsControllerState) => boolean | undefined, (state: PerpsControllerState, _coin: string) => PerpsControllerState['tradeConfigurations'] | undefined, (_state: PerpsControllerState, coin: string) => string];
263
- recomputations: () => number;
264
- resetRecomputations: () => void;
265
- dependencyRecomputations: () => number;
266
- resetDependencyRecomputations: () => void;
267
- } & {
268
- memoize: typeof import("reselect").weakMapMemoize;
269
- argsMemoize: typeof import("reselect").weakMapMemoize;
270
- };
179
+ export declare const selectPendingTradeConfiguration: (state: PerpsControllerState, coin: string) => PendingTradeConfiguration | undefined;
271
180
  /**
272
181
  * Select market filter preferences (network-independent)
273
182
  *
@@ -288,6 +197,27 @@ export declare const selectMarketFilterPreferences: (state: PerpsControllerState
288
197
  * @returns The pro-mode layout preferences object
289
198
  */
290
199
  export declare const selectProLayoutPreferences: (state: PerpsControllerState) => ProLayoutPreferences;
200
+ /**
201
+ * Select market-agnostic Pro order-book display preferences.
202
+ *
203
+ * @param state - PerpsController state
204
+ * @returns The order-book display preferences
205
+ */
206
+ export declare const selectOrderBookPreferences: (state: PerpsControllerState) => OrderBookPreferences;
207
+ /**
208
+ * Select the market-agnostic order type.
209
+ *
210
+ * @param state - PerpsController state
211
+ * @returns The selected order type
212
+ */
213
+ export declare const selectSelectedOrderType: (state: PerpsControllerState) => OrderType;
214
+ /**
215
+ * Select the visible candle count shared by Lite and Pro.
216
+ *
217
+ * @param state - PerpsController state
218
+ * @returns The visible candle count
219
+ */
220
+ export declare const selectVisibleCandleCount: (state: PerpsControllerState) => number;
291
221
  /**
292
222
  * Select the current Perps interface mode (lite/pro).
293
223
  *
@@ -323,6 +253,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
323
253
  stopLossPrice?: string | undefined;
324
254
  limitPrice?: string | undefined;
325
255
  orderType?: OrderType | undefined;
256
+ reduceOnly?: boolean | undefined;
326
257
  timestamp: number;
327
258
  } | undefined;
328
259
  };
@@ -338,6 +269,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
338
269
  stopLossPrice?: string | undefined;
339
270
  limitPrice?: string | undefined;
340
271
  orderType?: OrderType | undefined;
272
+ reduceOnly?: boolean | undefined;
341
273
  timestamp: number;
342
274
  } | undefined;
343
275
  };
@@ -355,6 +287,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
355
287
  stopLossPrice?: string | undefined;
356
288
  limitPrice?: string | undefined;
357
289
  orderType?: OrderType | undefined;
290
+ reduceOnly?: boolean | undefined;
358
291
  timestamp: number;
359
292
  } | undefined;
360
293
  };
@@ -370,6 +303,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
370
303
  stopLossPrice?: string | undefined;
371
304
  limitPrice?: string | undefined;
372
305
  orderType?: OrderType | undefined;
306
+ reduceOnly?: boolean | undefined;
373
307
  timestamp: number;
374
308
  } | undefined;
375
309
  };
@@ -389,4 +323,5 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
389
323
  memoize: typeof import("reselect").weakMapMemoize;
390
324
  argsMemoize: typeof import("reselect").weakMapMemoize;
391
325
  };
326
+ export {};
392
327
  //# sourceMappingURL=selectors.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,YAAY,EAGb,oCAAmC;AACpC,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACrB,oCAAmC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA6B;AACjE,OAAO,KAAK,EACV,SAAS,EACT,yBAAyB,EACzB,aAAa,EACd,0BAAyB;AAE1B;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UACzB,oBAAoB,GAAG,SAAS,KACtC,OAKF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,UAC7B,oBAAoB,KAC1B,OAKF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAC1B,oBAAoB,KAC1B,MAAM,EAKR,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,UAC3B,oBAAoB,UACnB,MAAM,KACb,OAGF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,UAC/B,oBAAoB,KAC1B,MAAM,EASR,CAAC;AAEF;;;;;;;;;GASG;AA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erpsMode, ProLayoutPreferences } from "./constants/perpsConfig.mjs";
2
+ import type { OrderBookPreferences, PerpsMode, ProLayoutPreferences } from "./constants/perpsConfig.mjs";
3
3
  import type { PerpsControllerState } from "./PerpsController.mjs";
4
4
  import type { OrderType, PerpsSelectedPaymentToken, SortDirection } from "./types/index.mjs";
5
5
  /**
@@ -71,6 +71,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
71
71
  stopLossPrice?: string | undefined;
72
72
  limitPrice?: string | undefined;
73
73
  orderType?: OrderType | undefined;
74
+ reduceOnly?: boolean | undefined;
74
75
  timestamp: number;
75
76
  } | undefined;
76
77
  };
@@ -86,6 +87,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
86
87
  stopLossPrice?: string | undefined;
87
88
  limitPrice?: string | undefined;
88
89
  orderType?: OrderType | undefined;
90
+ reduceOnly?: boolean | undefined;
89
91
  timestamp: number;
90
92
  } | undefined;
91
93
  };
@@ -105,6 +107,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
105
107
  stopLossPrice?: string | undefined;
106
108
  limitPrice?: string | undefined;
107
109
  orderType?: OrderType | undefined;
110
+ reduceOnly?: boolean | undefined;
108
111
  timestamp: number;
109
112
  } | undefined;
110
113
  };
@@ -120,6 +123,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
120
123
  stopLossPrice?: string | undefined;
121
124
  limitPrice?: string | undefined;
122
125
  orderType?: OrderType | undefined;
126
+ reduceOnly?: boolean | undefined;
123
127
  timestamp: number;
124
128
  } | undefined;
125
129
  };
@@ -143,9 +147,28 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
143
147
  memoize: typeof import("reselect").weakMapMemoize;
144
148
  argsMemoize: typeof import("reselect").weakMapMemoize;
145
149
  };
150
+ /**
151
+ * Pending trade configuration as returned to consumers (timestamp stripped).
152
+ */
153
+ type PendingTradeConfiguration = {
154
+ amount?: string;
155
+ leverage?: number;
156
+ takeProfitPrice?: string;
157
+ stopLossPrice?: string;
158
+ limitPrice?: string;
159
+ orderType?: OrderType;
160
+ reduceOnly?: boolean;
161
+ selectedPaymentToken?: PerpsSelectedPaymentToken | null;
162
+ };
146
163
  /**
147
164
  * Select pending trade configuration for a specific market on the current network.
148
- * Returns undefined if config doesn't exist or has expired (more than 5 minutes old).
165
+ * Returns undefined if config doesn't exist or has expired.
166
+ *
167
+ * The underlying data extraction is memoized for stable object references, but
168
+ * the TTL is checked on every call (using `Date.now()`) so expiry stays accurate
169
+ * even when the memoized inputs have not changed. This mirrors
170
+ * `PerpsController.getPendingTradeConfiguration`, which also evaluates time on
171
+ * every call.
149
172
  *
150
173
  * Usage: selectPendingTradeConfiguration(state, coin)
151
174
  *
@@ -153,121 +176,7 @@ export declare const selectTradeConfiguration: ((state: PerpsControllerState, _c
153
176
  * @param coin - The market coin symbol.
154
177
  * @returns The pending trade configuration, or undefined if expired or not found.
155
178
  */
156
- export declare const selectPendingTradeConfiguration: ((state: PerpsControllerState, _coin: string) => {
157
- amount?: string | undefined;
158
- leverage?: number | undefined;
159
- takeProfitPrice?: string | undefined;
160
- stopLossPrice?: string | undefined;
161
- limitPrice?: string | undefined;
162
- orderType?: OrderType | undefined;
163
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
164
- } | undefined) & {
165
- clearCache: () => void;
166
- resultsCount: () => number;
167
- resetResultsCount: () => void;
168
- } & {
169
- resultFunc: (resultFuncArgs_0: boolean | undefined, resultFuncArgs_1: {
170
- testnet: {
171
- [marketSymbol: string]: {
172
- leverage?: number | undefined;
173
- orderBookGrouping?: number | undefined;
174
- pendingConfig?: {
175
- amount?: string | undefined;
176
- leverage?: number | undefined;
177
- takeProfitPrice?: string | undefined;
178
- stopLossPrice?: string | undefined;
179
- limitPrice?: string | undefined;
180
- orderType?: OrderType | undefined;
181
- timestamp: number;
182
- } | undefined;
183
- };
184
- };
185
- mainnet: {
186
- [marketSymbol: string]: {
187
- leverage?: number | undefined;
188
- orderBookGrouping?: number | undefined;
189
- pendingConfig?: {
190
- amount?: string | undefined;
191
- leverage?: number | undefined;
192
- takeProfitPrice?: string | undefined;
193
- stopLossPrice?: string | undefined;
194
- limitPrice?: string | undefined;
195
- orderType?: OrderType | undefined;
196
- timestamp: number;
197
- } | undefined;
198
- };
199
- };
200
- } | undefined, resultFuncArgs_2: string) => {
201
- amount?: string | undefined;
202
- leverage?: number | undefined;
203
- takeProfitPrice?: string | undefined;
204
- stopLossPrice?: string | undefined;
205
- limitPrice?: string | undefined;
206
- orderType?: OrderType | undefined;
207
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
208
- } | undefined;
209
- memoizedResultFunc: ((resultFuncArgs_0: boolean | undefined, resultFuncArgs_1: {
210
- testnet: {
211
- [marketSymbol: string]: {
212
- leverage?: number | undefined;
213
- orderBookGrouping?: number | undefined;
214
- pendingConfig?: {
215
- amount?: string | undefined;
216
- leverage?: number | undefined;
217
- takeProfitPrice?: string | undefined;
218
- stopLossPrice?: string | undefined;
219
- limitPrice?: string | undefined;
220
- orderType?: OrderType | undefined;
221
- timestamp: number;
222
- } | undefined;
223
- };
224
- };
225
- mainnet: {
226
- [marketSymbol: string]: {
227
- leverage?: number | undefined;
228
- orderBookGrouping?: number | undefined;
229
- pendingConfig?: {
230
- amount?: string | undefined;
231
- leverage?: number | undefined;
232
- takeProfitPrice?: string | undefined;
233
- stopLossPrice?: string | undefined;
234
- limitPrice?: string | undefined;
235
- orderType?: OrderType | undefined;
236
- timestamp: number;
237
- } | undefined;
238
- };
239
- };
240
- } | undefined, resultFuncArgs_2: string) => {
241
- amount?: string | undefined;
242
- leverage?: number | undefined;
243
- takeProfitPrice?: string | undefined;
244
- stopLossPrice?: string | undefined;
245
- limitPrice?: string | undefined;
246
- orderType?: OrderType | undefined;
247
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
248
- } | undefined) & {
249
- clearCache: () => void;
250
- resultsCount: () => number;
251
- resetResultsCount: () => void;
252
- };
253
- lastResult: () => {
254
- amount?: string | undefined;
255
- leverage?: number | undefined;
256
- takeProfitPrice?: string | undefined;
257
- stopLossPrice?: string | undefined;
258
- limitPrice?: string | undefined;
259
- orderType?: OrderType | undefined;
260
- selectedPaymentToken?: PerpsSelectedPaymentToken | null | undefined;
261
- } | undefined;
262
- dependencies: [(state: PerpsControllerState) => boolean | undefined, (state: PerpsControllerState, _coin: string) => PerpsControllerState['tradeConfigurations'] | undefined, (_state: PerpsControllerState, coin: string) => string];
263
- recomputations: () => number;
264
- resetRecomputations: () => void;
265
- dependencyRecomputations: () => number;
266
- resetDependencyRecomputations: () => void;
267
- } & {
268
- memoize: typeof import("reselect").weakMapMemoize;
269
- argsMemoize: typeof import("reselect").weakMapMemoize;
270
- };
179
+ export declare const selectPendingTradeConfiguration: (state: PerpsControllerState, coin: string) => PendingTradeConfiguration | undefined;
271
180
  /**
272
181
  * Select market filter preferences (network-independent)
273
182
  *
@@ -288,6 +197,27 @@ export declare const selectMarketFilterPreferences: (state: PerpsControllerState
288
197
  * @returns The pro-mode layout preferences object
289
198
  */
290
199
  export declare const selectProLayoutPreferences: (state: PerpsControllerState) => ProLayoutPreferences;
200
+ /**
201
+ * Select market-agnostic Pro order-book display preferences.
202
+ *
203
+ * @param state - PerpsController state
204
+ * @returns The order-book display preferences
205
+ */
206
+ export declare const selectOrderBookPreferences: (state: PerpsControllerState) => OrderBookPreferences;
207
+ /**
208
+ * Select the market-agnostic order type.
209
+ *
210
+ * @param state - PerpsController state
211
+ * @returns The selected order type
212
+ */
213
+ export declare const selectSelectedOrderType: (state: PerpsControllerState) => OrderType;
214
+ /**
215
+ * Select the visible candle count shared by Lite and Pro.
216
+ *
217
+ * @param state - PerpsController state
218
+ * @returns The visible candle count
219
+ */
220
+ export declare const selectVisibleCandleCount: (state: PerpsControllerState) => number;
291
221
  /**
292
222
  * Select the current Perps interface mode (lite/pro).
293
223
  *
@@ -323,6 +253,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
323
253
  stopLossPrice?: string | undefined;
324
254
  limitPrice?: string | undefined;
325
255
  orderType?: OrderType | undefined;
256
+ reduceOnly?: boolean | undefined;
326
257
  timestamp: number;
327
258
  } | undefined;
328
259
  };
@@ -338,6 +269,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
338
269
  stopLossPrice?: string | undefined;
339
270
  limitPrice?: string | undefined;
340
271
  orderType?: OrderType | undefined;
272
+ reduceOnly?: boolean | undefined;
341
273
  timestamp: number;
342
274
  } | undefined;
343
275
  };
@@ -355,6 +287,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
355
287
  stopLossPrice?: string | undefined;
356
288
  limitPrice?: string | undefined;
357
289
  orderType?: OrderType | undefined;
290
+ reduceOnly?: boolean | undefined;
358
291
  timestamp: number;
359
292
  } | undefined;
360
293
  };
@@ -370,6 +303,7 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
370
303
  stopLossPrice?: string | undefined;
371
304
  limitPrice?: string | undefined;
372
305
  orderType?: OrderType | undefined;
306
+ reduceOnly?: boolean | undefined;
373
307
  timestamp: number;
374
308
  } | undefined;
375
309
  };
@@ -389,4 +323,5 @@ export declare const selectOrderBookGrouping: ((state: PerpsControllerState, _co
389
323
  memoize: typeof import("reselect").weakMapMemoize;
390
324
  argsMemoize: typeof import("reselect").weakMapMemoize;
391
325
  };
326
+ export {};
392
327
  //# sourceMappingURL=selectors.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,YAAY,EAGb,oCAAmC;AACpC,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACrB,oCAAmC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA6B;AACjE,OAAO,KAAK,EACV,SAAS,EACT,yBAAyB,EACzB,aAAa,EACd,0BAAyB;AAE1B;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAC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AC3B,CAAC;AAEpC;;;;;;;;GAQG;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAExB,oBAAoB,KAAG,OAAO,GAAG,SAAS,UAEzC,oBAAoB,SACpB,MAAM,KACZ,oBAAoB,CAAC,qBAAqB,CAAC,GAAG,SAAS,WAEjD,oBAAoB,QAAQ,MAAM,KAAG,MAAM;;;;;;;;CAMvD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { createSelector } from "reselect";
2
- import { MARKET_SORTING_CONFIG, PERPS_CONSTANTS, DEFAULT_PRO_LAYOUT_PREFERENCES, DEFAULT_PERPS_MODE } from "./constants/perpsConfig.mjs";
2
+ import { VISIBLE_CANDLE_COUNT_CONFIG } from "./constants/chartConfig.mjs";
3
+ import { MARKET_SORTING_CONFIG, PERPS_CONSTANTS, DEFAULT_ORDER_BOOK_PREFERENCES, DEFAULT_PRO_LAYOUT_PREFERENCES, DEFAULT_PERPS_MODE, DEFAULT_SELECTED_ORDER_TYPE } from "./constants/perpsConfig.mjs";
3
4
  /**
4
5
  * Select whether the user is a first-time perps user
5
6
  *
@@ -89,16 +90,20 @@ export const selectTradeConfiguration = createSelector([
89
90
  return { leverage: config.leverage };
90
91
  });
91
92
  /**
92
- * Select pending trade configuration for a specific market on the current network.
93
- * Returns undefined if config doesn't exist or has expired (more than 5 minutes old).
93
+ * Memoized extractor for the raw pending trade configuration of a market.
94
94
  *
95
- * Usage: selectPendingTradeConfiguration(state, coin)
95
+ * Keyed on `isTestnet`, `tradeConfigurations`, and `coin` so it yields a stable
96
+ * object reference (both the stripped `config` and its `timestamp`) while those
97
+ * inputs are unchanged. The TTL is deliberately NOT evaluated here: because the
98
+ * result is memoized, evaluating expiry inside this selector would freeze the
99
+ * `Date.now()` check between input changes. Expiry is applied per-call by
100
+ * `selectPendingTradeConfiguration` instead.
96
101
  *
97
102
  * @param state - The perps controller state.
98
103
  * @param coin - The market coin symbol.
99
- * @returns The pending trade configuration, or undefined if expired or not found.
104
+ * @returns The stripped config and its save timestamp, or undefined.
100
105
  */
101
- export const selectPendingTradeConfiguration = createSelector([
106
+ const selectRawPendingTradeConfiguration = createSelector([
102
107
  (state) => state?.isTestnet,
103
108
  (state, _coin) => state?.tradeConfigurations,
104
109
  (_state, coin) => coin,
@@ -108,18 +113,37 @@ export const selectPendingTradeConfiguration = createSelector([
108
113
  if (!config) {
109
114
  return undefined;
110
115
  }
111
- // Check if config has expired (5 minutes = 300,000 milliseconds)
112
- const now = Date.now();
113
- const FIVE_MINUTES_MS = 5 * 60 * 1000;
114
- const age = now - config.timestamp;
115
- if (age > FIVE_MINUTES_MS) {
116
+ const { timestamp, ...configWithoutTimestamp } = config;
117
+ return { timestamp, config: configWithoutTimestamp };
118
+ });
119
+ /**
120
+ * Select pending trade configuration for a specific market on the current network.
121
+ * Returns undefined if config doesn't exist or has expired.
122
+ *
123
+ * The underlying data extraction is memoized for stable object references, but
124
+ * the TTL is checked on every call (using `Date.now()`) so expiry stays accurate
125
+ * even when the memoized inputs have not changed. This mirrors
126
+ * `PerpsController.getPendingTradeConfiguration`, which also evaluates time on
127
+ * every call.
128
+ *
129
+ * Usage: selectPendingTradeConfiguration(state, coin)
130
+ *
131
+ * @param state - The perps controller state.
132
+ * @param coin - The market coin symbol.
133
+ * @returns The pending trade configuration, or undefined if expired or not found.
134
+ */
135
+ export const selectPendingTradeConfiguration = (state, coin) => {
136
+ const raw = selectRawPendingTradeConfiguration(state, coin);
137
+ if (!raw) {
138
+ return undefined;
139
+ }
140
+ const age = Date.now() - raw.timestamp;
141
+ if (age > PERPS_CONSTANTS.PendingTradeConfigurationTtlMs) {
116
142
  // Config expired, return undefined
117
143
  return undefined;
118
144
  }
119
- // Return config without timestamp
120
- const { timestamp, ...configWithoutTimestamp } = config;
121
- return configWithoutTimestamp;
122
- });
145
+ return raw.config;
146
+ };
123
147
  /**
124
148
  * Select market filter preferences (network-independent)
125
149
  *
@@ -170,6 +194,32 @@ export const selectProLayoutPreferences = (state) => ({
170
194
  ...DEFAULT_PRO_LAYOUT_PREFERENCES,
171
195
  ...state?.proLayoutPreferences,
172
196
  });
197
+ /**
198
+ * Select market-agnostic Pro order-book display preferences.
199
+ *
200
+ * @param state - PerpsController state
201
+ * @returns The order-book display preferences
202
+ */
203
+ export const selectOrderBookPreferences = (state) => ({
204
+ ...DEFAULT_ORDER_BOOK_PREFERENCES,
205
+ ...state?.orderBookPreferences,
206
+ });
207
+ /**
208
+ * Select the market-agnostic order type.
209
+ *
210
+ * @param state - PerpsController state
211
+ * @returns The selected order type
212
+ */
213
+ export const selectSelectedOrderType = (state) => state?.selectedOrderType ?? DEFAULT_SELECTED_ORDER_TYPE;
214
+ /**
215
+ * Select the visible candle count shared by Lite and Pro.
216
+ *
217
+ * @param state - PerpsController state
218
+ * @returns The visible candle count
219
+ */
220
+ export const selectVisibleCandleCount = (state) => Number.isFinite(state?.visibleCandleCount)
221
+ ? state.visibleCandleCount
222
+ : VISIBLE_CANDLE_COUNT_CONFIG.Default;
173
223
  /**
174
224
  * Select the current Perps interface mode (lite/pro).
175
225
  *