DEV Community

Cover image for Cross-Chain AI Agents: Bridging Assets Between EVM and Solana
Wallet Guy
Wallet Guy

Posted on

Cross-Chain AI Agents: Bridging Assets Between EVM and Solana

Your arb bot spotted a 2% price difference between Ethereum and Solana — but by the time it executes three separate transactions across different chains, the opportunity vanished. Cross-chain arbitrage requires lightning-fast execution across multiple protocols, and managing separate wallets for each chain creates dangerous delays that kill profitable trades.

Why Cross-Chain Speed Matters for Trading Bots

In high-frequency trading and arbitrage, milliseconds determine profitability. A typical cross-chain trade involves multiple steps: swap on the source chain, bridge assets, then execute on the destination chain. Each step introduces latency, gas estimation complexity, and potential failure points.

Trading bots that manage separate wallet infrastructure for each chain face additional overhead: multiple RPC connections, different signing methods, inconsistent error handling, and complex gas optimization strategies. Meanwhile, profitable opportunities slip away to bots with streamlined execution pipelines.

The WAIaaS Solution: Unified Cross-Chain Execution

WAIaaS provides a single wallet API that handles 2 chain types (solana, evm) with 18 networks, eliminating the complexity of managing separate wallet infrastructure for each protocol. Your trading bot gets unified access to 15 DeFi protocol providers including Jupiter (Solana DEX), LI.FI (cross-chain bridging), Drift (Solana perps), and major EVM protocols.

Key Features for Trading Bots

  • Gas conditional execution — transactions execute only when gas price meets your threshold
  • Dry-run API for simulating transactions before execution
  • 7-stage transaction pipeline with built-in retry logic and confirmation tracking
  • Cross-chain bridging via LI.FI and Across protocols in a single API call
  • ERC-4337 Account Abstraction with gasless transactions and batch execution

Cross-Chain Arbitrage Example

Here's how your bot executes a profitable arbitrage opportunity between Ethereum and Solana:

# Step 1: Check ETH/USDC price on Uniswap (EVM wallet)
curl http://127.0.0.1:3100/v1/wallet/balance \
  -H "Authorization: Bearer wai_sess_eth_wallet_token"

# Step 2: Swap ETH for USDC on Ethereum
curl -X POST http://127.0.0.1:3100/v1/actions/zerox-swap/swap \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_eth_wallet_token" \
  -d '{
    "sellToken": "ETH",
    "buyToken": "0xA0b86a33E6441E13C4AE1D5536b8f0E78E43C66A",
    "sellAmount": "1000000000000000000"
  }'

# Step 3: Bridge USDC 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_eth_wallet_token" \
  -d '{
    "fromChain": "ethereum",
    "toChain": "solana",
    "fromToken": "0xA0b86a33E6441E13C4AE1D5536b8f0E78E43C66A",
    "toToken": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000"
  }'

# Step 4: Swap USDC for SOL on Jupiter (Solana wallet)
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_sol_wallet_token" \
  -d '{
    "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "outputMint": "So11111111111111111111111111111111111111112",
    "amount": "1000000000"
  }'
Enter fullscreen mode Exit fullscreen mode

Gas-Optimized Execution

Your bot can set gas conditions to ensure trades only execute during profitable market conditions:

# Only execute when gas < 30 gwei
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": "0x742d35Cc6642C4532C7C23A1dBA08b",
    "amount": "0.1",
    "gasCondition": {
      "maxGasPrice": "30000000000"
    }
  }'
Enter fullscreen mode Exit fullscreen mode

Batch Transaction Execution

For complex multi-step trades, WAIaaS supports batch execution to reduce latency:

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": "Batch",
    "transactions": [
      {
        "type": "Approve",
        "spender": "0x...",
        "amount": "1000000"
      },
      {
        "type": "ContractCall",
        "to": "0x...",
        "data": "0x..."
      }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Risk Management Integration

The policy engine provides built-in risk controls without slowing down execution:

# Create spending limits for your trading bot
curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -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

Real-Time Position Monitoring

Track your bot's DeFi positions across all protocols with a single API call:

# Get positions across Aave, Drift, Hyperliquid, etc.
curl http://127.0.0.1:3100/v1/wallet/defi-positions \
  -H "Authorization: Bearer wai_sess_<token>"
Enter fullscreen mode Exit fullscreen mode

Quick Start for Trading Bot Integration

Step 1: Deploy 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 Cross-Chain Wallets

# Install CLI
npm install -g @waiaas/cli

# Create Ethereum wallet
waiaas wallet create --name "eth-trading" --chain evm --environment mainnet

# Create Solana wallet  
waiaas wallet create --name "sol-trading" --chain solana --environment mainnet
Enter fullscreen mode Exit fullscreen mode

Step 3: Generate Session Tokens

# Create sessions for both wallets
waiaas session create --wallet-id <eth-wallet-id> --name "eth-trading-session"
waiaas session create --wallet-id <sol-wallet-id> --name "sol-trading-session"
Enter fullscreen mode Exit fullscreen mode

Step 4: Fund and Configure Policies

# Set up risk controls
waiaas policy create --wallet-id <wallet-id> --type SPENDING_LIMIT \
  --rules '{"instant_max_usd": 5000, "daily_limit_usd": 100000}'
Enter fullscreen mode Exit fullscreen mode

Step 5: Integrate with Your Bot

import { WAIaaSClient } from '@waiaas/sdk';

const ethClient = new WAIaaSClient({
  baseUrl: 'http://127.0.0.1:3100',
  sessionToken: process.env.ETH_SESSION_TOKEN,
});

const solClient = new WAIaaSClient({
  baseUrl: 'http://127.0.0.1:3100', 
  sessionToken: process.env.SOL_SESSION_TOKEN,
});

// Your arbitrage logic here
const ethPrice = await getEthPrice();
const solPrice = await getSolPrice();
if (ethPrice - solPrice > PROFIT_THRESHOLD) {
  await executeArbitrage(ethClient, solClient);
}
Enter fullscreen mode Exit fullscreen mode

Related Posts

Explore these complementary guides for building comprehensive trading systems:

Building High-Performance Trading Bots with WAIaaS Policy Engine

Docker Deployment for Production Trading Infrastructure

What's Next

Ready to build faster, more reliable cross-chain trading bots? WAIaaS provides the wallet infrastructure so you can focus on trading logic instead of managing blockchain complexity. Get started with the complete codebase at https://github.com/minhoyoo-iotrust/WAIaaS or explore the full documentation at https://waiaas.ai.

Top comments (0)