UniOrder
On-Chain Fast Limit Orders, Auto-Smart, Gas-Savvy
Created on 9th May 2025
•
UniOrder
On-Chain Fast Limit Orders, Auto-Smart, Gas-Savvy
The problem UniOrder solves
Off-Chain Limit Orders: Delays and Costly Log Access: Off-chain bots (e.g., UniswapX, Gelato) for limit orders face delays due to slow mempool/log access, missing trades in volatile markets. Building custom RPC nodes to fetch logs faster costs thousands monthly, making it unscalable.
-> Unreliable executions frustrate users, limiting DeFi’s appeal for advanced trading.
Off-Chain Copy Trading: Delayed and Centralized: Copy trading in DeFi is off-chain, suffering from mempool/log access delays and centralization risks (e.g., bot failures, lack of transparency). No on-chain alternative exists, leaving users stuck with CEXs.
-> Blocks retail adoption and social trading, stunting DeFi’s growth.
Inefficient Off-Chain Dynamic Fee Optimization: Off-chain fee adjustments are slow, gas-heavy, or rely on costly RPC setups for real-time data, failing to optimize fees for LPs and traders.
-> Reduces LP profits and raises trading costs, making DeFi less competitive than CEXs.
Challenges I ran into
Complex Integration of On-Chain Limit Orders with Uniswap V4 Hooks
Implementing limit orders directly in Uniswap V4 pools using hooks (e.g., beforeSwap) was challenging due to the novelty of V4’s architecture. Ensuring real-time price checks via Chainlink oracles and managing order storage on-chain risked high gas costs and potential execution failures under network congestion.
-> Initial prototypes showed latency and gas inefficiencies, threatening the goal of instant, cost-effective trades.
Solution: The team optimized the hook contract by batching limit orders (limiting to maxBatchSize) and using gas-efficient data structures (e.g., packed structs). Rigorous testing on testnets like Sepolia and collaboration with Chainlink ensured reliable oracle integration.
-> Overcame by delivering a hook that executes limit orders instantly with minimal gas, rivaling CEX speed.
Building Real-Time On-Chain Copy Trading Without Mempool Dependency
Developing on-chain copy trading to replicate lead traders’ swaps in real-time was difficult, as Uniswap V4 hooks needed to track transactions without relying on mempool/log access (unlike off-chain bots). Ensuring fairness (e.g., preventing frontrunning) and distributing profits to lead traders added complexity.
-> Early designs risked delays or vulnerabilities, undermining the trustless social trading vision.
Our team designed a beforeSwap hook to detect lead trader swaps and execute follower trades in the same transaction, using on-chain events for transparency. A fee-sharing mechanism was coded into the hook to reward lead traders. Extensive audits by a firm like OpenZeppelin mitigated security risks.
-> Delivered a secure, real-time copy trading system, boosting community engagement.
Tracks Applied (1)
DeFi
Technologies used
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
