@0xmonaco/react 0.8.14 → 0.8.16

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.
@@ -33,6 +33,7 @@ export declare const COVERED: {
33
33
  get_user_profile: string;
34
34
  get_withdrawal: string;
35
35
  initiate_withdrawal: string;
36
+ list_pending_withdrawals: string;
36
37
  list_conditional_orders: string;
37
38
  list_funding_history: string;
38
39
  list_position_history: string;
package/dist/coverage.js CHANGED
@@ -33,6 +33,7 @@ export const COVERED = {
33
33
  get_user_profile: "useProfile",
34
34
  get_withdrawal: "useVault (retryWithdrawal)",
35
35
  initiate_withdrawal: "useVault (withdraw)",
36
+ list_pending_withdrawals: "useVault (listPendingWithdrawals)",
36
37
  list_conditional_orders: "useTrade",
37
38
  list_funding_history: "useMarket",
38
39
  list_position_history: "usePositions",
@@ -51,9 +51,9 @@ export const useProfile = () => {
51
51
  try {
52
52
  const [userProfileResult, balancesResult, movementsResult, ordersResult] = await Promise.allSettled([
53
53
  sdk.profile.getProfile(),
54
- sdk.profile.getUserBalances({ page_size: DEFAULT_PAGE_SIZE, page: 1 }),
55
- sdk.profile.getPaginatedUserMovements({ page: 1, page_size: DEFAULT_PAGE_SIZE }),
56
- sdk.trading.getPaginatedOrders({ page: 1, page_size: DEFAULT_PAGE_SIZE }),
54
+ sdk.profile.getUserBalances({ pageSize: DEFAULT_PAGE_SIZE, page: 1 }),
55
+ sdk.profile.getPaginatedUserMovements({ page: 1, pageSize: DEFAULT_PAGE_SIZE }),
56
+ sdk.trading.getPaginatedOrders({ page: 1, pageSize: DEFAULT_PAGE_SIZE }),
57
57
  ]);
58
58
  const userProfile = getSettledValueOrThrow(userProfileResult);
59
59
  const balances = getFulfilledValue(balancesResult);
@@ -19,7 +19,7 @@ export function useTradeFeed(tradingPairId) {
19
19
  if (!sdk?.ws || !sdk?.trades || !tradingPairId) {
20
20
  return;
21
21
  }
22
- const fetchInitialTrades = () => sdk.trades.getTrades(tradingPairId, { page_size: MAX_TRADES });
22
+ const fetchInitialTrades = () => sdk.trades.getTrades(tradingPairId, { pageSize: MAX_TRADES });
23
23
  const subscribeToWs = (handler) => sdk.ws.trades(tradingPairId, handler);
24
24
  return subscribe(tradingPairId, fetchInitialTrades, subscribeToWs);
25
25
  }, [sdk?.ws, sdk?.trades, tradingPairId, subscribe]);
@@ -8,12 +8,12 @@ export function updateBalanceFromEvent(balance, event) {
8
8
  const totalBalanceRaw = totalBalanceRawFromEvent(balance, event);
9
9
  return {
10
10
  ...balance,
11
- available_balance: event.data.available,
12
- available_balance_raw: event.data.availableRaw,
13
- locked_balance: event.data.locked,
14
- locked_balance_raw: event.data.lockedRaw,
15
- total_balance: totalBalance,
16
- total_balance_raw: totalBalanceRaw,
11
+ availableBalance: event.data.available,
12
+ availableBalanceRaw: event.data.availableRaw,
13
+ lockedBalance: event.data.locked,
14
+ lockedBalanceRaw: event.data.lockedRaw,
15
+ totalBalance: totalBalance,
16
+ totalBalanceRaw: totalBalanceRaw,
17
17
  };
18
18
  }
19
19
  function parseDecimal(value) {
@@ -68,7 +68,7 @@ function totalBalanceFromEvent(balance, event) {
68
68
  if (eventExtraTotal && decimalGreaterThanZero(eventExtraTotal)) {
69
69
  return event.data.total;
70
70
  }
71
- const previousMarginTotal = decimalDifference(balance.total_balance, balance.available_balance, balance.locked_balance);
71
+ const previousMarginTotal = decimalDifference(balance.totalBalance, balance.availableBalance, balance.lockedBalance);
72
72
  if (!previousMarginTotal || !decimalGreaterThanZero(previousMarginTotal)) {
73
73
  return event.data.total;
74
74
  }
@@ -82,7 +82,7 @@ function totalBalanceRawFromEvent(balance, event) {
82
82
  if (eventExtraTotalRaw && decimalGreaterThanZero(eventExtraTotalRaw)) {
83
83
  return event.data.totalRaw;
84
84
  }
85
- const previousMarginTotalRaw = decimalDifference(balance.total_balance_raw, balance.available_balance_raw, balance.locked_balance_raw);
85
+ const previousMarginTotalRaw = decimalDifference(balance.totalBalanceRaw, balance.availableBalanceRaw, balance.lockedBalanceRaw);
86
86
  if (!previousMarginTotalRaw || !decimalGreaterThanZero(previousMarginTotalRaw)) {
87
87
  return event.data.totalRaw;
88
88
  }
@@ -10,9 +10,9 @@ import type { UseUserMovementsOptions, UseUserMovementsReturn } from "./types";
10
10
  *
11
11
  * @param options - Optional filter and pagination options
12
12
  * @param options.maxMovements - Maximum number of movements to keep in state (default: 50)
13
- * @param options.page_size - Number of items per page for the API call (default: maxMovements)
14
- * @param options.entry_type - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
15
- * @param options.transaction_type - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
16
- * @param options.asset_id - Filter by asset ID (UUID)
13
+ * @param options.pageSize - Number of items per page for the API call (default: maxMovements)
14
+ * @param options.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
15
+ * @param options.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
16
+ * @param options.assetId - Filter by asset ID (UUID)
17
17
  */
18
18
  export declare function useUserMovements(options?: UseUserMovementsOptions): UseUserMovementsReturn;
@@ -10,26 +10,26 @@ function ledgerMovementToEvent(movement, userId) {
10
10
  userId,
11
11
  data: {
12
12
  id: movement.id,
13
- entryType: movement.entry_type,
14
- transactionType: movement.transaction_type,
13
+ entryType: movement.entryType,
14
+ transactionType: movement.transactionType,
15
15
  tokenAddress: movement.token,
16
16
  symbol: movement.symbol ?? undefined,
17
17
  decimals: movement.decimals,
18
18
  amount: movement.amount,
19
- amountRaw: movement.amount_raw,
20
- balanceBefore: movement.balance_before ?? undefined,
21
- balanceBeforeRaw: movement.balance_before_raw ?? undefined,
22
- balanceAfter: movement.balance_after ?? undefined,
23
- balanceAfterRaw: movement.balance_after_raw ?? undefined,
24
- lockedBefore: movement.locked_before ?? undefined,
25
- lockedBeforeRaw: movement.locked_before_raw ?? undefined,
26
- lockedAfter: movement.locked_after ?? undefined,
27
- lockedAfterRaw: movement.locked_after_raw ?? undefined,
28
- referenceId: movement.reference_id ?? undefined,
29
- referenceType: movement.reference_type ?? undefined,
19
+ amountRaw: movement.amountRaw,
20
+ balanceBefore: movement.balanceBefore ?? undefined,
21
+ balanceBeforeRaw: movement.balanceBeforeRaw ?? undefined,
22
+ balanceAfter: movement.balanceAfter ?? undefined,
23
+ balanceAfterRaw: movement.balanceAfterRaw ?? undefined,
24
+ lockedBefore: movement.lockedBefore ?? undefined,
25
+ lockedBeforeRaw: movement.lockedBeforeRaw ?? undefined,
26
+ lockedAfter: movement.lockedAfter ?? undefined,
27
+ lockedAfterRaw: movement.lockedAfterRaw ?? undefined,
28
+ referenceId: movement.referenceId ?? undefined,
29
+ referenceType: movement.referenceType ?? undefined,
30
30
  description: movement.description ?? undefined,
31
- txHash: movement.tx_hash ?? undefined,
32
- createdAt: movement.created_at ?? undefined,
31
+ txHash: movement.txHash ?? undefined,
32
+ createdAt: movement.createdAt ?? undefined,
33
33
  },
34
34
  };
35
35
  }
@@ -44,22 +44,22 @@ function ledgerMovementToEvent(movement, userId) {
44
44
  *
45
45
  * @param options - Optional filter and pagination options
46
46
  * @param options.maxMovements - Maximum number of movements to keep in state (default: 50)
47
- * @param options.page_size - Number of items per page for the API call (default: maxMovements)
48
- * @param options.entry_type - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
49
- * @param options.transaction_type - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
50
- * @param options.asset_id - Filter by asset ID (UUID)
47
+ * @param options.pageSize - Number of items per page for the API call (default: maxMovements)
48
+ * @param options.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
49
+ * @param options.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
50
+ * @param options.assetId - Filter by asset ID (UUID)
51
51
  */
52
52
  export function useUserMovements(options = {}) {
53
53
  const { sdk } = useMonacoSDK();
54
54
  const { authenticationStatus } = useMonacoContext();
55
- const { maxMovements = 50, page_size, entry_type, transaction_type, asset_id } = options;
55
+ const { maxMovements = 50, pageSize, entryType, transactionType, assetId } = options;
56
56
  const [movements, setMovements] = useState([]);
57
57
  const [loading, setLoading] = useState(false);
58
58
  const [error, setError] = useState(null);
59
59
  const [subscribed, setSubscribed] = useState(false);
60
60
  const clearError = useCallback(() => setError(null), []);
61
61
  const sliceSize = Number.isFinite(maxMovements) && maxMovements > 0 ? maxMovements : 50;
62
- const requestLimit = page_size ?? Math.min(Math.max(Math.round(sliceSize), 1), 100);
62
+ const requestLimit = pageSize ?? Math.min(Math.max(Math.round(sliceSize), 1), 100);
63
63
  // Derive userId reactively — authenticationStatus changes on login/logout, triggering a re-render
64
64
  const userId = authenticationStatus === "authenticated" ? sdk?.getAuthState()?.user.id : undefined;
65
65
  useEffect(() => {
@@ -73,7 +73,7 @@ export function useUserMovements(options = {}) {
73
73
  // Fetch initial movements via REST API, then subscribe to WebSocket updates
74
74
  let unsubscribe;
75
75
  sdk.profile
76
- .getPaginatedUserMovements({ page_size: requestLimit, entry_type, transaction_type, asset_id })
76
+ .getPaginatedUserMovements({ pageSize: requestLimit, entryType, transactionType, assetId })
77
77
  .then(async (response) => {
78
78
  // Combine latest_movements (from the live engine cache) with movements (from PostgreSQL)
79
79
  // latest_movements contains real-time data that may not yet be in PostgreSQL
@@ -117,6 +117,6 @@ export function useUserMovements(options = {}) {
117
117
  unsubscribe?.();
118
118
  setSubscribed(false);
119
119
  };
120
- }, [sdk?.ws, sdk?.profile, userId, sliceSize, requestLimit, entry_type, transaction_type, asset_id]);
120
+ }, [sdk?.ws, sdk?.profile, userId, sliceSize, requestLimit, entryType, transactionType, assetId]);
121
121
  return { movements, loading, subscribed, error, clearError };
122
122
  }
@@ -23,7 +23,7 @@ export function useUserOrders(maxOrders = 50) {
23
23
  try {
24
24
  const response = await sdk.trading.getPaginatedOrders({
25
25
  page: 1,
26
- page_size: maxOrders,
26
+ pageSize: maxOrders,
27
27
  });
28
28
  // Combine latest_orders (from the live engine cache) with orders (from PostgreSQL)
29
29
  // latest_orders contains real-time data that may not yet be in PostgreSQL
@@ -123,18 +123,18 @@ function orderFromEvent(event) {
123
123
  return null;
124
124
  return {
125
125
  id: event.orderId,
126
- trading_pair_id: tradingPairId,
127
- order_type: (data.orderType || "LIMIT"),
126
+ tradingPairId: tradingPairId,
127
+ orderType: (data.orderType || "LIMIT"),
128
128
  side: (data.side || "BUY"),
129
129
  price: data.price,
130
130
  quantity: data.quantity || "0",
131
- filled_quantity: "0",
132
- average_fill_price: undefined,
131
+ filledQuantity: "0",
132
+ averageFillPrice: undefined,
133
133
  status: data.status,
134
- trading_mode: (data.tradingMode || "SPOT"),
135
- time_in_force: data.timeInForce,
136
- created_at: event.timestamp,
137
- updated_at: event.timestamp,
134
+ tradingMode: (data.tradingMode || "SPOT"),
135
+ timeInForce: data.timeInForce,
136
+ createdAt: event.timestamp,
137
+ updatedAt: event.timestamp,
138
138
  };
139
139
  }
140
140
  /**
@@ -170,8 +170,8 @@ function updateOrderFromEvent(order, event) {
170
170
  }
171
171
  }
172
172
  // Get filled quantity from different event types
173
- let filledQuantity = order.filled_quantity;
174
- let avgFillPrice = order.average_fill_price;
173
+ let filledQuantity = order.filledQuantity;
174
+ let avgFillPrice = order.averageFillPrice;
175
175
  if ("totalFilled" in data && data.totalFilled) {
176
176
  filledQuantity = data.totalFilled;
177
177
  }
@@ -184,8 +184,8 @@ function updateOrderFromEvent(order, event) {
184
184
  return {
185
185
  ...order,
186
186
  status: newStatus,
187
- filled_quantity: filledQuantity,
188
- average_fill_price: avgFillPrice,
189
- updated_at: event.timestamp,
187
+ filledQuantity: filledQuantity,
188
+ averageFillPrice: avgFillPrice,
189
+ updatedAt: event.timestamp,
190
190
  };
191
191
  }
@@ -1,4 +1,4 @@
1
- import type { TransactionResult, WithdrawalSource, WithdrawResult } from "@0xmonaco/types";
1
+ import type { ListPendingWithdrawalsParams, ListPendingWithdrawalsResponse, TransactionResult, WithdrawalSource, WithdrawResult } from "@0xmonaco/types";
2
2
  export interface UseVaultReturn {
3
3
  /** Approve the vault to spend tokens */
4
4
  approve: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<TransactionResult>;
@@ -8,6 +8,8 @@ export interface UseVaultReturn {
8
8
  withdraw: (assetId: string, amount: bigint, autoWait?: boolean, source?: WithdrawalSource) => Promise<WithdrawResult>;
9
9
  /** Retry a withdrawal whose on-chain submission never landed — does NOT create a new one */
10
10
  retryWithdrawal: (withdrawalIndex: number, autoWait?: boolean) => Promise<WithdrawResult>;
11
+ /** List the caller's pending withdrawals (awaiting on-chain confirmation), newest first */
12
+ listPendingWithdrawals: (params?: ListPendingWithdrawalsParams) => Promise<ListPendingWithdrawalsResponse>;
11
13
  /** Get the allowance for a token */
12
14
  getAllowance: (assetId: string) => Promise<bigint>;
13
15
  /** Check if a token needs approval for an amount */
@@ -37,6 +37,11 @@ export const useVault = () => {
37
37
  }
38
38
  return await sdk.vault.retryWithdrawal(withdrawalIndex, autoWait);
39
39
  }, [sdk]);
40
+ const listPendingWithdrawals = useCallback(async (params) => {
41
+ if (!sdk)
42
+ throw new Error("SDK not available");
43
+ return await sdk.withdrawals.listPendingWithdrawals(params);
44
+ }, [sdk]);
40
45
  const getAllowance = useCallback(async (assetId) => {
41
46
  if (!sdk)
42
47
  throw new Error("SDK not available");
@@ -59,6 +64,7 @@ export const useVault = () => {
59
64
  deposit,
60
65
  withdraw,
61
66
  retryWithdrawal,
67
+ listPendingWithdrawals,
62
68
  // Approval and allowance queries
63
69
  getAllowance,
64
70
  needsApproval,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/react",
3
- "version": "0.8.14",
3
+ "version": "0.8.16",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,8 +20,8 @@
20
20
  "lint": "biome lint ."
21
21
  },
22
22
  "dependencies": {
23
- "@0xmonaco/core": "0.8.14",
24
- "@0xmonaco/types": "0.8.14"
23
+ "@0xmonaco/core": "0.8.16",
24
+ "@0xmonaco/types": "0.8.16"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.1.12",