Blockchain 6 min read

How to Clone and Run Uniswap V3 Core Tests to Master Ethereum Smart Contracts

This guide walks you through cloning the Uniswap V3 core repository, setting up the development environment, compiling Solidity contracts, and executing the comprehensive test suite to deeply understand the protocol's core mathematics and logic.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
How to Clone and Run Uniswap V3 Core Tests to Master Ethereum Smart Contracts

Clone the repository and set up the development environment

Clone the core repository

git clone https://github.com/Uniswap/v3-core.git
cd v3-core

Install dependencies The project uses yarn (npm works as well). Run: yarn install This installs Hardhat, Ethers.js, Waffle and other libraries required for compilation and testing.

Compile the Solidity contracts

The package.json defines a compile script that invokes Hardhat with the configuration in hardhat.config.ts (Solidity compiler version 0.7.6). Execute: yarn compile Hardhat compiles every .sol file under contracts/ and writes the bytecode and ABI to the artifacts/ directory. A successful run produces no errors.

Run the core test suite

The test suite is the primary source of truth for Uniswap V3 core behavior. Run it with: yarn test Hardhat automatically performs the following steps:

Start an in‑memory Ethereum network that exists only for the duration of the test run.

Deploy core contracts such as UniswapV3Factory and the pool contracts to this temporary network.

Execute test cases located in the test/ directory. Tests call functions like createPool, simulate price movements, calculate fees, and verify results with expect assertions.

Key test groups focus on the protocol’s mathematical correctness:

TickMath – validates the precision of price‑to‑tick conversions.

SwapMath – checks swap logic, slippage and fee calculations.

Liquidity management – ensures token amount calculations when adding or removing liquidity are accurate.

From core to periphery

The v3-core repository contains only the engine: the factory, pool contracts, and low‑level math libraries. User‑facing contracts such as SwapRouter and NonfungiblePositionManager reside in the separate v3-periphery repository: https://github.com/Uniswap/v3-periphery.git Cloning and testing v3-periphery follows the same workflow and provides examples of higher‑level interactions (e.g., swapping ETH for DAI, managing NFT positions).

Conclusion

By cloning v3-core, installing dependencies, compiling with yarn compile, and running yarn test, developers can verify their local setup, explore Uniswap V3’s core mathematics, and gain a solid understanding of the protocol’s low‑level logic. The core repository serves as the engine, while the periphery repository provides the cockpit for user interactions.

Testingsmart contractsSolidityEthereumHardhatBlockchain DevelopmentUniswap V3
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.