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

Aave v3.2 Updates #131

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
24 changes: 17 additions & 7 deletions contracts/protocols/mainnet/aave_v3/helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract AaveV3Helper is DSMath {
*@dev Returns UI Incentives Provider Feed Address
*/
function getUiIncetivesProvider() internal pure returns (address) {
return 0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6;
return 0x5a40cDe2b76Da2beD545efB3ae15708eE56aAF9c;
}

/**
Expand Down Expand Up @@ -118,7 +118,6 @@ contract AaveV3Helper is DSMath {
struct AaveV3Token {
uint256 supplyCap;
uint256 borrowCap;
uint256 eModeCategory;
uint256 debtCeiling;
uint256 debtCeilingDecimals;
uint256 liquidationFee;
Expand Down Expand Up @@ -310,15 +309,13 @@ contract AaveV3Helper is DSMath {
) internal view returns (AaveV3Token memory tokenData) {
(
(tokenData.borrowCap, tokenData.supplyCap),
tokenData.eModeCategory,
tokenData.debtCeiling,
tokenData.debtCeilingDecimals,
tokenData.liquidationFee,
tokenData.isPaused,
tokenData.flashLoanEnabled
) = (
aaveData.getReserveCaps(token),
aaveData.getReserveEModeCategory(token),
aaveData.getDebtCeiling(token),
aaveData.getDebtCeilingDecimals(),
aaveData.getLiquidationProtocolFee(token),
Expand All @@ -339,7 +336,21 @@ contract AaveV3Helper is DSMath {
address poolAddressProvider
) external view returns (EmodeData memory eModeData) {
PoolSpecificInfo memory poolInfo = getPoolSpecificInfo(poolAddressProvider);
EModeCategory memory data_ = poolInfo.pool.getEModeCategoryData(id);

EModeCollateralConfig memory config_ = poolInfo.pool.getEModeCategoryCollateralConfig(id);
string memory label = poolInfo.pool.getEModeCategoryLabel(id);
uint128 isCollateralBitmap = poolInfo.pool.getEModeCategoryCollateralBitmap(id);
uint128 isBorrowableBitmap = poolInfo.pool.getEModeCategoryBorrowableBitmap(id);

EModeCategory memory data_ = EModeCategory(
config_.ltv,
config_.liquidationThreshold,
config_.liquidationBonus,
label,
isCollateralBitmap,
isBorrowableBitmap
);

{
eModeData.data = data_;
}
Expand Down Expand Up @@ -368,11 +379,10 @@ contract AaveV3Helper is DSMath {
reserve.stableDebtToken.tokenAddress,
reserve.variableDebtToken.tokenAddress
) = aaveData.getReserveTokensAddresses(token);

reserve.aToken.symbol = IERC20Detailed(reserve.aToken.tokenAddress).symbol();
reserve.stableDebtToken.symbol = IERC20Detailed(reserve.stableDebtToken.tokenAddress).symbol();
reserve.variableDebtToken.symbol = IERC20Detailed(reserve.variableDebtToken.tokenAddress).symbol();
reserve.aToken.decimals = IERC20Detailed(reserve.aToken.tokenAddress).decimals();
reserve.stableDebtToken.decimals = IERC20Detailed(reserve.stableDebtToken.tokenAddress).decimals();
reserve.variableDebtToken.decimals = IERC20Detailed(reserve.variableDebtToken.tokenAddress).decimals();
}

Expand Down
20 changes: 15 additions & 5 deletions contracts/protocols/mainnet/aave_v3/interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ struct EModeCategory {
uint16 liquidationThreshold;
uint16 liquidationBonus;
// each eMode category may or may not have a custom oracle to override the individual assets price oracles
address priceSource;
string label;
uint128 isCollateralBitmap;
uint128 isBorrowableBitmap;
}

struct EModeCollateralConfig {
uint16 ltv;
uint16 liquidationThreshold;
uint16 liquidationBonus;
}

struct ReserveConfigurationMap {
Expand Down Expand Up @@ -153,7 +160,8 @@ struct AggregatedReserveData {
uint16 eModeLtv;
uint16 eModeLiquidationThreshold;
uint16 eModeLiquidationBonus;
address eModePriceSource;
uint128 isCollateralBitmap;
uint128 isBorrowableBitmap;
string eModeLabel;
bool borrowableInIsolation;
}
Expand All @@ -173,7 +181,11 @@ interface IPool {
uint256 healthFactor
);

function getEModeCategoryData(uint8 id) external view returns (EModeCategory memory);
// 3.2 Updated Interface for eMode
function getEModeCategoryCollateralConfig(uint8 id) external view returns (EModeCollateralConfig memory);
function getEModeCategoryLabel(uint8 id) external view returns (string memory);
function getEModeCategoryCollateralBitmap(uint8 id) external view returns (uint128);
function getEModeCategoryBorrowableBitmap(uint8 id) external view returns (uint128);

//@return emode id of the user
function getUserEMode(address user) external view returns (uint256);
Expand Down Expand Up @@ -300,8 +312,6 @@ interface IAaveProtocolDataProvider is IPoolDataProvider {

function getLiquidationProtocolFee(address asset) external view returns (uint256);

function getReserveEModeCategory(address asset) external view returns (uint256);

function getReserveCaps(address asset) external view returns (uint256 borrowCap, uint256 supplyCap);

// @notice Returns the debt ceiling of the reserve
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocols/mainnet/aave_v3/main.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ contract AaveV3Resolver is AaveV3Helper {
}

contract InstaAaveV3Resolver is AaveV3Resolver {
string public constant name = "AaveV3-Resolver-v1.1";
string public constant name = "AaveV3-Resolver-v1.2";
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,8 @@ interface IPoolConfigurator {
*/
event UnbackedMintCapChanged(address indexed asset, uint256 oldUnbackedMintCap, uint256 newUnbackedMintCap);

/**
* @dev Emitted when the category of an asset in eMode is changed.
* @param asset The address of the underlying asset of the reserve
* @param oldCategoryId The old eMode asset category
* @param newCategoryId The new eMode asset category
*/
event EModeAssetCategoryChanged(address indexed asset, uint8 oldCategoryId, uint8 newCategoryId);
event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool collateral);
event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable);

/**
* @dev Emitted when a new eMode category is added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ interface IReserveInterestRateStrategy {
* @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
returns (
uint256,
uint256,
uint256
);
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocols/mainnet/morpho/aave_v3/main.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ contract MorphoResolver is MorphoHelpers {
}

contract InstaAaveV3MorphoResolver is MorphoResolver {
string public constant name = "Morpho-Aave-Resolver-v3.0";
string public constant name = "Morpho-Aave-Resolver-v3.1";
}
7 changes: 4 additions & 3 deletions test/mainnet/aave_v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("AaveV3", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
blockNumber: 20821179,
blockNumber: 20921330,
},
},
],
Expand Down Expand Up @@ -208,7 +208,7 @@ describe("AaveV3", () => {
);
}
console.log();
console.log(`E-Mode category: ${tokenData[i].token.eModeCategory}`);
// console.log(`E-Mode category: ${tokenData[i].token.eModeCategory}`);
console.log(
"Debt ceiling: ",
formatUnits(tokenData[i].token.debtCeiling, tokenData[i].token.debtCeilingDecimals),
Expand All @@ -229,8 +229,9 @@ describe("AaveV3", () => {
console.log(`e-mode LTV: ${emodeData.data.ltv}`);
console.log(`e-mode liquidation threshold: ${emodeData.data.liquidationThreshold}`);
console.log(`e-mode liquidation bonus: ${emodeData.data.liquidationBonus}`);
console.log(`e-mode price oracle: ${emodeData.data.priceSource}`);
console.log(`e-mode label: ${emodeData.data.label}`);
console.log(`e-mode is colleteral bitmap: ${emodeData.data.isCollateralBitmap}`);
console.log(`e-mode is borrowable bitmap: ${emodeData.data.isBorrowableBitmap}`);
});

it("Returns the ethPrice", async () => {
Expand Down