Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dzimiks/onebalance-chain-abstracted-swap/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheBalanceDisplay component provides a clean, card-based interface for displaying wallet balance information. It handles loading and error states gracefully and can optionally show the balance for a specific selected asset.
Import
Props
The balance data returned from the
useBalances hook. Contains total balance and per-asset breakdown.Indicates whether balance data is currently being fetched. Shows skeleton loaders when
true.Error message to display if balance fetching fails. Shows an error alert when present.
Optional aggregated asset ID (e.g.,
"ob:usdc") to display a specific asset’s balance alongside the total.Type Definitions
Usage
Basic Usage
With Selected Asset
Component States
- Loading
- Error
- Success
- No Data
Displays skeleton loaders while fetching data:
Features
Total Balance Display
The component always shows the total portfolio value in USD:Selected Asset Details
WhenselectedAssetId is provided, the component displays additional information:
- Asset symbol (extracted from the aggregated asset ID)
- Token balance (converted from wei using 18 decimals)
- USD value of the selected asset
Balance Calculation
The component finds the selected asset’s balance using the aggregated asset ID:Styling
The component uses a card layout with consistent spacing:- Card padding:
p-4 - Vertical spacing:
space-y-2 - Border between sections:
border-t pt-2 mt-2 - Text sizes:
text-smfor labels,text-xsfor secondary info
Data Format
Fiat Value Formatting
All fiat values are displayed with exactly 2 decimal places:Token Amount Formatting
Token balances are stored as strings representing wei (BigInt) and converted for display:Integration with Hooks
The component is designed to work seamlessly with theuseBalances hook:
Accessibility
- Semantic HTML with proper heading levels (
h3) - Clear visual hierarchy with font weights and sizes
- Error messages are announced to screen readers via the Alert component
- Loading states prevent confusion during data fetching
Related Components
- AssetList - Detailed asset breakdown with chain distribution
- ConnectButton - Wallet connection with balance modal
Best Practices
Always provide loading and error props
Always provide loading and error props
The component relies on these props to show appropriate UI states. Never pass static
false values.Handle null balances gracefully
Handle null balances gracefully
The component returns
null when no data is available, so ensure parent components handle this case.Use with authentication checks
Use with authentication checks
Only render this component when a user is authenticated and has a wallet address.