Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas optimisation #1638

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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