DEV Community

Cover image for 14-Protocol Arbitrage Bot: Spotting Opportunities Across All Major DeFi Venues
Wallet Guy
Wallet Guy

Posted on

14-Protocol Arbitrage Bot: Spotting Opportunities Across All Major DeFi Venues

Spotting arbitrage opportunities across 15 DeFi protocols is just the first challenge for trading bot builders. The real test comes when your bot needs to execute a multi-step arbitrage trade across Jupiter, Hyperliquid, and LI.FI before the price gap closes—and your wallet infrastructure becomes the bottleneck.

Why Multi-Protocol Infrastructure Matters

Modern arbitrage opportunities rarely exist within a single protocol. The most profitable trades often require:

  • Swapping on one DEX (Jupiter, 0x)
  • Taking a leveraged position on a perpetual exchange (Hyperliquid, Drift)
  • Bridging assets between chains (LI.FI, Across)
  • Managing collateral across lending protocols (Aave, Kamino)

Each protocol has its own SDK, authentication method, and transaction format. Building this infrastructure from scratch means months of integration work—time your competitors are using to capture alpha.

The Multi-Protocol Trading Infrastructure Solution

WAIaaS provides a unified wallet service that connects your trading bot to 15 DeFi protocols through a single REST API. Instead of managing multiple wallets and SDKs, your bot makes one API call per action.

Supported Trading Protocols

The platform integrates these DeFi protocols for comprehensive arbitrage strategies:

DEX/Swap Protocols:

  • Jupiter (Solana's largest DEX aggregator)
  • 0x Protocol (Ethereum DEX aggregator)
  • XRPL DEX (native Ripple trading)

Perpetual Futures:

  • Hyperliquid (spot trading, perpetual futures, sub-accounts)
  • Drift (Solana perpetuals with cross-collateral)

Cross-Chain Bridging:

  • LI.FI (cross-chain bridge aggregator)
  • Across (optimistic bridging)

Lending/Borrowing:

  • Aave V3 (multi-chain lending)
  • Kamino (Solana lending with leverage)

Liquid Staking:

  • Lido (Ethereum liquid staking)
  • Jito (Solana liquid staking)

Prediction Markets:

  • Polymarket (outcome token trading)

Gas Conditional Execution

One critical feature for arbitrage bots is gas conditional execution. Your transactions only execute when gas prices meet your threshold:

curl -X POST http://127.0.0.1:3100/v1/transactions/send \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "type": "TRANSFER",
    "to": "0x742d35Cc6634C0532925a3b8D098342E92CcB1C1",
    "amount": "1.0",
    "gasCondition": {
      "maxGasPrice": "20000000000",
      "waitTimeout": 300
    }
  }'
Enter fullscreen mode Exit fullscreen mode

This prevents your bot from executing unprofitable trades when network congestion spikes.

Cross-Protocol Arbitrage Example

Here's how a bot executes a complete arbitrage cycle across multiple protocols:

Step 1: Check available liquidity across protocols

# Check Jupiter liquidity for SOL/USDC
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/quote \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000"
  }'

# Check Drift perpetual funding rates
curl -X POST http://127.0.0.1:3100/v1/actions/drift/get-market-info \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{"market": "SOL-PERP"}'
Enter fullscreen mode Exit fullscreen mode

Step 2: Execute the arbitrage sequence

# Swap SOL for USDC on Jupiter
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000",
    "slippageBps": 50
  }'

# Open leveraged SOL position on Drift
curl -X POST http://127.0.0.1:3100/v1/actions/drift/open-position \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "market": "SOL-PERP",
    "direction": "long",
    "baseAssetAmount": "10000000",
    "leverage": 3
  }'
Enter fullscreen mode Exit fullscreen mode

Step 3: Bridge profits to Ethereum for next opportunity

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

Transaction Simulation for Risk Management

Before executing any arbitrage trade, simulate it to check profitability and catch reverts:

curl -X POST http://127.0.0.1:3100/v1/transactions/send \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "type": "TRANSFER",
    "to": "recipient-address",
    "amount": "0.1",
    "dryRun": true
  }'
Enter fullscreen mode Exit fullscreen mode

This returns the expected outcome without spending gas, letting you validate trade logic before execution.

Policy-Based Risk Controls

Set automated risk limits to prevent catastrophic losses:

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "SPENDING_LIMIT",
    "rules": {
      "instant_max_usd": 1000,
      "daily_limit_usd": 50000,
      "monthly_limit_usd": 500000
    }
  }'
Enter fullscreen mode Exit fullscreen mode

The system automatically blocks trades exceeding your risk thresholds, even if your bot logic fails.

Quick Start: Deploy Your Arbitrage Bot

Step 1: Start WAIaaS with Docker

git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Step 2: Create trading wallets

# Create Solana wallet for Jupiter/Drift
curl -X POST http://127.0.0.1:3100/v1/wallets \
  -H "X-Master-Password: my-secret-password" \
  -d '{"name": "solana-arb", "chain": "solana", "environment": "mainnet"}'

# Create Ethereum wallet for 0x/Aave
curl -X POST http://127.0.0.1:3100/v1/wallets \
  -H "X-Master-Password: my-secret-password" \
  -d '{"name": "ethereum-arb", "chain": "evm", "environment": "mainnet"}'
Enter fullscreen mode Exit fullscreen mode

Step 3: Create bot sessions

curl -X POST http://127.0.0.1:3100/v1/sessions \
  -H "X-Master-Password: my-secret-password" \
  -d '{"walletId": "<solana-wallet-uuid>"}'
Enter fullscreen mode Exit fullscreen mode

Step 4: Set risk policies

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "ALLOWED_TOKENS",
    "rules": {
      "tokens": [
        {"address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "symbol": "USDC"},
        {"address": "So11111111111111111111111111111111111111112", "symbol": "SOL"}
      ]
    }
  }'
Enter fullscreen mode Exit fullscreen mode

Step 5: Start trading

Your bot now has access to 15 DeFi protocols through a single API. Begin with simple Jupiter swaps, then expand to cross-protocol arbitrage as opportunities emerge.

For ongoing development, Building DeFi Trading Bots with Hyperliquid Integration covers advanced perpetual futures strategies, while Cross-Chain Bridge Arbitrage: Automated Profit from Price Differences explores multi-chain opportunities.

What's Next

Start with the basic setup above to test your arbitrage logic across protocols. The 39 REST API routes give you complete control over wallet operations, while the 7-stage transaction pipeline ensures reliable execution even during network congestion.

Ready to build your multi-protocol arbitrage bot? Get the complete infrastructure at GitHub or explore more capabilities at waiaas.ai.

Top comments (0)