@0xmonaco/react 1.0.80 → 1.0.82

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 (32) 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/usePitpass/index.d.ts +10 -11
  6. package/dist/hooks/usePitpass/index.js +10 -10
  7. package/dist/hooks/useTraderCodes/index.d.ts +11 -0
  8. package/dist/hooks/useTraderCodes/index.js +10 -0
  9. package/dist/hooks/{usePitpass → useTraderCodes}/types.d.ts +3 -3
  10. package/dist/hooks/{usePitpass → useTraderCodes}/useClearTraderCode.js +1 -1
  11. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralDownline.js +1 -1
  12. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralPosition.js +1 -1
  13. package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralTree.js +1 -1
  14. package/dist/hooks/{usePitpass → useTraderCodes}/useMyTraderCode.d.ts +1 -1
  15. package/dist/hooks/{usePitpass → useTraderCodes}/useMyTraderCode.js +2 -2
  16. package/dist/hooks/{usePitpass → useTraderCodes}/useRewardsBalance.d.ts +1 -1
  17. package/dist/hooks/{usePitpass → useTraderCodes}/useRewardsBalance.js +2 -2
  18. package/dist/hooks/{usePitpass → useTraderCodes}/useSetTraderCode.js +1 -1
  19. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeAvailability.js +1 -1
  20. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeInfo.d.ts +1 -1
  21. package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeInfo.js +2 -2
  22. package/dist/hooks/{usePitpass → useTraderCodes}/useTransferRewards.d.ts +1 -1
  23. package/dist/hooks/{usePitpass → useTraderCodes}/useTransferRewards.js +2 -2
  24. package/dist/hooks/useUserOrders/useUserOrders.js +40 -24
  25. package/package.json +3 -3
  26. /package/dist/hooks/{usePitpass → useTraderCodes}/types.js +0 -0
  27. /package/dist/hooks/{usePitpass → useTraderCodes}/useClearTraderCode.d.ts +0 -0
  28. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralDownline.d.ts +0 -0
  29. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralPosition.d.ts +0 -0
  30. /package/dist/hooks/{usePitpass → useTraderCodes}/useMyReferralTree.d.ts +0 -0
  31. /package/dist/hooks/{usePitpass → useTraderCodes}/useSetTraderCode.d.ts +0 -0
  32. /package/dist/hooks/{usePitpass → useTraderCodes}/useTraderCodeAvailability.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";
@@ -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";
@@ -16,7 +16,7 @@ export interface UseTraderCodeAvailabilityReturn {
16
16
  checkTraderCodeAvailability: (code: string) => Promise<TraderCodeAvailabilityResponse>;
17
17
  }
18
18
  export interface UseRewardsBalanceReturn {
19
- /** Read the caller's current PitPass rewards-bucket balances. */
19
+ /** Read the caller's current TraderCodes rewards-bucket balances. */
20
20
  getRewardsBalance: () => Promise<GetRewardsBalanceResponse>;
21
21
  }
22
22
  export interface UseTraderCodeInfoReturn {
@@ -24,11 +24,11 @@ export interface UseTraderCodeInfoReturn {
24
24
  getTraderCodeInfo: (code: string) => Promise<TraderCodeInfoResponse>;
25
25
  }
26
26
  export interface UseTransferRewardsReturn {
27
- /** Transfer earned PitPass rewards into a tradeable balance. */
27
+ /** Transfer earned TraderCodes rewards into a tradeable balance. */
28
28
  transferRewards: (params: TransferRewardsParams) => Promise<TransferRewardsResponse>;
29
29
  }
30
30
  export interface UseMyReferralPositionReturn {
31
- /** Read the caller's own referral position: upline (as deep as PitPass rewards), L1 referrer, total earned, and recent rewards. */
31
+ /** Read the caller's own referral position: upline (as deep as TraderCodes rewards), L1 referrer, total earned, and recent rewards. */
32
32
  getMyReferralPosition: () => Promise<GetMyReferralPositionResponse>;
33
33
  }
34
34
  export interface UseMyReferralDownlineReturn {
@@ -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
  };
@@ -1,6 +1,6 @@
1
1
  import type { UseRewardsBalanceReturn } from "./types";
2
2
  /**
3
- * Read the authenticated caller's current PitPass rewards-bucket balances.
3
+ * Read the authenticated caller's current TraderCodes rewards-bucket balances.
4
4
  *
5
5
  * Rewards accrue in a separate bucket per token; call
6
6
  * {@link useTransferRewards} to move them into a tradeable balance.
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from "react";
2
2
  import { useMonacoSDK } from "../useMonaco";
3
3
  /**
4
- * Read the authenticated caller's current PitPass rewards-bucket balances.
4
+ * Read the authenticated caller's current TraderCodes rewards-bucket balances.
5
5
  *
6
6
  * Rewards accrue in a separate bucket per token; call
7
7
  * {@link useTransferRewards} to move them into a tradeable balance.
@@ -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
  };
@@ -1,6 +1,6 @@
1
1
  import type { UseTransferRewardsReturn } from "./types";
2
2
  /**
3
- * Transfer the authenticated caller's earned PitPass rewards into a tradeable
3
+ * Transfer the authenticated caller's earned TraderCodes rewards into a tradeable
4
4
  * balance.
5
5
  *
6
6
  * Parameters (`token`, `amount`) are validated by the SDK core using Zod; the
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from "react";
2
2
  import { useMonacoSDK } from "../useMonaco";
3
3
  /**
4
- * Transfer the authenticated caller's earned PitPass rewards into a tradeable
4
+ * Transfer the authenticated caller's earned TraderCodes rewards into a tradeable
5
5
  * balance.
6
6
  *
7
7
  * Parameters (`token`, `amount`) are validated by the SDK core using Zod; the
@@ -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
  };
@@ -783,30 +783,14 @@ export function mergeOrders(current, fetched, limit) {
783
783
  const live = currentById.get(incoming.id);
784
784
  if (!live)
785
785
  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);
786
+ const winner = reconcile(incoming, live);
787
+ // What placed an order never changes, so it is not ranked: whichever row
788
+ // knows it supplies it. A snapshot row carries none and learns it from
789
+ // REST; a row that learned it from its acknowledgement keeps it against a
790
+ // response from a server predating the field. If both report one and they
791
+ // differ, the REST row is the stored order and stands.
792
+ const origin = incoming.origin ?? live.origin ?? undefined;
793
+ return origin === winner.origin ? winner : { ...winner, origin };
810
794
  });
811
795
  const liveOnly = current.filter((order) => !fetchedIds.has(order.id));
812
796
  // Cap by RECENCY, not by side. Prepending every live-only row and slicing
@@ -818,6 +802,33 @@ export function mergeOrders(current, fetched, limit) {
818
802
  // lets a genuinely old one fall off, which is what the cap means.
819
803
  return [...liveOnly, ...reconciled].sort((a, b) => createdAtMs(b) - createdAtMs(a)).slice(0, limit);
820
804
  }
805
+ /** The row that wins between a REST row and the live row of one order. */
806
+ function reconcile(incoming, live) {
807
+ // Version first: it is the only field that orders these two soundly.
808
+ const ranked = supersedes(incoming, live);
809
+ if (ranked !== "unranked")
810
+ return ranked ? keepingPostOnly(incoming, live) : live;
811
+ const liveAt = updatedAtMs(live);
812
+ const incomingAt = updatedAtMs(incoming);
813
+ // An unparseable timestamp on either side is not evidence of staleness, so
814
+ // prefer the live row rather than silently rolling it back.
815
+ if (Number.isNaN(liveAt) || Number.isNaN(incomingAt))
816
+ return live;
817
+ if (liveAt > incomingAt)
818
+ return live;
819
+ if (liveAt < incomingAt)
820
+ return incoming;
821
+ // A TIE keeps the live row's own state — it cannot be older than the
822
+ // response, and at second resolution two genuinely different states can
823
+ // share a timestamp — but takes the REST-ONLY fields from the response.
824
+ // No WebSocket frame carries those, so the live row's copies are whatever
825
+ // an older read left behind, and a snapshot-derived row has none at all.
826
+ // Without this the post-snapshot repair could never land: a snapshot and a
827
+ // REST read of one order report the SAME `updated_at`, both projecting
828
+ // `orders.updated_at`, so the read returned the fee aggregates and the tie
829
+ // then discarded them.
830
+ return withRestOnlyFields(live, incoming);
831
+ }
821
832
  /**
822
833
  * Create an Order object from an OrderPlaced event
823
834
  */
@@ -872,6 +883,11 @@ export function orderFromEvent(event) {
872
883
  // disagree with REST. Only a real boolean is taken: anything else is not
873
884
  // evidence the order was post-only.
874
885
  postOnly: typeof data.postOnly === "boolean" ? data.postOnly : undefined,
886
+ // What placed the order, as sent: a liquidation is a reduce-only IOC
887
+ // limit, so this is the only thing on the row that says so. Absent means
888
+ // not reported, never "USER", and an unrecognized value is passed through
889
+ // (the model's type is widened for it).
890
+ origin: typeof data.origin === "string" ? data.origin : undefined,
875
891
  // The local revision the merge ranks against. Without it every REST
876
892
  // response outranks live state by default and the stream can be undone.
877
893
  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.80",
3
+ "version": "1.0.82",
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.80",
20
- "@0xmonaco/types": "1.0.80"
19
+ "@0xmonaco/core": "1.0.82",
20
+ "@0xmonaco/types": "1.0.82"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "^19.2.18",