Skip to content

Amount & quote ​

Transfer amounts on the public API are human-readable source crypto (the token the user is sending) for a resolved transfer plan. Fiat (currently USD) is available from rates on the balance and from getMinAmount / getQuote.

Minimum ​

ts
const min = await client.wallets.transfer.getMinAmount(plan)
// min.crypto - source token units, already ceiled to display decimals
// min.fiat  - USD, ceiled to maxFiatDecimals (default 2), when rates are known
FieldMeaning
cryptoMinimum in source token units (what the user enters)
fiat?Fiat value of that minimum when rates are known

The source min is never below the token's display-dust (getTokenMinAmount - e.g. 0.000001 ETH at 6 display decimals). A fiat amount that converts to less than that dust fails below_min. For swap/bridge, the destination min is converted into source units via exchange rates, then ceiled so typing the shown value cannot fall below the true minimum.

Validate ​

validateAmount does not throw. It checks flow, parse, and min. With checkFees: true it also runs the cached fee check (same as getFeeCheck).

ts
const validation = await client.wallets.transfer.validateAmount({
  plan,
  amount, // source crypto string
  checkFees: false, // default - no network I/O
})

if (!validation.ok) {
  switch (validation.code) {
    case 'BELOW_MIN':
      validation.minAmount // always present
      break
    case 'INVALID_AMOUNT':
      validation.minAmount // optional hint when a min exists
      break
    case 'INSUFFICIENT_FEE':
      validation.requiredFee // { amount, symbol, network }
      break
    case 'EXCEEDS_BALANCE_WITH_FEE':
      validation.suggestedAmount
      validation.requiredFee
      break
    case 'BELOW_MIN_AFTER_FEES':
      validation.availableAmount
      validation.minAmount
      break
    case 'WRONG_FLOW':
      break
  }
  validation.message
} else if (validation.isSponsored !== undefined) {
  // Only when checkFees: true and fees passed
  validation.networkFee
}

WalletTransferValidationFailure is a discriminated union: narrow on code to see which fields exist (TypeScript matches the runtime shape).

Failure fields by code ​

codeWhenExtra fields
WRONG_FLOWplan.flow === 'unavailable'—
BELOW_MINParsed amount below getMinAmountminAmount
INVALID_AMOUNTEmpty, zero, or unparsable amountminAmount? (when a positive min exists)
INSUFFICIENT_FEEcheckFees: true; not enough native token for gasrequiredFee
EXCEEDS_BALANCE_WITH_FEEcheckFees: true; native send exceeds balance after fee + buffersuggestedAmount, requiredFee
BELOW_MIN_AFTER_FEEScheckFees: true; max sendable after fees is below minavailableAmount, minAmount

Fee failure codes mirror getFeeCheck statuses (insufficient_fee, exceeds_balance_with_fee, below_min_after_fees).

Success with checkFees: true ​

When validation passes and fees were checked, { ok: true, isSponsored?, networkFee? } is returned. Those fields are omitted when checkFees is false (default).

Prefer calling getFeeCheck (debounced) while the user types instead of checkFees: true on every keystroke.

Fee check ​

ts
const feeCheck = await client.wallets.transfer.getFeeCheck({
  plan,
  amount,
  forceRefetch: false, // uses a 30s in-memory cache + in-flight dedupe
})
statusMeaningFields
okFees covered or transfer is sponsoredisSponsored, networkFee (nullable)
insufficient_feeNot enough native token for gas (typical ERC-20 / TRC-20)requiredFee, message
exceeds_balance_with_feeNative send: amount + fee + buffer exceeds balancesuggestedAmount, requiredFee, message
below_min_after_feesBalance after fees is below minimumavailableAmount, minAmount, message

submit always re-runs the fee check with forceRefetch: true and throws WALLET_TRANSFER_INSUFFICIENT_FEE when not ok. The SDK never adjusts the amount for you.

Configure the native safety buffer with wallets.networkFeeBufferUsd on the client (default 0.1 USD, widget parity).

On swap and bridge transfers, the SDK applies a multiplier to the minimum receive amount (default 1.05). Change it with config.limits.swapDestinationMinMultiplier on createSwappedConnectClient (must be ≥ 1).

  1. Sanitize the input (sanitizeAmountInput / parseAmountInput) so the string is parseable (no grouping).
  2. validateAmount({ plan, amount }) for flow / parse / min.
  3. Debounced getFeeCheck({ plan, amount }) (or useWalletTransferFeeCheck in React) before confirm.
  4. getQuote({ plan, amount }) when plan.flow is swap or bridge - for receive amount, fees, and ETA. Direct can skip.
  5. Pass the same amount into submit. Quote is display-only.

These helpers live on @swapped/connect-sdk (same suite Coinbase uses). You do not need every helper on the wallets page - sanitize → validate → quote when needed is enough.

Crypto / fiat helpers ​

From @swapped/connect-sdk (same helpers Coinbase uses):

HelperPurpose
convertCryptoToFiat({ amount, exchangeRate, decimals? })Crypto → fiat string. decimals defaults to maxFiatDecimals (then 2)
convertCryptoToFiatCeil({ amount, exchangeRate, decimals? })Crypto → fiat, ceiled (used for min labels)
convertFiatToCrypto({ amountFiat, exchangeRate, maxDecimals })Fiat → crypto
validateAmountInput({ amount, minAmount, maxAmount, … })Field validation
parseAmountInput / sanitizeAmountInput / formatAmountForInputInput parsing
ts
convertFiatToCrypto({
  amountFiat: '100',
  exchangeRate: 2000,
  maxDecimals: 6,
})
// "0.05"

WalletBalance.exchangeRate / fiatValue / formatted are the rate and display strings for the selected token. When min.fiat is missing, convertCryptoToFiatCeil with token.exchangeRate produces a fiat min from min.crypto.

React: useDualAmountInput keeps crypto and fiat fields in sync.

Quote ​

ts
const quote = await client.wallets.transfer.getQuote({
  plan,
  amount, // human-readable source crypto
})

WalletTransferQuote:

FieldMeaning
flow'direct' | 'swap' | 'bridge'
amountIn{ crypto, fiat? } - what the user sends. crypto is a plain decimal (0.00000004), never scientific (4e-8)
amountOut?{ crypto, fiat?, network, symbol } - expected receive (swap/bridge). Same plain-decimal crypto contract
networkFee?{ amount, symbol, tokenAddress } - display fee. Swap: fiat from the route; bridge: network fee USD. symbol can be 'USD'
protocolFeeFiat?Protocol fee in fiat when the quote exposes one
estimatedTimeSeconds?Estimated completion time in seconds
raw?Opaque payload from the swap/bridge quote API. Display / debug only

An invalid or empty amount throws WALLET_TRANSFER_INVALID_AMOUNT. Quote fetch failures throw WALLET_TRANSFER_QUOTE_FAILED.

submit only needs plan and amount. See Submit.