Skip to content

Commit 4ac8778

Browse files
Jean-GrimalQGarchery
authored andcommitted
fix: add call to irm at market creation
1 parent e4ccec8 commit 4ac8778

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Morpho.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ contract Morpho is IMorphoStaticTyping {
158158
idToMarketParams[id] = marketParams;
159159

160160
emit EventsLib.CreateMarket(id, marketParams);
161+
162+
// Call Irm in case it is statefull.
163+
IIrm(marketParams.irm).borrowRate(marketParams, market[id]);
161164
}
162165

163166
/* SUPPLY MANAGEMENT */

test/forge/integration/CreateMarketIntegrationTest.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ contract CreateMarketIntegrationTest is BaseTest {
4747
if (marketParamsFuzz.irm != marketParams.irm) morpho.enableIrm(marketParamsFuzz.irm);
4848
if (marketParamsFuzz.lltv != marketParams.lltv) morpho.enableLltv(marketParamsFuzz.lltv);
4949

50+
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
51+
5052
vm.expectEmit(true, true, true, true, address(morpho));
5153
emit EventsLib.CreateMarket(marketParamsFuzz.id(), marketParamsFuzz);
5254
morpho.createMarket(marketParamsFuzz);
@@ -66,6 +68,9 @@ contract CreateMarketIntegrationTest is BaseTest {
6668
vm.startPrank(OWNER);
6769
if (marketParamsFuzz.irm != marketParams.irm) morpho.enableIrm(marketParamsFuzz.irm);
6870
if (marketParamsFuzz.lltv != marketParams.lltv) morpho.enableLltv(marketParamsFuzz.lltv);
71+
72+
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
73+
6974
morpho.createMarket(marketParamsFuzz);
7075

7176
vm.expectRevert(bytes(ErrorsLib.MARKET_ALREADY_CREATED));
@@ -81,6 +86,8 @@ contract CreateMarketIntegrationTest is BaseTest {
8186
if (marketParamsFuzz.irm != marketParams.irm) morpho.enableIrm(marketParamsFuzz.irm);
8287
if (marketParamsFuzz.lltv != marketParams.lltv) morpho.enableLltv(marketParamsFuzz.lltv);
8388

89+
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
90+
8491
morpho.createMarket(marketParamsFuzz);
8592
vm.stopPrank();
8693

0 commit comments

Comments
 (0)