Demo 2: Testing Uniswap V2 against Theta Local Privatenet

This guide demonstrates how to test the V2 Uniswap protocol against the Theta Local Privatenet.

The V2 Uniswap protocol is separated across two repositories: uniswap-v2-core, and uniswap-v2-periphery. We have forked these two repositories:

uniswap-v2-core: https://github.com/thetatoken/uniswap-v2-core
uniswap-v2-periphery: https://github.com/thetatoken/uniswap-v2-periphery

We made some minor modifications to adapt the test cases to the Theta Blockchain. The changes (here and here) are mostly simple parameter tunings. No changes were made to the smart contracts.

Test the uniswap-v2-core contracts

Before running the uniswap-v2-core tests, we need to setup the Theta local privatenet with the Theta/Ethereum RPC Adaptor following this guide.

Assuming the work directory is $WORK_DIR, please execute the following commands clone the modified uniswap-v2-core repository:

cd $WORK_DIR
git clone https://github.com/thetatoken/uniswap-v2-core
cd uniswap-v2-core

Next, install Dependencies, compile Contracts, and run tests for uniswap-v2-core. Note that the following assumes the use of node@>=10. Also please ignore build errors related to scrypt_params_async.o if any when you run the yarn command.

yarn
yarn compile
yarn test

Test the uniswap-v2-periphery contracts

Similar to the above, before running the uniswap-v2-periphery tests, we need to setup the Theta local privatenet with the Theta/Ethereum RPC Adaptor following this guide.

Again, assuming the work directory is $WORK_DIR, please execute the following commands clone the modified uniswap-v2-periphery repository:

cd $WORK_DIR
git clone https://github.com/thetatoken/uniswap-v2-periphery
cd uniswap-v2-periphery

Next, install Dependencies, compile Contracts, and run tests for uniswap-v2-periphery.

yarn
yarn compile
yarn test