|
| 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 { Universal_SpokePool } from "../contracts/Universal_SpokePool.sol"; |
| 8 | +import { DeploymentUtils } from "./utils/DeploymentUtils.sol"; |
| 9 | +import { ITokenMessenger } from "../contracts/external/interfaces/CCTPInterfaces.sol"; |
| 10 | + |
| 11 | +// How to run: |
| 12 | +// 1. `source .env` where `.env` has MNEMONIC="x x x ... x" |
| 13 | +// 2. forge script script/111DeployUniversalSpokePool.s.sol:DeployUniversalSpokePool --sig "run(uint256)" <OFT_FEE_CAP> --rpc-url $NODE_URL_143 -vvvv |
| 14 | +// 3. Verify the above works in simulation mode. |
| 15 | +// 4. Deploy with: |
| 16 | +// forge script script/110DeployUniversalAdapter.s.sol:DeployUniversalAdapter --sig "run(uint256)" <OFT_FEE_CAP e.g. 78000> --rpc-url \ |
| 17 | +// $NODE_URL_143 --broadcast --verifier @todo --verifier-url @todo |
| 18 | + |
| 19 | +contract DeployUniversalSpokePool is Script, Test, DeploymentUtils { |
| 20 | + function run() external pure { |
| 21 | + revert("Not implemented, see script for run instructions"); |
| 22 | + } |
| 23 | + function run(uint256 oftFeeCap) external { |
| 24 | + string memory deployerMnemonic = vm.envString("MNEMONIC"); |
| 25 | + uint256 deployerPrivateKey = vm.deriveKey(deployerMnemonic, 0); |
| 26 | + |
| 27 | + // Get deployment information |
| 28 | + DeploymentInfo memory info = getSpokePoolDeploymentInfo(address(0)); |
| 29 | + |
| 30 | + // Get the appropriate addresses for this chain |
| 31 | + address wrappedNativeToken = getWrappedNativeToken(info.spokeChainId); |
| 32 | + |
| 33 | + // Get USDC address for this chain |
| 34 | + address usdcAddress = getUSDCAddress(info.spokeChainId); |
| 35 | + |
| 36 | + vm.startBroadcast(deployerPrivateKey); |
| 37 | + |
| 38 | + uint256 heliosAdminBufferUpdateSeconds = 1 days; |
| 39 | + address helios = getL2Address(info.spokeChainId, "helios"); |
| 40 | + address l1HubPoolStore = getL1Addresses(info.hubChainId).hubPoolStore; |
| 41 | + |
| 42 | + bool hasCctpDomain = hasCctpDomain(info.spokeChainId); |
| 43 | + address cctpTokenMessenger = hasCctpDomain |
| 44 | + ? getL2Address(info.spokeChainId, "cctpV2TokenMessenger") |
| 45 | + : address(0); |
| 46 | + uint32 oftDstEid = uint32(getOftEid(info.hubChainId)); |
| 47 | + |
| 48 | + // Prepare constructor arguments for Universal_SpokePool |
| 49 | + bytes memory constructorArgs = abi.encode( |
| 50 | + heliosAdminBufferUpdateSeconds, |
| 51 | + helios, |
| 52 | + l1HubPoolStore, |
| 53 | + wrappedNativeToken, |
| 54 | + QUOTE_TIME_BUFFER(), // _depositQuoteTimeBuffer |
| 55 | + FILL_DEADLINE_BUFFER(), // _fillDeadlineBuffer |
| 56 | + usdcAddress, |
| 57 | + cctpTokenMessenger, |
| 58 | + oftDstEid, |
| 59 | + oftFeeCap |
| 60 | + ); |
| 61 | + |
| 62 | + // Initialize deposit counter to 1 |
| 63 | + // Set hub pool as cross domain admin since it delegatecalls the Adapter logic. |
| 64 | + bytes memory initArgs = abi.encodeWithSelector( |
| 65 | + Universal_SpokePool.initialize.selector, |
| 66 | + 1, // _initialDepositId |
| 67 | + info.hubPool, // _crossDomainAdmin |
| 68 | + info.hubPool // _withdrawalRecipient |
| 69 | + ); |
| 70 | + |
| 71 | + // Deploy the proxy |
| 72 | + DeploymentResult memory result = deployNewProxy( |
| 73 | + "Universal_SpokePool", |
| 74 | + constructorArgs, |
| 75 | + initArgs, |
| 76 | + true // implementationOnly |
| 77 | + ); |
| 78 | + |
| 79 | + // Log the deployed addresses |
| 80 | + console.log("Chain ID:", info.spokeChainId); |
| 81 | + console.log("Hub Chain ID:", info.hubChainId); |
| 82 | + console.log("HubPool address:", info.hubPool); |
| 83 | + console.log("Helios address:", helios); |
| 84 | + console.log("L1 HubPoolStore address:", l1HubPoolStore); |
| 85 | + console.log("Wrapped Native Token address:", weth); |
| 86 | + console.log("USDC address:", usdcAddress); |
| 87 | + console.log("CCTP Token Messenger:", cctpTokenMessenger); |
| 88 | + console.log("OFT DST EID:", oftDstEid); |
| 89 | + console.log("OFT Fee Cap:", oftFeeCap); |
| 90 | + console.log("Universal_SpokePool proxy deployed to:", result.proxy); |
| 91 | + console.log("Universal_SpokePool implementation deployed to:", result.implementation); |
| 92 | + |
| 93 | + console.log("QUOTE_TIME_BUFFER()", QUOTE_TIME_BUFFER()); |
| 94 | + console.log("FILL_DEADLINE_BUFFER()", FILL_DEADLINE_BUFFER()); |
| 95 | + |
| 96 | + vm.stopBroadcast(); |
| 97 | + } |
| 98 | +} |
0 commit comments