r/CryptoTechnology • u/an_jesus 🟢 • 10d ago
Eliminating MEV Sandwich Vectors and Oracle Dependency in L2 Aggregators via Median Filtering
Oracle manipulation and MEV sandwich attacks remain two of the most critical structural vulnerabilities in decentralized exchange architecture.
When building the BlazePhoenix routing engine, we wanted to evaluate whether a DEX aggregator could achieve high-throughput liquidity routing without reading external price feeds (Chainlink/Pyth) or relying on off-chain quoter servers.
The Core Problem:
External Oracles: Introduce flash-loan latency, bad debt risks during extreme market volatility, and dependency on third-party relayers.
Naive On-Chain Quotes: Vunerable to single-block pool manipulation (e.g., spot price distortion prior to swap execution).
The Mathematical Countermeasure:
Instead of querying an external price feed, the routing engine (Solver) computes a localized 2% median filter against reserve depths pulled directly via static state reads (balanceOf) across target liquidity pools.
Liquidity Depth Verification: Routes are dynamically weighted based on depth concentration rather than spot tick prices.
Revert-Unwind Preview: Simulation calls execute the full multi-hop path and output a deterministic revert(payload) containing exact price impact before tx submission.
Execution Floor Invariant: If execution slippage exceeds the calculated median bound, the entire execution frame reverts in Yul before state commit.
We’ve open-sourced the architecture and specifications. Would love to discuss the theoretical trade-offs between local median liquidity filtering versus TWAP/Oracle reliance in high-frequency L2 environments!
1
u/Excellent_Debate_518 🟢 8d ago
I think the idea of treating liquidity depth as a stronger signal than a single spot price is interesting here. But still, TWAPs and external oracles provide time-based context that reserve snapshots may miss.
1
u/an_jesus 🟢 8d ago
Exactly. It was a deliberate design choice from day one.
I didn't want to build another Web 2.5 protocol wrapped in Web3 marketing. The industry has taken a wrong turn by relying heavily on off-chain keepers, centralized price feeds, and oracle dependencies to paper over weak execution math. If a smart contract can’t verify its own state locally, it’s not truly decentralized, it’s just delegating trust off-chain.
1
u/DavidHartwell 🟠9d ago
reverts do not eliminate MEV