Building a trading bot that can execute across multiple DEXs is like trying to conduct an orchestra where every instrument speaks a different language. Your bot needs to swap on Jupiter for Solana opportunities, execute on 0x for Ethereum arbitrage, and maybe hit Hyperliquid for perpetual futures — all while managing gas costs, handling failed transactions, and keeping your private keys secure.
Most developers end up with a fragmented mess: separate wallet implementations for each chain, custom gas management logic, and no unified way to handle approvals or monitor positions. Your bot becomes a collection of scripts held together with prayer and environment variables.
Why Multi-Protocol Trading Infrastructure Matters
The best trading opportunities don't respect chain boundaries. A price discrepancy between Solana and Ethereum might last seconds. Your bot needs to act fast, with reliable execution across protocols. Manual wallet management, gas estimation, and transaction monitoring slow you down when milliseconds matter.
Consider arbitrage between Jupiter (Solana) and 0x (Ethereum). Your bot needs to:
- Monitor prices across both DEXs
- Execute simultaneous swaps when spreads appear
- Handle different transaction models (Solana's single signature vs Ethereum's gas bidding)
- Manage slippage and MEV protection
- Bridge assets between chains when necessary
Building this infrastructure from scratch means months of work before you can focus on trading logic.
One API for All Your Trading Protocols
WAIaaS provides a unified wallet service that handles 15 DeFi protocol providers through a single REST API. Instead of managing separate SDKs for Jupiter, 0x, Hyperliquid, and others, your bot makes standardized HTTP calls.
Here's how to execute a 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"
}'
The same pattern works for Ethereum via 0x:
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": "0xA0b86a33E6417c5dE117c60f017D1C2D1A3c496f",
"buyToken": "0xC02aaA39b223FE8d0A0e5C4F27eAD9083C756Cc2",
"sellAmount": "1000000000000000000"
}'
Your trading logic stays focused on opportunities, not wallet plumbing.
Gas Conditional Execution for Better Performance
Nothing kills bot profitability like executing trades when gas prices spike. WAIaaS includes gas conditional execution — transactions only execute when gas meets 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": "CONTRACT_CALL",
"to": "0x...",
"data": "0x...",
"gasCondition": {
"maxGasPrice": "20000000000",
"timeoutSeconds": 300
}
}'
The transaction waits up to 5 minutes for gas to drop below 20 gwei, then executes automatically. Your bot doesn't waste profit margins on expensive gas.
Unified Position Monitoring
Trading bots need real-time visibility into positions across protocols. WAIaaS aggregates DeFi positions from all integrated protocols:
curl http://127.0.0.1:3100/v1/wallet/defi-positions \
-H "Authorization: Bearer wai_sess_<token>"
This returns lending positions from Aave, staking rewards from Lido, perpetual futures from Hyperliquid, and liquidity provider positions from multiple DEXs — in one API call.
Cross-Chain Arbitrage Made Simple
When you spot an arbitrage opportunity across chains, WAIaaS handles the bridging complexity. Execute a Jupiter swap on Solana, then bridge the proceeds to Ethereum via LI.FI:
# Step 1: Swap on Jupiter (Solana)
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
-H "Authorization: Bearer wai_sess_<token>" \
-d '{"inputMint": "SOL", "outputMint": "USDC", "amount": "10"}'
# Step 2: Bridge to Ethereum
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": "USDC",
"amount": "500"
}'
# Step 3: Execute on 0x (Ethereum)
curl -X POST http://127.0.0.1:3100/v1/actions/zerox-swap/swap \
-H "Authorization: Bearer wai_sess_<token>" \
-d '{"sellToken": "USDC", "buyToken": "ETH", "sellAmount": "500"}'
All through the same session token, same error handling, same transaction monitoring.
Risk Controls Built for Trading Bots
Production trading bots need safety rails. WAIaaS includes 21 policy types with 4 security tiers. Configure spending limits that allow small trades instantly but require delays for large positions:
curl -X POST http://localhost:3100/v1/policies \
-H 'Content-Type: application/json' \
-H 'X-Master-Password: <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
}
}'
Trades under $1000 execute immediately. Trades $1000-$5000 execute with notifications. Trades $5000-$25000 wait 5 minutes (cancellable). Trades over $25000 require manual approval. Your bot can't accidentally drain the wallet on a bad trade.
Simulation Before Execution
Test your trades before committing capital. WAIaaS includes dry-run simulation for all transaction types:
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": "recipient-address",
"amount": "0.1",
"dryRun": true
}'
The API returns success/failure and gas estimates without executing the transaction. Perfect for backtesting strategies or validating trade parameters.
TypeScript SDK for Bot Development
For TypeScript bots, the @waiaas/sdk package provides a clean interface:
import { WAIaaSClient } from '@waiaas/sdk';
const client = new WAIaaSClient({
baseUrl: 'http://127.0.0.1:3100',
sessionToken: process.env.WAIAAS_SESSION_TOKEN,
});
// Execute Jupiter swap with error handling
try {
const swap = await client.executeAction('jupiter-swap', 'swap', {
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '1000000000'
});
console.log(`Swap executed: ${swap.id}`);
} catch (error) {
if (error.code === 'INSUFFICIENT_BALANCE') {
console.log('Not enough SOL for swap');
} else if (error.code === 'POLICY_DENIED') {
console.log('Trade blocked by spending limits');
}
}
No need to manage RPC endpoints, private key signing, or protocol-specific SDKs.
Getting Started: Multi-DEX Trading Bot
Here's how to set up WAIaaS for multi-protocol trading:
- Deploy with Docker:
git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
docker compose up -d
- Create wallets for each chain:
# Solana wallet
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"name": "solana-trading", "chain": "solana", "environment": "mainnet"}'
# Ethereum wallet
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"name": "ethereum-trading", "chain": "evm", "environment": "mainnet"}'
- Configure trading policies:
curl -X POST http://localhost:3100/v1/policies \
-H 'Content-Type: application/json' \
-H 'X-Master-Password: my-secret-password' \
-d '{
"walletId": "<solana-wallet-uuid>",
"type": "ALLOWED_TOKENS",
"rules": {
"tokens": [
{"address": "So11111111111111111111111111111111111111112", "symbol": "SOL"},
{"address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "symbol": "USDC"}
]
}
}'
- Create session tokens for your bot:
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"walletId": "<wallet-uuid>"}'
- Start trading: Use the session tokens in your bot's HTTP headers for all trading calls.
Your bot now has unified access to Jupiter, 0x, Hyperliquid, and 12 other DeFi protocols through standardized API calls.
For advanced trading scenarios, check out Building Cross-Chain Arbitrage Bots with WAIaaS and DeFi Position Management for Trading Algorithms.
Ready to build your multi-DEX trading infrastructure? Get started with the open-source code at https://github.com/minhoyoo-iotrust/WAIaaS or explore the full documentation at https://waiaas.ai.
Top comments (0)