DEV Community

Cover image for Unified DEX API: 0x on Ethereum, Jupiter on Solana for Multi-Chain Arbitrage
Wallet Guy
Wallet Guy

Posted on

Unified DEX API: 0x on Ethereum, Jupiter on Solana for Multi-Chain Arbitrage

Trading bots need seamless access to DEX liquidity across multiple chains, but managing separate APIs, wallets, and execution logic for each protocol creates complexity and missed opportunities. WAIaaS provides a unified API that abstracts away the differences between 0x on Ethereum and Jupiter on Solana, letting your bot focus on strategy rather than infrastructure.

Why Multi-Chain DEX Access Matters for Trading Bots

Arbitrage opportunities don't respect chain boundaries. When SOL/USDC spreads diverge between Ethereum and Solana, or when a token launches simultaneously on multiple chains, execution speed determines profitability. Managing separate wallet infrastructure, gas optimization, and risk controls for each chain slows down development and introduces execution delays that can kill profitable trades.

Professional trading operations need gas conditional execution, automatic slippage protection, and integrated bridge routing to capture cross-chain arbitrage efficiently. WAIaaS handles this complexity through a single API that abstracts Jupiter's swap routing on Solana and 0x's aggregated liquidity on Ethereum.

Unified DEX API: One Call, Multiple Protocols

WAIaaS integrates 15 DeFi protocol providers including jupiter-swap and zerox-swap, giving your bot access to aggregated liquidity across chains through standardized endpoints. The action execution API handles protocol-specific details while your bot sends consistent swap instructions.

Execute Jupiter Swap on Solana

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",
    "slippageBps": 50
  }'
Enter fullscreen mode Exit fullscreen mode

Execute 0x Swap 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_<token>" \
  -d '{
    "sellToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "buyToken": "0xA0b86a33E6441986C3190547d4c5EEB1b39F4b8B",
    "sellAmount": "1000000000000000000",
    "slippagePercentage": 0.5
  }'
Enter fullscreen mode Exit fullscreen mode

Both calls return standardized transaction objects that move through WAIaaS's 7-stage transaction pipeline: validate → auth → policy → wait → execute → confirm → complete.

Gas Conditional Execution for MEV Protection

Trading bots need gas optimization to remain profitable. WAIaaS includes gas conditional execution that queues transactions until gas prices meet your threshold, preventing your bot from executing unprofitable trades during network congestion.

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": "ContractCall",
    "to": "0x...",
    "data": "0x...",
    "gasCondition": {
      "maxGasPriceGwei": 30,
      "timeoutSeconds": 300
    }
  }'
Enter fullscreen mode Exit fullscreen mode

The transaction waits in stage4-wait until gas drops below 30 gwei or times out after 5 minutes, giving your bot control over execution timing.

Risk Management Through Policy Engine

Production trading bots need programmatic risk controls. WAIaaS's policy engine provides 21 policy types with 4 security tiers (INSTANT/NOTIFY/DELAY/APPROVAL) to protect against runaway algorithms or compromised API keys.

Spending Limits with Per-Token Controls

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,
      "notify_max_usd": 5000,
      "delay_max_usd": 25000,
      "delay_seconds": 300,
      "daily_limit_usd": 50000,
      "token_limits": {
        "native:ethereum": {"instant_max": "1", "delay_max": "10"},
        "native:solana": {"instant_max": "100", "delay_max": "1000"}
      }
    }
  }'
Enter fullscreen mode Exit fullscreen mode

This policy allows instant execution up to $1,000, requires 5-minute delays for trades above $5,000, and blocks trades exceeding $25,000 until manual approval.

Contract Whitelisting for DEX-Only Trading

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "type": "CONTRACT_WHITELIST",
    "rules": {
      "contracts": [
        {"address": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", "name": "Jupiter", "chain": "solana"},
        {"address": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF", "name": "0x Exchange", "chain": "ethereum"}
      ]
    }
  }'
Enter fullscreen mode Exit fullscreen mode

Default-deny enforcement means your bot can only interact with whitelisted DEX contracts, preventing attacks through malicious contract calls.

Cross-Chain Arbitrage with Integrated Bridging

WAIaaS integrates LI.FI and Across protocols for cross-chain bridging, enabling arbitrage bots to capture price spreads between chains through automated bridge routing.

# Check cross-chain route via LI.FI
curl -X POST http://127.0.0.1:3100/v1/actions/lifi/quote \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{
    "fromChain": "ETH",
    "toChain": "SOL", 
    "fromToken": "0xA0b86a33E6441986C3190547d4c5EEB1b39F4b8B",
    "toToken": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "fromAmount": "1000000000000000000"
  }'

# Execute bridge transaction
curl -X POST http://127.0.0.1:3100/v1/actions/lifi/bridge \
  -H "Authorization: Bearer wai_sess_<token>" \
  -d '{...quote_response...}'
Enter fullscreen mode Exit fullscreen mode

Your bot can execute multi-leg arbitrage: buy on Ethereum DEX → bridge via LI.FI → sell on Solana DEX, all through consistent API calls.

TypeScript SDK for High-Frequency Trading

The WAIaaS TypeScript SDK provides zero-dependency access with async/await patterns optimized for trading bot integration.

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

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

// Multi-chain balance check
const [ethBalance, solBalance] = await Promise.all([
  client.getBalance(), // Current wallet's native balance
  client.getAssets()   // All token balances
]);

// Execute arbitrage trade
const jupiterSwap = client.executeAction('jupiter-swap', 'swap', {
  inputMint: 'So11111111111111111111111111111111111111112',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '1000000000'
});

// Simulate transaction first
const dryRun = await client.sendToken({
  to: 'recipient-address',
  amount: '0.1',
  dryRun: true
});

if (dryRun.success) {
  const actualTx = await client.sendToken({
    to: 'recipient-address', 
    amount: '0.1'
  });
}
Enter fullscreen mode Exit fullscreen mode

Quick Start: Deploy Multi-Chain Trading Infrastructure

Step 1: Launch 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

npm install -g @waiaas/cli
waiaas quickset --mode mainnet  # Creates Ethereum + Solana wallets
Enter fullscreen mode Exit fullscreen mode

Step 3: Configure Trading Policies

waiaas set-policy SPENDING_LIMIT --instant-max 1000 --daily-limit 50000
waiaas set-policy CONTRACT_WHITELIST --contracts jupiter,0x-exchange
Enter fullscreen mode Exit fullscreen mode

Step 4: Test DEX Integration

# Check wallet balances
curl http://127.0.0.1:3100/v1/wallet/balance \
  -H "Authorization: Bearer $(cat ~/.waiaas/session_token)"

# Execute test swap
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
  -H "Authorization: Bearer $(cat ~/.waiaas/session_token)" \
  -d '{"inputMint":"So11...", "outputMint":"EPjF...", "amount":"100000"}'
Enter fullscreen mode Exit fullscreen mode

Step 5: Integrate with Your Bot

Install the SDK and replace your existing wallet management with WAIaaS API calls. Your bot gains access to 15 DeFi protocols, gas optimization, and integrated risk management through a single interface.

What's Next

WAIaaS provides the wallet infrastructure layer that lets trading bots focus on alpha generation rather than protocol integration. The unified DEX API, gas conditional execution, and policy-based risk management handle the operational complexity while your algorithms capture market opportunities.

Get started at the GitHub repository or explore the full platform at waiaas.ai.

Top comments (0)