A Uniswap V1 clone for decentralized ERC20 token exchange via automated market maker on Ethereum. React frontend links to smart contracts on the local Ethereum blockchain to allow for providing/removing liquidity and swapping ETH
/tokens via browser wallet.
This project was completed to gain an understanding in writing/testing/deploying smart contracts, and interacting with them from a DApp. The frontend is not intended to be fully functional but rather to provide minimal functionality to allow for usage of the smart contracts.
-
Clone the project:
git clone hhttps://github.com/nefrob/sandman-swap && cd sandman-swap
-
Install smart contract dependencies:
npm install
-
Run blockchain: (initializes two accounts with
5000 ETH
each):npm run ganache
It is convienent to run the local blockchain deterministically for testing. To do so use:
npm run ganache-det
-
With
ganache
running, you can compile and deploy the contracts with:npm run migrate
-
Setup and run the React Dapp from the
client
directory:cd client npm install npm start
-
Note: MetaMask
ganache
account will need to be reset every timeganache
is restarted to clear the old test transaction history.
Unit tests are currently written for the smart contracts in this project (not the frontend components).
To run the tests from the project root directory do: npm test
.
Home pageSwap pageLiquidity pool pageWallet page with currennt ETH balance and a button to connect to a wallet
ETH/token exchange prices in USD (use API)Integration with MetaMaskAdd new token to wallet functionality- Integration with Ethereum testnet
- Setup frontend on CodeSandBox
-
/home
: -
/wallet
:(Uniswap V1 page for reference)
Component | Description |
---|---|
App | Page routing, user state setup |
Home | Landing page with project info |
Navigation | Page routing, display header |
Swap | Swapping eth/tokens for active pools |
LP | Add/remove liquidity |
Wallet | Setup MetaMask connection, display current holdings, add tokens to MetaMask |
This project is themed around Dream of the Endless (aka Sandman) for fun!
web3.js
for interaction with ethereum nodes.truffle
for testing and deployment of contracts.ganache
for local Ethereum blockchain testing.@openzeppelin/contracts
for ERC standards and smart contract libraries.react-boostrap
for styling.
MetaMask is a browser extension that allows you to interact with the Ethereum blockchain on decentralized applications. See MetaMask Docs for more information.
To make swap prices easier to understand, the current ETH
value in USD
will be fetched from CEX Rest API.
Example request: https://cex.io/api/last_price/ETH/USD
returns:
{
"lprice": "3400.36",
"curr1": "ETH",
"curr2": "USD"
}
- Post issues in the Issue Tracker.