Skip to content

Commit

Permalink
Revert "style: remove early return"
Browse files Browse the repository at this point in the history
This reverts commit 1e28a92.
  • Loading branch information
makcandrov committed Jul 31, 2023
1 parent ae177bf commit f5f40d2
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -290,26 +290,26 @@ contract Blue is IFlashLender {
function _accrueInterests(Market memory market, Id id) internal {
uint256 elapsed = block.timestamp - lastUpdate[id];

if (elapsed != 0) {
uint256 marketTotalBorrow = totalBorrow[id];

if (marketTotalBorrow != 0) {
uint256 borrowRate = market.irm.borrowRate(market);
uint256 accruedInterests = marketTotalBorrow.mulWadDown(borrowRate * elapsed);
totalBorrow[id] = marketTotalBorrow + accruedInterests;
totalSupply[id] += accruedInterests;

if (fee[id] != 0) {
uint256 feeAmount = accruedInterests.mulWadDown(fee[id]);
// The fee amount is subtracted from the total supply in this calculation to compensate for the fact that total supply is already updated.
uint256 feeShares = feeAmount.mulDivDown(totalSupplyShares[id], totalSupply[id] - feeAmount);
supplyShare[id][feeRecipient] += feeShares;
totalSupplyShares[id] += feeShares;
}
if (elapsed == 0) return;

uint256 marketTotalBorrow = totalBorrow[id];

if (marketTotalBorrow != 0) {
uint256 borrowRate = market.irm.borrowRate(market);
uint256 accruedInterests = marketTotalBorrow.mulWadDown(borrowRate * elapsed);
totalBorrow[id] = marketTotalBorrow + accruedInterests;
totalSupply[id] += accruedInterests;

if (fee[id] != 0) {
uint256 feeAmount = accruedInterests.mulWadDown(fee[id]);
// The fee amount is subtracted from the total supply in this calculation to compensate for the fact that total supply is already updated.
uint256 feeShares = feeAmount.mulDivDown(totalSupplyShares[id], totalSupply[id] - feeAmount);
supplyShare[id][feeRecipient] += feeShares;
totalSupplyShares[id] += feeShares;
}

lastUpdate[id] = block.timestamp;
}

lastUpdate[id] = block.timestamp;
}

// Health check.
Expand Down

0 comments on commit f5f40d2

Please sign in to comment.