Le-AMM Secure Batch-Based DEX with Enclave-Backed Sequencing
LeAMM addresses a critical vulnerability in decentralized finance: the extraction of Maximal Extractable Value (MEV) from users through front-running and sandwich attacks. Traditional AMMs expose transaction data in the public mempool, allowing malicious actors to manipulate transaction ordering for profit. This not only results in financial losses for users but also contributes to inefficiencies such as high gas fees and degraded trust in decentralized systems.
To solve these challenges, LeAMM introduces a privacy-preserving, batch-based architecture that leverages Trusted Execution Environment (TEE) technology. The system securely collects encrypted swap intents off-chain, sequences them confidentially within a Nitro Enclave, and executes them on-chain in batches. Through the use of enclave attestation, users gain verifiable proof that transactions are sequenced fairly, without exposure to the sequencer operator or external parties.
The AMM smart contract, developed with Solidity and OpenZeppelin libraries, implements a constant product formula (x*y=k) with customizable pool fees and robust vault accounting. Key user-facing features include deposit and withdrawal of ETH and ERC-20 tokens, liquidity provision and removal, and batch execution of swaps. The system incorporates ETH/WETH handling for seamless native asset operations and includes a transparent fee structure with both protocol and per-pool fees.
The front-end, built with React and ethers.js, provides an intuitive interface that allows users to initiate swaps, manage liquidity, and track transaction status in real time. Wallet integration is handled via MetaMask and WalletConnect, and the application features real-time pricing data along with automated token approval workflows to minimize gas costs.
A critical component of the architecture is the enclave-backed sequencer. It ensures that swap intents remain confidential throughout the sequencing process and uses secure key derivation and signature verification to maintain integrity. The sequencer host facilitates communication between users and the enclave, batches transaction requests, and submits them to the blockchain once verified.
This project required addressing several technical challenges, including optimizing cryptographic performance within the TEE's limited resources, securely linking off-chain components to the on-chain smart contract, and designing a system that balances batch size with execution efficiency. Through rigorous testing and iterative design, the team delivered a robust solution that meets stringent security and usability standards.
LeAMM demonstrates significant improvements in privacy, cost efficiency, and MEV mitigation for decentralized exchanges. By eliminating public mempool exposure of swap intents and reducing gas fees through batch execution, the system provides a more secure and cost-effective trading experience. The project also emphasizes trust and transparency by enabling users to independently verify the enclave's execution integrity through attestation.
Looking ahead, future development will focus on expanding functionality to include multi-token pools, stable swap curves, improved wallet integration, and fallback relay networks to enhance reliability. Deployment on Layer 2 solutions such as Optimism and Arbitrum is planned to further improve scalability and reduce costs, alongside the introduction of governance mechanisms for decentralized sequencer management.