Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Funding

Your money is held by the settlement contract, not by the exchange (see Custody). You deposit by calling the contract. You withdraw by asking the exchange, which debits you at once; the contract then pays the withdrawal in order with your trades, and it is sent to your address.
The contract's address, the USDC token's address and the chain are at GET /v1/config.
On the testnet the token is the exchange's mock USDC on Base Sepolia, and you get it from the faucet: the client's deposit step offers GET TEST FUNDS. It is worth nothing.

Deposit

  1. Approve USDC
    Call approve(settlement, amount) on the USDC token. Skip this if you use depositWithPermit.
  2. Deposit
    Call deposit(amount) on the settlement contract, with amount in micro-USDC. Or call depositWithPermit(amount, deadline, v, r, s) with an EIP-2612 permit to approve and deposit in one transaction. The contract refuses an amount below its MIN_DEPOSIT() (DepositTooSmall); on the testnet that is 10 USDC, but read it from the contract.
  3. Wait for the credit
    The exchange credits the deposit once its block is a few seconds old: the confirmation depth, confirmationSeconds in GET /v1/config. It credits what arrived at the contract. Your first deposit opens your account. Watch for a funds event on your WebSocket account: channel, or poll GET /v1/account/{addr} until known is true and freeCash includes it.
TypeScript (viem)
import { parseAbi } from 'viem' const erc20 = parseAbi(['function approve(address spender, uint256 amount) returns (bool)']) const settlement = parseAbi(['function deposit(uint256 amount)']) const amount = 1_000_000_000n // $1,000 await wallet.writeContract({ address: config.usdc, abi: erc20, functionName: 'approve', args: [config.settlement, amount] }) await wallet.writeContract({ address: config.settlement, abi: settlement, functionName: 'deposit', args: [amount] })

Withdraw

  1. Request it
    Sign a WithdrawalRequest(user, amount, nonce) with the account's own key and send it to POST /v1/withdraw. A registered signing key cannot withdraw. The exchange debits your free cash at once.
  2. The contract executes it
    The debit is a payout record in the exchange's sequence, which the settlement contract executes in order with the fills before it. Executing it moves the amount from your cash at the contract to owed(you). It executes only once every fill of yours before the debit has.
  3. Collect it
    collect(user) sends everything owed to user to that address, and to no other. Anyone may call it, and the exchange calls it for every payout it executes, so the USDC normally arrives on its own. If owed(you) stays above zero, call collect yourself.
TypeScript (viem)
const settlement = parseAbi([ 'function owed(address user) view returns (uint256)', 'function collect(address user)', ]) const owed = await client.readContract({ address: config.settlement, abi: settlement, functionName: 'owed', args: [me] }) if (owed > 0n) { await wallet.writeContract({ address: config.settlement, abi: settlement, functionName: 'collect', args: [me] }) }
A pause of the contract holds every payout until the unpause; what is already owed can still be collected.
A withdrawal over the declared large-withdrawal threshold ($5,000 on the testnet), when your cash less your deposits not yet at the chain's safe head does not cover it, is held by the gateway (a 202 with "held": true) and sent once the deposits made before it are safe, a few minutes on Base Sepolia.

Withdrawing without the exchange

If the exchange does not answer, call requestForcedWithdrawal(amount) on the contract. The exchange must answer with a forced payout record, which the contract executes like any other; if none has executed within the contract's FORCE_WINDOW, anyone can freeze your account and you withdraw with escapeWithdraw(). Custody has the details.