mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Removed unused param in struct
This commit is contained in:
parent
eb9077f25e
commit
7f44a0c242
|
@ -11,6 +11,22 @@ interface IReserveInterestRateStrategy {
|
||||||
|
|
||||||
function getMaxVariableBorrowRate() external view returns (uint256);
|
function getMaxVariableBorrowRate() external view returns (uint256);
|
||||||
|
|
||||||
|
function calculateInterestRates(
|
||||||
|
address reserve,
|
||||||
|
uint256 availableLiquidity,
|
||||||
|
uint256 totalStableDebt,
|
||||||
|
uint256 totalVariableDebt,
|
||||||
|
uint256 averageStableBorrowRate,
|
||||||
|
uint256 reserveFactor
|
||||||
|
)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
returns (
|
||||||
|
uint256,
|
||||||
|
uint256,
|
||||||
|
uint256
|
||||||
|
);
|
||||||
|
|
||||||
function calculateInterestRates(
|
function calculateInterestRates(
|
||||||
address reserve,
|
address reserve,
|
||||||
address aToken,
|
address aToken,
|
||||||
|
|
|
@ -98,15 +98,6 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
||||||
return _baseVariableBorrowRate.add(_variableRateSlope1).add(_variableRateSlope2);
|
return _baseVariableBorrowRate.add(_variableRateSlope1).add(_variableRateSlope2);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CalcInterestRatesLocalVars {
|
|
||||||
uint256 totalDebt;
|
|
||||||
uint256 currentVariableBorrowRate;
|
|
||||||
uint256 currentStableBorrowRate;
|
|
||||||
uint256 currentLiquidityRate;
|
|
||||||
uint256 utilizationRate;
|
|
||||||
uint256 availableLiquidity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Calculates the interest rates depending on the reserve's state and configurations
|
* @dev Calculates the interest rates depending on the reserve's state and configurations
|
||||||
* @param reserve The address of the reserve
|
* @param reserve The address of the reserve
|
||||||
|
@ -136,6 +127,58 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
||||||
uint256,
|
uint256,
|
||||||
uint256
|
uint256
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
uint256 availableLiquidity = IERC20(reserve).balanceOf(aToken);
|
||||||
|
//avoid stack too deep
|
||||||
|
availableLiquidity = availableLiquidity.add(liquidityAdded).sub(liquidityTaken);
|
||||||
|
|
||||||
|
return
|
||||||
|
calculateInterestRates(
|
||||||
|
reserve,
|
||||||
|
availableLiquidity,
|
||||||
|
totalStableDebt,
|
||||||
|
totalVariableDebt,
|
||||||
|
averageStableBorrowRate,
|
||||||
|
reserveFactor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CalcInterestRatesLocalVars {
|
||||||
|
uint256 totalDebt;
|
||||||
|
uint256 currentVariableBorrowRate;
|
||||||
|
uint256 currentStableBorrowRate;
|
||||||
|
uint256 currentLiquidityRate;
|
||||||
|
uint256 utilizationRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Calculates the interest rates depending on the reserve's state and configurations.
|
||||||
|
* NOTE This function is kept for compatibility with the previous DefaultInterestRateStrategy interface.
|
||||||
|
* New protocol implementation uses the new calculateInterestRates() interface
|
||||||
|
* @param reserve The address of the reserve
|
||||||
|
* @param availableLiquidity The liquidity available in the corresponding aToken
|
||||||
|
* @param totalStableDebt The total borrowed from the reserve a stable rate
|
||||||
|
* @param totalVariableDebt The total borrowed from the reserve at a variable rate
|
||||||
|
* @param averageStableBorrowRate The weighted average of all the stable rate loans
|
||||||
|
* @param reserveFactor The reserve portion of the interest that goes to the treasury of the market
|
||||||
|
* @return The liquidity rate, the stable borrow rate and the variable borrow rate
|
||||||
|
**/
|
||||||
|
function calculateInterestRates(
|
||||||
|
address reserve,
|
||||||
|
uint256 availableLiquidity,
|
||||||
|
uint256 totalStableDebt,
|
||||||
|
uint256 totalVariableDebt,
|
||||||
|
uint256 averageStableBorrowRate,
|
||||||
|
uint256 reserveFactor
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
override
|
||||||
|
returns (
|
||||||
|
uint256,
|
||||||
|
uint256,
|
||||||
|
uint256
|
||||||
|
)
|
||||||
{
|
{
|
||||||
CalcInterestRatesLocalVars memory vars;
|
CalcInterestRatesLocalVars memory vars;
|
||||||
|
|
||||||
|
@ -143,11 +186,10 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
||||||
vars.currentVariableBorrowRate = 0;
|
vars.currentVariableBorrowRate = 0;
|
||||||
vars.currentStableBorrowRate = 0;
|
vars.currentStableBorrowRate = 0;
|
||||||
vars.currentLiquidityRate = 0;
|
vars.currentLiquidityRate = 0;
|
||||||
vars.availableLiquidity = IERC20(reserve).balanceOf(aToken);
|
|
||||||
vars.availableLiquidity = vars.availableLiquidity.add(liquidityAdded).sub(liquidityTaken);
|
|
||||||
|
|
||||||
vars.utilizationRate =
|
vars.utilizationRate = vars.totalDebt == 0
|
||||||
vars.totalDebt == 0 ? 0 : vars.totalDebt.rayDiv(vars.availableLiquidity.add(vars.totalDebt));
|
? 0
|
||||||
|
: vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));
|
||||||
|
|
||||||
vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle())
|
vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle())
|
||||||
.getMarketBorrowRate(reserve);
|
.getMarketBorrowRate(reserve);
|
||||||
|
|
|
@ -42,7 +42,7 @@ makeSuite('Interest rate strategy tests', (testEnv: TestEnv) => {
|
||||||
0: currentLiquidityRate,
|
0: currentLiquidityRate,
|
||||||
1: currentStableBorrowRate,
|
1: currentStableBorrowRate,
|
||||||
2: currentVariableBorrowRate,
|
2: currentVariableBorrowRate,
|
||||||
} = await strategyInstance.calculateInterestRates(
|
} = await strategyInstance['calculateInterestRates(address,address,uint256,uint256,uint256,uint256,uint256,uint256)'](
|
||||||
dai.address,
|
dai.address,
|
||||||
aDai.address,
|
aDai.address,
|
||||||
0,
|
0,
|
||||||
|
@ -69,7 +69,7 @@ makeSuite('Interest rate strategy tests', (testEnv: TestEnv) => {
|
||||||
0: currentLiquidityRate,
|
0: currentLiquidityRate,
|
||||||
1: currentStableBorrowRate,
|
1: currentStableBorrowRate,
|
||||||
2: currentVariableBorrowRate,
|
2: currentVariableBorrowRate,
|
||||||
} = await strategyInstance.calculateInterestRates(
|
} = await strategyInstance['calculateInterestRates(address,address,uint256,uint256,uint256,uint256,uint256,uint256)'](
|
||||||
dai.address,
|
dai.address,
|
||||||
aDai.address,
|
aDai.address,
|
||||||
'200000000000000000',
|
'200000000000000000',
|
||||||
|
@ -108,7 +108,7 @@ makeSuite('Interest rate strategy tests', (testEnv: TestEnv) => {
|
||||||
0: currentLiquidityRate,
|
0: currentLiquidityRate,
|
||||||
1: currentStableBorrowRate,
|
1: currentStableBorrowRate,
|
||||||
2: currentVariableBorrowRate,
|
2: currentVariableBorrowRate,
|
||||||
} = await strategyInstance.calculateInterestRates(
|
} = await strategyInstance['calculateInterestRates(address,address,uint256,uint256,uint256,uint256,uint256,uint256)'](
|
||||||
dai.address,
|
dai.address,
|
||||||
aDai.address,
|
aDai.address,
|
||||||
'0',
|
'0',
|
||||||
|
@ -150,7 +150,7 @@ makeSuite('Interest rate strategy tests', (testEnv: TestEnv) => {
|
||||||
0: currentLiquidityRate,
|
0: currentLiquidityRate,
|
||||||
1: currentStableBorrowRate,
|
1: currentStableBorrowRate,
|
||||||
2: currentVariableBorrowRate,
|
2: currentVariableBorrowRate,
|
||||||
} = await strategyInstance.calculateInterestRates(
|
} = await strategyInstance['calculateInterestRates(address,address,uint256,uint256,uint256,uint256,uint256,uint256)'](
|
||||||
dai.address,
|
dai.address,
|
||||||
aDai.address,
|
aDai.address,
|
||||||
'0',
|
'0',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user