Skip to content

Commit

Permalink
fix: create2 bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmikko committed Sep 2, 2024
1 parent a3e62e4 commit eb274a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions script/Migrate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ interface IAddressProviderV3Legacy {
}

address constant emergencyLiquidator = 0x7BD9c8161836b1F402233E80F55E3CaE0Fde4d87;
address constant PUBLIC_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

contract Migrate is Script {
using LibString for bytes32;
Expand Down Expand Up @@ -156,7 +157,9 @@ contract Migrate is Script {
bytes memory parameters = abi.encode(oldAddressProvider, address(_addressProvider), "ChaosLabs", vetoAdmin);

bytes memory bytecodeWithParams = abi.encodePacked(bytecode, parameters);
address mcl = Create2.computeAddress(0, keccak256(bytecodeWithParams));
address mcl = Create2.computeAddress(0, keccak256(bytecodeWithParams), PUBLIC_FACTORY);

console.log("MarketConfiguratorLegacy:", mcl);

/// set this contract to add mcl as marketConfigurator
_addressProvider.setAddress(AP_MARKET_CONFIGURATOR_FACTORY.fromSmallString(), deployer, false);
Expand All @@ -165,7 +168,8 @@ contract Migrate is Script {
_addressProvider.addMarketConfigurator(address(mcl));

/// Deploy MarketConfiguratorLegacy
Create2.deploy(0, 0, bytecodeWithParams);
address pp = Create2.deploy(0, 0, bytecodeWithParams);
console.log("MarketConfiguratorLegacy deployed at:", pp);

factory = address(new MarketConfiguratorFactoryV3(address(_addressProvider)));
_addressProvider.setAddress(factory, false);
Expand Down

0 comments on commit eb274a2

Please sign in to comment.