Skip to content

Commit

Permalink
Merge pull request #91 from morpho-labs/refactor/interests-check-borrow
Browse files Browse the repository at this point in the history
Accrue interests checks borrow is non zero
  • Loading branch information
QGarchery authored Jul 10, 2023
2 parents 28a3995 + 214e6b5 commit d998d91
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,13 @@ contract Blue {
// Interests management.

function accrueInterests(Market calldata market, Id id) private {
uint256 marketTotalSupply = totalSupply[id];
uint256 marketTotalBorrow = totalBorrow[id];

if (marketTotalSupply != 0) {
uint256 marketTotalBorrow = totalBorrow[id];
if (marketTotalBorrow != 0) {
uint256 borrowRate = market.irm.borrowRate(market);
uint256 accruedInterests = marketTotalBorrow.wMul(borrowRate).wMul(block.timestamp - lastUpdate[id]);
totalSupply[id] = marketTotalSupply + accruedInterests;
totalBorrow[id] = marketTotalBorrow + accruedInterests;
totalSupply[id] += accruedInterests;
}

lastUpdate[id] = block.timestamp;
Expand Down

0 comments on commit d998d91

Please sign in to comment.