SuiSwap is a decentralized exchange (DEX) built using the Sui Move programming language. It enables users to swap tokens and provide liquidity in a fully on-chain, permissionless, and composable environment.
- Automated Market Maker (AMM) model based on Uniswap v2 (constant product formula x * y = k)
- Support for creating and managing custom liquidity pools
- Liquidity provision and withdrawal with LP token minting
- Token swaps with slippage and fee support
- Event emissions for front-end tracking
- Fully object-oriented design aligned with Sui’s architecture
LiquidityPool.move— Defines and manages each token pair pool and its reserves.Swap.move— Executes swaps using the AMM formula with fee logic.Math.move— Utility module for computing prices, ratios, and LP shares.Events.move— Emits structured events (e.g., AddLiquidity, Swap, RemoveLiquidity).
Each LiquidityPool is stored as a separate on-chain Sui object, giving full composability and traceability.
Prerequisites
Node.js & Git (for front-end dApp integration )
Build & Test
# Clone the repo
git clone https://github.com/libaice/sui_dex.git
cd sui_dex
# Build the modules
sui move build
# Run unit tests
sui move testDeploy to Devnet
You can publish to Sui Devnet using:
sui client publish --gas-budget 50000000Make sure to set up your wallet and request some test SUI tokens via the Sui Faucet.
-
create_pool(token_x, token_y)
→ Initializes a new trading pair
-
add_liquidity(amount_x, amount_y)
→ Adds reserves and mints LP tokens to the user
-
swap_exact_x_for_y(dx)
→ Swaps input token X for token Y using the pool
-
remove_liquidity(lp_amount)
→ Burns LP tokens and returns reserves
-
Unit tests cover:
- Initial pool creation
- LP token issuance and redemption
- Swap correctness under slippage and rounding
-
Future plans: Fuzz testing for pool invariants (e.g., k constant check)
Contributions are welcome! Please open an issue or pull request for suggestions, bug fixes, or improvements.
MIT License.
Copyright © 2025.