Appearance
useCoinbaseLimits
Min / max / fee-reserve limits for the selected token and network, in both crypto and fiat.
When to use
When you only need raw limits. For the amount input itself, prefer useCoinbaseAmount.
Example
tsx
import { useCoinbaseLimits } from '@swapped/connect-sdk/react'
function AmountHints() {
const {
minAmount,
maxAmount,
balanceMax,
feeReserve,
minAmountFiat,
maxAmountFiat,
balanceMaxFiat,
formatted,
isLoading,
error,
} = useCoinbaseLimits()
if (isLoading) return <p>Loading limits…</p>
if (error) return <p>{error.message}</p>
return (
<p>
Amount between {formatted.minAmount} and {formatted.maxAmount}
{formatted.minAmountFiat
? ` ($${formatted.minAmountFiat} – $${formatted.maxAmountFiat})`
: ''}
{feeReserve != null ? ` (fee reserve ${formatted.feeReserve})` : ''}
{balanceMax != null ? ` / balance ${balanceMax}` : ''}
{/* raw: {minAmount} … {maxAmount} / balance {balanceMax} */}
</p>
)
}maxAmount— soft / spendable ceiling (balance minus fee reserve)balanceMax— hard ceiling (raw aggregated balance)
Fiat mirrors (minAmountFiat, maxAmountFiat, balanceMaxFiat, feeReserveFiat, and their formatted.* counterparts) are null when the selected balance has no exchange rate. The minimum fiat value is rounded up to cents so the displayed minimum is enterable; max and fee reserve are truncated.
Returns
minAmount, maxAmount, balanceMax, feeReserve, minAmountFiat, maxAmountFiat, balanceMaxFiat, feeReserveFiat, formatted, isLoading, error, refetch.
Requires CoinbaseProvider. Balance, aggregated funding balance, and network come from the current selection.
Errors
This hook surfaces fetch failures for the minimum (COINBASE_NOT_CONNECTED, COINBASE_SESSION_EXPIRED, API_ERROR, REACT_COINBASE_PROVIDER_REQUIRED).
If the user still submits a below-min or invalid amount, useCoinbaseWithdrawal throws COINBASE_INVALID_WITHDRAWAL_AMOUNT. Above-spendable amounts are auto-adjusted to the fee-reserve max (optional onAmountAdjusted callback). See Errors.