mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'fix/156' into 'master'
Resolve "Add the OTIMAL_UTILIZATION_RATE as an immutable in DefaultInterestRateStrategy" Closes #156 See merge request aave-tech/protocol-v2!173
This commit is contained in:
commit
886f2fbc70
|
@ -31,9 +31,10 @@ contract ATokensAndRatesHelper is Ownable {
|
|||
function initDeployment(
|
||||
address[] calldata tokens,
|
||||
string[] calldata symbols,
|
||||
uint256[5][] calldata rates,
|
||||
uint256[6][] calldata rates,
|
||||
address incentivesController
|
||||
) external onlyOwner {
|
||||
|
||||
require(tokens.length == symbols.length, 't Arrays not same length');
|
||||
require(rates.length == symbols.length, 'r Arrays not same length');
|
||||
for (uint256 i = 0; i < tokens.length; i++) {
|
||||
|
@ -55,7 +56,8 @@ contract ATokensAndRatesHelper is Ownable {
|
|||
rates[i][1],
|
||||
rates[i][2],
|
||||
rates[i][3],
|
||||
rates[i][4]
|
||||
rates[i][4],
|
||||
rates[i][5]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -23,7 +23,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
|||
* @dev this constant represents the utilization rate at which the pool aims to obtain most competitive borrow rates
|
||||
* expressed in ray
|
||||
**/
|
||||
uint256 public constant OPTIMAL_UTILIZATION_RATE = 0.8 * 1e27;
|
||||
uint256 public immutable OPTIMAL_UTILIZATION_RATE;
|
||||
|
||||
/**
|
||||
* @dev this constant represents the excess utilization rate above the optimal. It's always equal to
|
||||
|
@ -31,7 +31,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
|||
* expressed in ray
|
||||
**/
|
||||
|
||||
uint256 public constant EXCESS_UTILIZATION_RATE = 0.2 * 1e27;
|
||||
uint256 public immutable EXCESS_UTILIZATION_RATE;
|
||||
|
||||
LendingPoolAddressesProvider public immutable addressesProvider;
|
||||
|
||||
|
@ -52,12 +52,16 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
|||
|
||||
constructor(
|
||||
LendingPoolAddressesProvider provider,
|
||||
uint256 optimalUtilizationRate,
|
||||
uint256 baseVariableBorrowRate,
|
||||
uint256 variableRateSlope1,
|
||||
uint256 variableRateSlope2,
|
||||
uint256 stableRateSlope1,
|
||||
uint256 stableRateSlope2
|
||||
) public {
|
||||
|
||||
OPTIMAL_UTILIZATION_RATE = optimalUtilizationRate;
|
||||
EXCESS_UTILIZATION_RATE = WadRayMath.ray().sub(optimalUtilizationRate);
|
||||
addressesProvider = provider;
|
||||
_baseVariableBorrowRate = baseVariableBorrowRate;
|
||||
_variableRateSlope1 = variableRateSlope1;
|
||||
|
|
|
@ -10,7 +10,6 @@ import {ReserveConfiguration} from '../libraries/configuration/ReserveConfigurat
|
|||
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
|
||||
import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol';
|
||||
import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol';
|
||||
import 'hardhat/console.sol';
|
||||
|
||||
contract AaveProtocolDataProvider {
|
||||
using ReserveConfiguration for ReserveConfiguration.Map;
|
||||
|
|
|
@ -16,7 +16,6 @@ export const MAX_UINT_AMOUNT =
|
|||
export const ONE_YEAR = '31536000';
|
||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';
|
||||
|
||||
// ----------------
|
||||
// PROTOCOL GLOBAL PARAMS
|
||||
// ----------------
|
||||
|
|
|
@ -54,6 +54,7 @@ export const initReservesByHelper = async (
|
|||
BigNumberish,
|
||||
BigNumberish,
|
||||
BigNumberish,
|
||||
BigNumberish,
|
||||
BigNumberish
|
||||
][] = [];
|
||||
const reservesDecimals: string[] = [];
|
||||
|
@ -72,6 +73,7 @@ export const initReservesByHelper = async (
|
|||
const [
|
||||
,
|
||||
{
|
||||
optimalUtilizationRate,
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
|
@ -83,6 +85,7 @@ export const initReservesByHelper = async (
|
|||
tokens.push(tokenAddress);
|
||||
symbols.push(assetSymbol);
|
||||
strategyRates.push([
|
||||
optimalUtilizationRate,
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
|
|
|
@ -263,6 +263,7 @@ export enum TokenContractId {
|
|||
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {}
|
||||
|
||||
export interface IReserveBorrowParams {
|
||||
optimalUtilizationRate: string;
|
||||
baseVariableBorrowRate: string;
|
||||
variableRateSlope1: string;
|
||||
variableRateSlope2: string;
|
||||
|
@ -321,12 +322,8 @@ export enum EthereumNetwork {
|
|||
}
|
||||
|
||||
export interface IProtocolGlobalConfig {
|
||||
OptimalUtilizationRate: BigNumber;
|
||||
ExcessUtilizationRate: BigNumber;
|
||||
ApprovalAmountLendingPoolCore: string;
|
||||
TokenDistributorPercentageBase: string;
|
||||
MockUsdPriceInWei: string;
|
||||
EthereumAddress: tEthereumAddress;
|
||||
UsdAddress: tEthereumAddress;
|
||||
NilAddress: tEthereumAddress;
|
||||
OneAddress: tEthereumAddress;
|
||||
|
|
|
@ -33,12 +33,8 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
ConfigName: 'Commons',
|
||||
ProviderId: 0,
|
||||
ProtocolGlobalParams: {
|
||||
OptimalUtilizationRate: new BigNumber(0.8).times(RAY),
|
||||
ExcessUtilizationRate: new BigNumber(0.2).times(RAY),
|
||||
ApprovalAmountLendingPoolCore: '1000000000000000000000000000',
|
||||
TokenDistributorPercentageBase: '10000',
|
||||
MockUsdPriceInWei: '5848466240000000',
|
||||
EthereumAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
||||
UsdAddress: '0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96',
|
||||
NilAddress: '0x0000000000000000000000000000000000000000',
|
||||
OneAddress: '0x0000000000000000000000000000000000000001',
|
||||
|
|
|
@ -3,6 +3,7 @@ import {oneRay} from '../../helpers/constants';
|
|||
import {IReserveParams} from '../../helpers/types';
|
||||
|
||||
export const strategyBase: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(),
|
||||
|
@ -17,6 +18,7 @@ export const strategyBase: IReserveParams = {
|
|||
};
|
||||
|
||||
export const stablecoinStrategyBase: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(1.5).multipliedBy(oneRay).toFixed(),
|
||||
|
@ -31,6 +33,7 @@ export const stablecoinStrategyBase: IReserveParams = {
|
|||
};
|
||||
|
||||
export const stablecoinStrategyCentralized: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
|
@ -117,6 +120,7 @@ export const strategyREN: IReserveParams = {
|
|||
};
|
||||
|
||||
export const stablecoinStrategySUSD: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(),
|
||||
|
@ -174,6 +178,7 @@ export const stablecoinStrategyUSDT: IReserveParams = {
|
|||
};
|
||||
|
||||
export const strategyWBTC: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
|
@ -188,6 +193,7 @@ export const strategyWBTC: IReserveParams = {
|
|||
};
|
||||
|
||||
export const strategyWETH: IReserveParams = {
|
||||
optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(),
|
||||
baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(),
|
||||
variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(),
|
||||
|
|
4898
package-lock.json
generated
4898
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
import {MAX_UINT_AMOUNT, ZERO_ADDRESS} from '../helpers/constants';
|
||||
import {APPROVAL_AMOUNT_LENDING_POOL, MAX_UINT_AMOUNT, ZERO_ADDRESS} from '../helpers/constants';
|
||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
|
||||
import {expect} from 'chai';
|
||||
import {ethers} from 'ethers';
|
||||
|
@ -6,8 +6,6 @@ import {RateMode, ProtocolErrors} from '../helpers/types';
|
|||
import {makeSuite, TestEnv} from './helpers/make-suite';
|
||||
import {CommonsConfig} from '../markets/aave/commons';
|
||||
|
||||
const APPROVAL_AMOUNT_LENDING_POOL =
|
||||
CommonsConfig.ProtocolGlobalParams.ApprovalAmountLendingPoolCore;
|
||||
const AAVE_REFERRAL = CommonsConfig.ProtocolGlobalParams.AaveReferral;
|
||||
|
||||
makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import {TestEnv, makeSuite} from './helpers/make-suite';
|
||||
import {RAY} from '../helpers/constants';
|
||||
import {APPROVAL_AMOUNT_LENDING_POOL, RAY} from '../helpers/constants';
|
||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
|
||||
import {ProtocolErrors} from '../helpers/types';
|
||||
import {CommonsConfig} from '../markets/aave/commons';
|
||||
|
||||
const APPROVAL_AMOUNT_LENDING_POOL =
|
||||
CommonsConfig.ProtocolGlobalParams.ApprovalAmountLendingPoolCore;
|
||||
|
||||
const {expect} = require('chai');
|
||||
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import {DRE} from '../helpers/misc-utils';
|
||||
import {oneEther} from '../helpers/constants';
|
||||
import {APPROVAL_AMOUNT_LENDING_POOL, oneEther} from '../helpers/constants';
|
||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
|
||||
import {makeSuite} from './helpers/make-suite';
|
||||
import {ProtocolErrors, RateMode} from '../helpers/types';
|
||||
import {calcExpectedVariableDebtTokenBalance} from './helpers/utils/calculations';
|
||||
import {getUserData, getReserveData} from './helpers/utils/helpers';
|
||||
import {CommonsConfig} from '../markets/aave/commons';
|
||||
|
||||
const APPROVAL_AMOUNT_LENDING_POOL =
|
||||
CommonsConfig.ProtocolGlobalParams.ApprovalAmountLendingPoolCore;
|
||||
|
||||
const chai = require('chai');
|
||||
const {expect} = chai;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import {DRE, increaseTime} from '../helpers/misc-utils';
|
||||
import {oneEther} from '../helpers/constants';
|
||||
import {APPROVAL_AMOUNT_LENDING_POOL, oneEther} from '../helpers/constants';
|
||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
|
||||
import {makeSuite} from './helpers/make-suite';
|
||||
import {ProtocolErrors, RateMode} from '../helpers/types';
|
||||
|
@ -9,8 +9,6 @@ import {calcExpectedStableDebtTokenBalance} from './helpers/utils/calculations';
|
|||
import {getUserData} from './helpers/utils/helpers';
|
||||
import {CommonsConfig} from '../markets/aave/commons';
|
||||
|
||||
const APPROVAL_AMOUNT_LENDING_POOL =
|
||||
CommonsConfig.ProtocolGlobalParams.ApprovalAmountLendingPoolCore;
|
||||
import {parseEther} from 'ethers/lib/utils';
|
||||
|
||||
const chai = require('chai');
|
||||
|
|
Loading…
Reference in New Issue
Block a user