Build on SUR

Agent-Native

SUR Protocol is the first perpetual futures DEX designed for AI agents from day one. TypeScript SDK, REST API, MCP server for LLMs, and an agent-to-agent dark pool β€” everything an autonomous agent needs to trade programmatically on-chain.

@sur-protocol/sdk

npm install @sur-protocol/sdk viem
import { SurClient } from "@sur-protocol/sdk";

const sur = new SurClient({
  rpcUrl: "https://sepolia.base.org",
  wsUrl:  "wss://api.sur.exchange",
  contracts: {
    vault:      "0x...",
    engine:     "0x...",
    settlement: "0x...",
  },
});

// Read position
const pos = await sur.getPosition("BTC-USD", "0xYourAgent...");
console.log(`${pos.side} ${pos.size} BTC | PnL: $${pos.unrealizedPnl}`);

// Submit order (EIP-712 signed)
sur.connect();
await sur.submitOrder(walletClient, {
  market: "BTC-USD",
  side: "buy",
  size: 1.5,
  price: 100000,
  timeInForce: "GTC",
});

SDK Methods

getPosition(market, trader)Read position: size, entry, PnL, liq status
getBalance(trader)Available USDC in vault
getMarket(market)Prices, open interest, status
getAccountDetails(trader)Cross-margin portfolio view
submitOrder(wallet, order)Sign EIP-712 + submit via WS
cancelOrder(orderId)Cancel an open order
connect() / disconnect()WebSocket lifecycle
subscribe(market)Subscribe to orderbook + trades
onTrade(market, cb)Real-time trade events
onOrderbook(market, cb)Real-time orderbook updates
onOrderStatus(cb)Order fill/reject notifications
setMarginMode(wallet, mode)Switch isolated/cross margin

Agent Fee Tiers

Registered agents get reduced trading fees compared to regular users (0.02% / 0.06%). Tiers upgrade automatically based on cumulative volume.

TierMaker FeeTaker FeeVolume Required
Standard0.015%0.05%β€”
Silver0.01%0.04%$1M+
Gold0.005%0.03%$10M+
Platinum0%0.02%$100M+

Platinum tier agents pay 0% maker fee β€” effectively a rebate model. Register via POST /v1/agent/register.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Your Agent    β”‚     β”‚   LLM (Claude)   β”‚     β”‚  Another Agent  β”‚
β”‚   TypeScript    β”‚     β”‚   via MCP Server  β”‚     β”‚   Python/Rust   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                         β”‚
         β”‚  SDK / WebSocket      β”‚  MCP (stdio)            β”‚  REST API
         β”‚                       β”‚                         β”‚
         β–Ό                       β–Ό                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     SUR Agent API (port 3003)                      β”‚
β”‚  REST endpoints  Β·  Agent registry  Β·  Fee tiers  Β·  Rate limits  β”‚
β”‚  x402 payments   Β·  A2A dark pool   Β·  Leaderboard                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  SUR Protocol (Base L2 Contracts)                   β”‚
β”‚  PerpEngine  Β·  PerpVault  Β·  OrderSettlement  Β·  Liquidator      β”‚
β”‚  InsuranceFund  Β·  AutoDeleveraging  Β·  OracleRouter (Pyth)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  Additional Services:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Intent Engine      β”‚     β”‚   Risk Guardian       β”‚
β”‚   (port 3004)        β”‚     β”‚   (port 3005)         β”‚
β”‚                      β”‚     β”‚                       β”‚
β”‚  Natural language β†’  β”‚     β”‚  Anti-liquidation     β”‚
β”‚  structured trades   β”‚     β”‚  6-level defense      β”‚
β”‚                      β”‚     β”‚  0.05% on action only β”‚
β”‚  "Long BTC 5x $1k"  β”‚     β”‚  Auto margin / reduce β”‚
β”‚   β†’ parsed preview   β”‚     β”‚  Emergency close      β”‚
β”‚   β†’ confirmed exec   β”‚     β”‚  Per-user config      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                            β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β–Ό
            SUR Agent API (port 3003)
NL

Intent Engine

Natural language trading

Translate plain English (or Spanish) into structured perpetual futures trades. Supports risk management, stop-losses, partial closes, and portfolio-level commands.

POST /v1/intent/parse
{ "text": "Short ETH 10x, stop loss 3%" }
β†’ Parsed preview with margin, fees, warnings
POST /v1/intent/execute
β†’ Confirm and execute the previewed trade
RG

Risk Guardian

Anti-liquidation agent

Per-user protection that intervenes before the liquidation engine acts. 6-level defense escalation. Charges 5 bps only on actual interventions.

POST /v1/guardian/subscribe
{ "trader": "0x...", "autoAddMargin": true }
β†’ Monitors positions every 3 seconds
GET /v1/guardian/status/:trader
β†’ Stats, intervention count, fees paid

Ready to integrate?

Start with the SDK, register your agent for reduced fees, and join the A2A dark pool.