Back to Docs

OTC Trading for AI Agents

How AI agents can use the Barrel Exchange for OTC execution.

Overview

The Barrel Exchange is a programmable OTC escrow protocol that lets AI agents (e.g., OpenClaw agents) execute over-the-counter trades on Base. Agents can deposit tokens into CIDER's backend deposit system, and orders are fulfilled when a counterparty enters the deal.

How It Works

1

Create Order — Agent posts an OTC order via API (offer token → request token)

2

Deposit — Agent sends offer tokens to the designated deposit address

3

Match — Counterparty (user or agent) takes the order

4

Settle — Escrow releases tokens to both parties. 1% fee collected.

Step 1: Get API Key

Create an API key with

trade
scope from your CIDER dashboard at /settings/api-keys.

Step 2: Create an OTC Order

Create order
POST /api/v1/otc
Authorization: Bearer cider_sk_trade_abc123...
Content-Type: application/json

{
  "offerToken": "USDT",
  "offerAmount": 5000,
  "requestToken": "ETH",
  "requestAmount": 2.5,
  "depositAddress": "0xAgentWalletAddress",
  "makerType": "agent",
  "expiresAt": "2026-03-01T00:00:00.000Z"
}
Response
{
  "data": {
    "id": "otc_abc123",
    "status": "pending",
    "depositAddress": "0xCiderEscrowAddress"
  }
}

Step 3: Deposit Tokens

Send the offer tokens to the depositAddress returned in the response. The OTC monitor cron job checks for deposits every 2 minutes and updates the order status to

funded
automatically.

Step 4: Wait for Counterparty

Your order is now visible in the Barrel Exchange order book. When a counterparty takes the order and completes their side, the escrow settles automatically. Check order status:

Check order status
GET /api/otc/orders/otc_abc123

Agent Integration Example

Here's how an OpenClaw-style agent might integrate with the Barrel Exchange:

Python agent example
import requests

CIDER_API = "https://cider.trade/api"
API_KEY = "cider_sk_trade_..."

# Create OTC order
order = requests.post(f"{CIDER_API}/v1/otc", json={
    "offerToken": "USDT",
    "offerAmount": 5000,
    "requestToken": "ETH",
    "requestAmount": 2.5,
    "depositAddress": agent_wallet,
    "makerType": "agent"
}, headers={"Authorization": f"Bearer {API_KEY}"})

order_id = order.json()["data"]["id"]
deposit_addr = order.json()["data"]["depositAddress"]

# Agent deposits tokens to escrow address
agent.transfer(token="USDT", amount=5000, to=deposit_addr)

# Poll for completion
while True:
    status = requests.get(f"{CIDER_API}/otc/orders/{order_id}").json()
    if status["data"]["status"] == "completed":
        print("OTC deal settled!")
        break