DEV Community

Cover image for AI Agents as DeFi Lenders: Aave V3 + Kamino Integration
Wallet Guy
Wallet Guy

Posted on

AI Agents as DeFi Lenders: Aave V3 + Kamino Integration

Your trading bot needs to lend idle USDC on Aave, earn stSOL rewards on Kamino, and maybe grab some Hyperliquid perp exposure — but integrating 14 different DeFi protocols means 14 different APIs, authentication schemes, and transaction formats. What if there was a better way?

Building multi-protocol DeFi strategies shouldn't require a PhD in protocol-specific SDKs. Every protocol has its own API design, error handling, and transaction building process. Jupiter wants one format, Aave expects another, Kamino has its own thing entirely. Your code becomes a sprawling mess of protocol adapters, and adding a new venue means weeks of integration work.

One API for All DeFi Protocols

WAIaaS provides a unified REST API across 14 DeFi protocols on both EVM and Solana. Instead of learning each protocol's quirks, you make standard HTTP calls with consistent request/response formats. Want to lend on Aave? Same API pattern as staking on Lido or swapping on Jupiter.

The architecture is built around "action providers" — each protocol gets wrapped in a standard interface that handles authentication, transaction building, and error formatting. Your application code stays clean and protocol-agnostic.

Here's what lending USDC on Aave V3 looks like:

curl -X POST http://127.0.0.1:3100/v1/actions/aave-v3/supply \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "asset": "0xA0b86a33E6441b55434DD5031Ee5CC8a0b080eb6",
    "amount": "1000000000",
    "onBehalfOf": "0x742d35cc6bf8cf8d3d7b87b4e0b3c3c7a8b9e2e1"
  }'
Enter fullscreen mode Exit fullscreen mode

The same pattern works for Kamino lending on Solana:

curl -X POST http://127.0.0.1:3100/v1/actions/kamino/lend \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "reserve": "USDC_RESERVE_ADDRESS",
    "amount": "1000000"
  }'
Enter fullscreen mode Exit fullscreen mode

Behind the scenes, WAIaaS handles the protocol-specific transaction building, gas estimation, and execution. You get a consistent transaction ID back and can poll for status using the same endpoints regardless of which protocol you're using.

Multi-Protocol Yield Strategy Example

Let's build a simple yield optimization bot that:

  1. Checks current positions across protocols
  2. Moves funds to the highest-yield opportunity
  3. Maintains target allocation percentages

First, check your current DeFi positions across all protocols:

curl http://127.0.0.1:3100/v1/wallet/defi-positions \
  -H "Authorization: Bearer wai_sess_<token>"
Enter fullscreen mode Exit fullscreen mode

This returns a unified view of lending positions, liquid staking balances, and perpetual futures across Aave, Kamino, Lido, Jito, Hyperliquid, and more. No need to query each protocol separately.

Now implement the rebalancing logic. If Kamino is offering better USDC yields than Aave, withdraw from Aave and deposit to Kamino:

# Withdraw from Aave
curl -X POST http://127.0.0.1:3100/v1/actions/aave-v3/withdraw \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "asset": "0xA0b86a33E6441b55434DD5031Ee5CC8a0b080eb6",
    "amount": "500000000"
  }'

# Deposit to Kamino
curl -X POST http://127.0.0.1:3100/v1/actions/kamino/lend \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "reserve": "USDC_RESERVE_ADDRESS", 
    "amount": "500000"
  }'
Enter fullscreen mode Exit fullscreen mode

Both transactions use the same authentication, error handling, and status polling. Your bot doesn't need to understand Aave's lending pool contracts or Kamino's instruction formats.

Cross-Chain Arbitrage Made Simple

WAIaaS includes cross-chain bridging via LI.FI and Across protocols, so you can easily move funds between chains when opportunities arise. If Solana DeFi is offering better yields than Ethereum, bridge your assets automatically:

# Bridge USDC from Ethereum to Solana via LI.FI
curl -X POST http://127.0.0.1:3100/v1/actions/lifi/bridge \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "fromChain": "ethereum",
    "toChain": "solana", 
    "fromToken": "0xA0b86a33E6441b55434DD5031Ee5CC8a0b080eb6",
    "toToken": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000"
  }'
Enter fullscreen mode Exit fullscreen mode

Once the bridge completes, deploy the funds on Solana DeFi:

# Lend on Kamino
curl -X POST http://127.0.0.1:3100/v1/actions/kamino/lend \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "reserve": "USDC_RESERVE_ADDRESS",
    "amount": "1000000"
  }'
Enter fullscreen mode Exit fullscreen mode

The same API handles Ethereum DeFi, Solana DeFi, and cross-chain bridging. Your arbitrage bot becomes chain-agnostic.

Advanced Features for DeFi Developers

Policy-Based Risk Management

Set spending limits, allowed tokens, and maximum leverage automatically:

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: <password>" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "LENDING_LTV_LIMIT",
    "rules": {"maxLtv": 0.7}
  }'
Enter fullscreen mode Exit fullscreen mode

This prevents your lending positions from exceeding 70% LTV across all protocols, automatically.

Transaction Simulation

Test strategies without spending gas:

curl -X POST http://127.0.0.1:3100/v1/actions/aave-v3/supply \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "asset": "0xA0b86a33E6441b55434DD5031Ee5CC8a0b080eb6",
    "amount": "1000000000",
    "dryRun": true
  }'
Enter fullscreen mode Exit fullscreen mode

Get gas estimates, success probability, and return calculations before executing real transactions.

Health Factor Monitoring

Track liquidation risk across all lending positions:

curl http://127.0.0.1:3100/v1/wallet/health-factor \
  -H "Authorization: Bearer wai_sess_<token>"
Enter fullscreen mode Exit fullscreen mode

Returns a unified health factor considering positions across Aave, Kamino, and other lending protocols.

Get Started in 5 Minutes

  1. Install and start WAIaaS:
npm install -g @waiaas/cli
waiaas init
waiaas start
Enter fullscreen mode Exit fullscreen mode
  1. Create wallets for both chains:
waiaas quickset --mode mainnet
Enter fullscreen mode Exit fullscreen mode
  1. Fund your wallets and create a session:
# Creates API session token
curl -X POST http://127.0.0.1:3100/v1/sessions \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: <your-password>" \
  -d '{"walletId": "<wallet-uuid>"}'
Enter fullscreen mode Exit fullscreen mode
  1. Test a simple lending operation:
curl -X POST http://127.0.0.1:3100/v1/actions/aave-v3/supply \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "asset": "0xA0b86a33E6441b55434DD5031Ee5CC8a0b080eb6",
    "amount": "1000000"
  }'
Enter fullscreen mode Exit fullscreen mode
  1. Check your positions:
curl http://127.0.0.1:3100/v1/wallet/defi-positions \
  -H "Authorization: Bearer wai_sess_<token>"
Enter fullscreen mode Exit fullscreen mode

You're now lending on Aave through a unified API. Adding Kamino, Jupiter swaps, or Hyperliquid perps uses the same authentication and request patterns.

What's Next

WAIaaS includes 39 REST API routes, 45 MCP tools for Claude integration, and comprehensive policy management for production DeFi applications. The complete protocol list includes Aave V3, Jupiter, Kamino, Lido, Hyperliquid, Drift, Polymarket, and more.

Ready to unify your DeFi integrations? Check out the full documentation and codebase at https://github.com/minhoyoo-iotrust/WAIaaS or visit https://waiaas.ai to get started.

Top comments (0)