Your arb bot spotted a 2.3% price difference between Jupiter and Drift. Gas is spiking, your transaction pool is scattered across three different wallet SDKs, and by the time you execute, the opportunity is gone. Trading bots need unified DeFi access with gas optimization and execution speed built in — not a collection of protocol-specific wrappers that break when you need them most.
Why Multi-Protocol Access Matters for Trading Bots
Modern DeFi opportunities don't respect protocol boundaries. A profitable trade might involve swapping on Jupiter, opening a leveraged position on Hyperliquid, and bridging profits back via Across — all within seconds. Your bot needs to think in strategies, not individual protocol calls.
The infrastructure challenge is real: each DeFi protocol has its own SDK, gas estimation quirks, and failure modes. Jupiter's Jupiter API expects Solana transaction formatting, while Hyperliquid requires REST API calls with custom signing. Your bot ends up with a frankenstein architecture of protocol wrappers, each with different error handling and retry logic.
Meanwhile, MEV bots are capturing opportunities faster because they have unified execution infrastructure. They're not debugging why the Pendle SDK failed when gas peaked — they're already onto the next trade.
Unified DeFi Protocol Access
WAIaaS provides 15 DeFi protocol integrations through a single REST API. Your bot makes the same HTTP call whether it's swapping on Jupiter or opening a Hyperliquid perp — the complexity lives in the infrastructure layer, not your trading logic.
Here's what cross-protocol execution looks like:
# Swap on Jupiter (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"
}'
# Open leveraged position on Hyperliquid (EVM)
curl -X POST http://127.0.0.1:3100/v1/actions/hyperliquid/place-order \
-H "Content-Type: application/json" \
-H "Authorization: Bearer wai_sess_<token>" \
-d '{
"symbol": "ETH-USD",
"side": "long",
"size": "0.5",
"leverage": 10,
"orderType": "market"
}'
# Bridge profits 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": "0xA0b86a33E6417c5cB68e...",
"toToken": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "500000000"
}'
Same authentication, same error format, same transaction monitoring. Your bot's architecture becomes strategy-focused instead of protocol-focused.
Gas Conditional Execution
Gas spikes kill trading bot profitability. You spot a 1.2% arbitrage opportunity, but 150 gwei gas costs eat 0.8% of your profit. WAIaaS includes gas conditional execution — transactions only execute when gas meets your threshold.
# Only execute if gas < 50 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": "CONTRACT_CALL",
"to": "0xE592427A0AEce92De3Edee1F18E0157C05861564",
"data": "0x414bf389...",
"gasCondition": {
"maxGasPrice": "50000000000",
"timeoutMs": 300000
}
}'
The transaction sits in the queue, monitoring gas prices. When gas drops below 50 gwei, it executes automatically. If gas doesn't drop within 5 minutes, the transaction expires. Your bot stays profitable by avoiding expensive executions.
The 15 Integrated DeFi Protocols
WAIaaS integrates with protocols across the major DeFi categories trading bots need:
DEX/Swapping:
- Jupiter (Solana aggregator)
- 0x Protocol (Ethereum aggregator)
- D'CENT Swap
Perpetual Futures:
- Hyperliquid (orderbook-based perps)
- Drift (AMM-based perps)
Cross-Chain:
- LI.FI (bridge aggregator)
- Across (optimistic bridging)
Lending/Leveraged Trading:
- Aave v3 (lending, flash loans)
- Kamino (Solana lending)
Liquid Staking:
- Lido (ETH staking)
- Jito (SOL staking)
Structured Products:
- Pendle (yield trading)
Prediction Markets:
- Polymarket (event betting)
Standards/Infrastructure:
- ERC-8004 (trustless agents)
Each protocol exposes its core trading functions through the actions API. Jupiter gets swap routing, Hyperliquid gets order management, Aave gets lending positions — the functions your bot actually uses for strategy execution.
Real Trading Bot Implementation
Here's how a cross-chain arbitrage bot looks with unified protocol access:
import { WAIaaSClient } from '@waiaas/sdk';
const client = new WAIaaSClient({
baseUrl: 'http://127.0.0.1:3100',
sessionToken: process.env.WAIAAS_SESSION_TOKEN,
});
class ArbBot {
async checkOpportunity() {
// Get Jupiter price (Solana)
const jupiterPrice = await client.executeAction('jupiter-swap', 'quote', {
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '1000000000'
});
// Get 0x price (Ethereum)
const zeroXPrice = await client.executeAction('zerox-swap', 'quote', {
sellToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
buyToken: '0xA0b86a33E6417c5Cb68e...',
sellAmount: '1000000000000000000'
});
const priceDiff = this.calculateSpread(jupiterPrice, zeroXPrice);
if (priceDiff > 0.015) { // 1.5% profit threshold
await this.executeArb(jupiterPrice, zeroXPrice);
}
}
async executeArb(jupiterPrice, zeroXPrice) {
// Execute on the cheaper venue first
const tx1 = await client.executeAction('jupiter-swap', 'swap', {
inputMint: jupiterPrice.inputMint,
outputMint: jupiterPrice.outputMint,
amount: jupiterPrice.inAmount,
slippage: 0.005 // 0.5% max slippage
});
// Wait for confirmation, then execute second leg
await this.waitForConfirmation(tx1.id);
const tx2 = await client.executeAction('zerox-swap', 'swap', {
sellToken: zeroXPrice.sellToken,
buyToken: zeroXPrice.buyToken,
sellAmount: zeroXPrice.sellAmount,
gasCondition: { maxGasPrice: '80000000000' }
});
}
}
Single SDK, unified error handling, automatic gas optimization. Your bot focuses on strategy logic instead of protocol integration complexity.
Risk Controls for Automated Trading
Trading bots need programmatic risk controls. WAIaaS includes 21 policy types that enforce limits without manual intervention:
- SPENDING_LIMIT: Daily/monthly USD limits with 4-tier security
- PERP_MAX_LEVERAGE: Cap leverage across all perp protocols
- PERP_MAX_POSITION_USD: Position size limits
- RATE_LIMIT: Max transactions per hour/day
- VENUE_WHITELIST: Only trade on approved protocols
- CONTRACT_WHITELIST: Prevent calls to unknown contracts
Policies apply across all protocols. Set a $50K daily limit — it works whether your bot is trading on Jupiter, Hyperliquid, or Drift. The risk controls live in the wallet layer, not scattered across protocol-specific code.
Multi-Wallet Orchestration
Sophisticated bots use multiple wallets for different strategies, gas optimization, and risk isolation. WAIaaS handles multi-wallet orchestration through the session system:
# Create wallets for different strategies
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "X-Master-Password: <password>" \
-d '{"name": "arb-wallet", "chain": "ethereum"}'
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "X-Master-Password: <password>" \
-d '{"name": "perp-wallet", "chain": "solana"}'
# Create sessions for each strategy
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "X-Master-Password: <password>" \
-d '{"walletId": "<arb-wallet-uuid>", "name": "arb-bot"}'
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "X-Master-Password: <password>" \
-d '{"walletId": "<perp-wallet-uuid>", "name": "perp-bot"}'
Each bot instance gets its own session token and wallet. Arbitrage profits stay isolated from perp trading risk. Gas optimization happens per wallet — your Ethereum wallet doesn't wait for Solana confirmations.
Quick Start for Trading Bots
- Deploy infrastructure:
git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
docker compose up -d
- Create trading wallets:
npm install -g @waiaas/cli
waiaas init
waiaas start
waiaas wallet create --name arb-bot --chain ethereum
waiaas wallet create --name solana-bot --chain solana
- Set up sessions and policies:
# Create bot sessions
waiaas session prompt --wallet arb-bot
waiaas session prompt --wallet solana-bot
# Set spending limits
curl -X POST http://127.0.0.1:3100/v1/policies \
-H "X-Master-Password: <password>" \
-d '{
"walletId": "<wallet-uuid>",
"type": "SPENDING_LIMIT",
"rules": {"daily_limit_usd": 10000}
}'
- Install SDK and start trading:
npm install @waiaas/sdk
const { WAIaaSClient } = require('@waiaas/sdk');
const client = new WAIaaSClient({
sessionToken: 'wai_sess_your_token_here'
});
// Your trading logic here
const balance = await client.getBalance();
console.log(`Ready to trade with ${balance.balance} ${balance.symbol}`);
- Test with simulation:
# Test trades with dry-run mode
curl -X POST http://127.0.0.1:3100/v1/actions/jupiter-swap/swap \
-d '{"dryRun": true, ...}' # Add dryRun to any trade
What's Next
Your trading bot now has unified access to 15 DeFi protocols with gas optimization and risk controls built in. Focus on strategy development instead of infrastructure headaches. Check out the full protocol documentation and start building your next trading system.
Get started: GitHub | Documentation
Top comments (0)