Uviswap is a decentralized automated market maker (AMM) that allows users to swap tokens and provide liquidity to earn fees. This repository contains the smart contracts for the Uviswap Pair and Factory, along with testing scripts and deployment instructions.
This repository comes with a full guide on how to implement it from scratch, you can find it here. Create your own Uniswap DeFi Application🦄! From scratch using Vyper & Python🐍
Uviswap is built on the principles of automated market makers, providing a decentralized solution for token swaps and liquidity provision. It utilizes a pair-based model where users can add liquidity to pairs of tokens, and swaps are executed based on the liquidity available in the pairs.
The UviswapPair
smart contract represents an individual token pair. It includes functions for adding liquidity, removing liquidity, swapping tokens, and collecting fees.
- UviswapPair.sol: The source code for the
UviswapPair
smart contract.
The UviswapFactory
smart contract is responsible for creating and managing pairs of tokens. It includes a method for creating new pairs and deploying instances of the UviswapPair
contract.
- UviswapFactory.sol: The source code for the
UviswapFactory
smart contract.
The testing scripts are provided in the tests
folder, specifically in the test_uviswap.py file. These tests cover various functionalities, including adding and removing liquidity, swapping tokens, and collecting fees.
To run the tests locally, use the following command:
$ ape test
Make sure to configure the testing fixtures and accounts in conftest.py based on your requirements.
To deploy the Uviswap application, follow these steps:
-
Install the Base plugin:
$ ape plugins install base
-
Configure the RPC URL endpoints in
ape-config.yaml
for the desired network (mainnet or testnet). -
Create accounts for deployment:
$ ape accounts generate <name_of_your_account>
Make sure to replace <name_of_your_account>
in the instructions with the actual name you used for the deployment account. Additionally, customize the content based on any specific details or features of your Uviswap application.
-
Customize the deployment script in deploy.py if needed.
-
Run the deployment script:
$ ape run deploy --network base:sepolia # For Base Testnet
$ ape run deploy --network base:mainnet # For Base Mainnet
Contributions are welcome! If you have any improvements, bug fixes, or additional features to add, please open an issue or submit a pull request.
This project is licensed under the MIT License