Skip to content

Commit

Permalink
Merge pull request #1638 from spalen0/fix/lens-pool-rates
Browse files Browse the repository at this point in the history
Gas optimisation
  • Loading branch information
Rubilmax committed Jan 11, 2023
2 parents c0c6a37 + 89df889 commit 1b921e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/aave-v2/libraries/InterestRatesModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ library InterestRatesModel {
if (_params.poolSupplyRatePerYear > _params.poolBorrowRatePerYear) {
p2pSupplyRate = _params.poolBorrowRatePerYear; // The p2pSupplyRate is set to the poolBorrowRatePerYear because there is no rate spread.
} else {
uint256 p2pRate = PercentageMath.weightedAvg(
p2pSupplyRate = PercentageMath.weightedAvg(
_params.poolSupplyRatePerYear,
_params.poolBorrowRatePerYear,
_params.p2pIndexCursor
);

p2pSupplyRate =
p2pRate -
(p2pRate - _params.poolSupplyRatePerYear).percentMul(_params.reserveFactor);
p2pSupplyRate -
(p2pSupplyRate - _params.poolSupplyRatePerYear).percentMul(_params.reserveFactor);
}

if (_params.p2pDelta > 0 && _params.p2pAmount > 0) {
Expand Down Expand Up @@ -155,15 +155,15 @@ library InterestRatesModel {
if (_params.poolSupplyRatePerYear > _params.poolBorrowRatePerYear) {
p2pBorrowRate = _params.poolBorrowRatePerYear; // The p2pBorrowRate is set to the poolBorrowRatePerYear because there is no rate spread.
} else {
uint256 p2pRate = PercentageMath.weightedAvg(
p2pBorrowRate = PercentageMath.weightedAvg(
_params.poolSupplyRatePerYear,
_params.poolBorrowRatePerYear,
_params.p2pIndexCursor
);

p2pBorrowRate =
p2pRate +
(_params.poolBorrowRatePerYear - p2pRate).percentMul(_params.reserveFactor);
p2pBorrowRate +
(_params.poolBorrowRatePerYear - p2pBorrowRate).percentMul(_params.reserveFactor);
}

if (_params.p2pDelta > 0 && _params.p2pAmount > 0) {
Expand Down

0 comments on commit 1b921e2

Please sign in to comment.