@@ -1658,4 +1658,40 @@ contract TestLens is TestSetup {
16581658 morpho.setIsLiquidateBorrowPaused (aDai, true );
16591659 assertTrue (lens.getMarketPauseStatus (aDai).isLiquidateBorrowPaused);
16601660 }
1661+
1662+ function testPoolIndexGrowthInsideBlock () public {
1663+ supplier1.approve (dai, type (uint256 ).max);
1664+ supplier1.supply (aDai, 10 ether);
1665+
1666+ uint256 poolSupplyIndexBefore = lens.getIndexes (aDai).poolSupplyIndex;
1667+
1668+ FlashLoan flashLoan = new FlashLoan (pool);
1669+ vm.prank (address (supplier2));
1670+ ERC20 (dai).transfer (address (flashLoan), 10_000 ether); // To pay the premium.
1671+ flashLoan.callFlashLoan (dai, 10_000 ether);
1672+
1673+ uint256 poolSupplyIndexAfter = lens.getIndexes (aDai).poolSupplyIndex;
1674+
1675+ assertGt (poolSupplyIndexAfter, poolSupplyIndexBefore);
1676+ }
1677+
1678+ function testP2PIndexGrowthInsideBlock () public {
1679+ borrower1.approve (dai, type (uint256 ).max);
1680+ borrower1.supply (aDai, 10 ether);
1681+ borrower1.borrow (aDai, 5 ether);
1682+ setDefaultMaxGasForMatchingHelper (3e6 , 3e6 , 3e6 , 0 );
1683+ // Create delta.
1684+ borrower1.repay (aDai, type (uint256 ).max);
1685+
1686+ uint256 p2pSupplyIndexBefore = lens.getCurrentP2PSupplyIndex (aDai);
1687+
1688+ FlashLoan flashLoan = new FlashLoan (pool);
1689+ vm.prank (address (supplier2));
1690+ ERC20 (dai).transfer (address (flashLoan), 10_000 ether); // To pay the premium.
1691+ flashLoan.callFlashLoan (dai, 10_000 ether);
1692+
1693+ uint256 p2pSupplyIndexAfter = lens.getCurrentP2PSupplyIndex (aDai);
1694+
1695+ assertGt (p2pSupplyIndexAfter, p2pSupplyIndexBefore);
1696+ }
16611697}
0 commit comments