Appearance
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
startWithdrawalthrowsCOINBASE_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
| Field | Purpose |
|---|---|
isInCooldown | true while a new start would throw |
remainingMs | Milliseconds left |
Updates from coinbase:cooldownChanged (begin, every second while active, end).
Errors
| Code | When | What to do |
|---|---|---|
COINBASE_COOLDOWN_ACTIVE | Start while cooling down | Disable Start using this hook; wait remainingMs |
See Errors. For tick side effects only, see Event hooks (useOnCoinbaseCooldownChanged).