@@ -474,26 +474,23 @@ contract Morpho is IMorphoStaticTyping {
474
474
475
475
if (elapsed == 0 ) return ;
476
476
477
- if (market[id].totalBorrowAssets != 0 ) {
478
- uint256 borrowRate = IIrm (marketParams.irm).borrowRate (marketParams, market[id]);
479
- uint256 interest = market[id].totalBorrowAssets.wMulDown (borrowRate.wTaylorCompounded (elapsed));
480
- market[id].totalBorrowAssets += interest.toUint128 ();
481
- market[id].totalSupplyAssets += interest.toUint128 ();
482
-
483
- uint256 feeShares;
484
- if (market[id].fee != 0 ) {
485
- uint256 feeAmount = interest.wMulDown (market[id].fee);
486
- // The fee amount is subtracted from the total supply in this calculation to compensate for the fact
487
- // that total supply is already increased by the full interest (including the fee amount).
488
- feeShares =
489
- feeAmount.toSharesDown (market[id].totalSupplyAssets - feeAmount, market[id].totalSupplyShares);
490
- position[id][feeRecipient].supplyShares += feeShares;
491
- market[id].totalSupplyShares += feeShares.toUint128 ();
492
- }
493
-
494
- emit EventsLib.AccrueInterest (id, borrowRate, interest, feeShares);
477
+ uint256 borrowRate = IIrm (marketParams.irm).borrowRate (marketParams, market[id]);
478
+ uint256 interest = market[id].totalBorrowAssets.wMulDown (borrowRate.wTaylorCompounded (elapsed));
479
+ market[id].totalBorrowAssets += interest.toUint128 ();
480
+ market[id].totalSupplyAssets += interest.toUint128 ();
481
+
482
+ uint256 feeShares;
483
+ if (market[id].fee != 0 ) {
484
+ uint256 feeAmount = interest.wMulDown (market[id].fee);
485
+ // The fee amount is subtracted from the total supply in this calculation to compensate for the fact
486
+ // that total supply is already increased by the full interest (including the fee amount).
487
+ feeShares = feeAmount.toSharesDown (market[id].totalSupplyAssets - feeAmount, market[id].totalSupplyShares);
488
+ position[id][feeRecipient].supplyShares += feeShares;
489
+ market[id].totalSupplyShares += feeShares.toUint128 ();
495
490
}
496
491
492
+ emit EventsLib.AccrueInterest (id, borrowRate, interest, feeShares);
493
+
497
494
// Safe "unchecked" cast.
498
495
market[id].lastUpdate = uint128 (block .timestamp );
499
496
}
0 commit comments