Multi venue MCP
MaigaXBT’s AI agent leverages a multi-venue MCP Server
1. Connector Layer: CEX & AMM Adapters
Each venue (Binance, OKX, Uniswap, Hyperliquid, etc.) is fronted by a Connector microservice that implements a unified interface
CEX adapters talk REST/WebSocket APIs, handle rate-limits, and parse order-book, trade, and funding-rate endpoints.
AMM adapters poll on-chain subgraphs or use direct RPC calls to fetch
get_pool_state
(reserves, fees, token balances) and assemble “virtual order books” by inverting the constant-product curve.
All connectors register themselves with the MCP Server’s service registry, advertising capabilities (supports_order_book
, supports_swap
, etc.).
2. MCP Server: Context Aggregation & Normalization
The MCP Server performs:
Fan-Out Fetch
In parallel, calls each Connector’s
get_order_book
,get_trades
, and, for AMMs,get_pool_state
.
Normalization
Maps CEX bids/asks and AMM “swap curve samples” into a unified
OrderBook
objectEmbeds pool reserves & implied price tiers under
amm_markets
.
Delta Tracking
If
since
is provided, only deltas (new/updated price levels, trades, pool changes) are included to minimize payload.
Merge & Return
Aggregates all venue data into one MCP Context Packet
3. Agent Inference: Signal Processing & Analysis
Inside a TEE-protected enclave, the MaigaXBT agent:
Ingests the MCP Context Packet (JSON) and:
Converts order books into time-series arrays.
Transforms AMM reserves into marginal price curves.
Extracts funding-rate trends and volume aggregates.
Feature Engineering
Computes cross-venue liquidity imbalances, price spreads, funding deviations, and on-chain flow ratios.
Applies sliding-window volatility measures and social-sentiment embeddings (if multimodal inputs are provided).
Model Inference
Passes engineered features into a neural network (e.g., Llama-based or custom MLP) to output
Risk Check (in-enclave)
Verifies aggregate exposure limits (e.g., max 10 BTC open across venues).
Applies position-size caps based on current volatilities.
4. Execution: Automated Trade & Swap Calls
The agent then posts its orders to the MCP Server:
Smart Routing
For CEX orders: may further split a large
2.5 BTC
buy across Binance and OKX based on real-time depth.For AMM swaps: calculates optimal path and slippage tolerances.
Atomic Execution
Uses either native OCO/ICEBERG features on CEXs or bundling via Flashbots (for AMM swaps) to ensure either all legs succeed or are rolled back.
Fill Reporting
Streams back a combined
FillReport
with per-venue fills, average fill prices, and gas/fee breakdowns.
5. Reporting & Post-Trade Analysis
All context packets, signal decisions, and fill reports are logged to a time-series store. Downstream “Reporting Services” can:
Generate PnL Dashboards
Query aggregate fills vs. average execution price across CEX+AMM.
Collateral & Fee Reports
Break down gas spent on AMM swaps vs. CEX taker fees.
Performance Analytics
Compare model confidence vs. actual profit, refine model hyperparameters.
6. End-to-End Automation Loop
Loop Scheduling
A cron-style scheduler inside the agent enclave triggers every minute (or on event hooks) to fetch a new MCP context.
Continuous Learning
Execution and outcome data feed back into an on-chain “Proof-of-Trading” smart contract; later batch-pulled for model retraining.
Failover & Alerts
If a venue connector fails, the MCP Server signals the agent, which can either pause or reroute orders automatically.
Audit & Compliance
All requests/responses are signed inside the enclave; an off-chain auditor can verify the chain of custody before funds are unlocked in PoT.
Last updated