LiteDEX is a simple Automated Market Maker (AMM) Decentralized Exchange built with Solidity and Next.js. It implements the constant product formula (
/contracts: Smart contracts (DEX, Factory, Mock Tokens)./frontend: Next.js web application./scripts: Hardhat deployment scripts./test: Automated test suite for smart contracts.
- SimpleDEX.sol: The core AMM contract handling swaps (0.3% fee) and liquidity provision.
- DEXFactory.sol: Factory contract to deploy and track multiple trading pairs.
- MockERC20.sol: Sample tokens for testing.
npm installnpx hardhat compilenpx hardhat testFirst, start a local Hardhat node:
npx hardhat nodeThen deploy the contracts:
npx hardhat run scripts/deploy.js --network localhost- ReentrancyGuard: Protects against recursive call attacks.
- Price Oracle (TWAP): Industry-standard time-weighted average price tracking.
- K-Invariant Check: Ensures pool mathematical stability after every swap.
