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

diffs: v3.0.2 and v3.1.0 #18

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 97 deletions src/core/contracts/interfaces/IDefaultInterestRateStrategy.sol

This file was deleted.

171 changes: 171 additions & 0 deletions src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/**
* @title IDefaultInterestRateStrategyV2
* @author BGD Labs
* @notice Interface of the default interest rate strategy used by the Aave protocol
*/
interface IDefaultInterestRateStrategyV2 is IReserveInterestRateStrategy {
struct CalcInterestRatesLocalVars {
uint256 availableLiquidity;
uint256 totalDebt;
uint256 currentVariableBorrowRate;
uint256 currentLiquidityRate;
uint256 borrowUsageRatio;
uint256 supplyUsageRatio;
uint256 availableLiquidityPlusDebt;
}

/**
* @notice Holds the interest rate data for a given reserve
*
* @dev Since values are in bps, they are multiplied by 1e23 in order to become rays with 27 decimals. This
* in turn means that the maximum supported interest rate is 4294967295 (2**32-1) bps or 42949672.95%.
*
* @param optimalUsageRatio The optimal usage ratio, in bps
* @param baseVariableBorrowRate The base variable borrow rate, in bps
* @param variableRateSlope1 The slope of the variable interest curve, before hitting the optimal ratio, in bps
* @param variableRateSlope2 The slope of the variable interest curve, after hitting the optimal ratio, in bps
*/
struct InterestRateData {
uint16 optimalUsageRatio;
uint32 baseVariableBorrowRate;
uint32 variableRateSlope1;
uint32 variableRateSlope2;
}

/**
* @notice The interest rate data, where all values are in ray (fixed-point 27 decimal numbers) for a given reserve,
* used in in-memory calculations.
*
* @param optimalUsageRatio The optimal usage ratio
* @param baseVariableBorrowRate The base variable borrow rate
* @param variableRateSlope1 The slope of the variable interest curve, before hitting the optimal ratio
* @param variableRateSlope2 The slope of the variable interest curve, after hitting the optimal ratio
*/
struct InterestRateDataRay {
uint256 optimalUsageRatio;
uint256 baseVariableBorrowRate;
uint256 variableRateSlope1;
uint256 variableRateSlope2;
}

/**
* @notice emitted when new interest rate data is set in a reserve
*
* @param reserve address of the reserve that has new interest rate data set
* @param optimalUsageRatio The optimal usage ratio, in bps
* @param baseVariableBorrowRate The base variable borrow rate, in bps
* @param variableRateSlope1 The slope of the variable interest curve, before hitting the optimal ratio, in bps
* @param variableRateSlope2 The slope of the variable interest curve, after hitting the optimal ratio, in bps
*/
event RateDataUpdate(
address indexed reserve,
uint256 optimalUsageRatio,
uint256 baseVariableBorrowRate,
uint256 variableRateSlope1,
uint256 variableRateSlope2
);

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

/**
* @notice Returns the maximum value achievable for variable borrow rate, in bps
* @return The maximum rate
*/
function MAX_BORROW_RATE() external view returns (uint256);

/**
* @notice Returns the minimum optimal point, in bps
* @return The optimal point
*/
function MIN_OPTIMAL_POINT() external view returns (uint256);

/**
* @notice Returns the maximum optimal point, in bps
* @return The optimal point
*/
function MAX_OPTIMAL_POINT() external view returns (uint256);

/**
* notice Returns the full InterestRateData object for the given reserve, in ray
*
* @param reserve The reserve to get the data of
*
* @return The InterestRateDataRay object for the given reserve
*/
function getInterestRateData(address reserve) external view returns (InterestRateDataRay memory);

/**
* notice Returns the full InterestRateDataRay object for the given reserve, in bps
*
* @param reserve The reserve to get the data of
*
* @return The InterestRateData object for the given reserve
*/
function getInterestRateDataBps(address reserve) external view returns (InterestRateData memory);

/**
* @notice Returns the optimal usage rate for the given reserve in ray
*
* @param reserve The reserve to get the optimal usage rate of
*
* @return The optimal usage rate is the level of borrow / collateral at which the borrow rate
*/
function getOptimalUsageRatio(address reserve) external view returns (uint256);

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

/**
* @notice Returns the variable rate slope above optimal usage ratio in ray
* @dev It's the variable rate when usage ratio > OPTIMAL_USAGE_RATIO
*
* @param reserve The reserve to get the variable rate slope 2 of
*
* @return The variable rate slope
*/
function getVariableRateSlope2(address reserve) external view returns (uint256);

/**
* @notice Returns the base variable borrow rate, in ray
*
* @param reserve The reserve to get the base variable borrow rate of
*
* @return The base variable borrow rate
*/
function getBaseVariableBorrowRate(address reserve) external view returns (uint256);

/**
* @notice Returns the maximum variable borrow rate, in ray
*
* @param reserve The reserve to get the maximum variable borrow rate of
*
* @return The maximum variable borrow rate
*/
function getMaxVariableBorrowRate(address reserve) external view returns (uint256);

/**
* @notice Sets interest rate data for an Aave rate strategy
* @param reserve The reserve to update
* @param rateData The reserve interest rate data to apply to the given reserve
* Being specific to this custom implementation, with custom struct type,
* overloading the function on the generic interface
*/
function setInterestRateParams(address reserve, InterestRateData calldata rateData) external;
}
93 changes: 92 additions & 1 deletion src/core/contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ interface IPool {
*/
function swapBorrowRateMode(address asset, uint256 interestRateMode) external;

/**
* @notice Allows a borrower to swap his debt between stable and variable mode,
* @dev introduce in a flavor stable rate deprecation
* @param asset The address of the underlying asset borrowed
* @param user The address of the user to be swapped
*/
function swapToVariable(address asset, address user) external;

/**
* @notice Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.
* - Users can be rebalanced if the following conditions are satisfied:
Expand Down Expand Up @@ -524,6 +532,22 @@ interface IPool {
address rateStrategyAddress
) external;

/**
* @notice Accumulates interest to all indexes of the reserve
* @dev Only callable by the PoolConfigurator contract
* @dev To be used when required by the configurator, for example when updating interest rates strategy data
* @param asset The address of the underlying asset of the reserve
*/
function syncIndexesState(address asset) external;

/**
* @notice Updates interest rates on the reserve data
* @dev Only callable by the PoolConfigurator contract
* @dev To be used when required by the configurator, for example when updating interest rates strategy data
* @param asset The address of the underlying asset of the reserve
*/
function syncRatesState(address asset) external;

/**
* @notice Sets the configuration bitmap of the reserve as a whole
* @dev Only callable by the PoolConfigurator contract
Expand Down Expand Up @@ -579,7 +603,23 @@ interface IPool {
* @param asset The address of the underlying asset of the reserve
* @return The state and configuration data of the reserve
*/
function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);
function getReserveData(address asset) external view returns (DataTypes.ReserveDataLegacy memory);

/**
* @notice Returns the state and configuration of the reserve, including extra data included with Aave v3.1
* @param asset The address of the underlying asset of the reserve
* @return The state and configuration data of the reserve with virtual accounting
*/
function getReserveDataExtended(
address asset
) external view returns (DataTypes.ReserveData memory);

/**
* @notice Returns the virtual underlying balance of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The reserve virtual underlying balance
*/
function getVirtualUnderlyingBalance(address asset) external view returns (uint128);

/**
* @notice Validates and finalizes an aToken transfer
Expand Down Expand Up @@ -684,6 +724,22 @@ interface IPool {
*/
function resetIsolationModeTotalDebt(address asset) external;

/**
* @notice Sets the liquidation grace period of the given asset
* @dev To enable a liquidation grace period, a timestamp in the future should be set,
* To disable a liquidation grace period, any timestamp in the past works, like 0
* @param asset The address of the underlying asset to set the liquidationGracePeriod
* @param until Timestamp when the liquidation grace period will end
**/
function setLiquidationGracePeriod(address asset, uint40 until) external;

/**
* @notice Returns the liquidation grace period of the given asset
* @param asset The address of the underlying asset
* @return Timestamp when the liquidation grace period will end
**/
function getLiquidationGracePeriod(address asset) external returns (uint40);

/**
* @notice Returns the percentage of available liquidity that can be borrowed at once at stable rate
* @return The percentage of available liquidity to borrow, expressed in bps
Expand Down Expand Up @@ -741,4 +797,39 @@ interface IPool {
* 0 if the action is executed directly by the user, without any middle-man
*/
function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;

/**
* @notice Gets the address of the external FlashLoanLogic
*/
function getFlashLoanLogic() external returns (address);

/**
* @notice Gets the address of the external BorrowLogic
*/
function getBorrowLogic() external returns (address);

/**
* @notice Gets the address of the external BridgeLogic
*/
function getBridgeLogic() external returns (address);

/**
* @notice Gets the address of the external EModeLogic
*/
function getEModeLogic() external returns (address);

/**
* @notice Gets the address of the external LiquidationLogic
*/
function getLiquidationLogic() external returns (address);

/**
* @notice Gets the address of the external PoolLogic
*/
function getPoolLogic() external returns (address);

/**
* @notice Gets the address of the external SupplyLogic
*/
function getSupplyLogic() external returns (address);
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.