LofiSwap is a simple decentralized exchange inspired by Uniswap v1.
It focuses on simplicity and core automated market maker (AMM) mechanics.
- Liquidity pools for token trading
- Constant product market maker (x * y = k)
- Basic swap functionality
- Liquidity provisioning and removal
- Minimalistic and gas-efficient
.
├── lib/ # External libraries
├── script/ # Deployment scripts
├── src/ # Smart contracts
├── test/ # Unit tests
├── foundry.toml # Foundry configuration
├── gas-report.txt # Gas usage snapshot
└── package.json # Package management
- Solidity for smart contracts
- Foundry for development, testing, and deployment
-
Foundry installed
Install Foundry with:curl -L https://foundry.paradigm.xyz | bash foundryup
-
RPC Provider URL (e.g., from Alchemy or Infura)
-
Private key for deploying contracts
Clone the repository:
git clone https://github.com/fobabs/lofiswap.git
cd lofiswap
Install dependencies:
forge install
forge build
forge test
Generate gas snapshots:
forge snapshot
Check the generated gas-report.txt
and gas-snapshot
for detailed gas usage.
Deploy contracts using a script:
forge script script/Deploy.s.sol:DeployScript --rpc-url <YOUR_RPC_URL> --private-key <YOUR_PRIVATE_KEY>
Replace <YOUR_RPC_URL>
and <YOUR_PRIVATE_KEY>
with your actual values.
Run a local Ethereum node:
anvil
Interact with contracts using:
cast <subcommand>
Contributions are welcome.
Please fork the repository, create a new branch, and submit a pull request.
This project is open-source and available under the MIT License.
- Inspired by Uniswap V1
- Built using Foundry