@0xmonaco/react 1.0.81 → 1.0.83

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 (35) hide show
  1. package/dist/coverage.d.ts +11 -0
  2. package/dist/coverage.js +11 -0
  3. package/dist/hooks/index.d.ts +1 -1
  4. package/dist/hooks/index.js +1 -1
  5. package/dist/hooks/useOHLCV/mergeLiveCandleOpenInterest.d.ts +6 -0
  6. package/dist/hooks/useOHLCV/mergeLiveCandleOpenInterest.js +14 -0
  7. package/dist/hooks/useOHLCV/useOHLCV.js +7 -4
  8. package/dist/hooks/usePitpass/index.d.ts +10 -11
  9. package/dist/hooks/usePitpass/index.js +10 -10
  10. package/dist/hooks/useTraderCodes/index.d.ts +11 -0
  11. package/dist/hooks/useTraderCodes/index.js +10 -0
  12. package/dist/hooks/{usePitpass → useTraderCodes}/useClearTraderCode.js +1 -1
  13. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralDownline.js +1 -1
  14. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralPosition.js +1 -1
  15. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralTree.js +1 -1
  16. package/dist/hooks/{usePitpass → useTraderCodes}/useMyTraderCode.d.ts +1 -1
  17. package/dist/hooks/{usePitpass → useTraderCodes}/useMyTraderCode.js +2 -2
  18. package/dist/hooks/{usePitpass → useTraderCodes}/useRewardsBalance.js +1 -1
  19. package/dist/hooks/{usePitpass → useTraderCodes}/useSetTraderCode.js +1 -1
  20. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeAvailability.js +1 -1
  21. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeInfo.d.ts +1 -1
  22. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeInfo.js +2 -2
  23. package/dist/hooks/{usePitpass → useTraderCodes}/useTransferRewards.js +1 -1
  24. package/dist/hooks/useUserOrders/useUserOrders.js +66 -25
  25. package/package.json +3 -3
  26. /package/dist/hooks/{usePitpass → useTraderCodes}/types.d.ts +0 -0
  27. /package/dist/hooks/{usePitpass → useTraderCodes}/types.js +0 -0
  28. /package/dist/hooks/{usePitpass → useTraderCodes}/useClearTraderCode.d.ts +0 -0
  29. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralDownline.d.ts +0 -0
  30. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralPosition.d.ts +0 -0
  31. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralTree.d.ts +0 -0
  32. /package/dist/hooks/{usePitpass → useTraderCodes}/useRewardsBalance.d.ts +0 -0
  33. /package/dist/hooks/{usePitpass → useTraderCodes}/useSetTraderCode.d.ts +0 -0
  34. /package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeAvailability.d.ts +0 -0
  35. /package/dist/hooks/{usePitpass → useTraderCodes}/useTransferRewards.d.ts +0 -0
@@ -74,6 +74,16 @@ export declare const COVERED: {
74
74
  };
75
75
  /** operationId → reason it is intentionally not covered by @0xmonaco/react. */
76
76
  export declare const INTENTIONALLY_EXCLUDED: {
77
+ pitpass_get_my_trader_code: string;
78
+ pitpass_set_trader_code: string;
79
+ pitpass_clear_trader_code: string;
80
+ pitpass_check_trader_code_availability: string;
81
+ pitpass_get_trader_code_info: string;
82
+ pitpass_get_rewards_balance: string;
83
+ pitpass_transfer_rewards: string;
84
+ pitpass_get_my_referral_position: string;
85
+ pitpass_get_my_referral_downline: string;
86
+ pitpass_get_my_referral_tree: string;
77
87
  list_managed_market_assignments: string;
78
88
  claim_managed_market_lease: string;
79
89
  refresh_managed_market_quotes: string;
@@ -128,6 +138,7 @@ export declare const INTENTIONALLY_EXCLUDED: {
128
138
  list_margin_accounts: string;
129
139
  list_sub_accounts_with_balances: string;
130
140
  list_twap_orders: string;
141
+ list_twap_order_slices: string;
131
142
  mint_tokens: string;
132
143
  revoke_delegated_agent: string;
133
144
  simulate_risk_bucket_order_risk: string;
package/dist/coverage.js CHANGED
@@ -74,6 +74,16 @@ export const COVERED = {
74
74
  };
75
75
  /** operationId → reason it is intentionally not covered by @0xmonaco/react. */
76
76
  export const INTENTIONALLY_EXCLUDED = {
77
+ pitpass_get_my_trader_code: "Deprecated /api/v1/pitpass alias of get_my_trader_code; the hooks call the canonical /api/v1/tradercodes path.",
78
+ pitpass_set_trader_code: "Deprecated /api/v1/pitpass alias of set_trader_code; the hooks call the canonical /api/v1/tradercodes path.",
79
+ pitpass_clear_trader_code: "Deprecated /api/v1/pitpass alias of clear_trader_code; the hooks call the canonical /api/v1/tradercodes path.",
80
+ pitpass_check_trader_code_availability: "Deprecated /api/v1/pitpass alias of check_trader_code_availability; the hooks call the canonical /api/v1/tradercodes path.",
81
+ pitpass_get_trader_code_info: "Deprecated /api/v1/pitpass alias of get_trader_code_info; the hooks call the canonical /api/v1/tradercodes path.",
82
+ pitpass_get_rewards_balance: "Deprecated /api/v1/pitpass alias of get_rewards_balance; the hooks call the canonical /api/v1/tradercodes path.",
83
+ pitpass_transfer_rewards: "Deprecated /api/v1/pitpass alias of transfer_rewards; the hooks call the canonical /api/v1/tradercodes path.",
84
+ pitpass_get_my_referral_position: "Deprecated /api/v1/pitpass alias of get_my_referral_position; the hooks call the canonical /api/v1/tradercodes path.",
85
+ pitpass_get_my_referral_downline: "Deprecated /api/v1/pitpass alias of get_my_referral_downline; the hooks call the canonical /api/v1/tradercodes path.",
86
+ pitpass_get_my_referral_tree: "Deprecated /api/v1/pitpass alias of get_my_referral_tree; the hooks call the canonical /api/v1/tradercodes path.",
77
87
  list_managed_market_assignments: "Operational maker inventory; consumed by the authenticated bot driver through the core SDK.",
78
88
  claim_managed_market_lease: "Process lease lifecycle belongs to the managed maker driver, not an interactive consumer.",
79
89
  refresh_managed_market_quotes: "Cadenced fenced intents belong to the managed maker driver; core SDK exposes the transport.",
@@ -128,6 +138,7 @@ export const INTENTIONALLY_EXCLUDED = {
128
138
  list_margin_accounts: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
129
139
  list_sub_accounts_with_balances: "Sub-account administration; no React hook.",
130
140
  list_twap_orders: "TWAP parent orders are an advanced execution-algo surface (covered by @0xmonaco/core); no React hook yet.",
141
+ list_twap_order_slices: "TWAP parent orders are an advanced execution-algo surface (covered by @0xmonaco/core); no React hook yet.",
131
142
  mint_tokens: "Test-net faucet; no React hook (use the MCP/core faucet path).",
132
143
  revoke_delegated_agent: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
133
144
  simulate_risk_bucket_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
@@ -7,13 +7,13 @@ export * from "./useMarket";
7
7
  export * from "./useMonaco";
8
8
  export * from "./useOHLCV";
9
9
  export * from "./useOrderbook";
10
- export * from "./usePitpass";
11
10
  export * from "./usePositionPnlHistory";
12
11
  export * from "./usePositions";
13
12
  export * from "./useProfile";
14
13
  export * from "./useTokenLifecycle";
15
14
  export * from "./useTrade";
16
15
  export * from "./useTradeFeed";
16
+ export * from "./useTraderCodes";
17
17
  export * from "./useUserBalances";
18
18
  export * from "./useUserMovements";
19
19
  export * from "./useUserOrders";
@@ -7,13 +7,13 @@ export * from "./useMarket";
7
7
  export * from "./useMonaco";
8
8
  export * from "./useOHLCV";
9
9
  export * from "./useOrderbook";
10
- export * from "./usePitpass";
11
10
  export * from "./usePositionPnlHistory";
12
11
  export * from "./usePositions";
13
12
  export * from "./useProfile";
14
13
  export * from "./useTokenLifecycle";
15
14
  export * from "./useTrade";
16
15
  export * from "./useTradeFeed";
16
+ export * from "./useTraderCodes";
17
17
  export * from "./useUserBalances";
18
18
  export * from "./useUserMovements";
19
19
  export * from "./useUserOrders";
@@ -0,0 +1,6 @@
1
+ import type { Candlestick } from "@0xmonaco/types";
2
+ /**
3
+ * Live candle events may omit persisted OI. Keep the REST-sampled pair only
4
+ * while updating that same candle; a new candle must not inherit the old pair.
5
+ */
6
+ export declare function mergeLiveCandleOpenInterest(previous: Candlestick | undefined, live: Candlestick): Candlestick;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Live candle events may omit persisted OI. Keep the REST-sampled pair only
3
+ * while updating that same candle; a new candle must not inherit the old pair.
4
+ */
5
+ export function mergeLiveCandleOpenInterest(previous, live) {
6
+ if (previous?.T === live.T && live.openInterestBase == null && live.openInterestNotional == null) {
7
+ return {
8
+ ...live,
9
+ openInterestBase: previous.openInterestBase,
10
+ openInterestNotional: previous.openInterestNotional,
11
+ };
12
+ }
13
+ return live;
14
+ }
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
2
  import { useMonacoSDK } from "../useMonaco";
3
+ import { mergeLiveCandleOpenInterest } from "./mergeLiveCandleOpenInterest";
3
4
  /**
4
5
  * Hook for subscribing to real-time OHLCV candlestick events via WebSocket (public)
5
6
  *
@@ -37,16 +38,18 @@ export function useOHLCV(params) {
37
38
  try {
38
39
  unsubscribe = sdk.ws.ohlcv(tradingPairId, tradingMode, interval, (event) => {
39
40
  setCandlesticks((prev) => {
41
+ const lastCandle = prev[prev.length - 1];
42
+ const liveCandle = event.candlestick;
43
+ const candle = mergeLiveCandleOpenInterest(lastCandle, liveCandle);
40
44
  if (prev.length === 0) {
41
- return [event.candlestick];
45
+ return [candle];
42
46
  }
43
- const lastCandle = prev[prev.length - 1];
44
47
  if (lastCandle && lastCandle.T === event.candlestick.T) {
45
48
  const updated = [...prev];
46
- updated[updated.length - 1] = event.candlestick;
49
+ updated[updated.length - 1] = candle;
47
50
  return updated;
48
51
  }
49
- return [...prev, event.candlestick];
52
+ return [...prev, candle];
50
53
  });
51
54
  });
52
55
  setSubscribed(true);
@@ -1,11 +1,10 @@
1
- export type { UseClearTraderCodeReturn, UseMyReferralDownlineReturn, UseMyReferralPositionReturn, UseMyReferralTreeReturn, UseMyTraderCodeReturn, UseRewardsBalanceReturn, UseSetTraderCodeReturn, UseTraderCodeAvailabilityReturn, UseTraderCodeInfoReturn, UseTransferRewardsReturn, } from "./types";
2
- export { useClearTraderCode } from "./useClearTraderCode";
3
- export { useMyReferralDownline } from "./useMyReferralDownline";
4
- export { useMyReferralPosition } from "./useMyReferralPosition";
5
- export { useMyReferralTree } from "./useMyReferralTree";
6
- export { useMyTraderCode } from "./useMyTraderCode";
7
- export { useRewardsBalance } from "./useRewardsBalance";
8
- export { useSetTraderCode } from "./useSetTraderCode";
9
- export { useTraderCodeAvailability } from "./useTraderCodeAvailability";
10
- export { useTraderCodeInfo } from "./useTraderCodeInfo";
11
- export { useTransferRewards } from "./useTransferRewards";
1
+ /**
2
+ * Deprecated module path for the TraderCodes hooks.
3
+ *
4
+ * PitPass is the umbrella over TraderCodes and BuilderCodes; these hooks only
5
+ * ever covered TraderCodes. Import them from `useTraderCodes` (or the package
6
+ * root) instead.
7
+ *
8
+ * @deprecated Use `useTraderCodes`. Removed after at least two SDK releases.
9
+ */
10
+ export * from "../useTraderCodes";
@@ -1,10 +1,10 @@
1
- export { useClearTraderCode } from "./useClearTraderCode";
2
- export { useMyReferralDownline } from "./useMyReferralDownline";
3
- export { useMyReferralPosition } from "./useMyReferralPosition";
4
- export { useMyReferralTree } from "./useMyReferralTree";
5
- export { useMyTraderCode } from "./useMyTraderCode";
6
- export { useRewardsBalance } from "./useRewardsBalance";
7
- export { useSetTraderCode } from "./useSetTraderCode";
8
- export { useTraderCodeAvailability } from "./useTraderCodeAvailability";
9
- export { useTraderCodeInfo } from "./useTraderCodeInfo";
10
- export { useTransferRewards } from "./useTransferRewards";
1
+ /**
2
+ * Deprecated module path for the TraderCodes hooks.
3
+ *
4
+ * PitPass is the umbrella over TraderCodes and BuilderCodes; these hooks only
5
+ * ever covered TraderCodes. Import them from `useTraderCodes` (or the package
6
+ * root) instead.
7
+ *
8
+ * @deprecated Use `useTraderCodes`. Removed after at least two SDK releases.
9
+ */
10
+ export * from "../useTraderCodes";
@@ -0,0 +1,11 @@
1
+ export type { UseClearTraderCodeReturn, UseMyReferralDownlineReturn, UseMyReferralPositionReturn, UseMyReferralTreeReturn, UseMyTraderCodeReturn, UseRewardsBalanceReturn, UseSetTraderCodeReturn, UseTraderCodeAvailabilityReturn, UseTraderCodeInfoReturn, UseTransferRewardsReturn, } from "./types";
2
+ export { useClearTraderCode } from "./useClearTraderCode";
3
+ export { useMyReferralDownline } from "./useMyReferralDownline";
4
+ export { useMyReferralPosition } from "./useMyReferralPosition";
5
+ export { useMyReferralTree } from "./useMyReferralTree";
6
+ export { useMyTraderCode } from "./useMyTraderCode";
7
+ export { useRewardsBalance } from "./useRewardsBalance";
8
+ export { useSetTraderCode } from "./useSetTraderCode";
9
+ export { useTraderCodeAvailability } from "./useTraderCodeAvailability";
10
+ export { useTraderCodeInfo } from "./useTraderCodeInfo";
11
+ export { useTransferRewards } from "./useTransferRewards";
@@ -0,0 +1,10 @@
1
+ export { useClearTraderCode } from "./useClearTraderCode";
2
+ export { useMyReferralDownline } from "./useMyReferralDownline";
3
+ export { useMyReferralPosition } from "./useMyReferralPosition";
4
+ export { useMyReferralTree } from "./useMyReferralTree";
5
+ export { useMyTraderCode } from "./useMyTraderCode";
6
+ export { useRewardsBalance } from "./useRewardsBalance";
7
+ export { useSetTraderCode } from "./useSetTraderCode";
8
+ export { useTraderCodeAvailability } from "./useTraderCodeAvailability";
9
+ export { useTraderCodeInfo } from "./useTraderCodeInfo";
10
+ export { useTransferRewards } from "./useTransferRewards";
@@ -10,7 +10,7 @@ export const useClearTraderCode = () => {
10
10
  const clearTraderCode = useCallback(async () => {
11
11
  if (!sdk)
12
12
  throw new Error("SDK not available");
13
- return await sdk.pitpass.clearTraderCode();
13
+ return await sdk.tradercodes.clearTraderCode();
14
14
  }, [sdk]);
15
15
  return { clearTraderCode };
16
16
  };
@@ -15,7 +15,7 @@ export const useMyReferralDownline = () => {
15
15
  const getMyReferralDownline = useCallback(async (params) => {
16
16
  if (!sdk)
17
17
  throw new Error("SDK not available");
18
- return await sdk.pitpass.getMyReferralDownline(params);
18
+ return await sdk.tradercodes.getMyReferralDownline(params);
19
19
  }, [sdk]);
20
20
  return { getMyReferralDownline };
21
21
  };
@@ -13,7 +13,7 @@ export const useMyReferralPosition = () => {
13
13
  const getMyReferralPosition = useCallback(async () => {
14
14
  if (!sdk)
15
15
  throw new Error("SDK not available");
16
- return await sdk.pitpass.getMyReferralPosition();
16
+ return await sdk.tradercodes.getMyReferralPosition();
17
17
  }, [sdk]);
18
18
  return { getMyReferralPosition };
19
19
  };
@@ -13,7 +13,7 @@ export const useMyReferralTree = () => {
13
13
  const getMyReferralTree = useCallback(async (params) => {
14
14
  if (!sdk)
15
15
  throw new Error("SDK not available");
16
- return await sdk.pitpass.getMyReferralTree(params);
16
+ return await sdk.tradercodes.getMyReferralTree(params);
17
17
  }, [sdk]);
18
18
  return { getMyReferralTree };
19
19
  };
@@ -1,6 +1,6 @@
1
1
  import type { UseMyTraderCodeReturn } from "./types";
2
2
  /**
3
- * Read the authenticated caller's PitPass TraderCode identity.
3
+ * Read the authenticated caller's TraderCode identity.
4
4
  *
5
5
  * The response carries both the permanent wallet-derived `code` and the
6
6
  * custom-handle fields (`customCode`, `isCustom`, `display`).
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from "react";
2
2
  import { useMonacoSDK } from "../useMonaco";
3
3
  /**
4
- * Read the authenticated caller's PitPass TraderCode identity.
4
+ * Read the authenticated caller's TraderCode identity.
5
5
  *
6
6
  * The response carries both the permanent wallet-derived `code` and the
7
7
  * custom-handle fields (`customCode`, `isCustom`, `display`).
@@ -11,7 +11,7 @@ export const useMyTraderCode = () => {
11
11
  const getMyTraderCode = useCallback(async () => {
12
12
  if (!sdk)
13
13
  throw new Error("SDK not available");
14
- return await sdk.pitpass.getMyTraderCode();
14
+ return await sdk.tradercodes.getMyTraderCode();
15
15
  }, [sdk]);
16
16
  return { getMyTraderCode };
17
17
  };
@@ -11,7 +11,7 @@ export const useRewardsBalance = () => {
11
11
  const getRewardsBalance = useCallback(async () => {
12
12
  if (!sdk)
13
13
  throw new Error("SDK not available");
14
- return await sdk.pitpass.getRewardsBalance();
14
+ return await sdk.tradercodes.getRewardsBalance();
15
15
  }, [sdk]);
16
16
  return { getRewardsBalance };
17
17
  };
@@ -12,7 +12,7 @@ export const useSetTraderCode = () => {
12
12
  if (!sdk)
13
13
  throw new Error("SDK not available");
14
14
  // Parameter validation is handled by the SDK core using Zod
15
- return await sdk.pitpass.setTraderCode(code);
15
+ return await sdk.tradercodes.setTraderCode(code);
16
16
  }, [sdk]);
17
17
  return { setTraderCode };
18
18
  };
@@ -12,7 +12,7 @@ export const useTraderCodeAvailability = () => {
12
12
  const checkTraderCodeAvailability = useCallback(async (code) => {
13
13
  if (!sdk)
14
14
  throw new Error("SDK not available");
15
- return await sdk.pitpass.checkTraderCodeAvailability(code);
15
+ return await sdk.tradercodes.checkTraderCodeAvailability(code);
16
16
  }, [sdk]);
17
17
  return { checkTraderCodeAvailability };
18
18
  };
@@ -1,6 +1,6 @@
1
1
  import type { UseTraderCodeInfoReturn } from "./types";
2
2
  /**
3
- * Public lookup of a PitPass TraderCode by wallet address.
3
+ * Public lookup of a TraderCode by wallet address.
4
4
  *
5
5
  * Accepts the bare address or the `Monaco - <address>` display form. Used at
6
6
  * sign-up to validate a referral code before it is applied. No authentication
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from "react";
2
2
  import { useMonacoSDK } from "../useMonaco";
3
3
  /**
4
- * Public lookup of a PitPass TraderCode by wallet address.
4
+ * Public lookup of a TraderCode by wallet address.
5
5
  *
6
6
  * Accepts the bare address or the `Monaco - <address>` display form. Used at
7
7
  * sign-up to validate a referral code before it is applied. No authentication
@@ -12,7 +12,7 @@ export const useTraderCodeInfo = () => {
12
12
  const getTraderCodeInfo = useCallback(async (code) => {
13
13
  if (!sdk)
14
14
  throw new Error("SDK not available");
15
- return await sdk.pitpass.getTraderCodeInfo(code);
15
+ return await sdk.tradercodes.getTraderCodeInfo(code);
16
16
  }, [sdk]);
17
17
  return { getTraderCodeInfo };
18
18
  };
@@ -13,7 +13,7 @@ export const useTransferRewards = () => {
13
13
  if (!sdk)
14
14
  throw new Error("SDK not available");
15
15
  // Parameter validation is handled by the SDK core using Zod
16
- return await sdk.pitpass.transferRewards(params);
16
+ return await sdk.tradercodes.transferRewards(params);
17
17
  }, [sdk]);
18
18
  return { transferRewards };
19
19
  };
@@ -96,9 +96,15 @@ export function useUserOrders(maxOrders = 50) {
96
96
  pageToken: "",
97
97
  });
98
98
  // Deduplicate the paginated orders by id, keeping the first occurrence.
99
+ // A slice is dropped too. Only a server from before 0XM-3070 lists slices,
100
+ // and against one this page can come back short of `maxOrders`; the hook
101
+ // does not page further to make up the difference, since the next server
102
+ // release stops listing them.
99
103
  const seenIds = new Set();
100
104
  const dedupedOrders = [];
101
105
  for (const order of response.orders) {
106
+ if (isTwapSlice(order.parentOrderId))
107
+ continue;
102
108
  if (!seenIds.has(order.id)) {
103
109
  seenIds.add(order.id);
104
110
  dedupedOrders.push(order);
@@ -304,6 +310,9 @@ export function useUserOrders(maxOrders = 50) {
304
310
  // This prevents race conditions where WS events could be overwritten by REST response
305
311
  try {
306
312
  unsubscribe = sdk.ws.userOrders((event) => {
313
+ // A slice's frames carry its parent; the list never holds one.
314
+ if ("parentOrderId" in event.data && isTwapSlice(event.data.parentOrderId))
315
+ return;
307
316
  // Built OUTSIDE the state updater: an updater must stay pure, and
308
317
  // React may invoke it more than once. `null` here means the event
309
318
  // is an `OrderPlaced` this version cannot describe.
@@ -334,7 +343,10 @@ export function useUserOrders(maxOrders = 50) {
334
343
  // REST round trip. It matters most after a reconnect: the
335
344
  // resubscribe brings a fresh one, while a targeted read resolves
336
345
  // each formerly-resting order it omits.
337
- (items) => {
346
+ (snapshotItems) => {
347
+ // The snapshot carries resting slices with their parent; the list
348
+ // never holds one, so it is neither added nor looked for.
349
+ const items = snapshotItems.filter((item) => !isTwapSlice(item.parentOrderId));
338
350
  // Read BEFORE the updater: whether a row was declined depends only
339
351
  // on the rows themselves, and an updater must stay free of side
340
352
  // effects because React may invoke it more than once. A row this
@@ -443,6 +455,19 @@ function asKnown(known, value) {
443
455
  function asOrderStatus(value) {
444
456
  return asKnown(ORDER_STATUSES, value);
445
457
  }
458
+ /**
459
+ * Whether a row or frame belongs to a TWAP slice: a child order its TWAP
460
+ * parent placed, which names that parent in `parentOrderId`.
461
+ *
462
+ * The order listing leaves slices to their parent's slice list
463
+ * (`listTwapOrderSlices`, 0XM-3070), and this hook mirrors the listing, so it
464
+ * drops them from every source — the REST page, the subscribe-time snapshot and
465
+ * the live frames. Without the last two, a resting slice would appear live and
466
+ * then vanish on the next REST read.
467
+ */
468
+ function isTwapSlice(parentOrderId) {
469
+ return typeof parentOrderId === "string" && parentOrderId.length > 0;
470
+ }
446
471
  /**
447
472
  * `live`, with every REST-only field taken from the fetched row.
448
473
  *
@@ -783,30 +808,14 @@ export function mergeOrders(current, fetched, limit) {
783
808
  const live = currentById.get(incoming.id);
784
809
  if (!live)
785
810
  return incoming;
786
- // Version first: it is the only field that orders these two soundly.
787
- const ranked = supersedes(incoming, live);
788
- if (ranked !== "unranked")
789
- return ranked ? keepingPostOnly(incoming, live) : live;
790
- const liveAt = updatedAtMs(live);
791
- const incomingAt = updatedAtMs(incoming);
792
- // An unparseable timestamp on either side is not evidence of staleness, so
793
- // prefer the live row rather than silently rolling it back.
794
- if (Number.isNaN(liveAt) || Number.isNaN(incomingAt))
795
- return live;
796
- if (liveAt > incomingAt)
797
- return live;
798
- if (liveAt < incomingAt)
799
- return incoming;
800
- // A TIE keeps the live row's own state — it cannot be older than the
801
- // response, and at second resolution two genuinely different states can
802
- // share a timestamp — but takes the REST-ONLY fields from the response.
803
- // No WebSocket frame carries those, so the live row's copies are whatever
804
- // an older read left behind, and a snapshot-derived row has none at all.
805
- // Without this the post-snapshot repair could never land: a snapshot and a
806
- // REST read of one order report the SAME `updated_at`, both projecting
807
- // `orders.updated_at`, so the read returned the fee aggregates and the tie
808
- // then discarded them.
809
- return withRestOnlyFields(live, incoming);
811
+ const winner = reconcile(incoming, live);
812
+ // What placed an order never changes, so it is not ranked: whichever row
813
+ // knows it supplies it. A snapshot row carries none and learns it from
814
+ // REST; a row that learned it from its acknowledgement keeps it against a
815
+ // response from a server predating the field. If both report one and they
816
+ // differ, the REST row is the stored order and stands.
817
+ const origin = incoming.origin ?? live.origin ?? undefined;
818
+ return origin === winner.origin ? winner : { ...winner, origin };
810
819
  });
811
820
  const liveOnly = current.filter((order) => !fetchedIds.has(order.id));
812
821
  // Cap by RECENCY, not by side. Prepending every live-only row and slicing
@@ -818,6 +827,33 @@ export function mergeOrders(current, fetched, limit) {
818
827
  // lets a genuinely old one fall off, which is what the cap means.
819
828
  return [...liveOnly, ...reconciled].sort((a, b) => createdAtMs(b) - createdAtMs(a)).slice(0, limit);
820
829
  }
830
+ /** The row that wins between a REST row and the live row of one order. */
831
+ function reconcile(incoming, live) {
832
+ // Version first: it is the only field that orders these two soundly.
833
+ const ranked = supersedes(incoming, live);
834
+ if (ranked !== "unranked")
835
+ return ranked ? keepingPostOnly(incoming, live) : live;
836
+ const liveAt = updatedAtMs(live);
837
+ const incomingAt = updatedAtMs(incoming);
838
+ // An unparseable timestamp on either side is not evidence of staleness, so
839
+ // prefer the live row rather than silently rolling it back.
840
+ if (Number.isNaN(liveAt) || Number.isNaN(incomingAt))
841
+ return live;
842
+ if (liveAt > incomingAt)
843
+ return live;
844
+ if (liveAt < incomingAt)
845
+ return incoming;
846
+ // A TIE keeps the live row's own state — it cannot be older than the
847
+ // response, and at second resolution two genuinely different states can
848
+ // share a timestamp — but takes the REST-ONLY fields from the response.
849
+ // No WebSocket frame carries those, so the live row's copies are whatever
850
+ // an older read left behind, and a snapshot-derived row has none at all.
851
+ // Without this the post-snapshot repair could never land: a snapshot and a
852
+ // REST read of one order report the SAME `updated_at`, both projecting
853
+ // `orders.updated_at`, so the read returned the fee aggregates and the tie
854
+ // then discarded them.
855
+ return withRestOnlyFields(live, incoming);
856
+ }
821
857
  /**
822
858
  * Create an Order object from an OrderPlaced event
823
859
  */
@@ -872,6 +908,11 @@ export function orderFromEvent(event) {
872
908
  // disagree with REST. Only a real boolean is taken: anything else is not
873
909
  // evidence the order was post-only.
874
910
  postOnly: typeof data.postOnly === "boolean" ? data.postOnly : undefined,
911
+ // What placed the order, as sent: a liquidation is a reduce-only IOC
912
+ // limit, so this is the only thing on the row that says so. Absent means
913
+ // not reported, never "USER", and an unrecognized value is passed through
914
+ // (the model's type is widened for it).
915
+ origin: typeof data.origin === "string" ? data.origin : undefined,
875
916
  // The local revision the merge ranks against. Without it every REST
876
917
  // response outranks live state by default and the stream can be undone.
877
918
  version: typeof data.version === "number" ? data.version : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/react",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -16,8 +16,8 @@
16
16
  "lint": "biome lint ."
17
17
  },
18
18
  "dependencies": {
19
- "@0xmonaco/core": "1.0.81",
20
- "@0xmonaco/types": "1.0.81"
19
+ "@0xmonaco/core": "1.0.83",
20
+ "@0xmonaco/types": "1.0.83"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "^19.2.18",