FlyDex is a decentralized token exchange built with Solidity and Foundry. It allows users to swap tokens, add/remove liquidity, and collect protocol fees, integrating directly with Uniswap V2 on Arbitrum. It includes production-ready patterns like reentrancy protection, fee tracking, slippage, clean architecture, and comprehensive test coverage.
- π Swap ERC20 tokens
- π Swap ETH for ERC20 tokens
- β Add liquidity to ERC20-ERC20 pools
- β Add liquidity to ETH-ERC20 pools
- β Remove liquidity from ERC20-ERC20 pools
- β Remove liquidity from ETH-ERC20 pools
- π° Customizable fee mechanism (set by owner)
- π Only owner can withdraw accumulated fees
- π‘οΈ Reentrancy protection on sensitive functions
- π’ Event emission for all features
- π§ͺ Complete unit tests and fuzzing with Foundry
- π Forked mainnet testing (Arbitrum One)
- Reentrancy protection using OpenZeppelin's
ReentrancyGuardon sensitive functions likewithdrawFees. - Use of
SafeERC20for all token transfers to handle non-standard ERC20 tokens. - Owner-only functions protected with
Ownable. - Event logging for transparency and easier off-chain tracking.
- Fes tracked per-token to avoid mixing funds.
- Fee percentage capped at 5% to prevent excessive charges.
- ETH tracked separately via
address(0)in fee mappings.
All core functionalities are tested using Foundry:
- β
swapTokens() - β
swapETHForTokens() - β
addLiquidityTokens() - β
addLiquidityETH() - β
removeLiquidity() - β
removeLiquidityETH() - β
changeFee() - β
withdrawFees() - β Fuzzing tests for swap paths and amounts
- β Invariant test for fee consistency
- β Revert tests for negative scenarios
Run tests with:
forge test --fork-url https://arb1.arbitrum.io/rpc --match-test test_swapTokens- Solidity (
^0.8.24) - Foundry β Smart contract development & testing framework
- Uniswap V2 β Token swap & liquidity router
- OpenZeppelin Contracts β
Ownable,ReentrancyGuard,SafeERC20 - Arbitrum One β Mainnet fork for realistic tests
This project is licensed under the MIT License.