Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit aaab802

Browse files
committed
fix: indexes caching (mc lens)
1 parent 5db2d28 commit aaab802

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/compound/lens/IndexesLens.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ abstract contract IndexesLens is LensStorage {
179179
{
180180
marketParameters = morpho.marketParameters(_poolToken);
181181

182-
if (!_updated || block.number == _lastPoolIndexes.lastUpdateBlockNumber) {
182+
if (!_updated) {
183183
return (
184184
morpho.p2pSupplyIndex(_poolToken),
185185
morpho.p2pBorrowIndex(_poolToken),

test/compound/TestLens.t.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ contract TestLens is TestSetup {
7474
uint256 amount = 10_000 ether;
7575
uint256 toBorrow = amount / 2;
7676

77-
borrower1.approve(dai, amount);
77+
borrower1.approve(dai, type(uint256).max);
7878
indexes.index1 = ICToken(cDai).exchangeRateCurrent();
7979
borrower1.supply(cDai, amount);
80-
uint256 p2pBorrowIndex = morpho.p2pBorrowIndex(cDai);
8180
borrower1.borrow(cDai, toBorrow);
8281

8382
indexes.index2 = ICToken(cDai).exchangeRateCurrent();
@@ -94,6 +93,9 @@ contract TestLens is TestSetup {
9493

9594
uint256 total;
9695

96+
// To update p2p indexes on Morpho (they can change inside of a block because the poolSupplyIndex can change due to rounding errors).
97+
borrower1.supply(cDai, 1);
98+
uint256 p2pBorrowIndex = morpho.p2pBorrowIndex(cDai);
9799
{
98100
uint256 onPool = amount.div(indexes.index1);
99101
uint256 matchedInP2P = toBorrow.div(morpho.p2pSupplyIndex(cDai));

0 commit comments

Comments
 (0)