Skip to content

Commit

Permalink
Implement task to deploy ChildPool contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Nov 3, 2024
1 parent ac1bc92 commit 6beaf00
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 1 deletion.
34 changes: 33 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,32 @@ NETWORK_ETHEREUM := ethereum
# Hardhat contract addresses
HARDHAT_VALIDATOR_REGISTRY := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MATIC_X := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_CHILD_POOL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_STAKE_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_CHECKPOINT_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_ROOT := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_STATE_ROOT_TUNNEL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_STATE_CHILD_TUNNEL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MATIC_TOKEN := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_POL_TOKEN := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MANAGER := 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
HARDHAT_TREASURY := 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
HARDHAT_INSTANT_POOL_OWNER := 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

# Localhost contract addresses
LOCALHOST_VALIDATOR_REGISTRY :=
LOCALHOST_MATIC_X :=
LOCALHOST_CHILD_POOL :=
LOCALHOST_STAKE_MANAGER :=
LOCALHOST_CHECKPOINT_MANAGER :=
LOCALHOST_FX_ROOT :=
LOCALHOST_FX_STATE_ROOT_TUNNEL :=
LOCALHOST_FX_STATE_CHILD_TUNNEL :=
LOCALHOST_MATIC_TOKEN :=
LOCALHOST_POL_TOKEN :=
LOCALHOST_MANAGER :=
LOCALHOST_TREASURY :=
LOCALHOST_TREASURY :=
LOCALHOST_INSTANT_POOL_OWNER :=

# Sepolia contract addresses
SEPOLIA_VALIDATOR_REGISTRY := 0xE98fc808E8aE8025a1D17d6F4Fbc3Df226788438
Expand All @@ -49,6 +55,14 @@ SEPOLIA_POL_TOKEN := 0x44499312f493F62f2DFd3C6435Ca3603EbFCeeBa
SEPOLIA_MANAGER := 0x369B31971250859d3AD37E7cEDCF42AA5CF2C4F4
SEPOLIA_TREASURY := 0xdeb90df43BBa8FC0e2C08C54dC0F48cfc694F896

# Amoy contract addresses
AMOY_MATIC_X :=
AMOY_CHILD_POOL :=
AMOY_FX_STATE_CHLID_TUNNEL :=
AMOY_MANAGER :=
AMOY_TREASURY :=
AMOY_INSTANT_POOL_OWNER :=

# Ethereum contract addresses
ETHEREUM_VALIDATOR_REGISTRY := 0xf556442D5B77A4B0252630E15d8BbE2160870d77
ETHEREUM_MATIC_X := 0xf03A7Eb46d01d9EcAA104558C732Cf82f6B6B645
Expand All @@ -61,6 +75,14 @@ ETHEREUM_POL_TOKEN := 0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6
ETHEREUM_MANAGER := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
ETHEREUM_TREASURY := 0x01422247a1d15BB4FcF91F5A077Cf25BA6460130

# Polygon contract addresses
POLYGON_MATIC_X := 0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6
POLYGON_CHILD_POOL := 0xfd225C9e6601C9d38d8F98d8731BF59eFcF8C0E3
POLYGON_FX_STATE_CHILD_TUNNEL := 0x97E58a6950D86d751082D5e1d350e74c19047570
POLYGON_MANAGER := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
POLYGON_TREASURY := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
POLYGON_INSTANT_POOL_OWNER := 0x51358004cFe135E64453d7F6a0dC433CAba09A2a

# Contract paths
CONTRACT_PATH_VALIDATOR_REGISTRY := contracts/ValidatorRegistry.sol
CONTRACT_PATH_MATIC_X := contracts/MaticX.sol
Expand Down Expand Up @@ -91,6 +113,16 @@ deploy-maticx-sepolia:
deploy-maticx-ethereum:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_ETHEREUM) --validator-registry $(ETHEREUM_VALIDATOR_REGISTRY) --stake-manager $(ETHEREUM_STAKE_MANAGER) --matic-token $(ETHEREUM_MATIC_TOKEN) --manager $(ETHEREUM_MANAGER) --treasury $(ETHEREUM_TREASURY)

# Deploy the ChildPool contract
deploy-childpool-hardhat:
$(BIN_HARDHAT) deploy:child-pool --network $(NETWORK_HARDHAT) --fx-state-child-tunnel $(HARDHAT_FX_STATE_CHILD_TUNNEL) --matic-x $(HARDHAT_MATIC_X) --manager $(HARDHAT_MANAGER) --instant-pool-owner $(HARDHAT_INSTANT_POOL_OWNER) --treasury $(HARDHAT_TREASURY)
deploy-childpool-localhost:
$(BIN_HARDHAT) deploy:child-pool --network $(NETWORK_LOCALHOST) --fx-state-child-tunnel $(LOCALHOST_FX_STATE_CHILD_TUNNEL) --matic-x $(LOCALHOST_MATIC_X) --manager $(LOCALHOST_MANAGER) --instant-pool-owner $(LOCALHOST_INSTANT_POOL_OWNER) --treasury $(LOCALHOST_TREASURY)
deploy-childpool-amoy:
$(BIN_HARDHAT) deploy:child-pool --network $(NETWORK_AMOY) --fx-state-child-tunnel $(AMOY_FX_STATE_CHILD_TUNNEL) --matic-x $(AMOY_MATIC_X) --manager $(AMOY_MANAGER) --instant-pool-owner $(AMOY_INSTANT_POOL_OWNER) --treasury $(AMOY_TREASURY)
deploy-childpool-polygon:
$(BIN_HARDHAT) deploy:child-pool --network $(NETWORK_POLYGON) --fx-state-child-tunnel $(POLYGON_FX_STATE_CHILD_TUNNEL) --matic-x $(POLYGON_MATIC_X) --manager $(POLYGON_MANAGER) --instant-pool-owner $(POLYGON_INSTANT_POOL_OWNER) --treasury $(POLYGON_TREASURY)

# Deploy the FxStateRootTunnel contract
deploy-fxstateroottunnel-hardhat:
$(BIN_HARDHAT) deploy:fx-state-root-tunnel --network $(NETWORK_HARDHAT) --checkpoint-manager $(HARDHAT_CHECKPOINT_MANAGER) --fx-root $(HARDHAT_FX_ROOT) --matic-x $(HARDHAT_MATIC_X)
Expand Down
127 changes: 127 additions & 0 deletions tasks/deploy-child-pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { TASK_CLEAN, TASK_COMPILE } from "hardhat/builtin-tasks/task-names";
import { task, types } from "hardhat/config";
import { getSigner } from "../utils/account";
import { isLocalNetwork, Network } from "../utils/network";

interface TaskParams {
fxStateChildTunnel: string;
maticX: string;
manager: string;
instantPoolOwner: string;
treasury: string;
instantWithdrawalFeeBps: number;
}

task("deploy:child-pool")
.setDescription("Deploy the ChildPool contract")
.addParam<string>(
"fxStateChildTunnel",
"Address of the FxStateChildTunnel contract",
undefined,
types.string
)
.addParam<string>(
"maticX",
"Address of the MaticX contract",
undefined,
types.string
)
.addParam<string>(
"manager",
"Address of the Manager contract",
undefined,
types.string
)
.addParam<string>(
"instantPoolOwner",
"Address of the InstantPoolOwner contract",
undefined,
types.string
)
.addParam<string>(
"treasury",
"Address of the Treasury contract",
undefined,
types.string
)
.addParam<number>(
"instantWithdrawalFeeBps",
"Instant withdrawal fee base points",
50,
types.int
)
.setAction(
async (
{
fxStateChildTunnel: fxStateChildTunnelAddress,
maticX: maticXAddress,
manager: managerAddress,
instantPoolOwner: instantPoolOwnerAddress,
treasury: treasuryAddress,
instantWithdrawalFeeBps,
}: TaskParams,
{ ethers, network, run, upgrades }
) => {
if (!ethers.utils.isAddress(fxStateChildTunnelAddress)) {
throw new Error("Invalid FxStateChildTunnel address");
}
if (!ethers.utils.isAddress(maticXAddress)) {
throw new Error("Invalid MaticX address");
}
if (!ethers.utils.isAddress(managerAddress)) {
throw new Error("Invalid Manager address");
}
if (!ethers.utils.isAddress(instantPoolOwnerAddress)) {
throw new Error("Invalid InstantPoolOwner address");
}
if (!ethers.utils.isAddress(treasuryAddress)) {
throw new Error("Invalid Treasury address");
}

const networkName = network.name as Network;
console.log(`Network name: ${networkName}`);
if (!isLocalNetwork(networkName)) {
await run(TASK_CLEAN);
}
await run(TASK_COMPILE);

const signer = await getSigner(
ethers,
network.provider,
network.config.from
);
const ChildPool = await ethers.getContractFactory(
"ChildPool",
signer
);

const childPool = await upgrades.deployProxy(
ChildPool,
[
fxStateChildTunnelAddress,
maticXAddress,
managerAddress,
instantPoolOwnerAddress,
treasuryAddress,
instantWithdrawalFeeBps,
],
{ kind: "transparent" }
);
await childPool.deployed();
console.log(`ChildPool Proxy deployed at ${childPool.address}`);

const implementationAddress =
await upgrades.erc1967.getImplementationAddress(
childPool.address
);
console.log(
`ChildPool Implementation deployed at ${implementationAddress}`
);
const proxyAdminAddress = await upgrades.erc1967.getAdminAddress(
childPool.address
);
console.log(
`ChildPool ProxyAdmin deployed at ${proxyAdminAddress}`
);
}
);
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./deploy-child-pool";
import "./deploy-fx-state-root-tunnel";
import "./deploy-matic-x";
import "./deploy-validator-registry";
Expand Down

0 comments on commit 6beaf00

Please sign in to comment.