Skip to content

Commit

Permalink
fix: minor fixes in migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
lekhovitsky committed Dec 24, 2024
1 parent 6c12a06 commit 6c9226b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 7 additions & 7 deletions contracts/migration/MarketConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {IContractsRegisterLegacy} from
import {ACL} from "@gearbox-protocol/governance/contracts/market/ACL.sol";
import {ContractsRegister} from "@gearbox-protocol/governance/contracts/market/ContractsRegister.sol";

contract LossPolicy {
uint256 public constant version = 3_10;
}

/// @dev Extremely dumbed-down version of `MarketConfiguratorLegacy` that is just enough to let compressors work
contract MarketConfigurator {
string public name;
Expand All @@ -22,8 +26,8 @@ contract MarketConfigurator {

constructor(string memory name_, address acl_, address contractsRegister_, address treasury_) {
name = name_;
acl = acl_;
contractsRegister = address(new ContractsRegister(address(new ACL())));
acl = address(new ACL());
contractsRegister = address(new ContractsRegister(acl));
treasury = treasury_;

address[] memory pools = IContractsRegisterLegacy(contractsRegister_).getPools();
Expand All @@ -38,7 +42,7 @@ contract MarketConfigurator {

address priceOracle = _priceOracle(creditManagers[0]);
// NOTE: v3.0.x contracts don't have loss policies set so we don't bother with them here
address lossPolicy = address(1);
address lossPolicy = address(new LossPolicy());

ContractsRegister(contractsRegister).registerMarket(pool, priceOracle, lossPolicy);
for (uint256 j; j < numCreditManagers; ++j) {
Expand All @@ -58,8 +62,4 @@ contract MarketConfigurator {
function _priceOracle(address creditManager) internal view returns (address) {
return ICreditManagerV3(creditManager).priceOracle();
}

function _lossLiquidator(address creditManager) internal view returns (address) {
return ICreditFacadeV3(ICreditManagerV3(creditManager).creditFacade()).lossLiquidator();
}
}
5 changes: 3 additions & 2 deletions script/Migrate.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ contract MigrateScript is Script {
AddressProvider addressProvider = new AddressProvider();
console.log("new address provider:", address(addressProvider));

addressProvider.transferOwnership(Ownable(acl).owner());

// NOTE: just some fake address
addressProvider.setAddress({
key: AP_MARKET_CONFIGURATOR_FACTORY.fromSmallString(),
Expand Down Expand Up @@ -117,6 +115,9 @@ contract MigrateScript is Script {
address creditAccountCompressor = address(new CreditAccountCompressor(address(addressProvider)));
addressProvider.setAddress(creditAccountCompressor, true);

// NOTE: configurator must later accept ownership over new address provider
addressProvider.transferOwnership(Ownable(acl).owner());

string memory obj1 = "address_provider";
vm.serializeAddress(obj1, "addressProvider", address(addressProvider));

Expand Down

0 comments on commit 6c9226b

Please sign in to comment.