Appearance
Balances
Load enriched Coinbase balances for the connected account.
When to use
Call after a successful connection. Use the list to let the user pick a withdrawal currency.
Methods
| Method | Returns | Purpose |
|---|---|---|
getBalances() | Promise<CoinbaseBalance[]> | Enriched balances (eligibility, fees, formatted display) |
Each balance includes:
currency,name,id(account name for networks)eligible/ineligibleReason(unsupported|zero_balance|below_min|below_fee_reserve)formatted.balance,formatted.valueFiatraw— pass into funding-token helpers
Example
ts
import { TokenSymbol } from '@swapped/connect-sdk';
const balances = await client.coinbase.getBalances();
const usdc = balances.find(
item => item.currency === TokenSymbol.USDC && item.eligible,
);
if (!usdc) {
// Show “no eligible USDC” — inspect ineligibleReason on matching rows
}
console.log(usdc?.formatted.balance, usdc?.formatted.valueFiat);Prefer eligible === true rows for selection. Keep ineligible rows visible with a hint if you want to explain why they cannot withdraw.
Errors
| Code | When | What to do |
|---|---|---|
COINBASE_NOT_CONNECTED | No OAuth token | Call connect() first |
COINBASE_SESSION_EXPIRED | Token rejected by API | Reconnect |
API_ERROR | Network / server failure | Retry on the same step |
See Errors.