Your trading bot spotted a 3% arbitrage opportunity between Jupiter and a centralized exchange. By the time you've simulated the trade, calculated slippage, and confirmed gas costs, the opportunity vanished. Your bot needs to make split-second decisions, but one wrong transaction can drain your entire balance.
Why Simulation Matters for Trading Bots
In algorithmic trading, execution speed determines profitability. But speed without safety is bankruptcy waiting to happen. A misconfigured bot can approve unlimited tokens to malicious contracts, execute trades at terrible prices due to sandwich attacks, or drain funds through reentrancy exploits.
Traditional approaches force you to choose: either simulate transactions using fork testing (slow, complex setup) or execute blindly and hope for the best (fast, but dangerous). Neither works for production trading bots that need millisecond decision-making with ironclad risk controls.
Dry-Run API: Test Every Trade Before Execution
WAIaaS provides a dry-run API that simulates any transaction without spending gas or moving funds. Your trading bot can validate trades, check slippage limits, and verify gas costs before committing real capital.
Here's how your Jupiter arbitrage bot validates a swap before execution:
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",
"dryRun": true,
"slippageBps": 50
}'
The simulation returns the exact output amount, effective price, and fee breakdown without executing the trade. If the numbers look good, remove "dryRun": true and execute the same request for real.
This works across all 14 DeFi protocols integrated into WAIaaS: Jupiter swaps, Drift perpetuals, Hyperliquid futures, Polymarket predictions, cross-chain bridges via LI.FI, and liquid staking through Lido and Jito.
Advanced Simulation: Batch Transactions and Gas Conditions
Your MEV bot needs to execute complex multi-step strategies atomically. WAIaaS supports batch transaction simulation, letting you test entire trade sequences before committing:
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": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
"amount": "1000000"
},
{
"type": "ContractCall",
"to": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
"data": "0x..."
}
],
"dryRun": true
}'
Gas conditional execution takes this further. Your bot can queue transactions that 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": "recipient-address",
"amount": "0.1",
"gasCondition": {
"maxGasPrice": "20000000000",
"timeoutSeconds": 1800
}
}'
This queues the transaction until gas drops below 20 gwei or the 30-minute timeout expires.
Real-Time Transaction Pipeline
WAIaaS processes transactions through a 7-stage pipeline that validates, simulates, checks policies, waits for gas conditions, executes, and confirms each trade. Your bot gets real-time status updates through the REST API:
# Check transaction status
curl http://127.0.0.1:3100/v1/transactions/<tx-id> \
-H "Authorization: Bearer wai_sess_<token>"
Response shows current pipeline stage:
{
"id": "019c47d6-51ef-7f43-a76b-d50e875d95f4",
"status": "PENDING",
"stage": "stage4-wait",
"gasCondition": {
"maxGasPrice": "20000000000",
"currentGasPrice": "25000000000",
"waitingFor": "gas_price_drop"
}
}
Built-in Risk Controls for Trading Bots
Simulation prevents obvious failures, but trading bots need defense in depth. WAIaaS includes 21 policy types that act as circuit breakers for automated trading:
- SPENDING_LIMIT: Kill switch when daily losses exceed threshold
- RATE_LIMIT: Prevent runaway bot loops (max 100 trades/hour)
- ALLOWED_TOKENS: Whitelist only tokens your bot should trade
- CONTRACT_WHITELIST: Block calls to unknown contracts (prevents rug pulls)
- TIME_RESTRICTION: Disable trading outside market hours
- PERP_MAX_LEVERAGE: Cap leverage on perpetual futures
These policies follow a 4-tier security model. Small trades execute instantly, larger amounts trigger notifications or delays, and huge positions require human approval via WalletConnect.
Multi-Chain Trading with One API
Your arbitrage opportunities span chains. WAIaaS supports 2 chain types across 15 networks, with cross-chain bridging through LI.FI and Across protocols. Your bot can:
- Swap SOL for USDC on Jupiter (Solana)
- Bridge USDC to Ethereum via LI.FI
- Provide liquidity on Aave (Ethereum)
- Trade perpetuals on Hyperliquid
All through the same session token and consistent API interface.
Get Started: Deploy a Trading Bot in 5 Steps
- Install via Docker (30 seconds):
git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
docker compose up -d
- Create trading wallets (funded with your strategy capital):
# Create Solana wallet for DeFi
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: your-password" \
-d '{"name": "solana-trading", "chain": "solana", "environment": "mainnet"}'
# Create Ethereum wallet for perps
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: your-password" \
-d '{"name": "ethereum-trading", "chain": "evm", "environment": "mainnet"}'
- Create bot session (API key for your trading bot):
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "Content-Type: application/json" \
-H "X-Master-Password: your-password" \
-d '{"walletId": "<solana-wallet-uuid>"}'
- Set risk policies (prevent bot from draining funds):
curl -X POST http://127.0.0.1:3100/v1/policies \
-H "Content-Type: application/json" \
-H "X-Master-Password: your-password" \
-d '{
"walletId": "<wallet-uuid>",
"type": "SPENDING_LIMIT",
"rules": {
"instant_max_usd": 1000,
"daily_limit_usd": 10000
}
}'
- Start trading (simulate first, execute if profitable):
import { WAIaaSClient } from '@waiaas/sdk';
const client = new WAIaaSClient({
baseUrl: 'http://127.0.0.1:3100',
sessionToken: process.env.WAIAAS_SESSION_TOKEN,
});
// Simulate Jupiter swap
const simulation = await client.executeAction('jupiter-swap', 'swap', {
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '1000000000',
dryRun: true
});
// Check if profitable after fees
if (simulation.outputAmount > profitabilityThreshold) {
// Execute for real
const trade = await client.executeAction('jupiter-swap', 'swap', {
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '1000000000'
});
}
What's Next
Your trading bot needs millisecond execution with bulletproof risk controls. WAIaaS gives you both through simulation APIs, gas conditional execution, and built-in policy enforcement across 14 DeFi protocols.
Explore the full capabilities at https://github.com/minhoyoo-iotrust/WAIaaS or dive into the interactive API docs at https://waiaas.ai.
Top comments (0)