|
| 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 { OP_SpokePool } from "../contracts/OP_SpokePool.sol"; |
| 8 | +import { DeploymentUtils } from "./utils/DeploymentUtils.sol"; |
| 9 | + |
| 10 | +// How to run: |
| 11 | +// 1. `source .env` where `.env` has MNEMONIC="x x x ... x" |
| 12 | +// 2. forge script script/025DeployOPSpokePool.s.sol:DeployOPSpokePool --rpc-url $NODE_URL_1 -vvvv |
| 13 | +// 3. Verify the above works in simulation mode. |
| 14 | +// 4. Deploy with: |
| 15 | +// forge script script/025DeployOPSpokePool.s.sol:DeployOPSpokePool --rpc-url \ |
| 16 | +// $NODE_URL_1 --broadcast --verify --verifier blockscout --verifier-url https://explorer.mode.network/api |
| 17 | + |
| 18 | +contract DeployOPSpokePool is Script, Test, DeploymentUtils { |
| 19 | + function run() external { |
| 20 | + string memory deployerMnemonic = vm.envString("MNEMONIC"); |
| 21 | + uint256 deployerPrivateKey = vm.deriveKey(deployerMnemonic, 0); |
| 22 | + |
| 23 | + // Get deployment information |
| 24 | + DeploymentInfo memory info = getSpokePoolDeploymentInfo(address(0)); |
| 25 | + |
| 26 | + // Get the appropriate addresses for this chain |
| 27 | + address weth = getWrappedNativeToken(info.spokeChainId); |
| 28 | + address cctpTokenMessenger = getL2Address(info.spokeChainId, "cctpV2TokenMessenger"); |
| 29 | + address l2Usdc = getUSDCAddress(info.spokeChainId); |
| 30 | + |
| 31 | + vm.startBroadcast(deployerPrivateKey); |
| 32 | + |
| 33 | + // Prepare constructor arguments for OP_SpokePool |
| 34 | + bytes memory constructorArgs = abi.encode( |
| 35 | + weth, // _wrappedNativeTokenAddress |
| 36 | + QUOTE_TIME_BUFFER(), // _depositQuoteTimeBuffer |
| 37 | + FILL_DEADLINE_BUFFER(), // _fillDeadlineBuffer |
| 38 | + l2Usdc, // _l2Usdc |
| 39 | + cctpTokenMessenger // _cctpTokenMessenger |
| 40 | + ); |
| 41 | + |
| 42 | + // Initialize deposit counter to 1 |
| 43 | + // Set hub pool as cross domain admin since it delegatecalls the Adapter logic. |
| 44 | + bytes memory initArgs = abi.encodeWithSelector( |
| 45 | + OP_SpokePool.initialize.selector, |
| 46 | + // Note: If this is a re-deployment of the spoke pool proxy, set this to a very high number of |
| 47 | + // deposits to avoid duplicate deposit IDs with deprecated spoke pool. Should be set to 1 otherwise. |
| 48 | + 1_000_000, // _initialDepositId |
| 49 | + info.hubPool, // _crossDomainAdmin |
| 50 | + info.hubPool // _withdrawalRecipient |
| 51 | + ); |
| 52 | + |
| 53 | + // Deploy the proxy |
| 54 | + DeploymentResult memory result = deployNewProxy( |
| 55 | + "OP_SpokePool", |
| 56 | + constructorArgs, |
| 57 | + initArgs, |
| 58 | + false // implementationOnly |
| 59 | + ); |
| 60 | + |
| 61 | + // Log the deployed addresses |
| 62 | + console.log("Chain ID:", info.spokeChainId); |
| 63 | + console.log("Hub Chain ID:", info.hubChainId); |
| 64 | + console.log("HubPool address:", info.hubPool); |
| 65 | + console.log("WETH address:", weth); |
| 66 | + console.log("OP_SpokePool proxy deployed to:", result.proxy); |
| 67 | + console.log("OP_SpokePool implementation deployed to:", result.implementation); |
| 68 | + |
| 69 | + console.log("QUOTE_TIME_BUFFER()", QUOTE_TIME_BUFFER()); |
| 70 | + console.log("FILL_DEADLINE_BUFFER()", FILL_DEADLINE_BUFFER()); |
| 71 | + |
| 72 | + vm.stopBroadcast(); |
| 73 | + } |
| 74 | +} |
0 commit comments