|
| 1 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | +pragma solidity 0.8.26; |
| 3 | + |
| 4 | +// system contracts |
| 5 | +import {RollupOrders} from "../src/orders/RollupOrders.sol"; |
| 6 | +import {RollupPassage} from "../src/passage/RollupPassage.sol"; |
| 7 | +// permit2 |
| 8 | +import {deployPermit2} from "./DeployPermit2.s.sol"; |
| 9 | +// gnosis safe |
| 10 | +import {deployGnosisCore, deploySafeInstance, SafeSetup} from "./DeployGnosisSafe.s.sol"; |
| 11 | +// simple erc20 |
| 12 | +import {SimpleERC20} from "simple-erc20/SimpleERC20.sol"; |
| 13 | +// utils |
| 14 | +import {console2} from "forge-std/Script.sol"; |
| 15 | + |
| 16 | +address constant MINTER = 0x9999999999999999999999999999999999999999; |
| 17 | +address constant OWNER_ONE = 0x1111111111111111111111111111111111111111; |
| 18 | +address constant OWNER_TWO = 0x2222222222222222222222222222222222222222; |
| 19 | + |
| 20 | +address constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3; |
| 21 | + |
| 22 | +function deployPartOne() returns (address rollupPassage, address rollupOrders, address wbtc, address usdt) { |
| 23 | + // NOTE: must deploy Permit2 via https://github.com/Uniswap/permit2/blob/main/script/DeployPermit2.s.sol |
| 24 | + // in order to properly setup _CACHED_CHAIN_ID and _CACHED_DOMAIN_SEPARATOR |
| 25 | + |
| 26 | + // deploy system contracts |
| 27 | + rollupPassage = address(new RollupPassage{salt: "zenith.rollupPassage"}(PERMIT2)); |
| 28 | + console2.log("rollupPassage", rollupPassage); |
| 29 | + rollupOrders = address(new RollupOrders{salt: "zenith.rollupOrders"}(PERMIT2)); |
| 30 | + console2.log("rollupOrders", rollupOrders); |
| 31 | + |
| 32 | + // deploy simple erc20 tokens |
| 33 | + // make minter a recognizable addrs to aid in inspecting storage layout |
| 34 | + wbtc = address(new SimpleERC20{salt: "zenith.wbtc"}(MINTER, "Wrapped BTC", "WBTC")); |
| 35 | + usdt = address(new SimpleERC20{salt: "zenith.usdt"}(MINTER, "Tether USD", "USDT")); |
| 36 | + console2.log("wbtc", wbtc); |
| 37 | + console2.log("usdt", usdt); |
| 38 | +} |
| 39 | + |
| 40 | +function deployPartTwo() |
| 41 | + returns (address gnosisFactory, address gnosisSingleton, address gnosisFallbackHandler, address usdcAdmin) |
| 42 | +{ |
| 43 | + // deploy gnosis safe singleton & proxy factory |
| 44 | + (gnosisFactory, gnosisSingleton, gnosisFallbackHandler) = deployGnosisCore(); |
| 45 | + console2.log("gnosisFactory", gnosisFactory); |
| 46 | + console2.log("gnosisSingleton", gnosisSingleton); |
| 47 | + console2.log("gnosisFallbackHandler", gnosisFallbackHandler); |
| 48 | + |
| 49 | + // deploy a gnosis safe proxy as the USDC admin |
| 50 | + usdcAdmin = deploySafeInstance(gnosisFactory, gnosisSingleton, getUsdcAdminSetup(gnosisFallbackHandler)); |
| 51 | + console2.log("usdcAdmin", usdcAdmin); |
| 52 | + |
| 53 | + // NOTE: must deploy USDC via https://github.com/circlefin/stablecoin-evm/blob/master/scripts/deploy/deploy-fiat-token.s.sol |
| 54 | + // cannot import USDC deploy script because of git submodules - |
| 55 | + // it has a different remapping for openzeppelin contracts and can't compile in this repo |
| 56 | +} |
| 57 | + |
| 58 | +// setup the gnosis safe with 2 owners, threshold of 1. |
| 59 | +// make the owners recognizable addrs to aid in inspecting storage layout |
| 60 | +function getUsdcAdminSetup(address fallbackHandler) pure returns (SafeSetup memory usdcAdminSetup) { |
| 61 | + address[] memory owners = new address[](2); |
| 62 | + owners[0] = OWNER_ONE; |
| 63 | + owners[1] = OWNER_TWO; |
| 64 | + usdcAdminSetup = SafeSetup({ |
| 65 | + owners: owners, |
| 66 | + threshold: 1, |
| 67 | + to: address(0), |
| 68 | + data: "", |
| 69 | + fallbackHandler: fallbackHandler, |
| 70 | + paymentToken: address(0), |
| 71 | + payment: 0, |
| 72 | + paymentReceiver: payable(address(0)), |
| 73 | + saltNonce: 17001 |
| 74 | + }); |
| 75 | +} |
0 commit comments