@@ -6,6 +6,7 @@ import {console2 as console} from "forge-std/console2.sol";
66import {stdJson} from "forge-std/StdJson.sol " ;
77
88import {UpgradeableBurnMintTokenPool} from "./../src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol " ;
9+ import {ITypeAndVersion} from "./../src/v0.8/shared/interfaces/ITypeAndVersion.sol " ;
910import {ITransparentProxyFactory} from "solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol " ;
1011import {IERC20Metadata } from "solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol " ;
1112
@@ -14,49 +15,56 @@ interface IProxyAdmin {
1415}
1516
1617struct Config {
17- IERC20Metadata GHO_TOKEN;
18+ address GHO_TOKEN;
1819 address OWNER;
19- ITransparentProxyFactory PROXY_FACTORY;
20+ address PROXY_FACTORY;
2021 address RMN_PROXY;
2122 address ROUTER;
2223}
2324
25+ /// @notice Deploys UpgradeableBurnMintTokenPool behind a transparent upgradable proxy for GHO.
26+ /// Pre-requisite: add parameters to config.json, the with key as `chainId` of the target network.
27+ /// Usage: forge script DeployUpgradableBurnMintTokenPool --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast --verify --etherscan-api-key <ETHERSCAN_API_KEY>
2428contract DeployUpgradableBurnMintTokenPool is Script {
2529 using stdJson for string ;
2630
2731 function run () external {
28- Config memory config = this .parseConfig ();
29- uint8 TOKEN_DECIMALS = _validateTokenAndFetchDecimals (config.GHO_TOKEN);
32+ Config memory config = _parseConfig ();
3033
34+ uint8 TOKEN_DECIMALS = IERC20Metadata (config.GHO_TOKEN).decimals ();
3135 address [] memory ALLOW_LIST = new address [](0 );
3236 bool ALLOW_LIST_ENABLED = false ;
3337
3438 vm.startBroadcast ();
3539 address tokenPool = address (
36- new UpgradeableBurnMintTokenPool (address ( config.GHO_TOKEN) , TOKEN_DECIMALS, config.RMN_PROXY, ALLOW_LIST_ENABLED)
40+ new UpgradeableBurnMintTokenPool (config.GHO_TOKEN, TOKEN_DECIMALS, config.RMN_PROXY, ALLOW_LIST_ENABLED)
3741 );
38- address tokenPoolProxy = config.PROXY_FACTORY.create (
42+ address tokenPoolProxy = ITransparentProxyFactory ( config.PROXY_FACTORY) .create (
3943 tokenPool,
4044 config.OWNER,
4145 abi.encodeCall (UpgradeableBurnMintTokenPool.initialize, (config.OWNER, ALLOW_LIST, config.ROUTER))
4246 );
4347 vm.stopBroadcast ();
4448
4549 console.log ("tokenPoolProxy: " , tokenPoolProxy);
46- console.log ("tokenPool: " , tokenPool);
50+ console.log ("tokenPool: " , tokenPool);
4751
4852 _validateProxyAdminVersion (tokenPoolProxy);
4953 }
5054
51- function parseConfig () external view returns (Config memory ) {
55+ function _parseConfig () internal view returns (Config memory ) {
5256 string memory config = vm.readFile (string .concat (vm.projectRoot (), "/script/config.json " ));
53- return abi.decode (vm.parseJson (config, string .concat (". " , vm.toString (block .chainid ))), (Config));
57+ return _validate ( abi.decode (vm.parseJson (config, string .concat (". " , vm.toString (block .chainid ))), (Config) ));
5458 }
5559
56- function _validateTokenAndFetchDecimals (IERC20Metadata token ) internal view returns (uint8 ) {
57- require (_cmp (token.name (), "Gho Token " ), "InvalidToken " );
58- require (_cmp (token.symbol (), "GHO " ), "InvalidToken " );
59- return token.decimals ();
60+ function _validate (Config memory config ) internal view returns (Config memory ) {
61+ require (address (config.OWNER) != address (0 ), "InvalidOwner " );
62+ require (address (config.PROXY_FACTORY) != address (0 ), "InvalidProxyFactory " );
63+ require (_cmp (IERC20Metadata (config.GHO_TOKEN).name (), "Gho Token " ), "InvalidToken " );
64+ require (_cmp (IERC20Metadata (config.GHO_TOKEN).symbol (), "GHO " ), "InvalidToken " );
65+ require (_cmp (ITypeAndVersion (config.RMN_PROXY).typeAndVersion (), "ARMProxy 1.0.0 " ), "InvalidRmnProxy " );
66+ require (_cmp (ITypeAndVersion (config.ROUTER).typeAndVersion (), "Router 1.2.0 " ), "InvalidRouter " );
67+ return config;
6068 }
6169
6270 function _validateProxyAdminVersion (address proxy ) internal view {
0 commit comments