From 4c58e7c1fdd4a87becdcd114bede46c2832a9118 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Wed, 28 Jun 2023 14:43:47 +0100 Subject: [PATCH 1/9] wip - etherscan verification --- .env.example | 6 +++ hardhat.config.ts | 16 ++++-- package.json | 4 +- scripts/deployMauve.ts | 19 +++---- src/deployer/MauveDeployer.ts | 99 +++++++++++++++++++++-------------- src/lib/deployMauve.ts | 16 +++--- tasks/deployMauveContracts.ts | 17 +++--- yarn.lock | 36 +++++++------ 8 files changed, 127 insertions(+), 86 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4fbca42 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +PRIVATE_KEY=your_private_key +INFURA_API_KEY=infura_key + +# ETHERSCAN +ETHERSCAN_API_KEY=XXXXX +OPTIMISM_API_KEY=XXXXX \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 0640d3e..2d4b067 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,5 +1,5 @@ import "@nomiclabs/hardhat-ethers"; -import "@nomiclabs/hardhat-etherscan"; +import "@nomicfoundation/hardhat-verify"; import "@nomiclabs/hardhat-waffle"; import "hardhat-typechain"; import "hardhat-watcher"; @@ -10,6 +10,10 @@ import "./tasks/getSqrtPrice"; import "./tasks/deployMauveContracts"; import "./tasks/deployEAT"; +if (!process.env.INFURA_API_KEY) { + throw new Error("Missing OP API KEY"); +} + export default { networks: { localhost: { @@ -47,15 +51,19 @@ export default { `0x15b856067decade001ce52ba5c91ff040ef550b0859bf26d1d24d04c4b726917`, ], url: `https://opt-goerli.g.alchemy.com/v2/Ay4DBPd3SGpvm_8jJM-MS9MhHoqN8-dr`, + gasPrice: 2000000000, }, optimism: { url: `https://optimism-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, }, }, etherscan: { - // Your API key for Etherscan - // Obtain one at https://etherscan.io/ - apiKey: process.env.ETHERSCAN_API_KEY, + apiKey: { + mainnet: process.env.ETHERSCAN_API_KEY || "", + optimisticEthereum: process.env.OPTIMISM_API_KEY || "", + optimisticGoerli: process.env.OPTIMISM_API_KEY || "", + goerli: process.env.ETHERSCAN_API_KEY || "", + }, }, contractSizer: { runOnCompile: false, diff --git a/package.json b/package.json index e30e739..329c2ca 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "README.md" ], "devDependencies": { + "@nomicfoundation/hardhat-verify": "^1.0.3", "@nomiclabs/hardhat-ethers": "^2.0.2", - "@nomiclabs/hardhat-etherscan": "^3.1.2", "@nomiclabs/hardhat-waffle": "^2.0.1", "@typechain/ethers-v5": "^4.0.0", "@types/chai": "^4.1.7", @@ -60,9 +60,9 @@ }, "dependencies": { "@openzeppelin/contracts": "^4.8.2", - "@violetprotocol/mauve-swap-router-contracts": "1.5.2", "@violetprotocol/mauve-core": "1.2.4", "@violetprotocol/mauve-periphery": "1.8.6", + "@violetprotocol/mauve-swap-router-contracts": "1.5.2", "cli-table3": "^0.6.0" } } diff --git a/scripts/deployMauve.ts b/scripts/deployMauve.ts index bbf9a87..74e9710 100644 --- a/scripts/deployMauve.ts +++ b/scripts/deployMauve.ts @@ -1,9 +1,9 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; -import { ethers } from "hardhat"; +import * as hre from "hardhat"; import { deployMauve } from "../src/lib/deployMauve"; async function main() { - const [signer] = await ethers.getSigners(); + const [signer] = await hre.ethers.getSigners(); const eatVerifier = "0x5Dbe2B4648FFAF2867F8Ad07d42003F5ce4b7d2C"; const violetId = "0x9A119a53cb065202d631ba01d55e3850eDcf3EAa"; @@ -15,17 +15,18 @@ async function main() { positionDescriptor, nftDescriptorLibrary, } = await deployMauve( - (signer as any) as SignerWithAddress, - (signer as any) as SignerWithAddress, - (signer as any) as SignerWithAddress, + hre, + signer as any as SignerWithAddress, + signer as any as SignerWithAddress, + signer as any as SignerWithAddress, violetId, eatVerifier ); - console.log(`Factory deployed at: ${factory.address}`); - console.log(`Router deployed at: ${mauveSwapRouter.address}`); - console.log(`Quoter deployed at: ${quoter.address}`); - console.log(`PositionManager deployed at: ${positionManager.address}`); + // console.log(`Factory deployed at: ${factory.address}`); + // console.log(`Router deployed at: ${mauveSwapRouter.address}`); + // console.log(`Quoter deployed at: ${quoter.address}`); + // console.log(`PositionManager deployed at: ${positionManager.address}`); console.log(`PositionDescriptor deployed at: ${positionDescriptor.address}`); console.log( `PositionDescriptorLibrary deployed at: ${nftDescriptorLibrary.address}` diff --git a/src/deployer/MauveDeployer.ts b/src/deployer/MauveDeployer.ts index d3e9253..3e41c77 100644 --- a/src/deployer/MauveDeployer.ts +++ b/src/deployer/MauveDeployer.ts @@ -1,4 +1,5 @@ import { Signer, Contract, ContractFactory } from "ethers"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; import { linkLibraries } from "../util/linkLibraries"; import { positionManagerBytes32, swapRouterBytes32 } from "../util/roles"; import WETH9 from "../util/WETH9.json"; @@ -24,64 +25,69 @@ const WETH9Address = "0x4200000000000000000000000000000000000006"; export class MauveDeployer { static async deploy( + hre: HardhatRuntimeEnvironment, actor: Signer, violetIdAddress: string, eatVerifierAddress: string ): Promise<{ [name: string]: Contract }> { - const deployer = new MauveDeployer(actor); - - // const weth9 = await deployer.deployWETH9(); - const factory = await deployer.deployFactory(); - console.log(`Factory deployed at: ${factory.address}`); - const quoter = await deployer.deployQuoter(factory.address, WETH9Address); - console.log(`Quoter deployed at: ${quoter.address}`); - const quoterV2 = await deployer.deployQuoterV2( - factory.address, - WETH9Address - ); - console.log(`QuoterV2 deployed at: ${quoterV2.address}`); + const deployer = new MauveDeployer(hre, actor); + + // const factory = await deployer.deployFactory(); + // console.log(`Factory deployed at: ${factory.address}`); + // const quoter = await deployer.deployQuoter(factory.address, WETH9Address); + // console.log(`Quoter deployed at: ${quoter.address}`); + // const quoterV2 = await deployer.deployQuoterV2( + // factory.address, + // WETH9Address + // ); + // console.log(`QuoterV2 deployed at: ${quoterV2.address}`); const nftDescriptorLibrary = await deployer.deployNFTDescriptorLibrary(); - console.log(`NFTDescriptorLibrary deployed at: ${nftDescriptorLibrary.address}`); + console.log( + `NFTDescriptorLibrary deployed at: ${nftDescriptorLibrary.address}` + ); const positionDescriptor = await deployer.deployPositionDescriptor( nftDescriptorLibrary.address, WETH9Address ); - console.log(`NFTPositionDescriptor deployed at: ${positionDescriptor.address}`); - const positionManager = await deployer.deployNonfungiblePositionManager( - factory.address, - WETH9Address, - positionDescriptor.address, - eatVerifierAddress, - violetIdAddress + console.log( + `NFTPositionDescriptor deployed at: ${positionDescriptor.address}` ); - console.log(`NFTPositionManager deployed at: ${positionManager.address}`); - - const mauveSwapRouter = await deployer.deployMauveSwapRouter( - factory.address, - positionManager.address, - WETH9Address, - eatVerifierAddress - ); - console.log(`MauveSwapRouter deployed at: ${mauveSwapRouter.address}`); - - await factory.setRole(mauveSwapRouter.address, swapRouterBytes32); - await factory.setRole(positionManager.address, positionManagerBytes32); + // const positionManager = await deployer.deployNonfungiblePositionManager( + // factory.address, + // WETH9Address, + // positionDescriptor.address, + // eatVerifierAddress, + // violetIdAddress + // ); + // console.log(`NFTPositionManager deployed at: ${positionManager.address}`); + + // const mauveSwapRouter = await deployer.deployMauveSwapRouter( + // factory.address, + // positionManager.address, + // WETH9Address, + // eatVerifierAddress + // ); + // console.log(`MauveSwapRouter deployed at: ${mauveSwapRouter.address}`); + + // await factory.setRole(mauveSwapRouter.address, swapRouterBytes32); + // await factory.setRole(positionManager.address, positionManagerBytes32); return { - // weth9, - factory, - mauveSwapRouter, - quoter, - quoterV2, + // factory, + // mauveSwapRouter, + // quoter, + // quoterV2, nftDescriptorLibrary, positionDescriptor, - positionManager, + // positionManager, }; } + hre: HardhatRuntimeEnvironment; deployer: Signer; - constructor(deployer: Signer) { + constructor(hre: HardhatRuntimeEnvironment, deployer: Signer) { + this.hre = hre; this.deployer = deployer; } @@ -221,6 +227,19 @@ export class MauveDeployer { actor: Signer ) { const factory = new ContractFactory(abi, bytecode, actor); - return await factory.deploy(...deployParams); + const contract = await factory.deploy(...deployParams); + + try { + await run("verify:verify", { + address: contract.address, + constructorArguments: deployParams, + }); + } catch (error) { + console.log( + `Error verifying contract at address ${contract.address}: ${error}` + ); + } + + return contract; } } diff --git a/src/lib/deployMauve.ts b/src/lib/deployMauve.ts index 82c3642..e248ec3 100644 --- a/src/lib/deployMauve.ts +++ b/src/lib/deployMauve.ts @@ -2,8 +2,10 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { MauveDeployer } from "../deployer/MauveDeployer"; import { ownerBytes32, poolAdminBytes32 } from "../util/roles"; import { IMauveFactory } from "../../typechain"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; export async function deployMauve( + hre: HardhatRuntimeEnvironment, deployer: SignerWithAddress, mauveOwner: SignerWithAddress, poolAdmin: SignerWithAddress, @@ -17,14 +19,14 @@ export async function deployMauve( positionManager, positionDescriptor, nftDescriptorLibrary, - } = await MauveDeployer.deploy(deployer, violetId, EATVerifier); + } = await MauveDeployer.deploy(hre, deployer, violetId, EATVerifier); - await (factory as IMauveFactory) - .connect(deployer) - .setRole(mauveOwner.address, ownerBytes32); - await (factory as IMauveFactory) - .connect(mauveOwner) - .setRole(poolAdmin.address, poolAdminBytes32); + // await (factory as IMauveFactory) + // .connect(deployer) + // .setRole(mauveOwner.address, ownerBytes32); + // await (factory as IMauveFactory) + // .connect(mauveOwner) + // .setRole(poolAdmin.address, poolAdminBytes32); return { factory, diff --git a/tasks/deployMauveContracts.ts b/tasks/deployMauveContracts.ts index 82a928a..a542a15 100644 --- a/tasks/deployMauveContracts.ts +++ b/tasks/deployMauveContracts.ts @@ -13,15 +13,16 @@ task("deploy:mauve") mauveOwner, poolAdmin, ] = signers; - - const contracts = await deployMauve( - deployer, - mauveOwner, - poolAdmin, - taskArguments.vid, - taskArguments.eatVerifier - ); + + const contracts = await deployMauve( + hre, + deployer, + mauveOwner, + poolAdmin, + taskArguments.vid, + taskArguments.eatVerifier + ); console.log("Mauve deployed"); diff --git a/yarn.lock b/yarn.lock index a83142f..518a69c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -607,6 +607,21 @@ mcl-wasm "^0.7.1" rustbn.js "~0.2.0" +"@nomicfoundation/hardhat-verify@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-1.0.3.tgz#573b326fe0f58dcdc527e8c11bd5a6336eb52bc4" + integrity sha512-KUj4O/Hd8QB6cr/rxEmRG0zcDjRUNYhWbjtGGwE4lUNuaEhVIDt/cHGJtF/A6lANQR0mpaxC6fwojhzice/ykQ== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^8.1.0" + chalk "^2.4.2" + debug "^4.1.1" + lodash.clonedeep "^4.5.0" + semver "^6.3.0" + table "^6.8.0" + undici "^5.14.0" + "@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz#4c858096b1c17fe58a474fe81b46815f93645c15" @@ -678,22 +693,6 @@ resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.2.tgz#812d48929c3bf8fe840ec29eab4b613693467679" integrity sha512-NLDlDFL2us07C0jB/9wzvR0kuLivChJWCXTKcj3yqjZqMoYp7g7wwS157F70VHx/+9gHIBGzak5pKDwG8gEefA== -"@nomiclabs/hardhat-etherscan@^3.1.2": - version "3.1.7" - resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.1.7.tgz#72e3d5bd5d0ceb695e097a7f6f5ff6fcbf062b9a" - integrity sha512-tZ3TvSgpvsQ6B6OGmo1/Au6u8BrAkvs1mIC/eURA3xgIfznUZBhmpne8hv7BXUzw9xNL3fXdpOYgOQlVMTcoHQ== - dependencies: - "@ethersproject/abi" "^5.1.2" - "@ethersproject/address" "^5.0.2" - cbor "^8.1.0" - chalk "^2.4.2" - debug "^4.1.1" - fs-extra "^7.0.1" - lodash "^4.17.11" - semver "^6.3.0" - table "^6.8.0" - undici "^5.14.0" - "@nomiclabs/hardhat-waffle@^2.0.1": version "2.0.5" resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.5.tgz#97c217f1db795395c04404291937edb528f3f218" @@ -5481,6 +5480,11 @@ lodash.assign@^4.0.3, lodash.assign@^4.0.6: resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" integrity sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw== +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== + lodash.truncate@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" From ce75fa44ea84eac988cbd9b49e18c0a2cc2ce8b3 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:09:15 +0100 Subject: [PATCH 2/9] uncomment --- scripts/deployMauve.ts | 8 ++--- scripts/e2e.ts | 16 +++++---- src/deployer/MauveDeployer.ts | 66 +++++++++++++++++------------------ src/lib/deployMauve.ts | 12 +++---- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/scripts/deployMauve.ts b/scripts/deployMauve.ts index 74e9710..8dd1e7d 100644 --- a/scripts/deployMauve.ts +++ b/scripts/deployMauve.ts @@ -23,10 +23,10 @@ async function main() { eatVerifier ); - // console.log(`Factory deployed at: ${factory.address}`); - // console.log(`Router deployed at: ${mauveSwapRouter.address}`); - // console.log(`Quoter deployed at: ${quoter.address}`); - // console.log(`PositionManager deployed at: ${positionManager.address}`); + console.log(`Factory deployed at: ${factory.address}`); + console.log(`Router deployed at: ${mauveSwapRouter.address}`); + console.log(`Quoter deployed at: ${quoter.address}`); + console.log(`PositionManager deployed at: ${positionManager.address}`); console.log(`PositionDescriptor deployed at: ${positionDescriptor.address}`); console.log( `PositionDescriptorLibrary deployed at: ${nftDescriptorLibrary.address}` diff --git a/scripts/e2e.ts b/scripts/e2e.ts index 53e369a..fd10824 100644 --- a/scripts/e2e.ts +++ b/scripts/e2e.ts @@ -38,13 +38,15 @@ async function main() { await token0.connect(trader).mint(parseEther("1000000000000000")); await token1.connect(trader).mint(parseEther("1000000000000000")); - const { factory, mauveSwapRouter, quoter, positionManager } = await deployMauve( - deployer, - mauveOwner, - poolAdmin, - VIOLET_ID_ADDRESS, - EATVerifier.address, - ); + const { factory, mauveSwapRouter, quoter, positionManager } = + await deployMauve( + hre, + deployer, + mauveOwner, + poolAdmin, + VIOLET_ID_ADDRESS, + EATVerifier.address + ); console.log(`Factory: ${factory.address}`); console.log(`Router: ${mauveSwapRouter.address}`); diff --git a/src/deployer/MauveDeployer.ts b/src/deployer/MauveDeployer.ts index 3e41c77..e764067 100644 --- a/src/deployer/MauveDeployer.ts +++ b/src/deployer/MauveDeployer.ts @@ -32,15 +32,15 @@ export class MauveDeployer { ): Promise<{ [name: string]: Contract }> { const deployer = new MauveDeployer(hre, actor); - // const factory = await deployer.deployFactory(); - // console.log(`Factory deployed at: ${factory.address}`); - // const quoter = await deployer.deployQuoter(factory.address, WETH9Address); - // console.log(`Quoter deployed at: ${quoter.address}`); - // const quoterV2 = await deployer.deployQuoterV2( - // factory.address, - // WETH9Address - // ); - // console.log(`QuoterV2 deployed at: ${quoterV2.address}`); + const factory = await deployer.deployFactory(); + console.log(`Factory deployed at: ${factory.address}`); + const quoter = await deployer.deployQuoter(factory.address, WETH9Address); + console.log(`Quoter deployed at: ${quoter.address}`); + const quoterV2 = await deployer.deployQuoterV2( + factory.address, + WETH9Address + ); + console.log(`QuoterV2 deployed at: ${quoterV2.address}`); const nftDescriptorLibrary = await deployer.deployNFTDescriptorLibrary(); console.log( `NFTDescriptorLibrary deployed at: ${nftDescriptorLibrary.address}` @@ -52,34 +52,34 @@ export class MauveDeployer { console.log( `NFTPositionDescriptor deployed at: ${positionDescriptor.address}` ); - // const positionManager = await deployer.deployNonfungiblePositionManager( - // factory.address, - // WETH9Address, - // positionDescriptor.address, - // eatVerifierAddress, - // violetIdAddress - // ); - // console.log(`NFTPositionManager deployed at: ${positionManager.address}`); - - // const mauveSwapRouter = await deployer.deployMauveSwapRouter( - // factory.address, - // positionManager.address, - // WETH9Address, - // eatVerifierAddress - // ); - // console.log(`MauveSwapRouter deployed at: ${mauveSwapRouter.address}`); - - // await factory.setRole(mauveSwapRouter.address, swapRouterBytes32); - // await factory.setRole(positionManager.address, positionManagerBytes32); + const positionManager = await deployer.deployNonfungiblePositionManager( + factory.address, + WETH9Address, + positionDescriptor.address, + eatVerifierAddress, + violetIdAddress + ); + console.log(`NFTPositionManager deployed at: ${positionManager.address}`); + + const mauveSwapRouter = await deployer.deployMauveSwapRouter( + factory.address, + positionManager.address, + WETH9Address, + eatVerifierAddress + ); + console.log(`MauveSwapRouter deployed at: ${mauveSwapRouter.address}`); + + await factory.setRole(mauveSwapRouter.address, swapRouterBytes32); + await factory.setRole(positionManager.address, positionManagerBytes32); return { - // factory, - // mauveSwapRouter, - // quoter, - // quoterV2, + factory, + mauveSwapRouter, + quoter, + quoterV2, nftDescriptorLibrary, positionDescriptor, - // positionManager, + positionManager, }; } diff --git a/src/lib/deployMauve.ts b/src/lib/deployMauve.ts index e248ec3..9c5690b 100644 --- a/src/lib/deployMauve.ts +++ b/src/lib/deployMauve.ts @@ -21,12 +21,12 @@ export async function deployMauve( nftDescriptorLibrary, } = await MauveDeployer.deploy(hre, deployer, violetId, EATVerifier); - // await (factory as IMauveFactory) - // .connect(deployer) - // .setRole(mauveOwner.address, ownerBytes32); - // await (factory as IMauveFactory) - // .connect(mauveOwner) - // .setRole(poolAdmin.address, poolAdminBytes32); + await(factory as IMauveFactory) + .connect(deployer) + .setRole(mauveOwner.address, ownerBytes32); + await(factory as IMauveFactory) + .connect(mauveOwner) + .setRole(poolAdmin.address, poolAdminBytes32); return { factory, From 1f36c5548d1669e68f1edbe46c979c73ca4dcf79 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:06:22 +0100 Subject: [PATCH 3/9] use hre --- scripts/deployMauveInterfaceMulticall.ts | 6 +++--- scripts/deployQuoterV2.ts | 6 +++--- src/deployer/MauveDeployer.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/deployMauveInterfaceMulticall.ts b/scripts/deployMauveInterfaceMulticall.ts index ac6779f..5fa063d 100644 --- a/scripts/deployMauveInterfaceMulticall.ts +++ b/scripts/deployMauveInterfaceMulticall.ts @@ -1,10 +1,10 @@ -import { ethers } from "hardhat"; +import * as hre from "hardhat"; import { MauveDeployer } from "../src/deployer/MauveDeployer"; async function main() { - const [signer] = await ethers.getSigners(); + const [signer] = await hre.ethers.getSigners(); - const deployer = new MauveDeployer(signer); + const deployer = new MauveDeployer(hre, signer); const mauveInterfaceMulticall = await deployer.deployMauveInterfaceMulticall(); diff --git a/scripts/deployQuoterV2.ts b/scripts/deployQuoterV2.ts index c087732..cbe51dd 100644 --- a/scripts/deployQuoterV2.ts +++ b/scripts/deployQuoterV2.ts @@ -1,12 +1,12 @@ -import { ethers } from "hardhat"; +import * as hre from "hardhat"; import { MauveDeployer } from "../src/deployer/MauveDeployer"; async function main() { - const [signer] = await ethers.getSigners(); + const [signer] = await hre.ethers.getSigners(); const factory = "0xC0cc4ca3f4EE58947256412d3AE35d90c1941D95"; const WETH9Address = "0x4200000000000000000000000000000000000006"; - const deployer = new MauveDeployer(signer); + const deployer = new MauveDeployer(hre, signer); const quoterV2 = await deployer.deployQuoterV2(factory, WETH9Address); console.log(`QuoterV2 deployed at: ${quoterV2.address}`); diff --git a/src/deployer/MauveDeployer.ts b/src/deployer/MauveDeployer.ts index e764067..b443d04 100644 --- a/src/deployer/MauveDeployer.ts +++ b/src/deployer/MauveDeployer.ts @@ -230,7 +230,7 @@ export class MauveDeployer { const contract = await factory.deploy(...deployParams); try { - await run("verify:verify", { + await this.hre.run("verify:verify", { address: contract.address, constructorArguments: deployParams, }); From f1c6ab4dbf47b65b5405b1e9b98500572745a003 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:35:54 +0100 Subject: [PATCH 4/9] update package dependencies --- contracts/TestERC20.sol | 2 +- package.json | 8 ++++---- yarn.lock | 37 ++++++++++++++++--------------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/contracts/TestERC20.sol b/contracts/TestERC20.sol index 7df0580..326f864 100644 --- a/contracts/TestERC20.sol +++ b/contracts/TestERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.0; +pragma solidity ^0.7.0; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; diff --git a/package.json b/package.json index 329c2ca..7d30d5e 100644 --- a/package.json +++ b/package.json @@ -59,10 +59,10 @@ "hardhat": "^2.0.0" }, "dependencies": { - "@openzeppelin/contracts": "^4.8.2", - "@violetprotocol/mauve-core": "1.2.4", - "@violetprotocol/mauve-periphery": "1.8.6", - "@violetprotocol/mauve-swap-router-contracts": "1.5.2", + "@openzeppelin/contracts": "^3.4.2-solc-0.7", + "@violetprotocol/mauve-core": "1.2.5", + "@violetprotocol/mauve-periphery": "1.8.7", + "@violetprotocol/mauve-swap-router-contracts": "1.5.3", "cli-table3": "^0.6.0" } } diff --git a/yarn.lock b/yarn.lock index 518a69c..3a8e0ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -703,16 +703,11 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.2.tgz#edef522bdbc46d478481391553bababdd2199e27" integrity sha512-zIggnBwemUmmt9IS73qxi+tumALxCY4QEs3zLCII78k0Gfse2hAOdAkuAeLUzvWUpneMUfFE5sGHzEUSTvn4Ag== -"@openzeppelin/contracts@3.4.2-solc-0.7": +"@openzeppelin/contracts@3.4.2-solc-0.7", "@openzeppelin/contracts@^3.4.2-solc-0.7": version "3.4.2-solc-0.7" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2-solc-0.7.tgz#38f4dbab672631034076ccdf2f3201fab1726635" integrity sha512-W6QmqgkADuFcTLzHL8vVoNBtkwjvQRpYIAom7KiUNoLKghyx3FgH0GBjt8NRvigV1ZmMOBllvE1By1C+bi8WpA== -"@openzeppelin/contracts@^4.8.2": - version "4.8.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.2.tgz#d815ade0027b50beb9bcca67143c6bcc3e3923d6" - integrity sha512-kEUOgPQszC0fSYWpbh2kT94ltOJwj1qfT2DWo+zVttmGmf97JZ99LspePNaeeaLhCImaHVeBbjaQFZQn7+Zc5g== - "@resolver-engine/core@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" @@ -1012,31 +1007,31 @@ resolved "https://registry.yarnpkg.com/@violetprotocol/ethereum-access-token/-/ethereum-access-token-0.2.2-sol07.tgz#71801e4e92f4cdb8b59eec9f81986443da96aaaa" integrity sha512-ltLpdD/w9lnmhP4CrT6RAiNrF+gYYSjvK/Y3a7lbW+ikUX+kPn9jaCH2pNxz6Ebvxl2tN8SEq6suxFDPmA/B4g== -"@violetprotocol/mauve-core@1.2.4": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-core/-/mauve-core-1.2.4.tgz#3535851af45acfb79ca1da80ca1f06362e052d59" - integrity sha512-axqr4ps4yA5UzE4h6TgwqoJeN0cubF1c8g9aRt0ogZ8QutcF1BGuarWn0VA5WJnVTPeXm9k1b0TcwAKdxwZazQ== +"@violetprotocol/mauve-core@1.2.5": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-core/-/mauve-core-1.2.5.tgz#cfa211a979df93e5318c4b22c6f89a6b18836cda" + integrity sha512-EtiBSbR4Ic1E4Uw2oz5p6nKXUtNrjuZWCymUZHYeJs/0HQXYnNKKU3x1mkRLLzW10QHPxZKYEGWzjoK3J9iyLA== -"@violetprotocol/mauve-periphery@1.8.6": - version "1.8.6" - resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-periphery/-/mauve-periphery-1.8.6.tgz#00107b33a6e3d750c465ac1530d16ac624c2f9b0" - integrity sha512-5A5RVi0uuj0mO7uqs7BI6K702i+nmEjPePIrl4/vWo8bNsRqLSNCjJQ8Q34j7GYkG0qjwMrCvRuSExAjWbh2Mw== +"@violetprotocol/mauve-periphery@1.8.7": + version "1.8.7" + resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-periphery/-/mauve-periphery-1.8.7.tgz#d73b27ae897f53c17194b9151c469b5861ace25f" + integrity sha512-E8pAOhHB4nBh/dPS3Ojg8qDyCvU8q4JenASVupHnbexbMosjL93NwQUGrPa/v98zUzBuV8dnNKfhozvNYyCvmw== dependencies: "@openzeppelin/contracts" "3.4.2-solc-0.7" "@violetprotocol/ethereum-access-token" "0.2.2-sol07" - "@violetprotocol/mauve-core" "1.2.4" + "@violetprotocol/mauve-core" "1.2.5" "@violetprotocol/violetid" "1.2.3" base64-sol "1.0.1" hardhat-watcher "^2.1.1" -"@violetprotocol/mauve-swap-router-contracts@1.5.2": - version "1.5.2" - resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-swap-router-contracts/-/mauve-swap-router-contracts-1.5.2.tgz#791e10cfd80ee25496157977f27520280fcae893" - integrity sha512-BH6yE2DMgy2fBV6rZ4O1VnWrVDFeQSzcoGT01uf9pJmuj7fQFuvmZSby7H5ruhkqvTGlXq9Hyw7RWWcJFfDSWg== +"@violetprotocol/mauve-swap-router-contracts@1.5.3": + version "1.5.3" + resolved "https://registry.yarnpkg.com/@violetprotocol/mauve-swap-router-contracts/-/mauve-swap-router-contracts-1.5.3.tgz#70aa337d7c990cd58f06af12559a3474f5e6ae11" + integrity sha512-qOXPL7vHM2iyxYv23uZFKt68qPRtd3bSrPqr2NhkYTcc385yEp5eQMnmVbETHwlZlFaTOrVGjM8xF5tdiNnqnw== dependencies: "@openzeppelin/contracts" "3.4.2-solc-0.7" - "@violetprotocol/mauve-core" "1.2.4" - "@violetprotocol/mauve-periphery" "1.8.6" + "@violetprotocol/mauve-core" "1.2.5" + "@violetprotocol/mauve-periphery" "1.8.7" dotenv "^14.2.0" hardhat-watcher "^2.1.1" From 1d891f58dba9eb882ab1324324ffae7bfe18c54c Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:37:43 +0100 Subject: [PATCH 5/9] compile Mauve contracts --- hardhat.config.ts | 40 ++++++++++++++++++++--- src/compilerSettings.ts | 71 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/compilerSettings.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index 26def18..057d55e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -14,11 +14,18 @@ import "./tasks/deployPool"; import { resolve } from "path"; import { config as dotenvConfig } from "dotenv"; +import { + MAUVE_CORE_COMPILER_SETTINGS, + MAUVE_PERIPHERY_LOWEST_COMPILER_SETTINGS, + MAUVE_PERIPHERY_LOW_COMPILER_SETTINGS, + MAUVE_PERIPHERY_DEFAULT_COMPILER_SETTINGS, + MAUVE_SWAP_ROUTER_COMPILER_SETTINGS, +} from "./src/compilerSettings"; dotenvConfig({ path: resolve(__dirname, "./.env") }); if (!process.env.INFURA_API_KEY) { - throw new Error("Missing OP API KEY"); + throw new Error("Missing Infura API KEY"); } export default { @@ -78,10 +85,25 @@ export default { { version: "0.7.6", }, - { - version: "0.8.0", - }, ], + overrides: { + "@violetprotocol/mauve-core/contracts/MauveFactory.sol": + MAUVE_CORE_COMPILER_SETTINGS, + "@violetprotocol/mauve-core/contracts/MauvePool.sol": + MAUVE_CORE_COMPILER_SETTINGS, + "@violetprotocol/mauve-periphery/contracts/libraries/NFTDescriptor.sol": + MAUVE_PERIPHERY_LOWEST_COMPILER_SETTINGS, + "@violetprotocol/mauve-periphery/contracts/NonfungiblePositionManager.sol": + MAUVE_PERIPHERY_LOW_COMPILER_SETTINGS, + "@violetprotocol/mauve-periphery/contracts/lens/MauveInterfaceMulticall.sol": + MAUVE_PERIPHERY_DEFAULT_COMPILER_SETTINGS, + "@violetprotocol/mauve-swap-router-contracts/contracts/MauveSwapRouter.sol": + MAUVE_SWAP_ROUTER_COMPILER_SETTINGS, + "@violetprotocol/mauve-swap-router-contracts/contracts/lens/Quoter.sol": + MAUVE_SWAP_ROUTER_COMPILER_SETTINGS, + "@violetprotocol/mauve-swap-router-contracts/contracts/lens/QuoterV2.sol": + MAUVE_SWAP_ROUTER_COMPILER_SETTINGS, + }, }, watcher: { test: { @@ -95,6 +117,16 @@ export default { "@violetprotocol/ethereum-access-token/contracts/AccessTokenVerifier.sol", "@violetprotocol/mauve-core/contracts/interfaces/IMauvePool.sol", "@violetprotocol/mauve-core/contracts/interfaces/IMauveFactory.sol", + "@violetprotocol/mauve-core/contracts/MauveFactory.sol", + "@violetprotocol/mauve-swap-router-contracts/contracts/lens/Quoter.sol", + "@violetprotocol/mauve-swap-router-contracts/contracts/lens/QuoterV2.sol", + "@violetprotocol/mauve-swap-router-contracts/contracts/MauveSwapRouter.sol", + "@violetprotocol/mauve-periphery/contracts/libraries/NFTDescriptor.sol", + // TODO: Fix compilation of NonfungibleTokenPositionDescriptor + // See https://github.com/violetprotocol/mauve-deploy/issues/7 + // "@violetprotocol/mauve-periphery/contracts/NonfungibleTokenPositionDescriptor.sol", + "@violetprotocol/mauve-periphery/contracts/NonfungiblePositionManager.sol", + "@violetprotocol/mauve-periphery/contracts/lens/MauveInterfaceMulticall.sol", ], }, }; diff --git a/src/compilerSettings.ts b/src/compilerSettings.ts new file mode 100644 index 0000000..2a8dbb2 --- /dev/null +++ b/src/compilerSettings.ts @@ -0,0 +1,71 @@ +export const MAUVE_CORE_COMPILER_SETTINGS = { + version: "0.7.6", + settings: { + optimizer: { + enabled: true, + runs: 850, + }, + metadata: { + // do not include the metadata hash, since this is machine dependent + // and we want all generated code to be deterministic + // https://docs.soliditylang.org/en/v0.7.6/metadata.html + bytecodeHash: "none", + }, + }, +}; + +export const MAUVE_PERIPHERY_DEFAULT_COMPILER_SETTINGS = { + version: "0.7.6", + settings: { + evmVersion: "istanbul", + optimizer: { + enabled: true, + runs: 1_000_000, + }, + metadata: { + bytecodeHash: "none", + }, + }, +}; + +export const MAUVE_PERIPHERY_LOW_COMPILER_SETTINGS = { + version: "0.7.6", + settings: { + evmVersion: "istanbul", + optimizer: { + enabled: true, + runs: 555, + }, + metadata: { + bytecodeHash: "none", + }, + }, +}; + +export const MAUVE_PERIPHERY_LOWEST_COMPILER_SETTINGS = { + version: "0.7.6", + settings: { + evmVersion: "istanbul", + optimizer: { + enabled: true, + runs: 900, + }, + metadata: { + bytecodeHash: "none", + }, + }, +}; + +export const MAUVE_SWAP_ROUTER_COMPILER_SETTINGS = { + version: "0.7.6", + settings: { + evmVersion: "istanbul", + optimizer: { + enabled: true, + runs: 49350, + }, + metadata: { + bytecodeHash: "none", + }, + }, +}; From 232af7c32b718c382654946477fa29d5c64547d5 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:38:28 +0100 Subject: [PATCH 6/9] add logs --- src/deployer/MauveDeployer.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/deployer/MauveDeployer.ts b/src/deployer/MauveDeployer.ts index b443d04..c4608a7 100644 --- a/src/deployer/MauveDeployer.ts +++ b/src/deployer/MauveDeployer.ts @@ -195,7 +195,8 @@ export class MauveDeployer { weth9Address, "0x4554480000000000000000000000000000000000000000000000000000000000", ], - this.deployer + this.deployer, + { NFTDescriptor: nftDescriptorLibraryAddress } )) as Contract; } @@ -224,15 +225,23 @@ export class MauveDeployer { abi: any, bytecode: string, deployParams: Array, - actor: Signer + actor: Signer, + libraries?: Record ) { + console.log(`------------`); + console.log(`Deploying contract...`); + const factory = new ContractFactory(abi, bytecode, actor); const contract = await factory.deploy(...deployParams); + console.log(`🚀 Contract deployed! Waiting for 5 confirmations...`); + await contract.deployTransaction.wait(5); + try { await this.hre.run("verify:verify", { address: contract.address, constructorArguments: deployParams, + libraries, }); } catch (error) { console.log( @@ -240,6 +249,7 @@ export class MauveDeployer { ); } + console.log(`✅ Done deploying contract.`); return contract; } } From 4033a54e3c575416823349219048400ad384aeb4 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:45:21 +0100 Subject: [PATCH 7/9] use latest deployments addresses --- scripts/deployMauve.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deployMauve.ts b/scripts/deployMauve.ts index 8dd1e7d..4d643eb 100644 --- a/scripts/deployMauve.ts +++ b/scripts/deployMauve.ts @@ -4,8 +4,8 @@ import { deployMauve } from "../src/lib/deployMauve"; async function main() { const [signer] = await hre.ethers.getSigners(); - const eatVerifier = "0x5Dbe2B4648FFAF2867F8Ad07d42003F5ce4b7d2C"; - const violetId = "0x9A119a53cb065202d631ba01d55e3850eDcf3EAa"; + const eatVerifier = "0x638734c011F68d2C6d65c7529E02e65C8Fd3B401"; + const violetId = "0x4Bc70da1D9eF635949878E28e9940678af912540"; const { factory, From cbe76076f4f101ceea14d2a62206fa54d169d329 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:55:12 +0100 Subject: [PATCH 8/9] add missing log for Quoter V2 --- scripts/deployMauve.ts | 5 ++++- src/lib/deployMauve.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/deployMauve.ts b/scripts/deployMauve.ts index 4d643eb..f7b8aba 100644 --- a/scripts/deployMauve.ts +++ b/scripts/deployMauve.ts @@ -11,6 +11,7 @@ async function main() { factory, mauveSwapRouter, quoter, + quoterV2, positionManager, positionDescriptor, nftDescriptorLibrary, @@ -23,9 +24,11 @@ async function main() { eatVerifier ); + console.log(`----- ALL CONTRACTS DEPLOYED ------`); console.log(`Factory deployed at: ${factory.address}`); - console.log(`Router deployed at: ${mauveSwapRouter.address}`); + console.log(`Mauve Swap Router deployed at: ${mauveSwapRouter.address}`); console.log(`Quoter deployed at: ${quoter.address}`); + console.log(`Quoter V2 deployed at: ${quoterV2.address}`); console.log(`PositionManager deployed at: ${positionManager.address}`); console.log(`PositionDescriptor deployed at: ${positionDescriptor.address}`); console.log( diff --git a/src/lib/deployMauve.ts b/src/lib/deployMauve.ts index 9c5690b..5902211 100644 --- a/src/lib/deployMauve.ts +++ b/src/lib/deployMauve.ts @@ -16,6 +16,7 @@ export async function deployMauve( factory, mauveSwapRouter, quoter, + quoterV2, positionManager, positionDescriptor, nftDescriptorLibrary, @@ -32,6 +33,7 @@ export async function deployMauve( factory, mauveSwapRouter, quoter, + quoterV2, positionManager, positionDescriptor, nftDescriptorLibrary, From 17007b8265d016e66af07bea7b3716fb8661ca69 Mon Sep 17 00:00:00 2001 From: ra-phael <10075759+ra-phael@users.noreply.github.com> Date: Mon, 3 Jul 2023 12:05:46 +0100 Subject: [PATCH 9/9] remove API Key --- .env.example | 3 +++ hardhat.config.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 4fbca42..e5fd1f1 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,9 @@ PRIVATE_KEY=your_private_key INFURA_API_KEY=infura_key +# ALCHEMY +ALCHEMY_OP_GOERLI_KEY=op_goerli_key + # ETHERSCAN ETHERSCAN_API_KEY=XXXXX OPTIMISM_API_KEY=XXXXX \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 057d55e..8e02853 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -25,7 +25,7 @@ import { dotenvConfig({ path: resolve(__dirname, "./.env") }); if (!process.env.INFURA_API_KEY) { - throw new Error("Missing Infura API KEY"); + throw new Error("Missing OP API KEY"); } export default { @@ -62,7 +62,7 @@ export default { }, optimismGoerli: { accounts: [`0x${process.env.PRIVATE_KEY}`], - url: `https://opt-goerli.g.alchemy.com/v2/Ay4DBPd3SGpvm_8jJM-MS9MhHoqN8-dr`, + url: `https://opt-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_OP_GOERLI_KEY}`, gasPrice: 2000000000, }, optimism: {