Skip to main content

MEV & Trading APIs

Axol provides specialized APIs for MEV (Maximal Extractable Value) extraction, trading automation, and DeFi opportunity detection. These endpoints are designed for low-latency, high-reliability applications like trading bots, liquidation bots, and arbitrage systems.

Feature Overview​

FeatureDescriptionUse Case
Gas OracleMulti-provider gas prices with failoverTransaction timing optimization
Mempool StreamingReal-time pending transaction monitoringArbitrage detection, sandwich protection
DeFi LiquidationsPosition health and opportunity detectionLiquidation bots
GatewayDirect node access for low latencyLatency-critical operations
MEV BundlesFlashbots bundle submissionAtomic transaction execution

Quick Start​

1. Get Gas Prices (No Auth Required)​

curl https://api.axol.io/api/v1/oracle/gas/ethereum

Response:

{
"chain": "ethereum",
"slow": {"max_fee_gwei": 25.0, "priority_fee_gwei": 1.0},
"standard": {"max_fee_gwei": 27.0, "priority_fee_gwei": 2.0},
"fast": {"max_fee_gwei": 30.0, "priority_fee_gwei": 3.0},
"instant": {"max_fee_gwei": 35.0, "priority_fee_gwei": 5.0},
"base_fee_gwei": 24.0,
"network_congestion": "medium",
"stale": false
}

2. Stream Mempool Transactions​

Python:

import asyncio
import websockets
import json

async def monitor():
uri = "wss://api.axol.io/api/v1/mempool/ethereum/stream"
headers = {"X-API-Key": "YOUR_KEY"}

async with websockets.connect(uri, extra_headers=headers) as ws:
await ws.send(json.dumps({
"action": "subscribe",
"filter": {"tx_types": ["swap"], "min_value_eth": 1.0}
}))

async for msg in ws:
print(json.loads(msg))

asyncio.run(monitor())

3. Find Liquidation Opportunities​

curl -H "X-API-Key: YOUR_KEY" \
"https://api.axol.io/api/v1/defi/ethereum/liquidations/opportunities?min_profit_usd=100"

Supported Chains​

Gas Oracle​

Ethereum, Polygon, Arbitrum, Optimism, Base, Avalanche

Mempool Monitoring​

Ethereum, Gnosis, Optimism, Arbitrum

DeFi Liquidations​

Ethereum, Optimism, Arbitrum, Polygon, Base, Gnosis

Gateway (Direct Node Access)​

Ethereum, Optimism, Base, Arbitrum

Key Concepts​

Multi-Provider Failover​

All Oracle endpoints use multiple RPC providers with automatic failover:

  1. Primary provider is tried first
  2. If it fails, backup providers are queried in parallel
  3. If all providers fail, cached data is served (marked stale: true)

This ensures your bot never goes blind, even during RPC outages.

Cache TTLs​

Data TypeCache TTLUpdate Frequency
Gas3sEvery 3 seconds
Lrt30sEvery 30 seconds
Beacon12sEvery 12 seconds
L1 Data Fee12sEvery 12 seconds
Prices60sEvery 60 seconds
Blocks3sEvery 3 seconds

Transaction Classification​

Mempool transactions are automatically classified:

TypeDescription
swapDEX trades (Uniswap, SushiSwap, etc.)
liquidationLending protocol liquidations
transferSimple token transfers
flashloanFlash loan operations
bridgeCross-chain bridge transactions
nftNFT trades and mints
otherUnclassified transactions

MEV Opportunity Detection​

Detected opportunities include:

TypeDescription
arbitragePrice discrepancy across DEXes
sandwichSandwich opportunity around large swaps
liquidationProfitable liquidation opportunity
backrunBackrun opportunity after large trade
frontrunFrontrun opportunity (detected for awareness)

Best Practices​

1. Use WebSocket for Real-Time Data​

For time-sensitive operations, always prefer WebSocket over polling:

# Good - WebSocket streaming
async with websockets.connect(uri) as ws:
async for msg in ws:
process(msg)

# Bad - Polling REST endpoint
while True:
response = requests.get(url)
process(response)
time.sleep(0.1) # Wastes time and rate limits

2. Handle Stale Data Gracefully​

When providers fail, you'll receive cached data marked as stale:

gas = response.json()
if gas['stale']:
# Data is cached, may be outdated
# Consider adding safety margin or skipping trade
gas_price = gas['fast']['max_fee_gwei'] * 1.2 # 20% buffer
else:
gas_price = gas['fast']['max_fee_gwei']

3. Filter Aggressively​

Reduce noise by filtering to only relevant transactions:

await ws.send(json.dumps({
"action": "subscribe",
"filter": {
"tx_types": ["swap"],
"min_value_eth": 10.0,
"dex_protocols": ["uniswap_v3"],
"include_mev": True
}
}))

4. Monitor Provider Health​

Check oracle health before critical operations:

health = requests.get(f"{BASE_URL}/oracle/health").json()
if health['overall_status'] != 'healthy':
# Consider fallback strategy
logger.warning(f"Oracle degraded: {health}")

Rate Limits​

MEV endpoints have higher rate limits to support trading applications:

TierOracle (req/min)Mempool WSDeFi (req/min)
Free3001 connection60
Pro30005 connections600
EnterpriseUnlimited20 connectionsUnlimited

Oracle endpoints (/oracle/*) do not require authentication and have generous limits.


Next Steps​