Sui.

Post

Share your knowledge.

obito.
Jul 13, 2025
Expert Q&A

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
2
2
Share
Comments
.

Answers

2
Ashford.
Jul 21 2025, 15:21

It’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

  1. Scan DEXs: Collect liquidity data (reserves) for token pairs from different DEXs.
  2. Compare Prices: Check the prices for the same token pair across DEXs.
  3. 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

  1. User wants to swap Token SUI for Token USDC.
  2. Aggregator checks prices: Looks at Cetus, Turbos, Bluefin for Token A → Token B price.
  3. Best route is selected: Chooses the DEX offering the best rate.
5
Best Answer
Comments
.

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.

1170Posts3608Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignAugust