Skip to content

Commit

Permalink
fix: Remove unneededv variable in cumulateToLiqIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Dec 22, 2021
1 parent 6dd5210 commit 75e7fdc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/protocol/libraries/logic/ReserveLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ library ReserveLogic {
uint256 totalLiquidity,
uint256 amount
) internal returns (uint256) {
//next liquidity index is calculated this way: `liquidityIndex * (1 + amount / totalLiquidity)`
//next liquidity index is calculated this way: `((amount / totalLiquidity) + 1) * liquidityIndex`
//division `amount / totalLiquidity` done in ray for precision
uint256 multiplier = amount.wadToRay().rayDiv(totalLiquidity.wadToRay()) + WadRayMath.RAY;
uint256 result = multiplier.rayMul(reserve.liquidityIndex);
uint256 result = (amount.wadToRay().rayDiv(totalLiquidity.wadToRay()) + WadRayMath.RAY).rayMul(
reserve.liquidityIndex
);
reserve.liquidityIndex = result.toUint128();
return result;
}
Expand Down

0 comments on commit 75e7fdc

Please sign in to comment.