Surface Map
Balance Model
Use non-raw fields for display and
*Raw (smallest-unit) fields for validation and transaction amounts.
Read Balances
getUserBalances is cursor-paginated: omit pageToken (or pass ""), then follow nextPageToken until it is empty. There is no page parameter: the SDK rejects it with a ValidationError, and REST returns 400.
getUserBalanceByAssetId when validating an order, deposit, withdrawal, or transfer. Treat a missing balance as zero, but handle 404 separately from auth or network failures.
Live Balance Updates
useUserBalances fetches over REST, then stays live via the balances channel.
- Spot-row events (including collateral transfers that move the spot row) carry the same
versionas REST and the subscribe-time snapshot. Apply a higher version, treat an equal one as a duplicate, ignore a lower one. Never order byupdatedAtor arrival time. - Margin-collateral notifications (e.g. a parent to risk-bucket allocation, which moves no wallet balance) have no
version, carry no margin account ID, and a margin-routed deposit may report a delta rather than whole-row state. Don’t compare them with a spot watermark or treat them as authoritative(user, token)state; handle them fail-open and refresh margin account state.
Movements
Movements are the ledger behind balance changes: deposits, withdrawals, trades, fees, funding, liquidations, rewards, interest, and collateral transfers. Paginate like balances.
REST rows and filters are upper-case; filters match case-insensitively. The live
movements frames for deposits, withdrawals, and funding use lower-case values ("funding", "debit") and carry no resolved asset ID; a spot order’s released lock frame is upper-case UNLOCK / TRADE with the row’s id. Normalize before comparing, and deduplicate REST against WebSocket by id only (useUserMovements does this).
Row specifics:
- Funding. A collateral USD delta, not a token transfer:
amountis a magnitude, direction isentryType(DEBITpaid,CREDITreceived),decimalsis0, andamountRawequalsamount. Zero-amount windows are excluded. - Margin account deposits and withdrawals. Listed as
DEPOSIT/CREDITandWITHDRAWAL/DEBIT, withreferenceTypemargin_account_depositormargin_account_withdrawalandreferenceIdset to the margin account ID.amountis the token amount; deposits carrytxHash.balanceBefore,balanceAfter,lockedBefore, andlockedAfterare0because margin collateral is not a wallet balance; see margin account state. Rows before v1.0.87 are not backfilled. - Maker rebates. A BUY maker rebate is its own
TRADE/CREDITrow described asTrade <tradeId> - maker rebate <amount> <symbol>. A SELL maker rebate is included in the fill’s quote-sideTRADEcredit. BUY rebate rows start at v1.0.91; balances were correct before then.
Asset IDs
Vault and balance methods (approve, needsApproval, deposit, withdraw, getAllowance, getUserBalanceByAssetId) take a Monaco asset UUID, never a symbol or token address. Symbols are display labels and can collide across products and networks.
Discover IDs from a trading pair (works before any balance exists) or balance rows:
Deposit Flow
1
Authenticate
Create a Monaco session for the connected wallet.
2
Resolve the asset ID
Use the pair’s
baseAssetId or quoteAssetId.3
Approve if needed
needsApproval checks the wallet’s ERC20 allowance for the vault; approve sets it.4
Deposit
Credits the spot account by default.
balanceOf on the token contract), not the Monaco balance. getAllowance(assetId) returns the current vault allowance; allowances are wallet-side, not Monaco balances.
With
autoWait set to false, deposit returns once the transaction is submitted; wait later with sdk.waitForTransaction(hash).
Deposit Directly to Perps Collateral
Pass"margin" as the target to route the deposit into perps collateral:
"cross_risk_bucket" instead to deposit straight into the default margin account’s cross risk bucket:
"margin" one does, then the same engine step allocates it to the cross risk bucket, creating the bucket if needed. If the allocation is refused (the cross risk bucket is in bad debt), the amount stays unallocated in the margin account.
If margin routing is unavailable for the asset or account, either deposit falls back to spot. Refresh both balances and perps collateral afterwards.
Calling the vault contract directly? Encode applicationData with encodeDepositApplicationData(clientId, target) from @0xmonaco/contracts:
- Spot: the bare client ID.
- Margin: exactly
{"clientId":"<clientId>","depositTarget":"MARGIN"}, byte for byte, no extra whitespace or keys. - Cross risk bucket: exactly
{"clientId":"<clientId>","depositTarget":"CROSS_RISK_BUCKET"}, byte for byte. - Client ID: 1–64 letters, digits,
_, or-.
{ is not guessed at: it is credited to the spot wallet of Monaco’s default application, not yours.
Registered Deposit Addresses
Instead of approve and deposit, give a user a stable address; watched assets sent there are swept into Monaco with no per-deposit signature from your app.sdk.sweeper.register({ depositTarget? })(POST /api/v1/sweeper/register, gRPCSweeperService.Register) returns the address for the session’s(application, user, deposit target). It is authenticated, takes identity only from the session (each user registers through their own client), idempotent, and returns immediately, so you can display and fund the address before any contract exists there.depositTarget: "margin"sweeps into the parent margin account’s collateral and yields a different address from spot.depositTarget: "cross_risk_bucket"sweeps into the margin account and on into its cross risk bucket, from a third address. Unavailable margin routing falls back to spot, so refresh both balances.- One registration covers every swept chain: the address is identical and watched on all of them.
sdk.sweeper.getChains()(GET /api/v1/sweeper/chains, gRPCSweeperService.GetChains) is public. Per chain: EVM chain ID, name, whether it is the settlement hub, and swept assets with token address, decimals, and minimum sweep amount in raw units. ERC20s not listed there are not swept.- A balance strictly below an asset’s minimum waits on the address until later deposits bring the total to at least the minimum.
sdk.sweeper.getDepositStatus(txHash) (GET /api/v1/sweeper/deposits/{txHash}, gRPC SweeperService.GetDepositStatus). The list is empty until the transaction is indexed. Poll until each entry is DEPOSITED, or FAILED with failureReason: "REFUNDED" when funds were returned to the depositor.
sdk.sweeper.listDeposits() (GET /api/v1/sweeper/deposits) lists the caller’s deposits newest first, for when a hash is lost. Both calls need a session and return only that session’s deposits. Full shapes and errors: Vault SDK guide.
USDC on Hyperliquid or Arc reaches the address through Circle’s CCTP, with Circle completing the mint on Sei:
- HyperCore (the Hyperliquid exchange balance), without gas:
sdk.sweeper.getHypercoreDepositInfo()reads what the wallet can deposit, andsdk.sweeper.depositFromHypercore({ amount })has the wallet that holds the Hyperliquid balance sign Circle’s CCTP withdrawal to the caller’s Sei deposit address and posts it to Hyperliquid, which executes it. - HyperEVM (USDC held as a token on Hyperliquid’s EVM chain), with HYPE for gas:
sdk.sweeper.getHyperEvmDepositInfo()reads what the wallet can deposit, andsdk.sweeper.depositFromHyperEvm({ amount })has the wallet approve and burn the USDC through Circle’s TokenMessengerV2 to the caller’s Sei deposit address. - Arc (Circle’s chain, whose gas token is USDC), with the gas paid out of the same USDC:
sdk.sweeper.getArcDepositInfo()reads what the wallet can deposit once the gas is kept back, andsdk.sweeper.depositFromArc({ amount })has the wallet approve and burn the USDC through Circle’s TokenMessengerV2 to the caller’s Sei deposit address.
getDepositStatus(burnTxHash), and a HyperCore deposit — which has no transaction hash the depositor sees — with sdk.sweeper.getHypercoreDepositStatus(nonce) and the nonce depositFromHypercore returns (GET /api/v1/sweeper/deposits/hypercore/{nonce}, gRPC SweeperService.GetHypercoreDepositStatus). All of them also list in listDeposits. Minimum, fee and outcomes: Vault SDK guide.
Withdrawal Flow
Check the amount againstavailableBalanceRaw (locked funds are not withdrawable), then withdraw and wait for the on-chain result.
Builder Checklist
- Keep wallet balances, Monaco spot balances, parent margin collateral, and risk-bucket exposure visually separate.
- Format every amount with the asset’s
decimals; validate max order, withdrawal, and transfer withavailableBalanceRaw. - Refresh balances after approval, deposit, withdrawal, retry, collateral transfer, fill, cancel, expiry, funding payment, or liquidation.
Related Pages
- Perps Collateral: margin transfers and risk buckets.
- Order Management: orders that lock and unlock balances.
- TypeScript Vault: full SDK method shapes.

