Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zkSync era #1

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org

- name: Set output of cache
Expand All @@ -34,7 +34,7 @@ jobs:
yarn-

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --network-concurrency 1

- name: Run linters
uses: wearerequired/lint-action@v1
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@ jobs:
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install test node dependencies
run: |
sudo apt-get update && sudo apt-get install -y \
cmake pkg-config libssl-dev clang

- name: Install test node
run: |
cargo install --git https://github.com/matter-labs/era-test-node.git --locked

- name: Set output of cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -34,7 +47,11 @@ jobs:
yarn-

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --network-concurrency 1

- name: Run test node
run: |
era_test_node run &

- name: Run unit tests
run: yarn test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ dist
.tern-port

.nvmrc

# hardhat
artifacts-zk/
cache-zk/
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Deploy script for zkSync Uniswap v3
Copyright (C) 2023 GFX Labs, Inc.
Licensed under GNU GPL v3 or later

This software incorporates:
deploy-v3
Copyright (C) 2021 Uniswap Labs
Licensed under GNU GPL v3
See https://github.com/Uniswap/deploy-v3

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Expand Down
44 changes: 17 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deploy Uniswap V3 Script

This package includes a CLI script for deploying the latest Uniswap V3 smart contracts to any EVM (Ethereum Virtual Machine) compatible network.
This package includes a CLI script for deploying the latest Uniswap V3 smart contracts to zkSync Era.

## Licensing

Expand Down Expand Up @@ -29,26 +29,24 @@ These contract function calls should ultimately be encoded into a governance pro
## Usage

This package vends a CLI for executing a deployment script that results in a full deployment of Uniswap Protocol v3.
Get the arguments for running the latest version of the script via `npx @uniswap/deploy-v3 --help`.
Get the arguments for running the latest version of the script via `yarn start --help`.

As of `v1.0.3` the arguments are:
As of `v1.0.4` the arguments are:

```text
> npx @uniswap/deploy-v3 --help
Usage: npx @uniswap/deploy-v3 [options]

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
Usage: yarn start [--confirmations <STRING>] [--gas-price <STRING>] --json-rpc <STRING> --native-currency-label <STRING> --owner-address <STRING> --private-key <STRING> [--state <STRING>] [--v2-core-factory-address <STRING>] --weth9-address <STRING>

OPTIONS:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually just the output of yarn start --help, but we can remove this line for consistency

--confirmations How many confirmations to wait for after each transaction (optional) (default: "2")
--gas-price The gas price to pay in GWEI for each transaction (optional)
--json-rpc JSON RPC URL where the program should be deployed
--native-currency-label Native currency label, e.g. ETH
--owner-address Contract address that will own the deployed artifacts after the script runs
--private-key Private key used to deploy all contracts
--state Path to the JSON file containing the migrations state (optional) (default: "./state.json")
--v2-core-factory-address The V2 core factory address used in the swap router (optional)
--weth9-address Address of the WETH9 contract on this chain
```

The script runs a set of migrations, each migration deploying a contract or executing a transaction. Migration state is
Expand All @@ -57,8 +55,7 @@ saved in a JSON file at the supplied path (by default `./state.json`).
To use the script, you must fund an address, and pass the private key of that address to the script so that it can construct
and broadcast the deployment transactions.

The block explorer verification process (e.g. Etherscan) is specific to the network. For the existing deployments,
we have used the `@nomiclabs/hardhat-etherscan` hardhat plugin in the individual repositories to verify the deployment addresses.
For the existing deployments, we have used the `@matterlabs/hardhat-zksync-verify` hardhat plugin in the individual repositories to verify the deployment addresses.

Note that in between deployment steps, the script waits for confirmations. By default, this is set to `2`. If the network
only mines blocks when the transactions is queued (e.g. a local testnet), you must set confirmations to `0`.
Expand All @@ -69,15 +66,8 @@ To run unit tests, run `yarn test`.

For testing the script, run `yarn start`.

To publish the script, first create a version: `npm version <version identifier>`, then publish via `npm publish`.
Don't forget to push your tagged commit!

## FAQs

### How much gas should I expect to use for full completion?

We estimate 30M - 40M gas needed to run the full deploy script.

### When I run the script, it says "Contract was already deployed..."

Delete `state.json` before a fresh deploy. `state.json` tracks which steps have already occurred. If there are any entries, the deploy script will attempt to pick up from the last step in `state.json`.
Expand Down
5 changes: 5 additions & 0 deletions contracts/ImportNonfungibleTokenPositionDescriptor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity =0.7.6;

import "v3-periphery-1_3_0/contracts/NonfungibleTokenPositionDescriptor.sol";
38 changes: 38 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import '@matterlabs/hardhat-zksync-solc'
import { task } from 'hardhat/config'
import { deployV3 } from './index'

task('deploy-v3')
.addParam('privateKey', 'Private key used to deploy all contracts')
.addParam('jsonRpc', 'JSON RPC URL where the program should be deployed')
.addParam('weth9Address', 'Address of the WETH9 contract on this chain')
.addParam('nativeCurrencyLabel', 'Native currency label, e.g. ETH')
.addParam('ownerAddress', 'Contract address that will own the deployed artifacts after the script runs')
.addOptionalParam('state', 'Path to the JSON file containing the migrations state (optional)', './state.json')
.addOptionalParam('v2CoreFactoryAddress', 'The V2 core factory address used in the swap router (optional)')
.addOptionalParam('gasPrice', 'The gas price to pay in GWEI for each transaction (optional)')
.addOptionalParam('confirmations', 'How many confirmations to wait for after each transaction (optional)', '2')
.setAction(async (taskArgs) => {
await deployV3(taskArgs)
})

// This config will be used to compile the `v3-periphery-1_3_0/contracts/NonfungibleTokenPositionDescriptor.sol` contract
export default {
networks: {
hardhat: {
zksync: true,
},
},
solidity: {
version: '0.7.6',
},
zksolc: {
version: '1.3.13',
compilerSource: 'binary',
settings: {
metadata: {
bytecodeHash: 'none',
},
},
},
}
Loading
Loading