|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import { Script } from "forge-std/Script.sol"; |
| 5 | +import { Test } from "forge-std/Test.sol"; |
| 6 | +import { console } from "forge-std/console.sol"; |
| 7 | +import { Arbitrum_SpokePool } from "../contracts/Arbitrum_SpokePool.sol"; |
| 8 | +import { WETH9Interface } from "../contracts/external/interfaces/WETH9Interface.sol"; |
| 9 | +import { DeploymentUtils } from "./utils/DeploymentUtils.sol"; |
| 10 | + |
| 11 | +// How to run: |
| 12 | +// 1. `source .env` where `.env` has MNEMONIC="x x x ... x" |
| 13 | +// 2. forge script script/008DeployArbitrumSpokePool.s.sol:DeployArbitrumSpokePool --rpc-url $NODE_URL_1 -vvvv |
| 14 | +// 3. Verify the above works in simulation mode. |
| 15 | +// 4. Deploy with: forge script script/008DeployArbitrumSpokePool.s.sol:DeployArbitrumSpokePool --rpc-url $NODE_URL_1 --broadcast --verify |
| 16 | + |
| 17 | +contract DeployArbitrumSpokePool is Script, Test, DeploymentUtils { |
| 18 | + function run() external { |
| 19 | + string memory deployerMnemonic = vm.envString("MNEMONIC"); |
| 20 | + uint256 deployerPrivateKey = vm.deriveKey(deployerMnemonic, 0); |
| 21 | + |
| 22 | + // Get deployment information |
| 23 | + DeploymentInfo memory info = getSpokePoolDeploymentInfo(address(0)); |
| 24 | + |
| 25 | + console.log("HubPool address:", info.hubPool); |
| 26 | + |
| 27 | + // Get the appropriate addresses for this chain |
| 28 | + WETH9Interface weth = getWrappedNativeToken(info.spokeChainId); |
| 29 | + |
| 30 | + // Get L2 addresses for Arbitrum |
| 31 | + address l2GatewayRouter = getL2Address(info.spokeChainId, "l2GatewayRouter"); |
| 32 | + address cctpTokenMessenger = getL2Address(info.spokeChainId, "cctpTokenMessenger"); |
| 33 | + |
| 34 | + vm.startBroadcast(deployerPrivateKey); |
| 35 | + |
| 36 | + // Prepare constructor arguments for Arbitrum_SpokePool |
| 37 | + bytes memory constructorArgs = abi.encode( |
| 38 | + address(weth), // _weth |
| 39 | + QUOTE_TIME_BUFFER(), // _quoteTimeBuffer |
| 40 | + FILL_DEADLINE_BUFFER(), // _fillDeadlineBuffer |
| 41 | + getUSDCAddress(info.spokeChainId), // _usdc |
| 42 | + cctpTokenMessenger, // _cctpTokenMessenger |
| 43 | + getOftEid(info.hubChainId), // _oftDstEid |
| 44 | + 1 ether // _oftFeeCap |
| 45 | + ); |
| 46 | + |
| 47 | + // Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's |
| 48 | + // with deprecated spoke pool. |
| 49 | + bytes memory initArgs = abi.encodeWithSelector( |
| 50 | + Arbitrum_SpokePool.initialize.selector, |
| 51 | + 1_000_000, // _initialDepositId |
| 52 | + l2GatewayRouter, // _l2GatewayRouter |
| 53 | + info.hubPool, // _crossDomainAdmin |
| 54 | + info.hubPool // _hubPool |
| 55 | + ); |
| 56 | + |
| 57 | + // Deploy the proxy |
| 58 | + DeploymentResult memory result = deployNewProxy( |
| 59 | + "Arbitrum_SpokePool", |
| 60 | + constructorArgs, |
| 61 | + initArgs, |
| 62 | + true // implementationOnly |
| 63 | + ); |
| 64 | + |
| 65 | + // Log the deployed addresses |
| 66 | + console.log("Chain ID:", info.spokeChainId); |
| 67 | + console.log("Hub Chain ID:", info.hubChainId); |
| 68 | + console.log("HubPool address:", info.hubPool); |
| 69 | + console.log("WETH address:", address(weth)); |
| 70 | + console.log("L2 Gateway Router:", l2GatewayRouter); |
| 71 | + console.log("CCTP Token Messenger:", cctpTokenMessenger); |
| 72 | + console.log("USDC address:", getUSDCAddress(info.spokeChainId)); |
| 73 | + console.log("Arbitrum_SpokePool proxy deployed to:", result.proxy); |
| 74 | + console.log("Arbitrum_SpokePool implementation deployed to:", result.implementation); |
| 75 | + |
| 76 | + console.log("QUOTE_TIME_BUFFER()", QUOTE_TIME_BUFFER()); |
| 77 | + console.log("FILL_DEADLINE_BUFFER()", FILL_DEADLINE_BUFFER()); |
| 78 | + console.log("OFT EID", getOftEid(info.hubChainId)); |
| 79 | + |
| 80 | + vm.stopBroadcast(); |
| 81 | + } |
| 82 | +} |
0 commit comments