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

refactor: Deployment script cleanup #561

Merged
merged 19 commits into from
Aug 22, 2024
5 changes: 2 additions & 3 deletions deploy/001_deploy_hubpool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { L1_ADDRESS_MAP } from "./consts";

import { L1_ADDRESS_MAP, WETH } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -20,7 +19,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [
lpTokenFactory.address,
L1_ADDRESS_MAP[chainId].finder,
L1_ADDRESS_MAP[chainId].weth,
WETH[chainId],
"0x0000000000000000000000000000000000000000",
],
libraries: { MerkleLib: lpTokenFactory.address },
Expand Down
6 changes: 3 additions & 3 deletions deploy/002_deploy_optimism_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, USDC, WETH } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -11,10 +11,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const chainId = parseInt(await getChainId());

const args = [
L1_ADDRESS_MAP[chainId].weth,
WETH[chainId],
L1_ADDRESS_MAP[chainId].optimismCrossDomainMessenger,
L1_ADDRESS_MAP[chainId].optimismStandardBridge,
L1_ADDRESS_MAP[chainId].usdc,
USDC[chainId],
L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
];
const instance = await deploy("Optimism_Adapter", {
Expand Down
11 changes: 6 additions & 5 deletions deploy/003_deploy_optimism_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L2_ADDRESS_MAP } from "./consts";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { CHAIN_IDs } from "../utils";
import { L2_ADDRESS_MAP, USDC, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -22,13 +23,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
"0x4200000000000000000000000000000000000006",
WETH[spokeChainId],
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Optimism_SpokePool", constructorArgs, initArgs, spokeChainId === 10);
await deployNewProxy("Optimism_SpokePool", constructorArgs, initArgs, spokeChainId === CHAIN_IDs.OPTIMISM);
};
pxrl marked this conversation as resolved.
Show resolved Hide resolved
module.exports = func;
func.tags = ["OptimismSpokePool", "optimism"];
6 changes: 3 additions & 3 deletions deploy/004_deploy_arbitrum_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, USDC } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -18,7 +18,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
L1_ADDRESS_MAP[chainId].l1ArbitrumInbox,
L1_ADDRESS_MAP[chainId].l1ERC20GatewayRouter,
l2RefundAddress,
L1_ADDRESS_MAP[chainId].usdc,
USDC[chainId],
L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
];
const instance = await deploy("Arbitrum_Adapter", {
Expand All @@ -29,7 +29,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
L1_ADDRESS_MAP[chainId].l1ArbitrumInbox,
L1_ADDRESS_MAP[chainId].l1ERC20GatewayRouter,
l2RefundAddress,
L1_ADDRESS_MAP[chainId].usdc,
USDC[chainId],
L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
],
});
Expand Down
11 changes: 6 additions & 5 deletions deploy/005_deploy_arbitrum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DeployFunction } from "hardhat-deploy/types";
import { L2_ADDRESS_MAP } from "./consts";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { CHAIN_IDs } from "../utils";
import { L2_ADDRESS_MAP, USDC, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -23,13 +24,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
L2_ADDRESS_MAP[spokeChainId].l2Weth,
WETH[spokeChainId],
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Arbitrum_SpokePool", constructorArgs, initArgs, spokeChainId === 42161);
await deployNewProxy("Arbitrum_SpokePool", constructorArgs, initArgs, spokeChainId === CHAIN_IDs.ARBITRUM);
};
module.exports = func;
func.tags = ["ArbitrumSpokePool", "arbitrum"];
4 changes: 2 additions & 2 deletions deploy/007_deploy_ethereum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeployFunction } from "hardhat-deploy/types";
import { deployNewProxy } from "../utils/utils.hre";
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, WETH } from "./consts";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand All @@ -17,7 +17,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * A WETH address of the WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
const constructorArgs = [L1_ADDRESS_MAP[chainId].weth, 3600, 21600];
const constructorArgs = [WETH[chainId], 3600, 21600];
await deployNewProxy("Ethereum_SpokePool", constructorArgs, initArgs, chainId === "1");

// Transfer ownership to hub pool.
Expand Down
15 changes: 8 additions & 7 deletions deploy/008_deploy_polygon_token_bridger_mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { DeployFunction } from "hardhat-deploy/types";
import { L1_ADDRESS_MAP, POLYGON_CHAIN_IDS } from "./consts";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L1_ADDRESS_MAP, POLYGON_CHAIN_IDS, WETH, WMATIC } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());
const hubChainId = parseInt(await getChainId());
const spokeChainId = POLYGON_CHAIN_IDS[hubChainId];
const hubPool = await deployments.get("HubPool");

await deploy("PolygonTokenBridger", {
Expand All @@ -17,11 +18,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
skipIfAlreadyDeployed: true,
args: [
hubPool.address,
L1_ADDRESS_MAP[chainId].polygonRegistry,
L1_ADDRESS_MAP[chainId].weth,
L1_ADDRESS_MAP[chainId].l2WrappedMatic,
chainId,
POLYGON_CHAIN_IDS[chainId],
L1_ADDRESS_MAP[hubChainId].polygonRegistry,
WETH[hubChainId],
WMATIC[spokeChainId],
hubChainId,
spokeChainId,
],
deterministicDeployment: "0x1234", // Salt for the create2 call.
});
Expand Down
11 changes: 7 additions & 4 deletions deploy/009_deploy_polygon_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { DeployFunction } from "hardhat-deploy/types";
import { L1_ADDRESS_MAP } from "./consts";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { TOKEN_SYMBOLS_MAP } from "../utils";
import { L1_ADDRESS_MAP, USDC, WETH } from "./consts";

const MATIC = TOKEN_SYMBOLS_MAP.MATIC.addresses;

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
Expand All @@ -15,9 +18,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
L1_ADDRESS_MAP[chainId].polygonFxRoot,
L1_ADDRESS_MAP[chainId].polygonDepositManager,
L1_ADDRESS_MAP[chainId].polygonERC20Predicate,
L1_ADDRESS_MAP[chainId].matic,
L1_ADDRESS_MAP[chainId].weth,
L1_ADDRESS_MAP[chainId].usdc,
MATIC[chainId],
WETH[chainId],
USDC[chainId],
L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
];
const instance = await deploy("Polygon_Adapter", {
Expand Down
16 changes: 8 additions & 8 deletions deploy/010_deploy_polygon_token_bridger_polygon.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { DeployFunction } from "hardhat-deploy/types";
import { L1_ADDRESS_MAP } from "./consts";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L1_ADDRESS_MAP, WETH, WMATIC } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());
const l1ChainId = parseInt(await hre.companionNetworks.l1.getChainId());
const spokeChainId = parseInt(await getChainId());
const hubChainId = parseInt(await hre.companionNetworks.l1.getChainId());
const l1HubPool = await hre.companionNetworks.l1.deployments.get("HubPool");

await deploy("PolygonTokenBridger", {
Expand All @@ -18,11 +18,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
skipIfAlreadyDeployed: true,
args: [
l1HubPool.address,
L1_ADDRESS_MAP[l1ChainId].polygonRegistry,
L1_ADDRESS_MAP[l1ChainId].weth,
L1_ADDRESS_MAP[l1ChainId].l2WrappedMatic,
l1ChainId,
chainId,
L1_ADDRESS_MAP[hubChainId].polygonRegistry,
WETH[hubChainId],
WMATIC[spokeChainId],
hubChainId,
spokeChainId,
],
deterministicDeployment: "0x1234", // Salt for the create2 call.
});
Expand Down
11 changes: 6 additions & 5 deletions deploy/011_deploy_polygon_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DeployFunction } from "hardhat-deploy/types";
import { L2_ADDRESS_MAP } from "./consts";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { CHAIN_IDs } from "../utils";
import { L2_ADDRESS_MAP, USDC, WMATIC } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -26,13 +27,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
L2_ADDRESS_MAP[spokeChainId].wMatic,
WMATIC[spokeChainId],
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Polygon_SpokePool", constructorArgs, initArgs, spokeChainId === 137);
await deployNewProxy("Polygon_SpokePool", constructorArgs, initArgs, spokeChainId === CHAIN_IDs.POLYGON);
};

module.exports = func;
Expand Down
8 changes: 2 additions & 6 deletions deploy/012_deploy_boba_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, WETH } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand All @@ -14,11 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
L1_ADDRESS_MAP[chainId].weth,
L1_ADDRESS_MAP[chainId].bobaCrossDomainMessenger,
L1_ADDRESS_MAP[chainId].bobaStandardBridge,
],
args: [WETH[chainId], L1_ADDRESS_MAP[chainId].bobaCrossDomainMessenger, L1_ADDRESS_MAP[chainId].bobaStandardBridge],
});
};

Expand Down
4 changes: 2 additions & 2 deletions deploy/015_deploy_zksync_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L1_ADDRESS_MAP } from "./consts";
import { WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
Expand All @@ -15,7 +15,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
log: true,
skipIfAlreadyDeployed: true,
// Most common across dataworker set as the refund address, but changeable by whoever runs the script.
args: [L1_ADDRESS_MAP[chainId].weth, "0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010"],
args: [WETH[chainId], "0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010"],
});
};

Expand Down
9 changes: 5 additions & 4 deletions deploy/016_deploy_zksync_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as zk from "zksync-web3";
import { Deployer as zkDeployer } from "@matterlabs/hardhat-zksync-deploy";
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
import { L2_ADDRESS_MAP } from "./consts";
import { CHAIN_IDs } from "../utils";
import { L2_ADDRESS_MAP, WETH } from "./consts";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getSpokePoolDeploymentInfo } from "../utils/utils.hre";

Expand All @@ -27,12 +28,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * A WETH address of the WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
const constructorArgs = [L2_ADDRESS_MAP[spokeChainId].l2Weth, 3600, 21600];
const constructorArgs = [WETH[spokeChainId], 3600, 21600];

let newAddress;
let newAddress: string;
// On production, we'll rarely want to deploy a new proxy contract so we'll default to deploying a new implementation
// contract.
if (spokeChainId === 324) {
if (spokeChainId === CHAIN_IDs.ZK_SYNC) {
const _deployment = await deployer.deploy(artifact, constructorArgs);
newAddress = _deployment.address;
console.log(`New ${contractName} implementation deployed @ ${newAddress}`);
Expand Down
4 changes: 2 additions & 2 deletions deploy/022_upgrade_spokepool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { getContractFactory } from "../utils";
import * as deployments from "../deployments/deployments.json";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L1_ADDRESS_MAP } from "./consts";
import { WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { upgrades, run, getChainId, getNamedAccounts } = hre;
Expand All @@ -16,7 +16,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const newImplementation = await upgrades.prepareUpgrade(
spokePool.address,
await getContractFactory("Ethereum_SpokePool", deployer),
{ constructorArgs: [L1_ADDRESS_MAP[chainId].weth, 3600, 32400] }
{ constructorArgs: [WETH[chainId], 3600, 32400] }
);
console.log(`Can upgrade to new implementation @ ${newImplementation}`);

Expand Down
6 changes: 3 additions & 3 deletions deploy/024_deploy_base_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, USDC, WETH } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -11,10 +11,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const chainId = parseInt(await getChainId());

const args = [
L1_ADDRESS_MAP[chainId].weth,
WETH[chainId],
L1_ADDRESS_MAP[chainId].baseCrossDomainMessenger,
L1_ADDRESS_MAP[chainId].baseStandardBridge,
L1_ADDRESS_MAP[chainId].usdc,
USDC[chainId],
L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
];
const instance = await deploy("Base_Adapter", {
Expand Down
11 changes: 6 additions & 5 deletions deploy/025_deploy_base_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { L2_ADDRESS_MAP } from "./consts";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { CHAIN_IDs } from "../utils";
import { L2_ADDRESS_MAP, USDC, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -21,13 +22,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
"0x4200000000000000000000000000000000000006",
WETH[spokeChainId],
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Base_SpokePool", constructorArgs, initArgs, spokeChainId === 8453);
await deployNewProxy("Base_SpokePool", constructorArgs, initArgs, spokeChainId === CHAIN_IDs.BASE);
};
module.exports = func;
func.tags = ["BaseSpokePool", "base"];
4 changes: 2 additions & 2 deletions deploy/027_deploy_scroll_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { L2_ADDRESS_MAP } from "./consts";
import { L2_ADDRESS_MAP, WETH } from "./consts";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
Expand All @@ -22,7 +22,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// * A WETH address of the L2 WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
const constructorArgs = [L2_ADDRESS_MAP[chainId].l2Weth, 3600, 21600];
const constructorArgs = [WETH[chainId], 3600, 21600];

await deployNewProxy("Scroll_SpokePool", constructorArgs, initArgs);
};
Expand Down
Loading
Loading