Skip to content

useCoinbaseWithdrawalCooldown ​

Live cooldown state after startWithdrawal.

When to use ​

Disable the Withdraw / Start button and show a countdown. This is the state hook - prefer it over useOnCoinbaseCooldownChanged for UI.

tsx
const { isInCooldown, remainingMs } = useCoinbaseWithdrawalCooldown()

What it is ​

  • Starts when startWithdrawal() is called (even if 2FA is still required)
  • Fixed 30 seconds (SDK-owned, not configurable)
  • While active, another startWithdrawal throws COINBASE_COOLDOWN_ACTIVE
  • Does not block confirmWithdrawal
  • Not a Coinbase API concept; not related to Exchange Pay order expiry
  • Clears on disconnect / reset

Example ​

tsx
import {
  useCoinbaseWithdrawal,
  useCoinbaseWithdrawalCooldown,
} from '@swapped/connect-sdk/react'

function StartButton() {
  const { startWithdrawal, isStartingWithdrawal } = useCoinbaseWithdrawal()
  const { isInCooldown, remainingMs } = useCoinbaseWithdrawalCooldown()

  return (
    <button
      type="button"
      disabled={isStartingWithdrawal || isInCooldown}
      onClick={() => void (startWithdrawal(/* … */))}
    >
      {isInCooldown ? `Wait ${Math.ceil(remainingMs / 1000)}s` : 'Withdraw'}
    </button>
  )
}

Returns ​

FieldPurpose
isInCooldowntrue while a new start would throw
remainingMsMilliseconds left

Updates from coinbase:cooldownChanged (begin, every second while active, end).

Errors ​

CodeWhenWhat to do
COINBASE_COOLDOWN_ACTIVEStart while cooling downDisable Start using this hook; wait remainingMs

See Errors. For tick side effects only, see Event hooks (useOnCoinbaseCooldownChanged).