Skip to content

useExchangePaySupportedCurrencies

Load supported deposit currencies for the selected Exchange Pay provider.

When to use

After a provider is selected (via useExchangePayProviders or defaultProvider on ExchangePayContextProvider). Drive the currency picker and amount minimum.

Example

tsx
import { useExchangePaySupportedCurrencies } from '@swapped/connect-sdk/react'

function CurrencyList() {
  const { currencies, isLoading, error, refetch } =
    useExchangePaySupportedCurrencies()

  if (isLoading) return <p>Loading currencies…</p>
  if (error) return <p>{error.message}</p>

  return (
    <div>
      <ul>
        {currencies.map(currency => (
          <li key={`${currency.symbol}-${currency.blockchain}`}>
            {currency.name} — min ${currency.minAmountFiat}
          </li>
        ))}
      </ul>
      <button type="button" onClick={() => void refetch()}>
        Refresh
      </button>
    </div>
  )
}

Pair with useExchangePayCurrency for selection. Mins are SDK-resolved (ceiled to cents, floored at the client default of $1). exchangeRateFiat may be omitted by some providers (e.g. OKX).

Returns

Returns currencies, isLoading, isRefetching, error, refetch.

Requires ExchangePayContextProvider. The provider argument is no longer passed to this hook — selection owns which exchange to fetch for.

Errors

CodeWhenWhat to do
REACT_EXCHANGE_PAY_PROVIDER_REQUIREDUsed outside ExchangePayContextProviderWrap with the provider
SESSION_REQUIREDSession not loadedloadSession() first
API_ERRORNetwork / server failureRetry via refetch

See Errors.