Skip to content

FlyDex is a decentralized exchange built with Solidity & Foundry. It allows to swaps tokens, add/remove liquidity and manage fee handling via Uniswap V2 Router on Arbitrum. With a complete testing suite.

Notifications You must be signed in to change notification settings

monipigr/fly-dex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ¦‹ FlyDex

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.


✨ Features

  • πŸ” 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)

πŸ” Security Measures

  • Reentrancy protection using OpenZeppelin's ReentrancyGuard on sensitive functions like withdrawFees.
  • Use of SafeERC20 for 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.

πŸ§ͺ Tests

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

🧠 Technologies Used

  • 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

πŸ“œ License

This project is licensed under the MIT License.

About

FlyDex is a decentralized exchange built with Solidity & Foundry. It allows to swaps tokens, add/remove liquidity and manage fee handling via Uniswap V2 Router on Arbitrum. With a complete testing suite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published