Skip to content

fobabs/lofiswap

Repository files navigation

LofiSwap

LofiSwap is a simple decentralized exchange inspired by Uniswap v1.
It focuses on simplicity and core automated market maker (AMM) mechanics.

Features

  • Liquidity pools for token trading
  • Constant product market maker (x * y = k)
  • Basic swap functionality
  • Liquidity provisioning and removal
  • Minimalistic and gas-efficient

Project Structure

.
├── 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

Tech Stack

  • Solidity for smart contracts
  • Foundry for development, testing, and deployment

Getting Started

Prerequisites

  • 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

Installation

Clone the repository:

git clone https://github.com/fobabs/lofiswap.git
cd lofiswap

Install dependencies:

forge install

Building Contracts

forge build

Running Tests

forge test

Gas Reporting

Generate gas snapshots:

forge snapshot

Check the generated gas-report.txt and gas-snapshot for detailed gas usage.

Deployment

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.

Local Development

Run a local Ethereum node:

anvil

Interact with contracts using:

cast <subcommand>

Contributing

Contributions are welcome.
Please fork the repository, create a new branch, and submit a pull request.

License

This project is open-source and available under the MIT License.

Acknowledgments

About

A simple DEX mimicking Uniswap v1

Resources

Stars

Watchers

Forks

Releases

No releases published