Developer Documentation
Build agent-first DeFi
Complete API, MCP tools, webhooks, and payment protocol for integrating AI agents with Aave V3 on Arbitrum.
Agent Delegation Keys
Create scoped API keys that let AI agents operate on behalf of users. Keys support three permission levels and are SHA-256 hashed for storage.
1. Create a key (Privy auth required)
POST /agent/keys
Authorization: Bearer <privy_token>
{
"name": "Trading Bot",
"scopes": ["trade"],
"maxDailySpendUsd": 500,
"allowedAssets": ["USDC", "WETH"],
"expiresInDays": 7
}
// Response: { apiKey: "prv_agent_a1b2c3..." }
// Save this key - it's shown only once!2. Use the key in requests
// REST API
curl -H "X-Agent-Key: prv_agent_a1b2c3..." \
https://api.privos.app/aave/positions
// MCP tool call
{
"tool": "check_health",
"arguments": {
"wallet_address": "0x..."
}
}Scope Hierarchy
readgetReserves, getPositions, checkHealth, getYieldOpportunities
tradeAll read + supply, withdraw, borrow, repay, rebalance
full-accessAll trade + key management, policy management
MCP Server
Model Context Protocol server with 9 tools and 2 resources. Any MCP-compatible AI agent (Claude, GPT, etc.) can read positions, check health, and build transactions.
Available Tools
getReservesreadList all Aave V3 reserves with APYs and liquidity
getPositionsreadGet user's supplied/borrowed positions and health
checkHealthreadHealth factor analysis with risk level and recommendations
getYieldOpportunitiesreadFind better yield opportunities for current positions
buildSupplytradeBuild a supply transaction for Aave V3
buildWithdrawtradeBuild a withdraw transaction from Aave V3
buildBorrowtradeBuild a borrow transaction on Aave V3
buildRepaytradeBuild a repay transaction for Aave V3
buildRebalancetradeBuild a rebalance (withdraw + supply) across assets
Resources
privos://reservesLive Aave V3 reserve data (auto-refreshes)
privos://positions/{wallet}User position data for a specific wallet
Spending Policies
10 programmable constraint types with “most restrictive wins” merging. Policies apply to both agent keys and user-level rules.
allowed_operationsWhitelist of allowed operations (supply, withdraw, borrow, repay, rebalance)
allowed_assetsWhitelist of allowed asset symbols (e.g., USDC, WETH)
max_transaction_usdMaximum USD value per single transaction
max_daily_spend_usdMaximum cumulative USD spend per 24h period
max_daily_transactionsMaximum number of transactions per 24h period
min_health_factorMinimum health factor floor (blocks risky borrows)
max_ltv_percentMaximum loan-to-value ceiling
time_window_start/endRestrict operations to specific hours (supports overnight windows)
time_window_timezoneIANA timezone for time window evaluation
auto_rebalance_min_improvementMinimum APY improvement required for auto-rebalance
Dry-Run Evaluation
POST /agent/policies/evaluate
{
"operation": "borrow",
"asset": "USDC",
"amountUsd": 2000,
"projectedHealthFactor": 1.8
}
// Response:
{
"allowed": true,
"warnings": ["Health factor approaching minimum threshold"],
"evaluatedPolicies": ["Conservative Policy", "agent-key:uuid"]
}Webhooks
Ingest external events via HMAC-SHA256 signed webhooks. Price alerts trigger notifications, on-chain events confirm transactions, and agent actions are policy-gated.
/webhooks/price-alertExternal price alerts (e.g., from Chainlink). Triggers user notifications for >5% moves.
HMAC-SHA256 signature required/webhooks/on-chain-eventOn-chain events (tx confirmations, liquidation warnings, position changes).
HMAC-SHA256 signature required/webhooks/agent-actionAgent action requests routed through policy engine before execution.
HMAC-SHA256 signature requiredHMAC Signature Verification
// Required headers:
X-Webhook-Signature: sha256=<hmac_hex>
X-Webhook-Timestamp: <unix_seconds>
// Compute HMAC:
const payload = timestamp + "." + JSON.stringify(body);
const signature = hmac("sha256", WEBHOOK_SECRET, payload);
// Replay protection: timestamp must be within 5 minutesx402 Payments
HTTP 402 Payment Required protocol for machine-to-machine commerce. Agents pay USDC micro-payments on Arbitrum for premium analytics.
Paid Endpoints
/agent/x402/analyze-position$0.01Deep position analysis with risk assessment
/agent/x402/simulate-strategy$0.005Strategy simulation with projected outcomes
/agent/x402/optimize-yield$0.02Yield optimization report with recommendations
/agent/x402/generate-strategy$0.05Custom AI-generated strategy for your positions
Payment Flow
// 1. Get pricing
GET /agent/x402/pricing
// 2. Submit USDC payment
POST /agent/x402/pay
{ "endpoint": "/agent/x402/analyze-position", "txHash": "0x..." }
// 3. Use receipt to access paid endpoint
POST /agent/x402/analyze-position
X-Payment-Receipt: <receipt_token>
{ "walletAddress": "0x..." }
// Receipts are single-use (replay-proof)API Endpoints
Authentication
/auth/callbackPrivy auth callback
/auth/meCurrent user
/auth/refreshRefresh token
/auth/logoutInvalidate session
Aave V3
/aave/reservesAll reserves (public)
/aave/positionsUser positions + E-mode
/aave/build/supplyBuild supply tx
/aave/build/withdrawBuild withdraw tx
/aave/build/borrowBuild borrow tx
/aave/build/repayBuild repay tx
Agent Keys
/agent/keysCreate agent delegation key
Privy auth/agent/keysList agent keys
Privy auth/agent/keys/:idRevoke key
Privy auth/agent/keys/:id/rotateRotate key
Privy auth/agent/sessionCurrent session info
Agent key or PrivySpending Policies
/agent/policiesCreate policy
Privy auth/agent/policiesList policies
Privy auth/agent/policies/:idUpdate policy
Privy auth/agent/policies/:idDelete policy
Privy auth/agent/policies/evaluateDry-run evaluation
Agent key or PrivyAutonomous Execution
/agent/executionsList execution history
Privy auth/agent/executions/statsMonitor stats
Privy auth/agent/executions/:idExecution details
Privy auth/agent/executions/simulateDry-run simulation
Privy auth/agent/executions/pausePause auto-execution
Privy auth/agent/executions/resumeResume auto-execution
Privy authDeposit / Base Chain
/deposit/base/balances/:addrBase L2 token balances
/deposit/base/supported-tokensSupported Base tokens
/deposit/base/bridgeBridge Base <-> Arbitrum via Stargate
Ready to integrate?
Explore the full Swagger documentation, create an agent key, and start building in minutes.