@0xmonaco/react 0.8.7-develop.34bd452 → 0.8.7-develop.a107b34

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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ function App() {
47
47
  return (
48
48
  <WagmiProvider config={wagmiConfig}>
49
49
  <MonacoProvider
50
- network="development"
50
+ network="staging"
51
51
  seiRpcUrl="https://evm-rpc-testnet.sei-apis.com"
52
52
  >
53
53
  <YourApp />
@@ -372,4 +372,3 @@ For support, please:
372
372
  - Join our [Discord community](https://discord.gg/monaco)
373
373
  - Visit our [documentation site](https://docs.monaco.xyz)
374
374
  - Check our [API documentation](https://docs.0xmonaco.com)
375
-
@@ -0,0 +1,92 @@
1
+ /** operationId → the @0xmonaco/react hook that covers it. */
2
+ export declare const COVERED: {
3
+ add_position_margin: string;
4
+ attach_position_tp_sl: string;
5
+ batch_cancel_all: string;
6
+ batch_cancel_all_by_pair: string;
7
+ batch_cancel_orders: string;
8
+ batch_create_orders: string;
9
+ batch_replace_orders: string;
10
+ cancel_conditional_order: string;
11
+ cancel_order: string;
12
+ close_position: string;
13
+ batch_close_all_positions: string;
14
+ create_challenge: string;
15
+ create_order: string;
16
+ get_candles: string;
17
+ get_funding_state: string;
18
+ get_index_price: string;
19
+ get_mark_price: string;
20
+ get_market_metadata: string;
21
+ get_open_interest: string;
22
+ get_order_by_id: string;
23
+ get_orderbook_snapshot: string;
24
+ get_orders: string;
25
+ get_perp_market_config: string;
26
+ get_perp_market_summary: string;
27
+ get_position: string;
28
+ get_position_risk: string;
29
+ get_trades: string;
30
+ get_user_balance_by_asset: string;
31
+ get_user_balances: string;
32
+ get_user_movements: string;
33
+ get_user_profile: string;
34
+ get_withdrawal: string;
35
+ initiate_withdrawal: string;
36
+ list_conditional_orders: string;
37
+ list_funding_history: string;
38
+ list_position_history: string;
39
+ list_positions: string;
40
+ list_trading_pairs: string;
41
+ reduce_position_margin: string;
42
+ refresh_session: string;
43
+ replace_order: string;
44
+ revoke_session: string;
45
+ simulate_fees: string;
46
+ };
47
+ /** operationId → reason it is intentionally not covered by @0xmonaco/react. */
48
+ export declare const INTENTIONALLY_EXCLUDED: {
49
+ authenticate_backend: string;
50
+ create_delegated_session: string;
51
+ create_sub_account_limit: string;
52
+ delete_sub_account_limit: string;
53
+ get_application_config: string;
54
+ get_application_stats: string;
55
+ get_available_collateral: string;
56
+ get_margin_account_movements: string;
57
+ get_margin_account_summary: string;
58
+ get_market_stats: string;
59
+ get_parent_margin_account_movements: string;
60
+ get_parent_margin_account_summary: string;
61
+ get_portfolio_chart: string;
62
+ get_portfolio_stats: string;
63
+ get_screener: string;
64
+ get_sub_account_limits: string;
65
+ get_trade_by_id: string;
66
+ get_trading_pair_by_id: string;
67
+ get_user_trades: string;
68
+ health_check: string;
69
+ list_application_balances: string;
70
+ list_application_movements: string;
71
+ list_application_orders: string;
72
+ list_application_users: string;
73
+ list_delegated_agent_owners: string;
74
+ list_delegated_agents: string;
75
+ list_funding_payments: string;
76
+ list_margin_accounts: string;
77
+ list_sub_accounts_with_balances: string;
78
+ mint_tokens: string;
79
+ revoke_delegated_agent: string;
80
+ simulate_risk_bucket_order_risk: string;
81
+ simulate_order_risk: string;
82
+ simulate_parent_margin_order_risk: string;
83
+ submit_whitelist: string;
84
+ transfer_collateral_from_parent_margin_account: string;
85
+ transfer_collateral_from_margin_account: string;
86
+ transfer_collateral_to_margin_account: string;
87
+ transfer_collateral_to_parent_margin_account: string;
88
+ transfer_collateral_to_risk_bucket: string;
89
+ update_sub_account_limit: string;
90
+ upsert_delegated_agent: string;
91
+ verify_signature: string;
92
+ };
@@ -0,0 +1,92 @@
1
+ /** operationId → the @0xmonaco/react hook that covers it. */
2
+ export const COVERED = {
3
+ add_position_margin: "usePositions",
4
+ attach_position_tp_sl: "usePositions",
5
+ batch_cancel_all: "useTrade",
6
+ batch_cancel_all_by_pair: "useTrade",
7
+ batch_cancel_orders: "useTrade",
8
+ batch_create_orders: "useTrade",
9
+ batch_replace_orders: "useTrade",
10
+ cancel_conditional_order: "useTrade",
11
+ cancel_order: "useTrade",
12
+ close_position: "usePositions",
13
+ batch_close_all_positions: "usePositions",
14
+ create_challenge: "useAuth",
15
+ create_order: "useTrade",
16
+ get_candles: "useMarket",
17
+ get_funding_state: "useMarket",
18
+ get_index_price: "useMarket",
19
+ get_mark_price: "useMarket",
20
+ get_market_metadata: "useMarket",
21
+ get_open_interest: "useMarket",
22
+ get_order_by_id: "useTrade",
23
+ get_orderbook_snapshot: "useOrderbook",
24
+ get_orders: "useTrade",
25
+ get_perp_market_config: "useMarket",
26
+ get_perp_market_summary: "useMarket",
27
+ get_position: "usePositions",
28
+ get_position_risk: "usePositions",
29
+ get_trades: "useTradeFeed",
30
+ get_user_balance_by_asset: "useProfile",
31
+ get_user_balances: "useUserBalances",
32
+ get_user_movements: "useUserMovements",
33
+ get_user_profile: "useProfile",
34
+ get_withdrawal: "useVault (retryWithdrawal)",
35
+ initiate_withdrawal: "useVault (withdraw)",
36
+ list_conditional_orders: "useTrade",
37
+ list_funding_history: "useMarket",
38
+ list_position_history: "usePositions",
39
+ list_positions: "usePositions",
40
+ list_trading_pairs: "useMarket",
41
+ reduce_position_margin: "usePositions",
42
+ refresh_session: "useAuth",
43
+ replace_order: "useTrade",
44
+ revoke_session: "useAuth",
45
+ simulate_fees: "useFees",
46
+ };
47
+ /** operationId → reason it is intentionally not covered by @0xmonaco/react. */
48
+ export const INTENTIONALLY_EXCLUDED = {
49
+ authenticate_backend: "Backend auth is header-based via setServerKey()/the x-server-key header, not an endpoint method (MON-1486).",
50
+ create_delegated_session: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
51
+ create_sub_account_limit: "Sub-account administration; no React hook.",
52
+ delete_sub_account_limit: "Sub-account administration; no React hook.",
53
+ get_application_config: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
54
+ get_application_stats: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
55
+ get_available_collateral: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
56
+ get_margin_account_movements: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
57
+ get_margin_account_summary: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
58
+ get_market_stats: "Exchange-wide cumulative stats endpoint; available via the core client but no dedicated React hook yet.",
59
+ get_parent_margin_account_movements: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
60
+ get_parent_margin_account_summary: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
61
+ get_portfolio_chart: "Portfolio analytics endpoint; no React hook yet.",
62
+ get_portfolio_stats: "Portfolio analytics endpoint; no React hook yet.",
63
+ get_screener: "Market lookup available via the core client / list+symbol hooks; no dedicated React hook.",
64
+ get_sub_account_limits: "Sub-account administration; no React hook.",
65
+ get_trade_by_id: "Trade-history lookup with a core client method but no dedicated React hook yet.",
66
+ get_trading_pair_by_id: "Market lookup available via the core client / list+symbol hooks; no dedicated React hook.",
67
+ get_user_trades: "Trade-history lookup with a core client method but no dedicated React hook yet.",
68
+ health_check: "Infrastructure liveness probe (GET /health); not part of the data SDK surface.",
69
+ list_application_balances: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
70
+ list_application_movements: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
71
+ list_application_orders: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
72
+ list_application_users: "Application/backend (server-key) admin endpoint; not a user-wallet React workflow.",
73
+ list_delegated_agent_owners: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
74
+ list_delegated_agents: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
75
+ list_funding_payments: "Perps funding-payment history; no React hook yet.",
76
+ list_margin_accounts: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
77
+ list_sub_accounts_with_balances: "Sub-account administration; no React hook.",
78
+ mint_tokens: "Test-net faucet; no React hook (use the MCP/core faucet path).",
79
+ revoke_delegated_agent: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
80
+ simulate_risk_bucket_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
81
+ simulate_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
82
+ simulate_parent_margin_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
83
+ submit_whitelist: "Whitelist submission; no React hook.",
84
+ transfer_collateral_from_parent_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
85
+ transfer_collateral_from_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
86
+ transfer_collateral_to_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
87
+ transfer_collateral_to_parent_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
88
+ transfer_collateral_to_risk_bucket: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
89
+ update_sub_account_limit: "Sub-account administration; no React hook.",
90
+ upsert_delegated_agent: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
91
+ verify_signature: "Auth verification runs inside login()/authenticate(); useAuth does not expose verifySignature as its own hook method.",
92
+ };
@@ -1,8 +1,9 @@
1
- import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, ReducePositionMarginRequest } from "@0xmonaco/types";
1
+ import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseAllRequest, BatchCloseAllResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, ReducePositionMarginRequest } from "@0xmonaco/types";
2
2
  export interface UsePositionsReturn {
3
3
  listPositions: (params?: ListPositionsParams) => Promise<ListPositionsResponse>;
4
4
  getPosition: (positionId: string) => Promise<GetPositionResponse>;
5
5
  closePosition: (positionId: string, request: ClosePositionRequest) => Promise<ClosePositionResponse>;
6
+ batchCloseAllPositions: (request?: BatchCloseAllRequest) => Promise<BatchCloseAllResponse>;
6
7
  getPositionRisk: (positionId: string) => Promise<PositionRisk>;
7
8
  addPositionMargin: (positionId: string, request: AddPositionMarginRequest) => Promise<PositionMarginResponse>;
8
9
  reducePositionMargin: (positionId: string, request: ReducePositionMarginRequest) => Promise<PositionMarginResponse>;
@@ -23,6 +23,11 @@ export const usePositions = () => {
23
23
  requirePositionId(positionId);
24
24
  return await sdk.positions.closePosition(positionId, request);
25
25
  }, [sdk]);
26
+ const batchCloseAllPositions = useCallback(async (request) => {
27
+ if (!sdk)
28
+ throw new Error("SDK not available");
29
+ return await sdk.positions.batchCloseAllPositions(request);
30
+ }, [sdk]);
26
31
  const getPositionRisk = useCallback(async (positionId) => {
27
32
  if (!sdk)
28
33
  throw new Error("SDK not available");
@@ -56,6 +61,7 @@ export const usePositions = () => {
56
61
  listPositions,
57
62
  getPosition,
58
63
  closePosition,
64
+ batchCloseAllPositions,
59
65
  getPositionRisk,
60
66
  addPositionMargin,
61
67
  reducePositionMargin,
@@ -1,35 +1,13 @@
1
- import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, OrderSide, ParentTpSlLegParams, PositionSide, ReplaceOrderResponse, TimeInForce, TradingMode } from "@0xmonaco/types";
1
+ import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, OrderSide, ReplaceOrderResponse, TradingAPI } from "@0xmonaco/types";
2
+ type PlaceLimitOrderOptions = NonNullable<Parameters<TradingAPI["placeLimitOrder"]>[4]>;
3
+ type PlaceMarketOrderOptions = NonNullable<Parameters<TradingAPI["placeMarketOrder"]>[3]>;
2
4
  export interface UseTradeReturn {
3
5
  /** Place a limit order */
4
- placeLimitOrder: (tradingPairId: string, side: OrderSide, quantity: string, price: string, options?: {
5
- tradingMode?: TradingMode;
6
- useMasterBalance?: boolean;
7
- expirationDate?: string;
8
- timeInForce?: TimeInForce;
9
- marginAccountId?: string;
10
- strategyKey?: string;
11
- positionSide?: PositionSide;
12
- leverage?: string;
13
- reduceOnly?: boolean;
14
- takeProfit?: ParentTpSlLegParams;
15
- stopLoss?: ParentTpSlLegParams;
16
- }) => Promise<CreateOrderResponse>;
6
+ placeLimitOrder: (tradingPairId: string, side: OrderSide, quantity: string, price: string, options?: PlaceLimitOrderOptions) => Promise<CreateOrderResponse>;
17
7
  /** Place a market order */
18
- placeMarketOrder: (tradingPairId: string, side: OrderSide, quantity: string, options?: {
19
- tradingMode?: TradingMode;
20
- slippageTolerance?: number;
21
- marginAccountId?: string;
22
- strategyKey?: string;
23
- positionSide?: PositionSide;
24
- leverage?: string;
25
- reduceOnly?: boolean;
26
- takeProfit?: ParentTpSlLegParams;
27
- stopLoss?: ParentTpSlLegParams;
28
- }) => Promise<CreateOrderResponse>;
8
+ placeMarketOrder: (tradingPairId: string, side: OrderSide, quantity: string, options?: PlaceMarketOrderOptions) => Promise<CreateOrderResponse>;
29
9
  /** Cancel an existing order */
30
10
  cancelOrder: (orderId: string) => Promise<CancelOrderResponse>;
31
- /** Create a standalone conditional TP/SL order */
32
- createConditionalOrder: (params: CreateConditionalOrderParams) => Promise<CreateConditionalOrderResponse>;
33
11
  /** Cancel an active conditional TP/SL order */
34
12
  cancelConditionalOrder: (conditionalOrderId: string) => Promise<CancelConditionalOrderResponse>;
35
13
  /** List conditional TP/SL orders */
@@ -53,3 +31,4 @@ export interface UseTradeReturn {
53
31
  /** Get a single order by ID */
54
32
  getOrder: (orderId: string) => Promise<GetOrderResponse>;
55
33
  }
34
+ export {};
@@ -39,11 +39,6 @@ export const useTrade = () => {
39
39
  throw new Error("Order ID is required and cannot be empty");
40
40
  return await sdk.trading.cancelOrder(orderId);
41
41
  }, [sdk]);
42
- const createConditionalOrder = useCallback(async (params) => {
43
- if (!sdk)
44
- throw new Error("SDK not available");
45
- return await sdk.trading.createConditionalOrder(params);
46
- }, [sdk]);
47
42
  const cancelConditionalOrder = useCallback(async (conditionalOrderId) => {
48
43
  if (!sdk)
49
44
  throw new Error("SDK not available");
@@ -117,7 +112,6 @@ export const useTrade = () => {
117
112
  placeMarketOrder,
118
113
  // Order management
119
114
  cancelOrder,
120
- createConditionalOrder,
121
115
  cancelConditionalOrder,
122
116
  listConditionalOrders,
123
117
  batchCancel,
@@ -1,4 +1,9 @@
1
+ import type { AccountBalance, UserBalanceEvent } from "@0xmonaco/types";
1
2
  import type { UseUserBalancesReturn } from "./types";
3
+ /**
4
+ * Update an AccountBalance with data from a WebSocket balance event
5
+ */
6
+ export declare function updateBalanceFromEvent(balance: AccountBalance, event: UserBalanceEvent): AccountBalance;
2
7
  /**
3
8
  * Hook for subscribing to real-time user balance updates via WebSocket (authenticated)
4
9
  *
@@ -3,8 +3,9 @@ import { useMonacoSDK } from "../useMonaco";
3
3
  /**
4
4
  * Update an AccountBalance with data from a WebSocket balance event
5
5
  */
6
- function updateBalanceFromEvent(balance, event) {
6
+ export function updateBalanceFromEvent(balance, event) {
7
7
  const totalBalance = totalBalanceFromEvent(balance, event);
8
+ const totalBalanceRaw = totalBalanceRawFromEvent(balance, event);
8
9
  return {
9
10
  ...balance,
10
11
  available_balance: event.data.available,
@@ -12,6 +13,7 @@ function updateBalanceFromEvent(balance, event) {
12
13
  locked_balance: event.data.locked,
13
14
  locked_balance_raw: event.data.lockedRaw,
14
15
  total_balance: totalBalance,
16
+ total_balance_raw: totalBalanceRaw,
15
17
  };
16
18
  }
17
19
  function parseDecimal(value) {
@@ -72,6 +74,20 @@ function totalBalanceFromEvent(balance, event) {
72
74
  }
73
75
  return decimalSum(event.data.total, previousMarginTotal) ?? event.data.total;
74
76
  }
77
+ function totalBalanceRawFromEvent(balance, event) {
78
+ if (event.data.reason === "margin_transfer_in" || event.data.reason === "margin_transfer_out") {
79
+ return event.data.totalRaw;
80
+ }
81
+ const eventExtraTotalRaw = decimalDifference(event.data.totalRaw, event.data.availableRaw, event.data.lockedRaw);
82
+ if (eventExtraTotalRaw && decimalGreaterThanZero(eventExtraTotalRaw)) {
83
+ return event.data.totalRaw;
84
+ }
85
+ const previousMarginTotalRaw = decimalDifference(balance.total_balance_raw, balance.available_balance_raw, balance.locked_balance_raw);
86
+ if (!previousMarginTotalRaw || !decimalGreaterThanZero(previousMarginTotalRaw)) {
87
+ return event.data.totalRaw;
88
+ }
89
+ return decimalSum(event.data.totalRaw, previousMarginTotalRaw) ?? event.data.totalRaw;
90
+ }
75
91
  /**
76
92
  * Hook for subscribing to real-time user balance updates via WebSocket (authenticated)
77
93
  *
@@ -1,11 +1,11 @@
1
- import type { TransactionResult, WithdrawResult } from "@0xmonaco/types";
1
+ import type { 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>;
5
5
  /** Deposit tokens into the vault */
6
6
  deposit: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<TransactionResult>;
7
7
  /** Initiate a withdrawal and submit the pre-signed calldata on-chain */
8
- withdraw: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<WithdrawResult>;
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
11
  /** Get the allowance for a token */
@@ -20,14 +20,14 @@ export const useVault = () => {
20
20
  throw new Error("Amount must be greater than 0");
21
21
  return await sdk.vault.deposit(assetId, amount, autoWait);
22
22
  }, [sdk]);
23
- const withdraw = useCallback(async (assetId, amount, autoWait) => {
23
+ const withdraw = useCallback(async (assetId, amount, autoWait, source) => {
24
24
  if (!sdk)
25
25
  throw new Error("SDK not available");
26
26
  if (!assetId?.trim())
27
27
  throw new Error("Asset ID is required and cannot be empty");
28
28
  if (amount <= 0n)
29
29
  throw new Error("Amount must be greater than 0");
30
- return await sdk.vault.withdraw(assetId, amount, autoWait);
30
+ return await sdk.vault.withdraw(assetId, amount, autoWait, source);
31
31
  }, [sdk]);
32
32
  const retryWithdrawal = useCallback(async (withdrawalIndex, autoWait) => {
33
33
  if (!sdk)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/react",
3
- "version": "0.8.7-develop.34bd452",
3
+ "version": "0.8.7-develop.a107b34",
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.7-develop.34bd452",
24
- "@0xmonaco/types": "0.8.7-develop.34bd452"
23
+ "@0xmonaco/core": "0.8.7-develop.a107b34",
24
+ "@0xmonaco/types": "0.8.7-develop.a107b34"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.1.12",