Scroll network is a new scaling solution for Ethereum that uses zero-knowledge proofs to make transactions fast, secure, and cheap. It's fully compatible with the EVM (Ethereum Virtual Machine), so developers can easily port their DApps to Scroll without any changes.
Chainstack recently announced support for Scroll’s Sepolia Testnet, which makes it even easier for developers to get started. In this tutorial, you’ll learn how to deploy the full Uniswap v3 AMM suite on Scroll in just a few easy steps.
Scroll's hierarchical ZKP system is optimized for both provers and verifiers, allowing it to achieve faster transaction finality and lower gas fees than other layer-2 scaling solutions.
The first layer of Scroll's ZKP system is optimized for provers, using custom circuit optimization and hardware-friendly proving algorithms. This allows provers to generate proofs much faster, reducing the overall transaction latency.
The second layer of Scroll's ZKP system is optimized for verifiers, using succinct proofs and verification algorithms compatible with the EVM. This allows verifiers to verify proofs much faster, reducing the overall transaction cost.
As a result of its hierarchical ZKP system, Scroll is able to achieve much faster transaction finality and lower gas fees than other layer-2 scaling solutions. This makes it a great choice for applications that require high throughput and low latency, such as DeFi and NFT trading.
- Chainstack account to deploy a Scroll Sepolia node
- The yarn package manager
- TypeScript V4.2.3
This tutorial shows you how to deploy the Uniswap V3 smart contracts on the Scroll Sepolia Testnet. To get from zero to a deployed instance of Uniswap V3, do the following:
- With Chainstack, create a public chain project.
- With Chainstack, join the Scroll Sepolia Testnet.
- With Chainstack, access your Scroll Sepolia node endpoint.
- Fund your account through the Chainstack Faucet.
- Deploy the Uniswap v3 suite.
See Create a project.
Before diving into the project, top up your wallet with testnet Scroll ETH. The best option is to get some Sepolia ETH from the Chainstack Faucet and then bridge them to Scroll Sepolia:
- Get Sepolia ETH from the Chainstack Sepolia Faucet.
- Bridge to Scroll Sepolia using the Scroll Bridge.
To deploy the Uniswap v3 Suite you will need about 0.5 ETH in your wallet with a gas price of 11 gwei. Make sure you have enough funds in your wallet before you proceed.
In this step, we will deploy the full Uniswap v3 AMM suite on Scroll network. And we will leverage the v3 deploy official repository to automate the process.
The repository contains a CLI script for deploying the latest Uniswap v3 smart contracts to any EVM-compatible network.
This repository collects almost all of the contracts that make up Uniswap v3 and provides scripts to deploy them easily in a single command.
Uniswap is one of the most popular decentralized finance (DeFi) solutions in the Web3 space. Uniswap v3 is the third major version of Uniswap, and it allows users to swap ERC-20 tokens without a centralized intermediary. Since its launch in May 2021, Uniswap v3 has quickly become the most popular DeX in the world, with over $100 billion in total value locked.
Clone the repository:
git clone https://github.com/Uniswap/deploy-v3.git
Make sure you install TypeScript V4.2.3:
yarn add [email protected] --dev
Move into the repository's directory:
Install the dependencies and build:
yarn && yarn build
The console should have a similar output:
$ ncc build index.ts -o dist -m
ncc: Version 0.36.1
ncc: Compiling file index.js into CJS
ncc: Using [email protected] (local user-provided)
1480kB [3043ms] - ncc 0.36.1
$ cat shebang.txt dist/index.js > dist/index.cmd.js && mv dist/index.cmd.js dist/index.js
✨ Done in 3.76s.
For the next step, you will need the following:
- The private key of the account deploying the smart contracts, starting with
- The Chainstack Scroll Sepolia HTTPS endpoint
- The address of the account that will manage the smart contracts
In the console, run the following command, adding your private key, endpoint, and address:
yarn start \
-pk YOUR_PRIVATE_KEY \
-j YOUR_CHAINSTACK_ENDPOINT \
-w9 0xa1EA0B2354F5A344110af2b6AD68e75545009a03 \
-ncl ETH -o YOUR_ADDRESS
Here is a list of what the flags mean:
-pk— your deployment account's private key.
-j— the JSON-RPC endpoint.
-w9— the address of the WETH9 contract. On the Scroll Testnet, this contract is deployed at
-ncl— the native currency label. This is the symbol for the native token, which is
-o— the owner's address of the deployed administrator contract.
Below is the full list of options:
> npx @uniswap/deploy-v3 --help
Usage: npx @uniswap/deploy-v3 [options]
-pk, --private-key <string> Private key used to deploy all contracts
-j, --json-rpc <url> JSON RPC URL where the program should be deployed
-w9, --weth9-address <address> Address of the WETH9 contract on this chain
-ncl, --native-currency-label <string> Native currency label, e.g. ETH
-o, --owner-address <address> Contract address that will own the deployed artifacts after the script runs
-s, --state <path> Path to the JSON file containing the migrations state (optional) (default: "./state.json")
-v2, --v2-core-factory-address <address> The V2 core factory address used in the swap router (optional)
-g, --gas-price <number> The gas price to pay in GWEI for each transaction (optional)
-c, --confirmations <number> How many confirmations to wait for after each transaction (optional) (default: "2")
-V, --version output the version number
-h, --help display help for command
Running this command will deploy the contracts one by one; the console will display each deployment like the following:
Step 1 complete [
message: 'Contract UniswapV3Factory deployed',
Step 2 complete [
message: 'UniswapV3Factory added a new fee tier 1 bps with tick spacing 1',
You can also find the details of the contracts in the
Congratulations, you deployed all of the Uniswap v3 smart contracts on the Scroll Sepolia Testnet.
Use the block explorer to see the transactions.
The UniswapV3Factory contract is the central hub for all Uniswap v3 pools. It allows users to create new pools, query information about existing pools, and add or remove liquidity from pools. The UniswapV3Factory contract is also responsible for managing the protocol fees for all Uniswap v3 pools.
UniswapInterfaceMulticall is a helper contract allowing users to group multiple function calls into one call. This can be useful for reducing the number of transactions that need to be sent to the blockchain and ensuring that all calls are executed in the same block.
A proxy gateway contract is a smart contract that allows for the easy upgrade of other smart contracts. This is essential for any project that wants to evolve over time without having to fork the blockchain.
The TickLens contract is a peripheral contract in the Uniswap v3 protocol. It provides functions for querying information about the ticks in a Uniswap v3 pool. The
TickLens contract can be used to:
- Find out how many ticks are in a pool.
- Determine which ticks are initialized.
- Identify which ticks have liquidity.
The NonfungibleTokenPositionDescriptor contract stores the ID of NFTs and their respective
NonFungiblePositionManger contract address.
The NonfungiblePositionManager manages the positions and liquidity for ERC-721 non-fungible tokens.
The V3Migrator contract is a tool that helps developers migrate their Uniswap v2 pools to Uniswap v3.
The UniswapV3Staker contract is a peripheral contract in the Uniswap v3 protocol. It allows users to stake their ERC-20 tokens in Uniswap v3 pools in order to earn rewards. The rewards are paid out as the pool's native token.
UniswapV3Staker contract is critical to the Uniswap v3 protocol because it incentivizes liquidity provision. By allowing users to earn rewards for staking their tokens, the
UniswapV3Staker contract helps to ensure that there is always enough liquidity in Uniswap v3 pools to facilitate swaps. This makes the protocol more decentralized and efficient.
SwapRouter contracts are essential for users who want to exchange tokens on Uniswap.
QuoterV2 is a peripheral contract in the Uniswap v3 protocol. It allows users to get price quotes for swaps without executing the swap.
QuoterV2 uses the Uniswap v3 core, periphery contracts, and the
PoolTicksCounter library. It includes functions to quote exact input or output amounts and handles reverts by counting initialized ticks crossed.
SwapRouter02 executes swaps across different asset pools. It is a stateless contract, meaning it holds no token balances. This makes it more efficient and secure than other types of contracts.
SwapRouter contract considers the price of tokens, the liquidity in different pools, and the fees for swaps to calculate the best price for a swap. It then executes the swap, transferring tokens between pools and updating users' balances.
In conclusion, deploying Uniswap v3 on Scroll is a relatively straightforward process. Following the steps outlined in this tutorial, you can create a Uniswap v3 pool on Scroll in just a few minutes. Once your pool is deployed, you can start providing liquidity and earning fees.
Updated 3 months ago