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

fix: Complete interfaces of IReserveInterestRateStrategy and IPoolDataProvider #766

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
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
97 changes: 97 additions & 0 deletions contracts/interfaces/IDefaultInterestRateStrategy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IReserveInterestRateStrategy} from './IReserveInterestRateStrategy.sol';
import {IPoolAddressesProvider} from './IPoolAddressesProvider.sol';

/**
* @title IDefaultInterestRateStrategy
* @author Aave
* @notice Defines the basic interface of the DefaultReserveInterestRateStrategy
*/
interface IDefaultInterestRateStrategy is IReserveInterestRateStrategy {
/**
* @notice Returns the usage ratio at which the pool aims to obtain most competitive borrow rates.
* @return The optimal usage ratio, expressed in ray.
*/
function OPTIMAL_USAGE_RATIO() external view returns (uint256);

/**
* @notice Returns the optimal stable to total debt ratio of the reserve.
* @return The optimal stable to total debt ratio, expressed in ray.
*/
function OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO() external view returns (uint256);

/**
* @notice Returns the excess usage ratio above the optimal.
* @dev It's always equal to 1-optimal usage ratio (added as constant for gas optimizations)
* @return The max excess usage ratio, expressed in ray.
*/
function MAX_EXCESS_USAGE_RATIO() external view returns (uint256);

/**
* @notice Returns the excess stable debt ratio above the optimal.
* @dev It's always equal to 1-optimal stable to total debt ratio (added as constant for gas optimizations)
* @return The max excess stable to total debt ratio, expressed in ray.
*/
function MAX_EXCESS_STABLE_TO_TOTAL_DEBT_RATIO() external view returns (uint256);

/**
* @notice Returns the address of the PoolAddressesProvider
* @return The address of the PoolAddressesProvider contract
*/
function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);

/**
* @notice Returns the variable rate slope below optimal usage ratio
* @dev It's the variable rate when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO
* @return The variable rate slope, expressed in ray
*/
function getVariableRateSlope1() external view returns (uint256);

/**
* @notice Returns the variable rate slope above optimal usage ratio
* @dev It's the variable rate when usage ratio > OPTIMAL_USAGE_RATIO
* @return The variable rate slope, expressed in ray
*/
function getVariableRateSlope2() external view returns (uint256);

/**
* @notice Returns the stable rate slope below optimal usage ratio
* @dev It's the stable rate when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO
* @return The stable rate slope, expressed in ray
*/
function getStableRateSlope1() external view returns (uint256);

/**
* @notice Returns the stable rate slope above optimal usage ratio
* @dev It's the variable rate when usage ratio > OPTIMAL_USAGE_RATIO
* @return The stable rate slope, expressed in ray
*/
function getStableRateSlope2() external view returns (uint256);

/**
* @notice Returns the stable rate excess offset
* @dev It's an additional premium applied to the stable when stable debt > OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO
* @return The stable rate excess offset, expressed in ray
*/
function getStableRateExcessOffset() external view returns (uint256);

/**
* @notice Returns the base stable borrow rate
* @return The base stable borrow rate, expressed in ray
*/
function getBaseStableBorrowRate() external view returns (uint256);

/**
* @notice Returns the base variable borrow rate
* @return The base variable borrow rate, expressed in ray
*/
function getBaseVariableBorrowRate() external view returns (uint256);

/**
* @notice Returns the maximum variable borrow rate
* @return The maximum variable borrow rate, expressed in ray
*/
function getMaxVariableBorrowRate() external view returns (uint256);
}
190 changes: 187 additions & 3 deletions contracts/interfaces/IPoolDataProvider.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,128 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IPoolAddressesProvider} from './IPoolAddressesProvider.sol';

/**
* @title IPoolDataProvider
* @author Aave
* @notice Defines the basic interface of a PoolDataProvider
*/
interface IPoolDataProvider {
struct TokenData {
string symbol;
address tokenAddress;
}

/**
* @notice Returns the address for the PoolAddressesProvider contract.
* @return The address for the PoolAddressesProvider contract
*/
function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);

/**
* @notice Returns the list of the existing reserves in the pool.
* @dev Handling MKR and ETH in a different way since they do not have standard `symbol` functions.
* @return The list of reserves, pairs of symbols and addresses
*/
function getAllReservesTokens() external view returns (TokenData[] memory);

/**
* @notice Returns the list of the existing ATokens in the pool.
* @return The list of ATokens, pairs of symbols and addresses
*/
function getAllATokens() external view returns (TokenData[] memory);

/**
* @notice Returns the configuration data of the reserve
* @dev Not returning borrow and supply caps for compatibility, nor pause flag
* @param asset The address of the underlying asset of the reserve
* @return decimals The number of decimals of the reserve
* @return ltv The ltv of the reserve
* @return liquidationThreshold The liquidationThreshold of the reserve
* @return liquidationBonus The liquidationBonus of the reserve
* @return reserveFactor The reserveFactor of the reserve
* @return usageAsCollateralEnabled True if the usage as collateral is enabled, false otherwise
* @return borrowingEnabled True if borrowing is enabled, false otherwise
* @return stableBorrowRateEnabled True if stable rate borrowing is enabled, false otherwise
* @return isActive True if it is active, false otherwise
* @return isFrozen True if it is frozen, false otherwise
*/
function getReserveConfigurationData(address asset)
external
view
returns (
uint256 decimals,
uint256 ltv,
uint256 liquidationThreshold,
uint256 liquidationBonus,
uint256 reserveFactor,
bool usageAsCollateralEnabled,
bool borrowingEnabled,
bool stableBorrowRateEnabled,
bool isActive,
bool isFrozen
);

/**
* @notice Returns the efficiency mode category of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The eMode id of the reserve
*/
function getReserveEModeCategory(address asset) external view returns (uint256);

/**
* @notice Returns the caps parameters of the reserve
* @param asset The address of the underlying asset of the reserve
* @return borrowCap The borrow cap of the reserve
* @return supplyCap The supply cap of the reserve
**/
function getReserveCaps(address asset)
external
view
returns (uint256 borrowCap, uint256 supplyCap);

/**
* @notice Returns if the pool is paused
* @param asset The address of the underlying asset of the reserve
* @return isPaused True if the pool is paused, false otherwise
*/
function getPaused(address asset) external view returns (bool isPaused);

/**
* @notice Returns the siloed borrowing flag
* @param asset The address of the underlying asset of the reserve
* @return True if the asset is siloed for borrowing
*/
function getSiloedBorrowing(address asset) external view returns (bool);

/**
* @notice Returns the protocol fee on the liquidation bonus
* @param asset The address of the underlying asset of the reserve
* @return The protocol fee on liquidation
*/
function getLiquidationProtocolFee(address asset) external view returns (uint256);

/**
* @notice Returns the unbacked mint cap of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The unbacked mint cap of the reserve
*/
function getUnbackedMintCap(address asset) external view returns (uint256);

/**
* @notice Returns the debt ceiling of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The debt ceiling of the reserve
*/
function getDebtCeiling(address asset) external view returns (uint256);

/**
* @notice Returns the debt ceiling decimals
* @return The debt ceiling decimals
*/
function getDebtCeilingDecimals() external pure returns (uint256);

/**
* @notice Returns the reserve data
* @param asset The address of the underlying asset of the reserve
Expand All @@ -17,7 +138,7 @@ interface IPoolDataProvider {
* @return liquidityIndex The liquidity index of the reserve
* @return variableBorrowIndex The variable borrow index of the reserve
* @return lastUpdateTimestamp The timestamp of the last update of the reserve
**/
*/
function getReserveData(address asset)
external
view
Expand All @@ -40,13 +161,76 @@ interface IPoolDataProvider {
* @notice Returns the total supply of aTokens for a given asset
* @param asset The address of the underlying asset of the reserve
* @return The total supply of the aToken
**/
*/
function getATokenTotalSupply(address asset) external view returns (uint256);

/**
* @notice Returns the total debt for a given asset
* @param asset The address of the underlying asset of the reserve
* @return The total debt for asset
**/
*/
function getTotalDebt(address asset) external view returns (uint256);

/**
* @notice Returns the user data in a reserve
* @param asset The address of the underlying asset of the reserve
* @param user The address of the user
* @return currentATokenBalance The current AToken balance of the user
* @return currentStableDebt The current stable debt of the user
* @return currentVariableDebt The current variable debt of the user
* @return principalStableDebt The principal stable debt of the user
* @return scaledVariableDebt The scaled variable debt of the user
* @return stableBorrowRate The stable borrow rate of the user
* @return liquidityRate The liquidity rate of the reserve
* @return stableRateLastUpdated The timestamp of the last update of the user stable rate
* @return usageAsCollateralEnabled True if the user is using the asset as collateral, false
* otherwise
*/
function getUserReserveData(address asset, address user)
external
view
returns (
uint256 currentATokenBalance,
uint256 currentStableDebt,
uint256 currentVariableDebt,
uint256 principalStableDebt,
uint256 scaledVariableDebt,
uint256 stableBorrowRate,
uint256 liquidityRate,
uint40 stableRateLastUpdated,
bool usageAsCollateralEnabled
);

/**
* @notice Returns the token addresses of the reserve
* @param asset The address of the underlying asset of the reserve
* @return aTokenAddress The AToken address of the reserve
* @return stableDebtTokenAddress The StableDebtToken address of the reserve
* @return variableDebtTokenAddress The VariableDebtToken address of the reserve
*/
function getReserveTokensAddresses(address asset)
external
view
returns (
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress
);

/**
* @notice Returns the address of the Interest Rate strategy
* @param asset The address of the underlying asset of the reserve
* @return irStrategyAddress The address of the Interest Rate strategy
*/
function getInterestRateStrategyAddress(address asset)
external
view
returns (address irStrategyAddress);

/**
* @notice Returns whether the reserve has FlashLoans enabled or disabled
* @param asset The address of the underlying asset of the reserve
* @return True if FlashLoans are enabled, false otherwise
*/
function getFlashLoanEnabled(address asset) external view returns (bool);
}
14 changes: 1 addition & 13 deletions contracts/interfaces/IReserveInterestRateStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@ import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
* @notice Interface for the calculation of the interest rates
*/
interface IReserveInterestRateStrategy {
/**
* @notice Returns the base variable borrow rate
* @return The base variable borrow rate, expressed in ray
**/
function getBaseVariableBorrowRate() external view returns (uint256);

/**
* @notice Returns the maximum variable borrow rate
* @return The maximum variable borrow rate, expressed in ray
**/
function getMaxVariableBorrowRate() external view returns (uint256);

/**
* @notice Calculates the interest rates depending on the reserve's state and configurations
* @param params The parameters needed to calculate interest rates
* @return liquidityRate The liquidity rate expressed in rays
* @return stableBorrowRate The stable borrow rate expressed in rays
* @return variableBorrowRate The variable borrow rate expressed in rays
**/
*/
function calculateInterestRates(DataTypes.CalculateInterestRatesParams memory params)
external
view
Expand Down
Loading