Skip to content

Just-Code-Builder/Alpharouting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Base Monad Solidity Rust Foundry License


Multi-chain MEV execution contract — flashloan arbitrage, liquidations, and flash-swap strategies. Deployed on Base and Monad mainnet.


X Follow Contact


⚡ What is AlphaRouting?

AlphaRouting is a production MEV bot running on Base mainnet and Monad mainnet.

It executes flashloan-funded arbitrage and liquidations atomically — the entire flashloan, swap sequence, and repayment happen in one transaction. You either profit or the whole transaction reverts. No principal at risk, ever.

This repository is a public interface snippet of the on-chain contract. The full execution engine — Rust, 16 crates, ~8 000 lines — is private.

💬 Want the full source? DM @web4coder on X or email [email protected]


🌐 Supported Chains

Chain Status Flashloan Source Notes
🟢 Live Aave V3 + Balancer V2 + Uni V3 Full strategy suite — all 7 strategies active
🟢 Live Uni V3 flash-swap only Aave V3 and Balancer V2 not deployed on Monad — FlashSwap arb only

Same contract bytecode deploys to both chains. Router addresses are constructor-injected — address(0) for any protocol not deployed on that chain gracefully disables those strategy paths.


🎯 Strategies

# Strategy ⛽ Flashloan Source 📋 Description
1 Triangular Arb Aave V3 A→B→C→A across 2–3 DEXes in one atomic tx
2 🔄 Flash-Swap Arb Uniswap V3 Pool Borrows directly from a V3 pool; pays pool fee instead of Aave's 9 bps
3 🏦 Balancer Arb Balancer V2 Vault Same A→B→C→A hop structure; 0-fee borrow from Balancer
4 🎯 Liquidation Aave V3 Atomically seize an under-collateralised position + sell collateral
5 💥 Liquidation Combo Aave V3 Liquidation + immediate cross-DEX arb on the price gap it opens
6 📦 Batch Liquidation Aave V3 Multiple borrowers in a single flashloan — one tx, N liquidations
7 🔁 Rebase Arb Aave V3 Fires at scheduled rebase windows for rebasing tokens

All strategies share a minProfit revert guard — if the trade doesn't clear the configured profit floor, the entire transaction reverts. Gas is the only cost you can ever incur.


🏗️ Architecture

                        ┌─────────────────────────────────┐
                        │        AlphaRouting.sol          │
                        │   Ownable  ·  ReentrancyGuard   │
                        └──────────────┬──────────────────┘
                                       │
             ┌─────────────────────────┼──────────────────────┐
             │                         │                      │
    ┌────────▼────────┐    ┌──────────▼──────────┐  ┌───────▼────────┐
    │   Aave V3 Path  │    │  Uniswap V3 Path     │  │  Balancer Path │
    │  flashLoanSimple│    │  pool.flash()        │  │  vault.flashL  │
    └────────┬────────┘    └──────────┬──────────┘  └───────┬────────┘
             │                        │                      │
    ┌────────▼────────┐    ┌──────────▼──────────┐  ┌───────▼────────┐
    │executeOperation │    │uniswapV3FlashCallback│  │receiveFlashLoan│
    │  (Aave cb)      │    │   (Uni V3 cb)        │  │ (Balancer cb)  │
    └────────┬────────┘    └──────────┬──────────┘  └───────┬────────┘
             │                        │                      │
             └─────────────────────────┴──────────────────────┘
                                       │
                              ┌────────▼────────┐
                              │   _swap()        │
                              │  DEX dispatcher  │
                              └────────┬────────┘
                                       │
        ┌──────────┬──────────┬────────┴──────────┬──────────┐
        ▼          ▼          ▼                    ▼          ▼
   Uniswap V3  SushiSwap  BaseSwap V3        PancakeSwap  Aerodrome

🔐 Security Properties

Property Implementation
🔒 Re-entrancy proof EIP-1153 transient-storage locks — impossible to re-enter even within the same tx
🛡️ Callback auth Strategy slots in transient storage — callbacks authenticated from trusted state, never caller-supplied data
📊 Delta-based profit Pre-flashloan inventory snapshot — losing trades that consume balance fail loudly, never silently
👑 Owner-only execution All entry points gated by onlyOwner — only the deployer wallet can trigger trades
🔄 Health-factor guard Double-checked inside the Aave callback — prevents wasted gas on already-liquidated positions

🔌 DEX Support

DEX Protocol Base Monad
🦄 Uniswap V3 Concentrated liquidity
🍣 SushiSwap V3 Concentrated liquidity
🔵 BaseSwap V3 Base-native fork
🥞 PancakeSwap V3 Concentrated liquidity
🌊 Aerodrome Stable + volatile AMM

📄 Contract Interface (Snippet)

// Entry points — owner only
function executeArbitrage(address borrowToken, uint256 borrowAmount, bytes calldata params) external;
function executeFlashSwapArb(address pool, address tokenBorrow, uint256 amount, bytes calldata params) external;
function executeBalancerArb(address borrowToken, uint256 borrowAmount, bytes calldata params) external;
function executeLiquidation(address collateral, address debt, address borrower, uint256 amount, bytes calldata params) external;
function executeLiquidationCombo(address collateral, address debt, address borrower, uint256 amount, bytes calldata params) external;
function executeBatchLiquidations(BatchLiqParams calldata p) external;
function executeRebaseArb(address borrowToken, uint256 borrowAmount, bytes calldata params) external;

// Flashloan callbacks — authenticated via transient storage
function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata params) external returns (bool);
function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external;
function receiveFlashLoan(address[] calldata tokens, uint256[] calldata amounts, uint256[] calldata feeAmounts, bytes calldata userData) external;

Full implementation bodies are private. Request access →


🦀 Rust Snippets

Selected modules from the off-chain execution engine are shared here for public inspection. These cover infrastructure concerns — no strategy logic is included.

File What it shows
crates/api/src/lib.rs Axum HTTP server — /health, /stats, /routes, /trades, /metrics endpoints + URL sanitisation (strips embedded API keys from RPC URLs before serving)
crates/chain/src/nonce.rs Lock-free nonce manager — AtomicU64 counter + BTreeSet release pool that prevents wallet-wedge when broadcasts abort mid-flight. 10 unit tests
crates/workers/src/priority_queue.rs Bounded priority queue — BinaryHeap with FIFO tie-breaking via monotonic sequence counter. Hard capacity with try_push backpressure
crates/observability/src/lib.rs Execution event model — ring-buffer backed replay store tracking every opportunity from detection → simulation → broadcast → receipt

The full execution engine (scanners, executor, route discovery, prediction, mempool, scoring — 16 crates total) is private. DM @web4coder for access.


🛠️ Tech Stack

Rust Solidity Foundry SQLite Telegram Docker

Layer Details
On-chain Solidity 0.8.26 · Foundry · OpenZeppelin 5 · EIP-1153 transient storage
Off-chain bot Rust (async/tokio) · 16 crates · ~8 000 lines
Persistence SQLite — trades, borrowers, routes, RPC keys
Infra Railway / VPS · Flashbots Protect / MEV Blocker private RPC
Alerts & UI Telegram inline-keyboard — /trades, /diag, /rpc, daily digest

🗺️ Roadmap

Phase Status Chain What
1 🟢 Live Base Aave V3 liquidations + triangular arb + flashswap + Balancer
2 🟢 Live Monad FlashSwap arb via Uni V3 pool.flash() — Aave V3 and Balancer V2 not on Monad
3 🟡 Planned Ethereum Same contract re-deployed; Aave V3 ETH addresses
4 🟡 Planned BNB Chain Venus protocol + PancakeSwap V3
5 🔵 Research Solana Rust SDK rewrite — Solend + Raydium/Orca/Meteora
6 🔵 Design All chains $AR token — revenue-share bridge token, holders earn % of bot profits

📬 Get the Full Source

This repo shows the contract interface only — structs, events, errors, and function signatures.

Implementation bodies + the full Rust execution engine are private.


Contact Link
🐦 X (Twitter) @web4coder
📧 Email [email protected]

Built atomic. Running live. Profits only.


About

MEV routing infrastructure — profitable arbitrage & liquidation routing with Flash loans. Telegram bot. Multi-chain. FCFS whale/token ownership model. Sybil-resistant.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors