Skip to content

Commit

Permalink
fix: User rayDiv over plain div for discountScaled calc (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf authored Jan 19, 2023
1 parent 0bcf294 commit e41d7ee
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,7 @@ contract GhoVariableDebtToken is DebtTokenBase, ScaledBalanceTokenBase, IGhoVari
uint256 discountScaled = 0;
if (balanceIncrease != 0 && discountPercent != 0) {
uint256 discount = balanceIncrease.percentMul(discountPercent);

// skip checked division to
// avoid rounding in the case discount = 100%
// The index will never be 0
discountScaled = (discount * WadRayMath.RAY) / index;

discountScaled = discount.rayDiv(index);
balanceIncrease = balanceIncrease - discount;
}

Expand Down

0 comments on commit e41d7ee

Please sign in to comment.