DEV Community

Cover image for 14 DeFi Protocols, One API: Building an AI DeFi Agent
Wallet Guy
Wallet Guy

Posted on

14 DeFi Protocols, One API: Building an AI DeFi Agent

Building DeFi applications today means juggling a dozen different APIs, SDKs, and integration patterns. Want to swap on Jupiter? One SDK. Lend on Aave? Different API. Stake with Lido? Yet another integration. Your trading bot ends up looking like a Frankenstein monster of protocol-specific code that breaks every time someone updates their interface.

This fragmentation isn't just annoying—it's expensive. Every new protocol integration costs weeks of development time. Testing across multiple chains doubles the complexity. And when you're building AI agents that need to make split-second decisions across DeFi protocols, wrestling with 14 different APIs isn't just inefficient, it's prohibitive.

The Multi-Protocol Problem

Most DeFi developers face the same pattern: start with one protocol, then gradually add more as requirements grow. You begin with a simple Uniswap integration, then add Compound for lending, then Lido for staking. Each integration brings its own quirks:

  • Different authentication patterns
  • Inconsistent error handling
  • Varying gas estimation approaches
  • Protocol-specific transaction formats
  • Different slippage protection mechanisms

Before you know it, your clean codebase becomes a maze of protocol adapters, each with its own failure modes and edge cases. And that's just on Ethereum—add Solana protocols like Jupiter and Drift, and you're now maintaining two completely different tech stacks.

One API, 14 Protocols

WAIaaS solves this with a unified REST API that abstracts away protocol complexity while preserving full functionality. Instead of learning 14 different integration patterns, you make standard HTTP requests to execute actions across all major DeFi protocols.

Here's the complete list of integrated protocols:

  • EVM: Aave v3, LI.FI, Lido, 0x, Pendle, Kamino
  • Solana: Jupiter, Drift, Jito Staking
  • Cross-chain: Across Protocol
  • Multi-chain: Hyperliquid, Polymarket
  • Specialized: D'CENT Swap, ERC-8004

The beauty is in the consistency. Whether you're swapping on Jupiter or lending on Aave, the API pattern remains the same:

curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000"
  }'
Enter fullscreen mode Exit fullscreen mode

Protocol Deep Dive: What's Actually Integrated

Let's break down what you can do with each protocol through the unified API:

Jupiter (Solana DEX Aggregator)

  • Token swaps with optimal routing
  • Slippage protection and MEV resistance
  • Real-time price discovery across Solana DEXs

Aave v3 (Lending Protocol)

  • Supply assets to earn yield
  • Borrow against collateral with dynamic interest rates
  • Health factor monitoring and liquidation protection

Hyperliquid (Perpetual Futures)

  • Perpetual contract trading with up to 50x leverage
  • Sub-account management for risk isolation
  • Real-time position and PnL tracking

Lido & Jito (Liquid Staking)

  • Stake ETH/SOL while maintaining liquidity
  • Automatic reward compounding
  • Unstaking queue management

LI.FI & Across (Cross-chain Bridges)

  • Asset transfers between 20+ chains
  • Optimal route selection for cost and speed
  • Bridge status monitoring and completion tracking

The key insight is that each protocol maintains its full feature set—you're not getting a dumbed-down wrapper. You can access advanced features like Aave's debt token operations or Hyperliquid's sub-accounts through the same clean REST interface.

Building a Multi-Protocol Agent

Here's where things get interesting for AI agents. With traditional integrations, building a bot that can arbitrage across protocols means managing multiple connection states, different error handling patterns, and inconsistent response formats.

With WAIaaS, your AI agent can execute complex strategies with simple HTTP calls:

// Multi-protocol strategy: stake SOL, bridge USDC, provide liquidity
const client = new WAIaaSClient({
  baseUrl: 'http://127.0.0.1:3100',
  sessionToken: process.env.WAIAAS_SESSION_TOKEN,
});

// 1. Stake SOL with Jito for yield
const stakeResult = await client.executeAction('jito-staking', 'stake', {
  amount: '10.0'
});

// 2. Bridge USDC to Ethereum via LI.FI  
const bridgeResult = await client.executeAction('lifi', 'bridge', {
  fromChain: 'solana',
  toChain: 'ethereum',
  token: 'USDC',
  amount: '5000.0'
});

// 3. Supply bridged USDC to Aave for lending yield
const lendResult = await client.executeAction('aave-v3', 'supply', {
  asset: '0xA0b86a33E6441A8DAB5F0C3B0C44c71b30E11Da3', 
  amount: '5000.0'
});
Enter fullscreen mode Exit fullscreen mode

Each action returns a consistent response format with transaction status, fees, and completion tracking. No protocol-specific quirks to handle.

Real-World Performance

The unified approach shines when building production DeFi systems. Instead of maintaining separate monitoring, error handling, and retry logic for each protocol, you get:

  • Consistent Error Handling: All protocols return standardized error codes
  • Unified Gas Management: Automatic gas estimation across EVM protocols
  • Transaction Lifecycle: Same status polling pattern for all protocols
  • Policy Enforcement: Universal spending limits and security controls

This matters for AI agents that need to make autonomous decisions. Your agent can implement sophisticated strategies—like yield farming across multiple protocols or cross-chain arbitrage—without getting bogged down in integration complexity.

Security at Scale

Managing multiple DeFi protocols also means managing multiple attack vectors. Each protocol has its own security model, approval patterns, and risk profile. WAIaaS addresses this with a unified policy engine that works across all 14 protocols.

You can set protocol-specific limits:

curl -X POST http://localhost:3100/v1/policies \
  -H 'Content-Type: application/json' \
  -H 'X-Master-Password: <password>' \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "PERP_MAX_LEVERAGE", 
    "rules": {
      "maxLeverage": 10,
      "allowedMarkets": ["BTC-USD", "ETH-USD"]
    }
  }'
Enter fullscreen mode Exit fullscreen mode

Or set universal spending limits that apply across all protocols:

{
  "type": "SPENDING_LIMIT",
  "rules": {
    "instant_max_usd": 100,
    "daily_limit_usd": 5000,
    "monthly_limit_usd": 50000
  }
}
Enter fullscreen mode Exit fullscreen mode

This means your AI agent can safely operate across DeFi protocols without risking catastrophic losses from a single bad decision.

Getting Started: Your First Multi-Protocol Agent

Ready to try it? Here's how to get a multi-protocol DeFi agent running in under 5 minutes:

  1. Install and Initialize
npm install -g @waiaas/cli
waiaas init
waiaas start
Enter fullscreen mode Exit fullscreen mode
  1. Create Wallets and Sessions
waiaas quickset --mode mainnet  # Creates EVM + Solana wallets
Enter fullscreen mode Exit fullscreen mode
  1. Fund Your Wallets
    Transfer some ETH and SOL to the generated addresses for gas and trading.

  2. Test Cross-Protocol Operations

# Check DeFi positions across all protocols
curl http://127.0.0.1:3100/v1/defi/positions \
  -H "Authorization: Bearer wai_sess_<your-token>"
Enter fullscreen mode Exit fullscreen mode
  1. Execute Your First Multi-Protocol Strategy Use the TypeScript SDK or direct REST calls to execute actions across any of the 14 integrated protocols.

The complete setup takes minutes instead of weeks, and you immediately have access to the entire DeFi ecosystem through one consistent interface.

What's Next

This unified approach opens up possibilities that weren't practical before. AI agents can now implement sophisticated multi-protocol strategies, cross-chain arbitrage, and dynamic yield optimization without drowning in integration complexity.

The next step is to try it yourself. Clone the repository and see how quickly you can build DeFi functionality that would have taken months with traditional protocol-by-protocol integration.

Ready to unify your DeFi stack? Get started at GitHub or learn more at waiaas.ai.

Top comments (0)