@@ -105,14 +105,10 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
105105 onlyMarketConfigurators
106106 returns (DeployResult memory )
107107 {
108- address contractsRegister = IMarketConfigurator (msg .sender ).contractsRegister ();
109- address priceOracle = IContractsRegister (contractsRegister).getPriceOracle (pool);
110- address lossLiquidator = IContractsRegister (contractsRegister).getLossLiquidator (pool);
111-
112108 (CreditManagerParams memory params , CreditFacadeParams memory facadeParams ) =
113109 abi.decode (encodedParams, (CreditManagerParams, CreditFacadeParams));
114110
115- address creditManager = _deployCreditManager (msg .sender , pool, priceOracle, params);
111+ address creditManager = _deployCreditManager (msg .sender , pool, params);
116112 address creditConfigurator = _deployCreditConfigurator (msg .sender , creditManager);
117113 address creditFacade = _deployCreditFacade (msg .sender , creditManager, facadeParams);
118114
@@ -124,7 +120,6 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
124120 _authorizeFactory (msg .sender , creditManager, creditConfigurator),
125121 _authorizeFactory (msg .sender , creditManager, creditFacade),
126122 _setCreditFacade (creditConfigurator, creditFacade, false ),
127- _setLossLiquidator (creditConfigurator, lossLiquidator),
128123 _setDebtLimits (creditConfigurator, params.minDebt, params.maxDebt)
129124 )
130125 });
@@ -143,13 +138,13 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
143138 return CallBuilder.build (_setPriceOracle (_creditConfigurator (creditManager), newPriceOracle));
144139 }
145140
146- function onUpdateLossLiquidator (address creditManager , address newLossLiquidator , address )
141+ function onUpdateLossPolicy (address creditManager , address newLossPolicy , address )
147142 external
148143 view
149144 override
150145 returns (Call[] memory )
151146 {
152- return CallBuilder.build (_setLossLiquidator (_creditConfigurator (creditManager), newLossLiquidator ));
147+ return CallBuilder.build (_setLossPolicy (_creditConfigurator (creditManager), newLossPolicy ));
153148 }
154149
155150 // ------------- //
@@ -238,12 +233,13 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
238233 // INTERNALS //
239234 // --------- //
240235
241- function _deployCreditManager (
242- address marketConfigurator ,
243- address pool ,
244- address priceOracle ,
245- CreditManagerParams memory params
246- ) internal returns (address ) {
236+ function _deployCreditManager (address marketConfigurator , address pool , CreditManagerParams memory params )
237+ internal
238+ returns (address )
239+ {
240+ address contractsRegister = IMarketConfigurator (marketConfigurator).contractsRegister ();
241+ address priceOracle = IContractsRegister (contractsRegister).getPriceOracle (pool);
242+
247243 bytes32 postfix = _getTokenSpecificPostfix (IPoolV3 (pool).asset ());
248244
249245 // TODO: ensure that account factory is registered, add manager to it
@@ -269,7 +265,8 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
269265 }
270266
271267 function _deployCreditConfigurator (address marketConfigurator , address creditManager ) internal returns (address ) {
272- bytes memory constructorParams = abi.encode (creditManager);
268+ address acl = IMarketConfigurator (marketConfigurator).acl ();
269+ bytes memory constructorParams = abi.encode (acl, creditManager);
273270
274271 return _deployLatestPatch ({
275272 contractType: AP_CREDIT_CONFIGURATOR,
@@ -284,10 +281,13 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
284281 returns (address )
285282 {
286283 address acl = IMarketConfigurator (marketConfigurator).acl ();
284+ address contractsRegister = IMarketConfigurator (marketConfigurator).contractsRegister ();
285+ address lossPolicy = IContractsRegister (contractsRegister).getLossPolicy (ICreditManagerV3 (creditManager).pool ());
286+
287287 // TODO: ensure that botList is registered, coincides with the previous one, add manager to it
288288 // TODO: ensure that degenNFT is registered, add facade to it
289289 bytes memory constructorParams =
290- abi.encode (acl, creditManager, params.botList, weth, params.degenNFT, params.expirable);
290+ abi.encode (acl, creditManager, lossPolicy, params.botList, weth, params.degenNFT, params.expirable);
291291
292292 return _deployLatestPatch ({
293293 contractType: AP_CREDIT_FACADE,
@@ -304,7 +304,7 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
304304 address decodedCreditManager = address (bytes20 (bytes32 (params.constructorParams)));
305305 if (decodedCreditManager != creditManager) revert InvalidConstructorParamsException ();
306306
307- // NOTE : unlike other contracts, this might be deployed multiple times, so using the same salt
307+ // FIXME : unlike other contracts, this might be deployed multiple times, so using the same salt
308308 // can be an issue. Same thing can happen to rate keepers, IRMs, etc.
309309 return _deployLatestPatch ({
310310 contractType: _getContractType (DOMAIN_ADAPTER, params.postfix),
@@ -346,12 +346,8 @@ contract CreditFactory is AbstractFactory, ICreditFactory {
346346 return Call (creditConfigurator, abi.encodeCall (ICreditConfiguratorV3.setPriceOracle, priceOracle));
347347 }
348348
349- function _setLossLiquidator (address creditConfigurator , address lossLiquidator )
350- internal
351- pure
352- returns (Call memory )
353- {
354- return Call (creditConfigurator, abi.encodeCall (ICreditConfiguratorV3.setLossLiquidator, lossLiquidator));
349+ function _setLossPolicy (address creditConfigurator , address lossPolicy ) internal pure returns (Call memory ) {
350+ return Call (creditConfigurator, abi.encodeCall (ICreditConfiguratorV3.setLossPolicy, lossPolicy));
355351 }
356352
357353 function _allowAdapter (address creditConfigurator , address adapter ) internal pure returns (Call memory ) {
0 commit comments