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
13 changes: 4 additions & 9 deletions deploy/001_deploy_hubpool.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { L1_ADDRESS_MAP } from "./consts";

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

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

const { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());

const lpTokenFactory = await deploy("LpTokenFactory", { from: deployer, log: true, skipIfAlreadyDeployed: true });

await deploy("HubPool", {
Expand All @@ -20,8 +15,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [
lpTokenFactory.address,
L1_ADDRESS_MAP[chainId].finder,
L1_ADDRESS_MAP[chainId].weth,
"0x0000000000000000000000000000000000000000",
WETH[chainId],
ZERO_ADDRESS,
],
libraries: { MerkleLib: lpTokenFactory.address },
});
Expand Down
11 changes: 4 additions & 7 deletions deploy/002_deploy_optimism_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
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";

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

const { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
const { deployer } = await getNamedAccounts();

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
18 changes: 6 additions & 12 deletions deploy/003_deploy_optimism_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { FILL_DEADLINE_BUFFER, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -15,17 +15,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
hubPool.address,
];

// Construct this spokepool with a:
// * A WETH address of the WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
pxrl marked this conversation as resolved.
Show resolved Hide resolved
"0x4200000000000000000000000000000000000006",
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
WETH[spokeChainId],
QUOTE_TIME_BUFFER,
FILL_DEADLINE_BUFFER,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Optimism_SpokePool", constructorArgs, initArgs);
Expand Down
11 changes: 4 additions & 7 deletions deploy/004_deploy_arbitrum_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { L1_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, USDC } from "./consts";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());

// This address receives gas refunds on the L2 after messages are relayed. Currently
Expand All @@ -18,7 +15,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 +26,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
18 changes: 6 additions & 12 deletions deploy/005_deploy_arbitrum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { FILL_DEADLINE_BUFFER, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -16,17 +16,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
hubPool.address,
];

// Construct this spokepool with a:
// * A WETH address of the WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
// * Native USDC address on L2
// * CCTP token messenger address on L2
const constructorArgs = [
L2_ADDRESS_MAP[spokeChainId].l2Weth,
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
WETH[spokeChainId],
QUOTE_TIME_BUFFER,
FILL_DEADLINE_BUFFER,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Arbitrum_SpokePool", constructorArgs, initArgs);
Expand Down
4 changes: 1 addition & 3 deletions deploy/006_deploy_ethereum_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const { deployments: { deploy }, getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();

await deploy("Ethereum_Adapter", {
Expand Down
8 changes: 2 additions & 6 deletions deploy/007_deploy_ethereum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { L1_ADDRESS_MAP } from "./consts";
import { FILL_DEADLINE_BUFFER, QUOTE_TIME_BUFFER, WETH } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -11,11 +11,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// with deprecated spoke pool.
const initArgs = [1_000_000, hubPool.address];

// Construct this spokepool with a:
// * A WETH address of the WETH address
// * A depositQuoteTimeBuffer of 1 hour
// * A fillDeadlineBuffer of 6 hours
const constructorArgs = [L1_ADDRESS_MAP[spokeChainId].weth, 3600, 21600];
const constructorArgs = [WETH[spokeChainId], QUOTE_TIME_BUFFER, FILL_DEADLINE_BUFFER];
await deployNewProxy("Ethereum_SpokePool", constructorArgs, initArgs);

// 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
16 changes: 8 additions & 8 deletions deploy/009_deploy_polygon_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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 func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;
const MATIC = TOKEN_SYMBOLS_MAP.MATIC.addresses;

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

const chainId = parseInt(await getChainId());

const args = [
L1_ADDRESS_MAP[chainId].polygonRootChainManager,
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
21 changes: 9 additions & 12 deletions deploy/010_deploy_polygon_token_bridger_polygon.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
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 { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
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 +15,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
12 changes: 6 additions & 6 deletions deploy/011_deploy_polygon_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { FILL_DEADLINE_BUFFER, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, WMATIC } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -26,10 +26,10 @@ 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,
3600,
21600,
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
WMATIC[spokeChainId],
QUOTE_TIME_BUFFER,
FILL_DEADLINE_BUFFER,
USDC[spokeChainId],
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
];
await deployNewProxy("Polygon_SpokePool", constructorArgs, initArgs);
Expand Down
13 changes: 3 additions & 10 deletions deploy/012_deploy_boba_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
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) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

const { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());

await deploy("Boba_Adapter", {
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
9 changes: 7 additions & 2 deletions deploy/013_deploy_boba_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DeployFunction } from "hardhat-deploy/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { FILL_DEADLINE_BUFFER, QUOTE_TIME_BUFFER } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool } = await getSpokePoolDeploymentInfo(hre);
Expand All @@ -14,7 +15,11 @@ 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 = ["0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000", 3600, 21600];
const constructorArgs = [
"0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
QUOTE_TIME_BUFFER,
FILL_DEADLINE_BUFFER
];
await deployNewProxy("Boba_SpokePool", constructorArgs, initArgs);
};
module.exports = func;
Expand Down
4 changes: 1 addition & 3 deletions deploy/014_deploy_config_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const { deployments: { deploy }, getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();

await deploy("AcrossConfigStore", {
Expand Down
9 changes: 3 additions & 6 deletions deploy/015_deploy_zksync_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
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;

const { deploy } = deployments;

const { deployments: { deploy }, getNamedAccounts, getChainId } = hre;
const { deployer } = await getNamedAccounts();
const chainId = parseInt(await getChainId());

Expand All @@ -15,7 +12,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
Loading
Loading