π System Interaction
Understanding how UtopiaSwap operates behind the scenes is key to appreciating its efficiency and flexibility. This page breaks down the interaction between users, smart contracts, and third-party protocols across multiple chains.
π§βπ» User Interaction Flowβ
-
User connects wallet
- Supports EVM-compatible wallets (e.g., MetaMask, WalletConnect).
- Automatically detects selected network (ETH, BNB, POLY, etc.).
-
Token Pair & Chain Selection
- User selects input and output tokens.
- UtopiaSwap dynamically fetches available routes on the selected chain.
-
Quote Aggregation
- UtopiaSwap queries rates from multiple DEXs (e.g., Uniswap, Balancer).
- The Best Rate Tunnel selects the optimal path based on price, liquidity depth, and gas efficiency.
-
Transaction Preview
- User is shown expected output, slippage, and gas estimates.
- All routing is abstracted β even multi-hop swaps are shown as a single action.
-
Transaction Signing & Execution
- User signs the transaction via their wallet.
- Smart contract executes the trade using the selected route.
-
Settlement
- Tokens are received directly in the user's wallet.
- UtopiaSwap does not custody assets at any point.
π§ Behind the Scenesβ
π Chain Adaptersβ
- Each supported blockchain (ETH, POLY, BNB, BASE, OP, CELO) has its own adapter layer.
- Adapters standardize interaction between the frontend and contract layer, abstracting differences in token standards and gas models.
π Best Rate Tunnelβ
- Central routing engine that:
- Queries on-chain DEXs for current swap rates.
- Compares slippage-adjusted output across protocols.
- Chooses the most cost-effective route.
- Extensible to support new DEXs and chains.
π§© Smart Contractsβ
- Modular contracts for:
- Swapping
- Routing logic
- Token validation
- Gas-optimized and auditable
π System Architecture (Simplified)β
[User Wallet]
β
[Utopia Frontend]
β
[Chain Adapter + Best Rate Tunnel]
β
[Smart Contracts]
β
[DEXes / Liquidity Sources]
β Key Guaranteesβ
- Non-custodial: UtopiaSwap never holds user funds.
- Optimized Routing: Always attempts best price including gas.
- Cross-chain scalability: New networks can be added with minimal change.
Want a deeper dive? Head to Architecture next for a more technical breakdown.