Post
Share your knowledge.
How can I implement a Dex Aggerator
How can I implement a DEX aggregator on Sui that dynamically routes token swaps across multiple DEXs (e.g., Cetus, Turbos, Bluefin) to achieve optimal pricing? Specifically, how should I design the routing logic, integrate with different pool types (constant product, stable, or concentrated liquidity), and handle on-chain execution, slippage protection, and gas efficiency within Sui Move?
- Sui
- Architecture
- Move
Answers
2It’s challenging to find a reference because the logic behind it is what makes the aggregator stand out by offering the best routing for swaps.
But you can approach the concept (how they do) first then optimize aggerator later
Routing Logic
- Scan DEXs: Collect liquidity data (reserves) for token pairs from different DEXs.
- Compare Prices: Check the prices for the same token pair across DEXs.
- Select Best Route: Choose the DEX offering the best price (lowest slippage).
Atomic Transaction: Thanks to PTB (Programable Transaction Block) we could do this easily
Gas Efficiency: Minimize the number of actions to reduce gas cost
Slippage Protection
- User Input: Let users set a slippage tolerance
- Check Before Execution: Ensure the final price doesn’t exceed the user’s slippage tolerance before confirming the transaction.
User Flow Example
- User wants to swap Token SUI for Token USDC.
- Aggregator checks prices: Looks at Cetus, Turbos, Bluefin for Token A → Token B price.
- Best route is selected: Chooses the DEX offering the best rate.
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.

- ... SUIacher+1666
- ... SUIjakodelarin+1060
- ... SUITucker+1045
- ... SUIChubbycheeks +1041
- ... SUIOpiiii+789
- ... SUItolexwills47+783
- ... SUImarcus+718
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking413
- Sui Transaction Failing: Objects Reserved for Another Transaction49
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction315