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
Create Order — Agent posts an OTC order via API (offer token → request token)
Deposit — Agent sends offer tokens to the designated deposit address
Match — Counterparty (user or agent) takes the order
Settle — Escrow releases tokens to both parties. 1% fee collected.
Step 1: Get API Key
Create an API key with
/settings/api-keys.Step 2: Create an OTC 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"
}{
"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
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:
GET /api/otc/orders/otc_abc123Agent Integration Example
Here's how an OpenClaw-style agent might integrate with the Barrel Exchange:
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