This repository showcases the migration of Uniswap V2 to the =nil; We have adapted Uniswap’s core contracts — Factory, Pair, and Router — to work seamlessly with the unique capabilities of =nil; By using this example, developers can learn how to migrate dApps from Ethereum compatible networks to the =nil; and take advantage of its features, such as:
- Multi-Currency Support: Learn how =nil; supports multiple currencies natively and how they replace the ERC20 standard
- Async/Sync Calls: Discover how to effectively utilize async and sync messaging between shards, making the protocol both scalable and performant
- Load Distribution: Understand how to distribute operations across multiple shards, enhancing parallel processing and scalability
This repository also aims to spark discussion on the potential of running DeFi protocols on sharded architectures, demonstrating their feasibility and advantages
Before working with this repository, ensure that you have properly set up your environment:
-
.env Configuration:
Make sure to create a.env
file in the root directory. All required environment variables are listed in the.env.example
file, which you can use as a reference. Link to.env.example
-
Getting an RPC Endpoint:
To request an RPC endpoint:- Join our Telegram chat: https://t.me/nilfoundation
- Request access, and our DevRel team will assist you.
-
Obtaining a Private Key and Wallet:
- Download the
nil
CLI: https://github.com/NilFoundation/nil_cli - Follow the setup instructions in our documentation: nil CLI Docs
- Download the
To help you get started quickly, we provide two demo tasks that showcase the full lifecycle from deployment to execution. These tasks cover deploying and initializing all necessary contracts, as well as performing operations like minting, swapping, and burning
-
Using Factory and Pair Contracts Only
This demo handles deploying the Factory and Pair contracts and executing a complete flow of operations
View the demo task -
Using Factory, Pair, and Router Contracts
This demo includes an additional layer by utilizing the Router contract along with Factory and Pair View the demo-router task
- Compile the Project:
npx hardhat compile
- Run the Demo Tasks:
- For the core demo (Factory and Pair):
npx hardhat demo --network nil
- For the demo with Router (Factory, Pair, and Router):
npx hardhat demo-router --network nil
- For the core demo (Factory and Pair):
If you prefer to run everything manually, we provide Ignition modules for each contract: Ignition Modules
Additionally, all crucial contract methods have corresponding tasks: Tasks
Each subdirectory contains a README explaining the details of the tasks
We welcome contributions from the community to make this project even better! If you have suggestions, improvements, or find any bugs, please feel free to submit a pull request or open an issue.
Check out our open issues and improvements in the GitHub Issues section. If you're new to the project, look for issues labeled as good first issue
— they're a great place to start.
Your input and contributions are greatly appreciated!
This project is licensed under the GPL-3.0 License. See the LICENSE file for more details. Portions of this project are derived from Uniswap V2 and are also subject to the GPL-3.0 License.