@0xmonaco/react 0.8.10 → 0.8.14

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
-
@@ -10,6 +10,7 @@ export declare const COVERED: {
10
10
  cancel_conditional_order: string;
11
11
  cancel_order: string;
12
12
  close_position: string;
13
+ batch_close_all_positions: string;
13
14
  create_challenge: string;
14
15
  create_order: string;
15
16
  get_candles: string;
@@ -54,6 +55,9 @@ export declare const INTENTIONALLY_EXCLUDED: {
54
55
  get_available_collateral: string;
55
56
  get_margin_account_movements: string;
56
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;
57
61
  get_portfolio_chart: string;
58
62
  get_portfolio_stats: string;
59
63
  get_screener: string;
@@ -73,12 +77,15 @@ export declare const INTENTIONALLY_EXCLUDED: {
73
77
  list_sub_accounts_with_balances: string;
74
78
  mint_tokens: string;
75
79
  revoke_delegated_agent: string;
76
- simulate_auto_margin_order_risk: string;
80
+ simulate_risk_bucket_order_risk: string;
77
81
  simulate_order_risk: string;
82
+ simulate_parent_margin_order_risk: string;
78
83
  submit_whitelist: string;
84
+ transfer_collateral_from_parent_margin_account: string;
79
85
  transfer_collateral_from_margin_account: string;
80
- transfer_collateral_to_auto_margin_account: string;
81
86
  transfer_collateral_to_margin_account: string;
87
+ transfer_collateral_to_parent_margin_account: string;
88
+ transfer_collateral_to_risk_bucket: string;
82
89
  update_sub_account_limit: string;
83
90
  upsert_delegated_agent: string;
84
91
  verify_signature: string;
package/dist/coverage.js CHANGED
@@ -10,6 +10,7 @@ export const COVERED = {
10
10
  cancel_conditional_order: "useTrade",
11
11
  cancel_order: "useTrade",
12
12
  close_position: "usePositions",
13
+ batch_close_all_positions: "usePositions",
13
14
  create_challenge: "useAuth",
14
15
  create_order: "useTrade",
15
16
  get_candles: "useMarket",
@@ -54,6 +55,9 @@ export const INTENTIONALLY_EXCLUDED = {
54
55
  get_available_collateral: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
55
56
  get_margin_account_movements: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
56
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.",
57
61
  get_portfolio_chart: "Portfolio analytics endpoint; no React hook yet.",
58
62
  get_portfolio_stats: "Portfolio analytics endpoint; no React hook yet.",
59
63
  get_screener: "Market lookup available via the core client / list+symbol hooks; no dedicated React hook.",
@@ -73,12 +77,15 @@ export const INTENTIONALLY_EXCLUDED = {
73
77
  list_sub_accounts_with_balances: "Sub-account administration; no React hook.",
74
78
  mint_tokens: "Test-net faucet; no React hook (use the MCP/core faucet path).",
75
79
  revoke_delegated_agent: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
76
- simulate_auto_margin_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
80
+ simulate_risk_bucket_order_risk: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
77
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.",
78
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.",
79
85
  transfer_collateral_from_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
80
- transfer_collateral_to_auto_margin_account: "Margin-account management/collateral/simulation endpoint; no React hook yet.",
81
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.",
82
89
  update_sub_account_limit: "Sub-account administration; no React hook.",
83
90
  upsert_delegated_agent: "Delegated-agent management is an automation/agent surface, not a UI workflow; no React hook.",
84
91
  verify_signature: "Auth verification runs inside login()/authenticate(); useAuth does not expose verifySignature as its own hook method.",
@@ -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,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.10",
3
+ "version": "0.8.14",
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.10",
24
- "@0xmonaco/types": "0.8.10"
23
+ "@0xmonaco/core": "0.8.14",
24
+ "@0xmonaco/types": "0.8.14"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.1.12",