@@ -7,7 +7,12 @@ import {IERC20} from "../misc/interfaces/IERC20.sol";
77import {Root} from "../admin/Root.sol " ;
88
99Root constant ROOT_V2 = Root (0x0C1fDfd6a1331a875EA013F3897fc8a76ada5DfC );
10- Root constant ROOT_V3 = Root (0x7Ed48C31f2fdC40d37407cBaBf0870B2b688368f );
10+
11+ address constant CONTRACT_UPDATER = 0x3B150B19245D2C366bc8f18c775b725DFB298F71 ;
12+ address constant FREEZE_ONLY_HOOK = 0xd5B243F05b2906F1f6C80c6096945faADa0731C1 ;
13+ address constant FULL_RESTRICTIONS_HOOK = 0x8E680873b4C77e6088b4Ba0aBD59d100c3D224a4 ;
14+ address constant FREELY_TRANSFERABLE_HOOK = 0x2a9B9C14851Baf7AD19f26607C9171CA1E7a1A61 ;
15+ address constant REDEMPTION_RESTRICTIONS_HOOK = 0xE5423eD8602Fa0F263e17b6212d88Efe42317f06 ;
1116
1217address constant CFG = 0xcccCCCcCCC33D538DBC2EE4fEab0a7A1FF4e8A94 ;
1318address constant WCFG = 0xc221b7E65FfC80DE234bbB6667aBDd46593D34F0 ;
@@ -38,45 +43,52 @@ contract V2CleaningsSpell {
3843 bool public done;
3944 string public constant description = "Pending cleanings from V2 " ;
4045
41- function cast () external {
46+ function cast (Root rootV3 ) external {
4247 require (! done, "Spell already executed " );
4348 done = true ;
4449
45- _updateCFGWards ();
46- _disableRootV2FromShareTokensV2 ();
50+ _updateCFGWards (rootV3 );
51+ _disableRootV2FromShareTokensV2 (rootV3 );
4752 _moveFundsFromEscrowToTreasury ();
53+ _relyContractUpdaterOnHooks (rootV3);
4854
49- ROOT_V2.deny (address (this ));
50- ROOT_V3.deny (address (this ));
55+ if (address (ROOT_V2).code.length > 0 ) {
56+ ROOT_V2.deny (address (this ));
57+ }
58+ rootV3.deny (address (this ));
5159 }
5260
53- function _updateCFGWards () internal {
61+ function _updateCFGWards (Root rootV3 ) internal {
5462 // Check if CFG exists
5563 if (CFG.code.length > 0 ) {
5664 // Mainnet CFG only has the v2 root relied, need to replace with v3 root
5765 if (block .chainid == ETHEREUM_CHAIN_ID) {
58- ROOT_V2.relyContract (CFG, address (ROOT_V3));
59- ROOT_V2.relyContract (CFG, CFG_MINTER);
60- ROOT_V3.denyContract (CFG, IOU_CFG);
61- ROOT_V3.denyContract (CFG, address (ROOT_V2));
66+ if (address (ROOT_V2).code.length > 0 ) {
67+ ROOT_V2.relyContract (CFG, address (rootV3));
68+ ROOT_V2.relyContract (CFG, CFG_MINTER);
69+ rootV3.denyContract (CFG, address (ROOT_V2));
70+ }
71+ rootV3.denyContract (CFG, IOU_CFG);
6272 }
6373
6474 // Deny CREATE3 proxy on new chains
6575 if (block .chainid != ETHEREUM_CHAIN_ID) {
66- ROOT_V3 .denyContract (CFG, CREATE3_PROXY);
76+ rootV3 .denyContract (CFG, CREATE3_PROXY);
6777 }
6878 }
6979
7080 // Check if WCFG exists (only in Ethereum)
7181 if (WCFG.code.length > 0 ) {
72- Root (ROOT_V2).relyContract (WCFG, address (ROOT_V3));
73- ROOT_V3.denyContract (WCFG, WCFG_MULTISIG);
74- ROOT_V3.denyContract (WCFG, CHAINBRIDGE_ERC20_HANDLER);
75- ROOT_V3.denyContract (WCFG, address (ROOT_V2));
82+ if (address (ROOT_V2).code.length > 0 ) {
83+ Root (ROOT_V2).relyContract (WCFG, address (rootV3));
84+ rootV3.denyContract (WCFG, address (ROOT_V2));
85+ }
86+ rootV3.denyContract (WCFG, WCFG_MULTISIG);
87+ rootV3.denyContract (WCFG, CHAINBRIDGE_ERC20_HANDLER);
7688 }
7789 }
7890
79- function _disableRootV2FromShareTokensV2 () internal {
91+ function _disableRootV2FromShareTokensV2 (Root rootV3 ) internal {
8092 address [] memory shareTokens = new address [](2 );
8193 shareTokens[0 ] = TRANCHE_JTRSY;
8294 shareTokens[1 ] = TRANCHE_JAAA;
@@ -87,11 +99,11 @@ contract V2CleaningsSpell {
8799 // forgefmt: disable-next-item
88100 if (address (shareTokenV2).code.length > 0 &&
89101 shareTokenV2.wards (address (ROOT_V2)) == 1 &&
90- shareTokenV2.wards (address (ROOT_V3 )) == 1
102+ shareTokenV2.wards (address (rootV3 )) == 1
91103 ) {
92- ROOT_V3 .relyContract (address (shareTokenV2), address (this ));
104+ rootV3 .relyContract (address (shareTokenV2), address (this ));
93105 shareTokenV2.deny (address (ROOT_V2));
94- ROOT_V3 .denyContract (address (shareTokenV2), address (this ));
106+ rootV3 .denyContract (address (shareTokenV2), address (this ));
95107 }
96108 }
97109 }
@@ -105,6 +117,8 @@ contract V2CleaningsSpell {
105117 usdc = USDC_BASE;
106118 } else if (block .chainid == ARBITRUM_CHAIN_ID) {
107119 usdc = USDC_ARBITRUM;
120+ } else {
121+ return ;
108122 }
109123
110124 ROOT_V2.relyContract (address (ESCROW_V2), address (this ));
@@ -115,4 +129,11 @@ contract V2CleaningsSpell {
115129 ROOT_V2.denyContract (address (ESCROW_V2), address (this ));
116130 }
117131 }
132+
133+ function _relyContractUpdaterOnHooks (Root rootV3 ) internal {
134+ rootV3.relyContract (FREEZE_ONLY_HOOK, CONTRACT_UPDATER);
135+ rootV3.relyContract (FULL_RESTRICTIONS_HOOK, CONTRACT_UPDATER);
136+ rootV3.relyContract (FREELY_TRANSFERABLE_HOOK, CONTRACT_UPDATER);
137+ rootV3.relyContract (REDEMPTION_RESTRICTIONS_HOOK, CONTRACT_UPDATER);
138+ }
118139}
0 commit comments