From da5b6738c1e8addc84b627284456a2e06958fd96 Mon Sep 17 00:00:00 2001 From: andyk Date: Mon, 24 Aug 2020 15:35:59 +0300 Subject: [PATCH] refactoring of DefaultReserveInterestRateStrategy to follow the stuileguide --- .../interfaces/IReserveInterestRateStrategy.sol | 2 +- .../DefaultReserveInterestRateStrategy.sol | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/contracts/interfaces/IReserveInterestRateStrategy.sol b/contracts/interfaces/IReserveInterestRateStrategy.sol index 5d41c100..48311e70 100644 --- a/contracts/interfaces/IReserveInterestRateStrategy.sol +++ b/contracts/interfaces/IReserveInterestRateStrategy.sol @@ -11,7 +11,7 @@ interface IReserveInterestRateStrategy { * @dev returns the base variable borrow rate, in rays */ - function getBaseVariableBorrowRate() external view returns (uint256); + function baseVariableBorrowRate() external view returns (uint256); /** * @dev calculates the liquidity, stable, and variable rates depending on the current utilization rate diff --git a/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol b/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol index 5059b7eb..c2303254 100644 --- a/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol +++ b/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol @@ -69,23 +69,23 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy { * @dev accessors */ - function getVariableRateSlope1() external view returns (uint256) { + function variableRateSlope1() external view returns (uint256) { return _variableRateSlope1; } - function getVariableRateSlope2() external view returns (uint256) { + function variableRateSlope2() external view returns (uint256) { return _variableRateSlope2; } - function getStableRateSlope1() external view returns (uint256) { + function stableRateSlope1() external view returns (uint256) { return _stableRateSlope1; } - function getStableRateSlope2() external view returns (uint256) { + function stableRateSlope2() external view returns (uint256) { return _stableRateSlope2; } - function getBaseVariableBorrowRate() external override view returns (uint256) { + function baseVariableBorrowRate() external override view returns (uint256) { return _baseVariableBorrowRate; } @@ -121,7 +121,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy { uint256 currentStableBorrowRate = 0; uint256 currentLiquidityRate = 0; - uint256 utilizationRate = (totalBorrows == 0 && availableLiquidity == 0) + uint256 utilizationRate = totalBorrows == 0 ? 0 : totalBorrows.rayDiv(availableLiquidity.add(totalBorrows)); @@ -157,9 +157,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy { ) .rayMul(utilizationRate); - return (currentLiquidityRate, - currentStableBorrowRate, - currentVariableBorrowRate); + return (currentLiquidityRate, currentStableBorrowRate, currentVariableBorrowRate); } /**