HannesExchange is a smart contract implementation of a decentralized exchange based on the constant product automated market maker model. It includes two versions: HannesExchangeV1
and HannesExchangeV2
:
HannesExchangeV1
: UsesETH
as the base currency, supporting only directETH ↔ ERC20
swapsHannesExchangeV2
: Supports anyERC20
token pair, removing theETH
base currency restriction
- Advanced role-based access control
- Emergency circuit breaker mechanism
- Comprehensive reentrancy protection
- Gas-optimized operations
- UUPS upgradeable design pattern
- Complete test coverage
- Solidity
- Foundry Framework
- OpenZeppelin Contracts
- Ethereum Sepolia Testnet
- Solidity
- Rust and Cargo
- Foundry Toolchain
- Git
curl -L https://foundry.paradigm.xyz | bash
foundryup
git clone https://github.com/hannesgao/HannesExchange.git
cd HannesExchange
forge install
cp .env.example .env
# Edit .env with your configuration
forge test -vvvvv
forge script script/DeployHannesExchangeV1Factory.s.sol \
--rpc-url sepolia \
--broadcast \
--verify
forge script script/DeployHannesExchangeV1Pair.s.sol \
--rpc-url sepolia \
--broadcast \
--verify
forge script script/DeployHannesExchangeV2.s.sol:DeployHannesExchangeV2 \
--rpc-url sepolia \
--broadcast \
--verify
forge script script/DeployHannesExchangeV2.s.sol:CreatePairV2 \
--rpc-url sepolia \
--broadcast \
--verify
- Role-based access control
- Emergency pause functionality
- Reentrancy protection
- Safe transfer implementations
- Overflow/underflow protection
- DoS attack prevention
- Comprehensive security checks
MIT License