From 83b245abda2b69306408f2be5891581d82b359a2 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 23 Apr 2024 18:48:17 +0300 Subject: [PATCH 01/88] DRAFT: stable rate removal --- .../IDefaultInterestRateStrategyV2.sol | 10 - src/core/contracts/interfaces/IL2Pool.sol | 18 - src/core/contracts/interfaces/IPool.sol | 44 +- .../interfaces/IPoolConfigurator.sol | 21 +- .../interfaces/IPoolDataProvider.sol | 2 +- .../IReserveInterestRateStrategy.sol | 3 +- .../misc/AaveProtocolDataProvider.sol | 36 +- .../helpers/MockReserveConfiguration.sol | 12 +- .../tests/MockReserveInterestRateStrategy.sol | 9 +- .../contracts/mocks/tokens/MockDebtTokens.sol | 9 - .../configuration/ReserveConfiguration.sol | 29 +- .../protocol/libraries/helpers/Helpers.sol | 8 +- .../protocol/libraries/logic/BorrowLogic.sol | 147 +- .../libraries/logic/ConfiguratorLogic.sol | 60 +- .../libraries/logic/FlashLoanLogic.sol | 4 +- .../protocol/libraries/logic/GenericLogic.sol | 11 +- .../libraries/logic/LiquidationLogic.sol | 42 +- .../protocol/libraries/logic/PoolLogic.sol | 1 - .../protocol/libraries/logic/ReserveLogic.sol | 100 +- .../libraries/logic/ValidationLogic.sol | 174 +-- .../types/ConfiguratorInputTypes.sol | 3 - .../protocol/libraries/types/DataTypes.sol | 48 +- .../DefaultReserveInterestRateStrategyV2.sol | 69 +- src/core/contracts/protocol/pool/L2Pool.sol | 18 - src/core/contracts/protocol/pool/Pool.sol | 51 +- .../protocol/pool/PoolConfigurator.sol | 25 +- .../contracts/protocol/pool/PoolStorage.sol | 2 +- .../tokenization/base/IncentivizedERC20.sol | 3 +- src/core/instances/PoolInstance.sol | 1 - .../procedures/AaveV3TokensProcedure.sol | 14 - .../contracts/utilities/MarketReportUtils.sol | 1 - .../contracts/utilities/MetadataReporter.sol | 1 - .../interfaces/IMarketReportTypes.sol | 2 - .../AaveV3BatchOrchestration.sol | 1 - .../paraswap/ParaSwapRepayAdapter.sol | 10 +- .../contracts/libraries/DataTypesHelper.sol | 8 +- .../misc/UiIncentiveDataProviderV3.sol | 107 -- .../contracts/misc/UiPoolDataProviderV3.sol | 23 - .../contracts/misc/WalletBalanceProvider.sol | 2 +- .../contracts/misc/WrappedTokenGatewayV3.sol | 33 +- .../v3-config-engine/AaveV3ConfigEngine.sol | 15 +- .../v3-config-engine/AaveV3Payload.sol | 2 +- .../v3-config-engine/IAaveV3ConfigEngine.sol | 7 - .../libraries/BorrowEngine.sol | 11 +- .../libraries/ListingEngine.sol | 13 - tests/core/L2Pool.t.sol | 35 +- tests/core/Pool.Borrow.t.sol | 213 +-- tests/core/Pool.FlashLoans.t.sol | 2 +- tests/core/Pool.Liquidations.t.sol | 10 +- tests/core/Pool.Repay.t.sol | 8 +- tests/core/Pool.t.sol | 12 +- .../core/PoolConfigurator.ACLModifiers.t.sol | 28 - tests/core/PoolConfigurator.borrowCaps.t.sol | 10 +- .../core/PoolConfigurator.initReserves.t.sol | 34 +- .../PoolConfigurator.reserveRiskConfig.t.sol | 73 +- .../core/PoolConfigurator.upgradeabilty.t.sol | 81 +- tests/core/PoolLogic.initReserves.edge.t.sol | 5 - tests/core/RateStrategy.calculateRates.t.sol | 465 +++++++ tests/core/RateStrategy.setters.t.sol | 149 ++ tests/core/RateStrategy.t.sol | 1207 +---------------- tests/core/RateStrategy.template.sol | 80 ++ tests/core/RatesOverflow.t.sol | 5 - tests/core/StableDebtToken.t.sol | 419 ------ tests/core/ZeroInteresRateStrategy.t.sol | 12 +- tests/mocks/AaveV3TestListing.sol | 14 +- tests/periphery/WrappedTokenGateway.t.sol | 9 +- tests/utils/BatchTestProcedures.sol | 6 - tests/utils/ConfigEngineDeployer.sol | 1 - tests/utils/ProtocolV3TestBase.sol | 1 - tests/utils/TestnetProcedures.sol | 17 +- 70 files changed, 960 insertions(+), 3146 deletions(-) create mode 100644 tests/core/RateStrategy.calculateRates.t.sol create mode 100644 tests/core/RateStrategy.setters.t.sol create mode 100644 tests/core/RateStrategy.template.sol delete mode 100644 tests/core/StableDebtToken.t.sol diff --git a/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol b/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol index c0e1afae..2e6ad1a2 100644 --- a/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol +++ b/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol @@ -10,16 +10,6 @@ import {IPoolAddressesProvider} from './IPoolAddressesProvider.sol'; * @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 * diff --git a/src/core/contracts/interfaces/IL2Pool.sol b/src/core/contracts/interfaces/IL2Pool.sol index 64f3e2eb..56dee912 100644 --- a/src/core/contracts/interfaces/IL2Pool.sol +++ b/src/core/contracts/interfaces/IL2Pool.sol @@ -92,24 +92,6 @@ interface IL2Pool { */ function repayWithATokens(bytes32 args) external returns (uint256); - /** - * @notice Calldata efficient wrapper of the swapBorrowRateMode function - * @param args Arguments for the swapBorrowRateMode function packed in one bytes32 - * 232 bits 8 bits 16 bits - * | 0-padding | shortenedInterestRateMode | assetId | - * @dev assetId is the index of the asset in the reservesList. - */ - function swapBorrowRateMode(bytes32 args) external; - - /** - * @notice Calldata efficient wrapper of the rebalanceStableBorrowRate function - * @param args Arguments for the rebalanceStableBorrowRate function packed in one bytes32 - * 80 bits 160 bits 16 bits - * | 0-padding | user address | assetId | - * @dev assetId is the index of the asset in the reservesList. - */ - function rebalanceStableBorrowRate(bytes32 args) external; - /** * @notice Calldata efficient wrapper of the setUserUseReserveAsCollateral function * @param args Arguments for the setUserUseReserveAsCollateral function packed in one bytes32 diff --git a/src/core/contracts/interfaces/IPool.sol b/src/core/contracts/interfaces/IPool.sol index f746d172..4ba36bdc 100644 --- a/src/core/contracts/interfaces/IPool.sol +++ b/src/core/contracts/interfaces/IPool.sol @@ -288,13 +288,12 @@ interface IPool { /** * @notice Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower - * already supplied enough collateral, or he was given enough allowance by a credit delegator on the - * corresponding debt token (StableDebtToken or VariableDebtToken) + * already supplied enough collateral, or he was given enough allowance by a credit delegator on the VariableDebtToken * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet - * and 100 stable/variable debt tokens, depending on the `interestRateMode` + * and 100 variable debt tokens * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed - * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param interestRateMode DEPRECATED in v3.2.0 * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf The address of the user who will receive the debt. Should be the address of the borrower itself @@ -315,7 +314,7 @@ interface IPool { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode DEPRECATED in v3.2.0 * @param onBehalfOf The address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed @@ -334,7 +333,7 @@ interface IPool { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode DEPRECATED in v3.2.0 * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed @@ -364,7 +363,7 @@ interface IPool { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode DEPRECATED in v3.2.0 * @return The final amount repaid */ function repayWithATokens( @@ -373,32 +372,6 @@ interface IPool { uint256 interestRateMode ) external returns (uint256); - /** - * @notice Allows a borrower to swap his debt between stable and variable mode, or vice versa - * @param asset The address of the underlying asset borrowed - * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable - */ - 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: - * 1. Usage ratio is above 95% - * 2. the current supply APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too - * much has been borrowed at a stable rate and suppliers are not earning enough - * @param asset The address of the underlying asset borrowed - * @param user The address of the user to be rebalanced - */ - function rebalanceStableBorrowRate(address asset, address user) external; - /** * @notice Allows suppliers to enable/disable a specific supplied asset as collateral * @param asset The address of the underlying asset supplied @@ -435,8 +408,7 @@ interface IPool { * @param amounts The amounts of the assets being flash-borrowed * @param interestRateModes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver - * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address - * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * 1 or 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode The code used to register the integrator originating the operation, for potential rewards. @@ -502,14 +474,12 @@ interface IPool { * @dev Only callable by the PoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param aTokenAddress The address of the aToken that will be assigned to the reserve - * @param stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve * @param variableDebtAddress The address of the VariableDebtToken that will be assigned to the reserve * @param interestRateStrategyAddress The address of the interest rate strategy contract */ function initReserve( address asset, address aTokenAddress, - address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; diff --git a/src/core/contracts/interfaces/IPoolConfigurator.sol b/src/core/contracts/interfaces/IPoolConfigurator.sol index beab809a..d33aa9ae 100644 --- a/src/core/contracts/interfaces/IPoolConfigurator.sol +++ b/src/core/contracts/interfaces/IPoolConfigurator.sol @@ -14,7 +14,7 @@ interface IPoolConfigurator { * @dev Emitted when a reserve is initialized. * @param asset The address of the underlying asset of the reserve * @param aToken The address of the associated aToken contract - * @param stableDebtToken The address of the associated stable rate debt token + * @param stableDebtToken DEPRECATED in v3.2.0 * @param variableDebtToken The address of the associated variable rate debt token * @param interestRateStrategyAddress The address of the interest rate strategy for the reserve */ @@ -69,6 +69,7 @@ interface IPoolConfigurator { /** * @dev Emitted when stable rate borrowing is enabled or disabled on a reserve + * @notice deprecated in v3.2.0 * @param asset The address of the underlying asset of the reserve * @param enabled True if stable rate borrowing is enabled, false otherwise */ @@ -215,6 +216,7 @@ interface IPoolConfigurator { /** * @dev Emitted when the implementation of a stable debt token is upgraded. + * @notice deprecated in v3.2.0 * @param asset The address of the underlying asset of the reserve * @param proxy The stable debt token proxy address * @param implementation The new aToken implementation @@ -299,14 +301,6 @@ interface IPoolConfigurator { */ function updateAToken(ConfiguratorInputTypes.UpdateATokenInput calldata input) external; - /** - * @notice Updates the stable debt token implementation for the reserve. - * @param input The stableDebtToken update parameters - */ - function updateStableDebtToken( - ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - ) external; - /** * @notice Updates the variable debt token implementation for the asset. * @param input The variableDebtToken update parameters @@ -317,7 +311,6 @@ interface IPoolConfigurator { /** * @notice Configures borrowing on a reserve. - * @dev Can only be disabled (set to false) if stable borrowing is disabled * @param asset The address of the underlying asset of the reserve * @param enabled True if borrowing needs to be enabled, false otherwise */ @@ -339,14 +332,6 @@ interface IPoolConfigurator { uint256 liquidationBonus ) external; - /** - * @notice Enable or disable stable rate borrowing on a reserve. - * @dev Can only be enabled (set to true) if borrowing is enabled - * @param asset The address of the underlying asset of the reserve - * @param enabled True if stable rate borrowing needs to be enabled, false otherwise - */ - function setReserveStableRateBorrowing(address asset, bool enabled) external; - /** * @notice Enable or disable flashloans on a reserve * @param asset The address of the underlying asset of the reserve diff --git a/src/core/contracts/interfaces/IPoolDataProvider.sol b/src/core/contracts/interfaces/IPoolDataProvider.sol index 2ec458b9..9e5e4266 100644 --- a/src/core/contracts/interfaces/IPoolDataProvider.sol +++ b/src/core/contracts/interfaces/IPoolDataProvider.sol @@ -211,7 +211,7 @@ interface IPoolDataProvider { * @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 stableDebtTokenAddress DEPRECATED in v3.2.0 * @return variableDebtTokenAddress The VariableDebtToken address of the reserve */ function getReserveTokensAddresses( diff --git a/src/core/contracts/interfaces/IReserveInterestRateStrategy.sol b/src/core/contracts/interfaces/IReserveInterestRateStrategy.sol index cdd81565..e953cce5 100644 --- a/src/core/contracts/interfaces/IReserveInterestRateStrategy.sol +++ b/src/core/contracts/interfaces/IReserveInterestRateStrategy.sol @@ -21,10 +21,9 @@ 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 ray - * @return stableBorrowRate The stable borrow rate expressed in ray * @return variableBorrowRate The variable borrow rate expressed in ray */ function calculateInterestRates( DataTypes.CalculateInterestRatesParams memory params - ) external view returns (uint256, uint256, uint256); + ) external view returns (uint256, uint256); } diff --git a/src/core/contracts/misc/AaveProtocolDataProvider.sol b/src/core/contracts/misc/AaveProtocolDataProvider.sol index 4db9441b..41fa1c9b 100644 --- a/src/core/contracts/misc/AaveProtocolDataProvider.sol +++ b/src/core/contracts/misc/AaveProtocolDataProvider.sol @@ -7,7 +7,6 @@ import {UserConfiguration} from '../protocol/libraries/configuration/UserConfigu import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {WadRayMath} from '../protocol/libraries/math/WadRayMath.sol'; import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; -import {IStableDebtToken} from '../interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../interfaces/IVariableDebtToken.sol'; import {IPool} from '../interfaces/IPool.sol'; import {IPoolDataProvider} from '../interfaces/IPoolDataProvider.sol'; @@ -99,7 +98,10 @@ contract AaveProtocolDataProvider is IPoolDataProvider { (ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor, ) = configuration .getParams(); - (isActive, isFrozen, borrowingEnabled, stableBorrowRateEnabled, ) = configuration.getFlags(); + (isActive, isFrozen, borrowingEnabled, ) = configuration.getFlags(); + + // @notice all stable debt related parameters deprecated in v3.2.0 + stableBorrowRateEnabled = false; usageAsCollateralEnabled = liquidationThreshold != 0; } @@ -120,7 +122,7 @@ contract AaveProtocolDataProvider is IPoolDataProvider { /// @inheritdoc IPoolDataProvider function getPaused(address asset) external view override returns (bool isPaused) { - (, , , , isPaused) = IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getFlags(); + (, , , isPaused) = IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getFlags(); } /// @inheritdoc IPoolDataProvider @@ -174,16 +176,17 @@ contract AaveProtocolDataProvider is IPoolDataProvider { asset ); + // @notice all stable debt related parameters deprecated in v3.2.0 return ( reserve.unbacked, reserve.accruedToTreasury, IERC20Detailed(reserve.aTokenAddress).totalSupply(), - IERC20Detailed(reserve.stableDebtTokenAddress).totalSupply(), + 0, IERC20Detailed(reserve.variableDebtTokenAddress).totalSupply(), reserve.currentLiquidityRate, reserve.currentVariableBorrowRate, - reserve.currentStableBorrowRate, - IStableDebtToken(reserve.stableDebtTokenAddress).getAverageStableRate(), + 0, + 0, reserve.liquidityIndex, reserve.variableBorrowIndex, reserve.lastUpdateTimestamp @@ -203,9 +206,7 @@ contract AaveProtocolDataProvider is IPoolDataProvider { DataTypes.ReserveDataLegacy memory reserve = IPool(ADDRESSES_PROVIDER.getPool()).getReserveData( asset ); - return - IERC20Detailed(reserve.stableDebtTokenAddress).totalSupply() + - IERC20Detailed(reserve.variableDebtTokenAddress).totalSupply(); + return IERC20Detailed(reserve.variableDebtTokenAddress).totalSupply(); } /// @inheritdoc IPoolDataProvider @@ -237,14 +238,12 @@ contract AaveProtocolDataProvider is IPoolDataProvider { currentATokenBalance = IERC20Detailed(reserve.aTokenAddress).balanceOf(user); currentVariableDebt = IERC20Detailed(reserve.variableDebtTokenAddress).balanceOf(user); - currentStableDebt = IERC20Detailed(reserve.stableDebtTokenAddress).balanceOf(user); - principalStableDebt = IStableDebtToken(reserve.stableDebtTokenAddress).principalBalanceOf(user); + + // @notice all stable debt related parameters deprecated in v3.2.0 + currentStableDebt = principalStableDebt = stableBorrowRate = stableRateLastUpdated = 0; + scaledVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress).scaledBalanceOf(user); liquidityRate = reserve.currentLiquidityRate; - stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(user); - stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated( - user - ); usageAsCollateralEnabled = userConfig.isUsingAsCollateral(reserve.id); } @@ -265,11 +264,8 @@ contract AaveProtocolDataProvider is IPoolDataProvider { asset ); - return ( - reserve.aTokenAddress, - reserve.stableDebtTokenAddress, - reserve.variableDebtTokenAddress - ); + // @notice all stable debt related parameters deprecated in v3.2.0 + return (reserve.aTokenAddress, address(0), reserve.variableDebtTokenAddress); } /// @inheritdoc IPoolDataProvider diff --git a/src/core/contracts/mocks/helpers/MockReserveConfiguration.sol b/src/core/contracts/mocks/helpers/MockReserveConfiguration.sol index cce1cc9f..6d9738d6 100644 --- a/src/core/contracts/mocks/helpers/MockReserveConfiguration.sol +++ b/src/core/contracts/mocks/helpers/MockReserveConfiguration.sol @@ -69,16 +69,6 @@ contract MockReserveConfiguration { return configuration.getBorrowingEnabled(); } - function setStableRateBorrowingEnabled(bool enabled) external { - DataTypes.ReserveConfigurationMap memory config = configuration; - config.setStableRateBorrowingEnabled(enabled); - configuration = config; - } - - function getStableRateBorrowingEnabled() external view returns (bool) { - return configuration.getStableRateBorrowingEnabled(); - } - function setReserveFactor(uint256 reserveFactor) external { DataTypes.ReserveConfigurationMap memory config = configuration; config.setReserveFactor(reserveFactor); @@ -149,7 +139,7 @@ contract MockReserveConfiguration { return configuration.getUnbackedMintCap(); } - function getFlags() external view returns (bool, bool, bool, bool, bool) { + function getFlags() external view returns (bool, bool, bool, bool) { return configuration.getFlags(); } diff --git a/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol b/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol index 082d7651..0b644fa6 100644 --- a/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol +++ b/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol @@ -20,12 +20,7 @@ contract MockReserveInterestRateStrategy is DefaultReserveInterestRateStrategyV2 function calculateInterestRates( DataTypes.CalculateInterestRatesParams memory - ) - public - view - override - returns (uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate) - { - return (_liquidityRate, 0, _variableBorrowRate); + ) public view override returns (uint256 liquidityRate, uint256 variableBorrowRate) { + return (_liquidityRate, _variableBorrowRate); } } diff --git a/src/core/contracts/mocks/tokens/MockDebtTokens.sol b/src/core/contracts/mocks/tokens/MockDebtTokens.sol index 8c186b82..211821f5 100644 --- a/src/core/contracts/mocks/tokens/MockDebtTokens.sol +++ b/src/core/contracts/mocks/tokens/MockDebtTokens.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.10; import {VariableDebtTokenInstance} from '../../../instances/VariableDebtTokenInstance.sol'; -import {StableDebtTokenInstance} from '../../../instances/StableDebtTokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockVariableDebtToken is VariableDebtTokenInstance { @@ -12,11 +11,3 @@ contract MockVariableDebtToken is VariableDebtTokenInstance { return 0x2; } } - -contract MockStableDebtToken is StableDebtTokenInstance { - constructor(IPool pool) StableDebtTokenInstance(pool) {} - - function getRevision() internal pure override returns (uint256) { - return 0x2; - } -} diff --git a/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol index 700b129a..57d961c0 100644 --- a/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol +++ b/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol @@ -311,31 +311,6 @@ library ReserveConfiguration { return (self.data & ~BORROWING_MASK) != 0; } - /** - * @notice Enables or disables stable rate borrowing on the reserve - * @param self The reserve configuration - * @param enabled True if the stable rate borrowing needs to be enabled, false otherwise - */ - function setStableRateBorrowingEnabled( - DataTypes.ReserveConfigurationMap memory self, - bool enabled - ) internal pure { - self.data = - (self.data & STABLE_BORROWING_MASK) | - (uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION); - } - - /** - * @notice Gets the stable rate borrowing state of the reserve - * @param self The reserve configuration - * @return The stable rate borrowing state - */ - function getStableRateBorrowingEnabled( - DataTypes.ReserveConfigurationMap memory self - ) internal pure returns (bool) { - return (self.data & ~STABLE_BORROWING_MASK) != 0; - } - /** * @notice Sets the reserve factor of the reserve * @param self The reserve configuration @@ -577,19 +552,17 @@ library ReserveConfiguration { * @return The state flag representing active * @return The state flag representing frozen * @return The state flag representing borrowing enabled - * @return The state flag representing stableRateBorrowing enabled * @return The state flag representing paused */ function getFlags( DataTypes.ReserveConfigurationMap memory self - ) internal pure returns (bool, bool, bool, bool, bool) { + ) internal pure returns (bool, bool, bool, bool) { uint256 dataLocal = self.data; return ( (dataLocal & ~ACTIVE_MASK) != 0, (dataLocal & ~FROZEN_MASK) != 0, (dataLocal & ~BORROWING_MASK) != 0, - (dataLocal & ~STABLE_BORROWING_MASK) != 0, (dataLocal & ~PAUSED_MASK) != 0 ); } diff --git a/src/core/contracts/protocol/libraries/helpers/Helpers.sol b/src/core/contracts/protocol/libraries/helpers/Helpers.sol index 4daf97c5..29a6e8c1 100644 --- a/src/core/contracts/protocol/libraries/helpers/Helpers.sol +++ b/src/core/contracts/protocol/libraries/helpers/Helpers.sol @@ -13,16 +13,12 @@ library Helpers { * @notice Fetches the user current stable and variable debt balances * @param user The user address * @param reserveCache The reserve cache data object - * @return The stable debt balance * @return The variable debt balance */ function getUserCurrentDebt( address user, DataTypes.ReserveCache memory reserveCache - ) internal view returns (uint256, uint256) { - return ( - IERC20(reserveCache.stableDebtTokenAddress).balanceOf(user), - IERC20(reserveCache.variableDebtTokenAddress).balanceOf(user) - ); + ) internal view returns (uint256) { + return IERC20(reserveCache.variableDebtTokenAddress).balanceOf(user); } } diff --git a/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol b/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol index 865a5cf3..1d5eddca 100644 --- a/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.10; import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol'; import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; @@ -93,8 +92,6 @@ library BorrowLogic { asset: params.asset, userAddress: params.onBehalfOf, amount: params.amount, - interestRateMode: params.interestRateMode, - maxStableLoanPercent: params.maxStableRateBorrowSizePercent, reservesCount: params.reservesCount, oracle: params.oracle, userEModeCategory: params.userEModeCategory, @@ -105,27 +102,11 @@ library BorrowLogic { }) ); - uint256 currentStableRate = 0; bool isFirstBorrowing = false; - if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - currentStableRate = reserve.currentStableBorrowRate; - - ( - isFirstBorrowing, - reserveCache.nextTotalStableDebt, - reserveCache.nextAvgStableBorrowRate - ) = IStableDebtToken(reserveCache.stableDebtTokenAddress).mint( - params.user, - params.onBehalfOf, - params.amount, - currentStableRate - ); - } else { - (isFirstBorrowing, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( - reserveCache.variableDebtTokenAddress - ).mint(params.user, params.onBehalfOf, params.amount, reserveCache.nextVariableBorrowIndex); - } + (isFirstBorrowing, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( + reserveCache.variableDebtTokenAddress + ).mint(params.user, params.onBehalfOf, params.amount, reserveCache.nextVariableBorrowIndex); if (isFirstBorrowing) { userConfig.setBorrowing(reserve.id, true); @@ -159,10 +140,8 @@ library BorrowLogic { params.user, params.onBehalfOf, params.amount, - params.interestRateMode, - params.interestRateMode == DataTypes.InterestRateMode.STABLE - ? currentStableRate - : reserve.currentVariableBorrowRate, + DataTypes.InterestRateMode.VARIABLE, + reserve.currentVariableBorrowRate, params.referralCode ); } @@ -188,23 +167,11 @@ library BorrowLogic { DataTypes.ReserveCache memory reserveCache = reserve.cache(); reserve.updateState(reserveCache); - (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt( - params.onBehalfOf, - reserveCache - ); + uint256 variableDebt = Helpers.getUserCurrentDebt(params.onBehalfOf, reserveCache); - ValidationLogic.validateRepay( - reserveCache, - params.amount, - params.interestRateMode, - params.onBehalfOf, - stableDebt, - variableDebt - ); + ValidationLogic.validateRepay(reserveCache, params.amount, params.onBehalfOf, variableDebt); - uint256 paybackAmount = params.interestRateMode == DataTypes.InterestRateMode.STABLE - ? stableDebt - : variableDebt; + uint256 paybackAmount = variableDebt; // Allows a user to repay with aTokens without leaving dust from interest. if (params.useATokens && params.amount == type(uint256).max) { @@ -215,15 +182,8 @@ library BorrowLogic { paybackAmount = params.amount; } - if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - (reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - reserveCache.stableDebtTokenAddress - ).burn(params.onBehalfOf, paybackAmount); - } else { - reserveCache.nextScaledVariableDebt = IVariableDebtToken( - reserveCache.variableDebtTokenAddress - ).burn(params.onBehalfOf, paybackAmount, reserveCache.nextVariableBorrowIndex); - } + reserveCache.nextScaledVariableDebt = IVariableDebtToken(reserveCache.variableDebtTokenAddress) + .burn(params.onBehalfOf, paybackAmount, reserveCache.nextVariableBorrowIndex); reserve.updateInterestRatesAndVirtualBalance( reserveCache, @@ -232,7 +192,7 @@ library BorrowLogic { 0 ); - if (stableDebt + variableDebt - paybackAmount == 0) { + if (variableDebt - paybackAmount == 0) { userConfig.setBorrowing(reserve.id, false); } @@ -269,89 +229,4 @@ library BorrowLogic { return paybackAmount; } - - /** - * @notice Implements the rebalance stable borrow rate feature. In case of liquidity crunches on the protocol, stable - * rate borrows might need to be rebalanced to bring back equilibrium between the borrow and supply APYs. - * @dev The rules that define if a position can be rebalanced are implemented in `ValidationLogic.validateRebalanceStableBorrowRate()` - * @dev Emits the `RebalanceStableBorrowRate()` event - * @param reserve The state of the reserve of the asset being repaid - * @param asset The asset of the position being rebalanced - * @param user The user being rebalanced - */ - function executeRebalanceStableBorrowRate( - DataTypes.ReserveData storage reserve, - address asset, - address user - ) external { - DataTypes.ReserveCache memory reserveCache = reserve.cache(); - reserve.updateState(reserveCache); - - ValidationLogic.validateRebalanceStableBorrowRate(reserve, reserveCache, asset); - - IStableDebtToken stableDebtToken = IStableDebtToken(reserveCache.stableDebtTokenAddress); - uint256 stableDebt = IERC20(address(stableDebtToken)).balanceOf(user); - - stableDebtToken.burn(user, stableDebt); - - (, reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = stableDebtToken - .mint(user, user, stableDebt, reserve.currentStableBorrowRate); - - reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); - - emit RebalanceStableBorrowRate(asset, user); - } - - /** - * @notice Implements the swap borrow rate feature. Borrowers can swap from variable to stable positions at any time. - * @dev Emits the `Swap()` event - * @param reserve The of the reserve of the asset being repaid - * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - * @param asset The asset of the position being swapped - * @param interestRateMode The current interest rate mode of the position being swapped - */ - function executeSwapBorrowRateMode( - DataTypes.ReserveData storage reserve, - DataTypes.UserConfigurationMap storage userConfig, - address asset, - address user, - DataTypes.InterestRateMode interestRateMode - ) external { - DataTypes.ReserveCache memory reserveCache = reserve.cache(); - - reserve.updateState(reserveCache); - - (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(user, reserveCache); - - ValidationLogic.validateSwapRateMode( - reserve, - reserveCache, - userConfig, - stableDebt, - variableDebt, - interestRateMode - ); - - if (interestRateMode == DataTypes.InterestRateMode.STABLE) { - (reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - reserveCache.stableDebtTokenAddress - ).burn(user, stableDebt); - - (, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( - reserveCache.variableDebtTokenAddress - ).mint(user, user, stableDebt, reserveCache.nextVariableBorrowIndex); - } else { - reserveCache.nextScaledVariableDebt = IVariableDebtToken( - reserveCache.variableDebtTokenAddress - ).burn(user, variableDebt, reserveCache.nextVariableBorrowIndex); - - (, reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - reserveCache.stableDebtTokenAddress - ).mint(user, user, variableDebt, reserve.currentStableBorrowRate); - } - - reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); - - emit SwapBorrowRateMode(asset, user, interestRateMode); - } } diff --git a/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol b/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol index e0b14e7b..5a3bb333 100644 --- a/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol @@ -31,11 +31,6 @@ library ConfiguratorLogic { address indexed proxy, address indexed implementation ); - event StableDebtTokenUpgraded( - address indexed asset, - address indexed proxy, - address indexed implementation - ); event VariableDebtTokenUpgraded( address indexed asset, address indexed proxy, @@ -67,20 +62,6 @@ library ConfiguratorLogic { ) ); - address stableDebtTokenProxyAddress = _initTokenWithProxy( - input.stableDebtTokenImpl, - abi.encodeWithSelector( - IInitializableDebtToken.initialize.selector, - pool, - input.underlyingAsset, - input.incentivesController, - input.underlyingAssetDecimals, - input.stableDebtTokenName, - input.stableDebtTokenSymbol, - input.params - ) - ); - address variableDebtTokenProxyAddress = _initTokenWithProxy( input.variableDebtTokenImpl, abi.encodeWithSelector( @@ -98,7 +79,6 @@ library ConfiguratorLogic { pool.initReserve( input.underlyingAsset, aTokenProxyAddress, - stableDebtTokenProxyAddress, variableDebtTokenProxyAddress, input.interestRateStrategyAddress ); @@ -122,7 +102,7 @@ library ConfiguratorLogic { emit ReserveInitialized( input.underlyingAsset, aTokenProxyAddress, - stableDebtTokenProxyAddress, + address(0), variableDebtTokenProxyAddress, input.interestRateStrategyAddress ); @@ -159,44 +139,6 @@ library ConfiguratorLogic { emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); } - /** - * @notice Updates the stable debt token implementation and initializes it - * @dev Emits the `StableDebtTokenUpgraded` event - * @param cachedPool The Pool containing the reserve with the stable debt token - * @param input The parameters needed for the initialize call - */ - function executeUpdateStableDebtToken( - IPool cachedPool, - ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - ) public { - DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); - - (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); - - bytes memory encodedCall = abi.encodeWithSelector( - IInitializableDebtToken.initialize.selector, - cachedPool, - input.asset, - input.incentivesController, - decimals, - input.name, - input.symbol, - input.params - ); - - _upgradeTokenImplementation( - reserveData.stableDebtTokenAddress, - input.implementation, - encodedCall - ); - - emit StableDebtTokenUpgraded( - input.asset, - reserveData.stableDebtTokenAddress, - input.implementation - ); - } - /** * @notice Updates the variable debt token implementation and initializes it * @dev Emits the `VariableDebtTokenUpgraded` event diff --git a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol b/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol index 615b2fdd..ffd2a13c 100644 --- a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol @@ -120,6 +120,7 @@ library FlashLoanLogic { Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN ); + // TODO: try to remove i from vars for (vars.i = 0; vars.i < params.assets.length; vars.i++) { vars.currentAsset = params.assets[vars.i]; vars.currentAmount = params.amounts[vars.i]; @@ -152,11 +153,8 @@ library FlashLoanLogic { user: msg.sender, onBehalfOf: params.onBehalfOf, amount: vars.currentAmount, - interestRateMode: DataTypes.InterestRateMode(params.interestRateModes[vars.i]), referralCode: params.referralCode, releaseUnderlying: false, - maxStableRateBorrowSizePercent: IPool(params.pool) - .MAX_STABLE_RATE_BORROW_SIZE_PERCENT(), reservesCount: IPool(params.pool).getReservesCount(), oracle: IPoolAddressesProvider(params.addressesProvider).getPriceOracle(), userEModeCategory: IPool(params.pool).getUserEMode(params.onBehalfOf).toUint8(), diff --git a/src/core/contracts/protocol/libraries/logic/GenericLogic.sol b/src/core/contracts/protocol/libraries/logic/GenericLogic.sol index 3342316e..254e24ae 100644 --- a/src/core/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/GenericLogic.sol @@ -209,7 +209,7 @@ library GenericLogic { /** * @notice Calculates total debt of the user in the based currency used to normalize the values of the assets - * @dev This fetches the `balanceOf` of the stable and variable debt tokens for the user. For gas reasons, the + * @dev This fetches the `balanceOf` of the variable debt token for the user. For gas reasons, the * variable debt balance is calculated by fetching `scaledBalancesOf` normalized debt, which is cheaper than * fetching `balanceOf` * @param user The address of the user @@ -228,14 +228,11 @@ library GenericLogic { uint256 userTotalDebt = IScaledBalanceToken(reserve.variableDebtTokenAddress).scaledBalanceOf( user ); - if (userTotalDebt != 0) { - userTotalDebt = userTotalDebt.rayMul(reserve.getNormalizedDebt()); + if (userTotalDebt == 0) { + return 0; } - userTotalDebt = userTotalDebt + IERC20(reserve.stableDebtTokenAddress).balanceOf(user); - - userTotalDebt = assetPrice * userTotalDebt; - + userTotalDebt = userTotalDebt.rayMul(reserve.getNormalizedDebt()) * assetPrice; unchecked { return userTotalDebt / assetUnit; } diff --git a/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol index 158cd46f..80d4d732 100644 --- a/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -15,7 +15,6 @@ import {EModeLogic} from './EModeLogic.sol'; import {UserConfiguration} from '../../libraries/configuration/UserConfiguration.sol'; import {ReserveConfiguration} from '../../libraries/configuration/ReserveConfiguration.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; -import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; @@ -69,7 +68,6 @@ library LiquidationLogic { struct LiquidationCallLocalVars { uint256 userCollateralBalance; - uint256 userVariableDebt; uint256 userTotalDebt; uint256 actualDebtToLiquidate; uint256 actualCollateralToLiquidate; @@ -121,7 +119,7 @@ library LiquidationLogic { }) ); - (vars.userVariableDebt, vars.userTotalDebt, vars.actualDebtToLiquidate) = _calculateDebt( + (vars.userTotalDebt, vars.actualDebtToLiquidate) = _calculateDebt( vars.debtReserveCache, params, vars.healthFactor @@ -325,29 +323,9 @@ library LiquidationLogic { DataTypes.ExecuteLiquidationCallParams memory params, LiquidationCallLocalVars memory vars ) internal { - if (vars.userVariableDebt >= vars.actualDebtToLiquidate) { - vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( - vars.debtReserveCache.variableDebtTokenAddress - ).burn( - params.user, - vars.actualDebtToLiquidate, - vars.debtReserveCache.nextVariableBorrowIndex - ); - } else { - // If the user doesn't have variable debt, no need to try to burn variable debt tokens - if (vars.userVariableDebt != 0) { - vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( - vars.debtReserveCache.variableDebtTokenAddress - ).burn(params.user, vars.userVariableDebt, vars.debtReserveCache.nextVariableBorrowIndex); - } - ( - vars.debtReserveCache.nextTotalStableDebt, - vars.debtReserveCache.nextAvgStableBorrowRate - ) = IStableDebtToken(vars.debtReserveCache.stableDebtTokenAddress).burn( - params.user, - vars.actualDebtToLiquidate - vars.userVariableDebt - ); - } + vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( + vars.debtReserveCache.variableDebtTokenAddress + ).burn(params.user, vars.actualDebtToLiquidate, vars.debtReserveCache.nextVariableBorrowIndex); } /** @@ -357,7 +335,6 @@ library LiquidationLogic { * @param debtReserveCache The reserve cache data object of the debt reserve * @param params The additional parameters needed to execute the liquidation function * @param healthFactor The health factor of the position - * @return The variable debt of the user * @return The total debt of the user * @return The actual debt to liquidate as a function of the closeFactor */ @@ -365,13 +342,8 @@ library LiquidationLogic { DataTypes.ReserveCache memory debtReserveCache, DataTypes.ExecuteLiquidationCallParams memory params, uint256 healthFactor - ) internal view returns (uint256, uint256, uint256) { - (uint256 userStableDebt, uint256 userVariableDebt) = Helpers.getUserCurrentDebt( - params.user, - debtReserveCache - ); - - uint256 userTotalDebt = userStableDebt + userVariableDebt; + ) internal view returns (uint256, uint256) { + uint256 userTotalDebt = Helpers.getUserCurrentDebt(params.user, debtReserveCache); uint256 closeFactor = healthFactor > CLOSE_FACTOR_HF_THRESHOLD ? DEFAULT_LIQUIDATION_CLOSE_FACTOR @@ -383,7 +355,7 @@ library LiquidationLogic { ? maxLiquidatableDebt : params.debtToCover; - return (userVariableDebt, userTotalDebt, actualDebtToLiquidate); + return (userTotalDebt, actualDebtToLiquidate); } /** diff --git a/src/core/contracts/protocol/libraries/logic/PoolLogic.sol b/src/core/contracts/protocol/libraries/logic/PoolLogic.sol index 92138fe8..1558fe55 100644 --- a/src/core/contracts/protocol/libraries/logic/PoolLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/PoolLogic.sol @@ -43,7 +43,6 @@ library PoolLogic { require(Address.isContract(params.asset), Errors.NOT_CONTRACT); reservesData[params.asset].init( params.aTokenAddress, - params.stableDebtAddress, params.variableDebtAddress, params.interestRateStrategyAddress ); diff --git a/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol b/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol index dedcfb61..80ed2965 100644 --- a/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.10; import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; @@ -133,14 +132,12 @@ library ReserveLogic { * @notice Initializes a reserve. * @param reserve The reserve object * @param aTokenAddress The address of the overlying atoken contract - * @param stableDebtTokenAddress The address of the overlying stable debt token contract * @param variableDebtTokenAddress The address of the overlying variable debt token contract * @param interestRateStrategyAddress The address of the interest rate strategy contract */ function init( DataTypes.ReserveData storage reserve, address aTokenAddress, - address stableDebtTokenAddress, address variableDebtTokenAddress, address interestRateStrategyAddress ) internal { @@ -149,20 +146,18 @@ library ReserveLogic { reserve.liquidityIndex = uint128(WadRayMath.RAY); reserve.variableBorrowIndex = uint128(WadRayMath.RAY); reserve.aTokenAddress = aTokenAddress; - reserve.stableDebtTokenAddress = stableDebtTokenAddress; reserve.variableDebtTokenAddress = variableDebtTokenAddress; reserve.interestRateStrategyAddress = interestRateStrategyAddress; } struct UpdateInterestRatesAndVirtualBalanceLocalVars { uint256 nextLiquidityRate; - uint256 nextStableRate; uint256 nextVariableRate; uint256 totalVariableDebt; } /** - * @notice Updates the reserve current stable borrow rate, the current variable borrow rate and the current liquidity rate. + * @notice Updates the reserve current variable borrow rate and the current liquidity rate. * @param reserve The reserve reserve to be updated * @param reserveCache The caching layer for the reserve data * @param reserveAddress The address of the reserve to be updated @@ -177,32 +172,27 @@ library ReserveLogic { uint256 liquidityTaken ) internal { UpdateInterestRatesAndVirtualBalanceLocalVars memory vars; - + //TODO: check, maybe local vars can be removed vars.totalVariableDebt = reserveCache.nextScaledVariableDebt.rayMul( reserveCache.nextVariableBorrowIndex ); - ( - vars.nextLiquidityRate, - vars.nextStableRate, - vars.nextVariableRate - ) = IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).calculateInterestRates( - DataTypes.CalculateInterestRatesParams({ - unbacked: reserve.unbacked, - liquidityAdded: liquidityAdded, - liquidityTaken: liquidityTaken, - totalStableDebt: reserveCache.nextTotalStableDebt, - totalVariableDebt: vars.totalVariableDebt, - averageStableBorrowRate: reserveCache.nextAvgStableBorrowRate, - reserveFactor: reserveCache.reserveFactor, - reserve: reserveAddress, - usingVirtualBalance: reserve.configuration.getIsVirtualAccActive(), - virtualUnderlyingBalance: reserve.virtualUnderlyingBalance - }) - ); + (vars.nextLiquidityRate, vars.nextVariableRate) = IReserveInterestRateStrategy( + reserve.interestRateStrategyAddress + ).calculateInterestRates( + DataTypes.CalculateInterestRatesParams({ + unbacked: reserve.unbacked, + liquidityAdded: liquidityAdded, + liquidityTaken: liquidityTaken, + totalDebt: vars.totalVariableDebt, + reserveFactor: reserveCache.reserveFactor, + reserve: reserveAddress, + usingVirtualBalance: reserve.configuration.getIsVirtualAccActive(), + virtualUnderlyingBalance: reserve.virtualUnderlyingBalance + }) + ); reserve.currentLiquidityRate = vars.nextLiquidityRate.toUint128(); - reserve.currentStableBorrowRate = vars.nextStableRate.toUint128(); reserve.currentVariableBorrowRate = vars.nextVariableRate.toUint128(); // Only affect virtual balance if the reserve uses it @@ -218,22 +208,13 @@ library ReserveLogic { emit ReserveDataUpdated( reserveAddress, vars.nextLiquidityRate, - vars.nextStableRate, + 0, vars.nextVariableRate, reserveCache.nextLiquidityIndex, reserveCache.nextVariableBorrowIndex ); } - struct AccrueToTreasuryLocalVars { - uint256 prevTotalStableDebt; - uint256 prevTotalVariableDebt; - uint256 currTotalVariableDebt; - uint256 cumulatedStableInterest; - uint256 totalDebtAccrued; - uint256 amountToMint; - } - /** * @notice Mints part of the repaid interest to the reserve treasury as a function of the reserve factor for the * specific asset. @@ -244,47 +225,27 @@ library ReserveLogic { DataTypes.ReserveData storage reserve, DataTypes.ReserveCache memory reserveCache ) internal { - AccrueToTreasuryLocalVars memory vars; - if (reserveCache.reserveFactor == 0) { return; } //calculate the total variable debt at moment of the last interaction - vars.prevTotalVariableDebt = reserveCache.currScaledVariableDebt.rayMul( + uint256 prevTotalVariableDebt = reserveCache.currScaledVariableDebt.rayMul( reserveCache.currVariableBorrowIndex ); //calculate the new total variable debt after accumulation of the interest on the index - vars.currTotalVariableDebt = reserveCache.currScaledVariableDebt.rayMul( + uint256 currTotalVariableDebt = reserveCache.currScaledVariableDebt.rayMul( reserveCache.nextVariableBorrowIndex ); - //calculate the stable debt until the last timestamp update - vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest( - reserveCache.currAvgStableBorrowRate, - reserveCache.stableDebtLastUpdateTimestamp, - reserveCache.reserveLastUpdateTimestamp - ); + //debt accrued is the sum of the current debt minus the sum of the debt at the last update + uint256 totalDebtAccrued = currTotalVariableDebt - prevTotalVariableDebt; - vars.prevTotalStableDebt = reserveCache.currPrincipalStableDebt.rayMul( - vars.cumulatedStableInterest - ); + uint256 amountToMint = totalDebtAccrued.percentMul(reserveCache.reserveFactor); - //debt accrued is the sum of the current debt minus the sum of the debt at the last update - vars.totalDebtAccrued = - vars.currTotalVariableDebt + - reserveCache.currTotalStableDebt - - vars.prevTotalVariableDebt - - vars.prevTotalStableDebt; - - vars.amountToMint = vars.totalDebtAccrued.percentMul(reserveCache.reserveFactor); - - if (vars.amountToMint != 0) { - reserve.accruedToTreasury += vars - .amountToMint - .rayDiv(reserveCache.nextLiquidityIndex) - .toUint128(); + if (amountToMint != 0) { + reserve.accruedToTreasury += amountToMint.rayDiv(reserveCache.nextLiquidityIndex).toUint128(); } } @@ -347,7 +308,6 @@ library ReserveLogic { reserveCache.currVariableBorrowRate = reserve.currentVariableBorrowRate; reserveCache.aTokenAddress = reserve.aTokenAddress; - reserveCache.stableDebtTokenAddress = reserve.stableDebtTokenAddress; reserveCache.variableDebtTokenAddress = reserve.variableDebtTokenAddress; reserveCache.reserveLastUpdateTimestamp = reserve.lastUpdateTimestamp; @@ -356,18 +316,6 @@ library ReserveLogic { reserveCache.variableDebtTokenAddress ).scaledTotalSupply(); - ( - reserveCache.currPrincipalStableDebt, - reserveCache.currTotalStableDebt, - reserveCache.currAvgStableBorrowRate, - reserveCache.stableDebtLastUpdateTimestamp - ) = IStableDebtToken(reserveCache.stableDebtTokenAddress).getSupplyData(); - - // by default the actions are considered as not affecting the debt balances. - // if the action involves mint/burn of debt, the cache needs to be updated - reserveCache.nextTotalStableDebt = reserveCache.currTotalStableDebt; - reserveCache.nextAvgStableBorrowRate = reserveCache.currAvgStableBorrowRate; - return reserveCache; } } diff --git a/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol index 2486db31..4dbee499 100644 --- a/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -5,7 +5,6 @@ import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {Address} from '../../../dependencies/openzeppelin/contracts/Address.sol'; import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; -import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; @@ -71,9 +70,7 @@ library ValidationLogic { ) internal view { require(amount != 0, Errors.INVALID_AMOUNT); - (bool isActive, bool isFrozen, , , bool isPaused) = reserveCache - .reserveConfiguration - .getFlags(); + (bool isActive, bool isFrozen, , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); require(isActive, Errors.RESERVE_INACTIVE); require(!isPaused, Errors.RESERVE_PAUSED); require(!isFrozen, Errors.RESERVE_FROZEN); @@ -103,7 +100,7 @@ library ValidationLogic { require(amount != 0, Errors.INVALID_AMOUNT); require(amount <= userBalance, Errors.NOT_ENOUGH_AVAILABLE_USER_BALANCE); - (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); require(isActive, Errors.RESERVE_INACTIVE); require(!isPaused, Errors.RESERVE_PAUSED); } @@ -127,7 +124,6 @@ library ValidationLogic { bool isFrozen; bool isPaused; bool borrowingEnabled; - bool stableRateBorrowingEnabled; bool siloedBorrowingEnabled; } @@ -148,13 +144,10 @@ library ValidationLogic { ValidateBorrowLocalVars memory vars; - ( - vars.isActive, - vars.isFrozen, - vars.borrowingEnabled, - vars.stableRateBorrowingEnabled, - vars.isPaused - ) = params.reserveCache.reserveConfiguration.getFlags(); + (vars.isActive, vars.isFrozen, vars.borrowingEnabled, vars.isPaused) = params + .reserveCache + .reserveConfiguration + .getFlags(); require(vars.isActive, Errors.RESERVE_INACTIVE); require(!vars.isPaused, Errors.RESERVE_PAUSED); @@ -172,13 +165,6 @@ library ValidationLogic { Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED ); - //validate interest rate mode - require( - params.interestRateMode == DataTypes.InterestRateMode.VARIABLE || - params.interestRateMode == DataTypes.InterestRateMode.STABLE, - Errors.INVALID_INTEREST_RATE_MODE_SELECTED - ); - vars.reserveDecimals = params.reserveCache.reserveConfiguration.getDecimals(); vars.borrowCap = params.reserveCache.reserveConfiguration.getBorrowCap(); unchecked { @@ -190,10 +176,7 @@ library ValidationLogic { params.reserveCache.nextVariableBorrowIndex ); - vars.totalDebt = - params.reserveCache.currTotalStableDebt + - vars.totalSupplyVariableDebt + - params.amount; + vars.totalDebt = vars.totalSupplyVariableDebt + params.amount; unchecked { require(vars.totalDebt <= vars.borrowCap * vars.assetUnit, Errors.BORROW_CAP_EXCEEDED); @@ -272,35 +255,6 @@ library ValidationLogic { Errors.COLLATERAL_CANNOT_COVER_NEW_BORROW ); - /** - * Following conditions need to be met if the user is borrowing at a stable rate: - * 1. Reserve must be enabled for stable rate borrowing - * 2. Users cannot borrow from the reserve if their collateral is (mostly) the same currency - * they are borrowing, to prevent abuses. - * 3. Users will be able to borrow only a portion of the total available liquidity - */ - - if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - //check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve - - require(vars.stableRateBorrowingEnabled, Errors.STABLE_BORROWING_NOT_ENABLED); - - require( - !params.userConfig.isUsingAsCollateral(reservesData[params.asset].id) || - params.reserveCache.reserveConfiguration.getLtv() == 0 || - params.amount > IERC20(params.reserveCache.aTokenAddress).balanceOf(params.userAddress), - Errors.COLLATERAL_SAME_AS_BORROWING_CURRENCY - ); - - vars.availableLiquidity = reservesData[params.asset].virtualUnderlyingBalance; - - //calculate the max available loan size in stable rate mode as a percentage of the - //available liquidity - uint256 maxLoanSizeStable = vars.availableLiquidity.percentMul(params.maxStableLoanPercent); - - require(params.amount <= maxLoanSizeStable, Errors.AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE); - } - if (params.userConfig.isBorrowingAny()) { (vars.siloedBorrowingEnabled, vars.siloedBorrowingAddress) = params .userConfig @@ -321,18 +275,14 @@ library ValidationLogic { * @notice Validates a repay action. * @param reserveCache The cached data of the reserve * @param amountSent The amount sent for the repayment. Can be an actual value or uint(-1) - * @param interestRateMode The interest rate mode of the debt being repaid * @param onBehalfOf The address of the user msg.sender is repaying for - * @param stableDebt The borrow balance of the user - * @param variableDebt The borrow balance of the user + * @param debt The borrow balance of the user */ function validateRepay( DataTypes.ReserveCache memory reserveCache, uint256 amountSent, - DataTypes.InterestRateMode interestRateMode, address onBehalfOf, - uint256 stableDebt, - uint256 variableDebt + uint256 debt ) internal view { require(amountSent != 0, Errors.INVALID_AMOUNT); require( @@ -340,106 +290,11 @@ library ValidationLogic { Errors.NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF ); - (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); require(isActive, Errors.RESERVE_INACTIVE); require(!isPaused, Errors.RESERVE_PAUSED); - require( - (stableDebt != 0 && interestRateMode == DataTypes.InterestRateMode.STABLE) || - (variableDebt != 0 && interestRateMode == DataTypes.InterestRateMode.VARIABLE), - Errors.NO_DEBT_OF_SELECTED_TYPE - ); - } - - /** - * @notice Validates a swap of borrow rate mode. - * @param reserve The reserve state on which the user is swapping the rate - * @param reserveCache The cached data of the reserve - * @param userConfig The user reserves configuration - * @param stableDebt The stable debt of the user - * @param variableDebt The variable debt of the user - * @param currentRateMode The rate mode of the debt being swapped - */ - function validateSwapRateMode( - DataTypes.ReserveData storage reserve, - DataTypes.ReserveCache memory reserveCache, - DataTypes.UserConfigurationMap storage userConfig, - uint256 stableDebt, - uint256 variableDebt, - DataTypes.InterestRateMode currentRateMode - ) internal view { - (bool isActive, , , bool stableRateEnabled, bool isPaused) = reserveCache - .reserveConfiguration - .getFlags(); - require(isActive, Errors.RESERVE_INACTIVE); - require(!isPaused, Errors.RESERVE_PAUSED); - - if (currentRateMode == DataTypes.InterestRateMode.STABLE) { - require(stableDebt != 0, Errors.NO_OUTSTANDING_STABLE_DEBT); - } else if (currentRateMode == DataTypes.InterestRateMode.VARIABLE) { - require(variableDebt != 0, Errors.NO_OUTSTANDING_VARIABLE_DEBT); - /** - * user wants to swap to stable, before swapping we need to ensure that - * 1. stable borrow rate is enabled on the reserve - * 2. user is not trying to abuse the reserve by supplying - * more collateral than he is borrowing, artificially lowering - * the interest rate, borrowing at variable, and switching to stable - */ - require(stableRateEnabled, Errors.STABLE_BORROWING_NOT_ENABLED); - - require( - !userConfig.isUsingAsCollateral(reserve.id) || - reserveCache.reserveConfiguration.getLtv() == 0 || - stableDebt + variableDebt > IERC20(reserveCache.aTokenAddress).balanceOf(msg.sender), - Errors.COLLATERAL_SAME_AS_BORROWING_CURRENCY - ); - } else { - revert(Errors.INVALID_INTEREST_RATE_MODE_SELECTED); - } - } - - /** - * @notice Validates a stable borrow rate rebalance action. - * @dev Rebalancing is accepted when depositors are earning <= 90% of their earnings in pure supply/demand market (variable rate only) - * For this to be the case, there has to be quite large stable debt with an interest rate below the current variable rate. - * @param reserve The reserve state on which the user is getting rebalanced - * @param reserveCache The cached state of the reserve - * @param reserveAddress The address of the reserve - */ - function validateRebalanceStableBorrowRate( - DataTypes.ReserveData storage reserve, - DataTypes.ReserveCache memory reserveCache, - address reserveAddress - ) internal view { - (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); - require(isActive, Errors.RESERVE_INACTIVE); - require(!isPaused, Errors.RESERVE_PAUSED); - - uint256 totalDebt = IERC20(reserveCache.stableDebtTokenAddress).totalSupply() + - IERC20(reserveCache.variableDebtTokenAddress).totalSupply(); - - (uint256 liquidityRateVariableDebtOnly, , ) = IReserveInterestRateStrategy( - reserve.interestRateStrategyAddress - ).calculateInterestRates( - DataTypes.CalculateInterestRatesParams({ - unbacked: reserve.unbacked, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: totalDebt, - averageStableBorrowRate: 0, - reserveFactor: reserveCache.reserveFactor, - reserve: reserveAddress, - usingVirtualBalance: reserve.configuration.getIsVirtualAccActive(), - virtualUnderlyingBalance: reserve.virtualUnderlyingBalance - }) - ); - - require( - reserveCache.currLiquidityRate <= - liquidityRateVariableDebtOnly.percentMul(REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD), - Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET - ); + require(debt != 0, Errors.NO_DEBT_OF_SELECTED_TYPE); // TODO: maybe not needed, rename error } /** @@ -453,7 +308,7 @@ library ValidationLogic { ) internal pure { require(userBalance != 0, Errors.UNDERLYING_BALANCE_ZERO); - (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); require(isActive, Errors.RESERVE_INACTIVE); require(!isPaused, Errors.RESERVE_PAUSED); } @@ -517,11 +372,11 @@ library ValidationLogic { ) internal view { ValidateLiquidationCallLocalVars memory vars; - (vars.collateralReserveActive, , , , vars.collateralReservePaused) = collateralReserve + (vars.collateralReserveActive, , , vars.collateralReservePaused) = collateralReserve .configuration .getFlags(); - (vars.principalReserveActive, , , , vars.principalReservePaused) = params + (vars.principalReserveActive, , , vars.principalReservePaused) = params .debtReserveCache .reserveConfiguration .getFlags(); @@ -662,7 +517,6 @@ library ValidationLogic { ) internal view { require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); require(reserve.id != 0 || reservesList[0] == asset, Errors.ASSET_NOT_LISTED); - require(IERC20(reserve.stableDebtTokenAddress).totalSupply() == 0, Errors.STABLE_DEBT_NOT_ZERO); require( IERC20(reserve.variableDebtTokenAddress).totalSupply() == 0, Errors.VARIABLE_DEBT_SUPPLY_NOT_ZERO diff --git a/src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol b/src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol index ad297064..834ccea9 100644 --- a/src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol +++ b/src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.0; library ConfiguratorInputTypes { struct InitReserveInput { address aTokenImpl; - address stableDebtTokenImpl; address variableDebtTokenImpl; uint8 underlyingAssetDecimals; bool useVirtualBalance; @@ -16,8 +15,6 @@ library ConfiguratorInputTypes { string aTokenSymbol; string variableDebtTokenName; string variableDebtTokenSymbol; - string stableDebtTokenName; - string stableDebtTokenSymbol; bytes params; bytes interestRateData; } diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/core/contracts/protocol/libraries/types/DataTypes.sol index 22920a32..6a09eb5a 100644 --- a/src/core/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/core/contracts/protocol/libraries/types/DataTypes.sol @@ -17,16 +17,14 @@ library DataTypes { uint128 variableBorrowIndex; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; - //the current stable borrow rate. Expressed in ray - uint128 currentStableBorrowRate; + uint128 __deprecatedStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; //the id of the reserve. Represents the position in the list of the active reserves uint16 id; //aToken address address aTokenAddress; - //stableDebtToken address - address stableDebtTokenAddress; + address __deprecatedStableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; //address of the interest rate strategy @@ -50,8 +48,7 @@ library DataTypes { uint128 variableBorrowIndex; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; - //the current stable borrow rate. Expressed in ray - uint128 currentStableBorrowRate; + uint128 __deprecatedStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; //the id of the reserve. Represents the position in the list of the active reserves @@ -60,8 +57,7 @@ library DataTypes { uint40 liquidationGracePeriodUntil; //aToken address address aTokenAddress; - //stableDebtToken address - address stableDebtTokenAddress; + address __deprecatedStableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; //address of the interest rate strategy @@ -84,7 +80,7 @@ library DataTypes { //bit 56: reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled - //bit 59: stable rate borrowing enabled + //bit 59: DEPRECATED: stable rate borrowing enabled // TODO: wipe it and reuse //bit 60: asset is paused //bit 61: borrowing in isolation mode is enabled //bit 62: siloed borrowing enabled @@ -123,18 +119,18 @@ library DataTypes { enum InterestRateMode { NONE, - STABLE, + __DEPRECATED, VARIABLE } struct ReserveCache { uint256 currScaledVariableDebt; uint256 nextScaledVariableDebt; - uint256 currPrincipalStableDebt; - uint256 currAvgStableBorrowRate; - uint256 currTotalStableDebt; - uint256 nextAvgStableBorrowRate; - uint256 nextTotalStableDebt; + // uint256 currPrincipalStableDebt; + // uint256 currAvgStableBorrowRate; TODO: cleanup + // uint256 currTotalStableDebt; + // uint256 nextAvgStableBorrowRate; + // uint256 nextTotalStableDebt; uint256 currLiquidityIndex; uint256 nextLiquidityIndex; uint256 currVariableBorrowIndex; @@ -144,10 +140,10 @@ library DataTypes { uint256 reserveFactor; ReserveConfigurationMap reserveConfiguration; address aTokenAddress; - address stableDebtTokenAddress; + // address stableDebtTokenAddress; TODO: cleanup address variableDebtTokenAddress; uint40 reserveLastUpdateTimestamp; - uint40 stableDebtLastUpdateTimestamp; + // uint40 stableDebtLastUpdateTimestamp; TODO: cleanup } struct ExecuteLiquidationCallParams { @@ -174,10 +170,10 @@ library DataTypes { address user; address onBehalfOf; uint256 amount; - InterestRateMode interestRateMode; + // InterestRateMode interestRateMode; uint16 referralCode; bool releaseUnderlying; - uint256 maxStableRateBorrowSizePercent; + // uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; @@ -187,7 +183,7 @@ library DataTypes { struct ExecuteRepayParams { address asset; uint256 amount; - InterestRateMode interestRateMode; + // InterestRateMode interestRateMode; address onBehalfOf; bool useATokens; } @@ -229,7 +225,7 @@ library DataTypes { uint16 referralCode; uint256 flashLoanPremiumToProtocol; uint256 flashLoanPremiumTotal; - uint256 maxStableRateBorrowSizePercent; + // uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address addressesProvider; address pool; @@ -270,8 +266,8 @@ library DataTypes { address asset; address userAddress; uint256 amount; - InterestRateMode interestRateMode; - uint256 maxStableLoanPercent; + // InterestRateMode interestRateMode; + // uint256 maxStableLoanPercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; @@ -292,9 +288,7 @@ library DataTypes { uint256 unbacked; uint256 liquidityAdded; uint256 liquidityTaken; - uint256 totalStableDebt; - uint256 totalVariableDebt; - uint256 averageStableBorrowRate; + uint256 totalDebt; uint256 reserveFactor; address reserve; bool usingVirtualBalance; @@ -304,7 +298,7 @@ library DataTypes { struct InitReserveParams { address asset; address aTokenAddress; - address stableDebtAddress; + // address stableDebtAddress; address variableDebtAddress; address interestRateStrategyAddress; uint16 reservesCount; diff --git a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol b/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol index 40a25683..7ecaeaee 100644 --- a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol +++ b/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol @@ -22,6 +22,15 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 using WadRayMath for uint256; using PercentageMath for uint256; + struct CalcInterestRatesLocalVars { + uint256 availableLiquidity; + uint256 currentVariableBorrowRate; + uint256 currentLiquidityRate; + uint256 borrowUsageRatio; + uint256 supplyUsageRatio; + uint256 availableLiquidityPlusDebt; + } + /// @inheritdoc IDefaultInterestRateStrategyV2 IPoolAddressesProvider public immutable ADDRESSES_PROVIDER; @@ -114,35 +123,33 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 /// @inheritdoc IReserveInterestRateStrategy function calculateInterestRates( DataTypes.CalculateInterestRatesParams memory params - ) public view virtual override returns (uint256, uint256, uint256) { + ) public view virtual override returns (uint256, uint256) { InterestRateDataRay memory rateData = _rayifyRateData(_interestRateData[params.reserve]); // @note This is a short circuit to allow mintable assets, which by definition cannot be supplied // and thus do not use virtual underlying balances. if (!params.usingVirtualBalance) { - return (0, 0, rateData.baseVariableBorrowRate); + return (0, rateData.baseVariableBorrowRate); } CalcInterestRatesLocalVars memory vars; - vars.totalDebt = params.totalStableDebt + params.totalVariableDebt; - vars.currentLiquidityRate = 0; vars.currentVariableBorrowRate = rateData.baseVariableBorrowRate; - if (vars.totalDebt != 0) { + if (params.totalDebt != 0) { vars.availableLiquidity = params.virtualUnderlyingBalance + params.liquidityAdded - params.liquidityTaken; - vars.availableLiquidityPlusDebt = vars.availableLiquidity + vars.totalDebt; - vars.borrowUsageRatio = vars.totalDebt.rayDiv(vars.availableLiquidityPlusDebt); - vars.supplyUsageRatio = vars.totalDebt.rayDiv( + vars.availableLiquidityPlusDebt = vars.availableLiquidity + params.totalDebt; + vars.borrowUsageRatio = params.totalDebt.rayDiv(vars.availableLiquidityPlusDebt); + vars.supplyUsageRatio = params.totalDebt.rayDiv( vars.availableLiquidityPlusDebt + params.unbacked ); } else { - return (0, 0, vars.currentVariableBorrowRate); + return (0, vars.currentVariableBorrowRate); } if (vars.borrowUsageRatio > rateData.optimalUsageRatio) { @@ -160,50 +167,18 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 .rayDiv(rateData.optimalUsageRatio); } - vars.currentLiquidityRate = _getOverallBorrowRate( - params.totalStableDebt, - params.totalVariableDebt, - vars.currentVariableBorrowRate, - params.averageStableBorrowRate - ).rayMul(vars.supplyUsageRatio).percentMul( - PercentageMath.PERCENTAGE_FACTOR - params.reserveFactor - ); - - return (vars.currentLiquidityRate, 0, vars.currentVariableBorrowRate); - } - - /** - * @dev Calculates the overall borrow rate as the weighted average between the total variable debt and total stable - * debt - * @param totalStableDebt The total borrowed from the reserve at a stable rate - * @param totalVariableDebt The total borrowed from the reserve at a variable rate - * @param currentVariableBorrowRate The current variable borrow rate of the reserve - * @param currentAverageStableBorrowRate The current weighted average of all the stable rate loans - * @return The weighted averaged borrow rate - */ - function _getOverallBorrowRate( - uint256 totalStableDebt, - uint256 totalVariableDebt, - uint256 currentVariableBorrowRate, - uint256 currentAverageStableBorrowRate - ) internal pure returns (uint256) { - uint256 totalDebt = totalStableDebt + totalVariableDebt; - - uint256 weightedVariableRate = totalVariableDebt.wadToRay().rayMul(currentVariableBorrowRate); - - uint256 weightedStableRate = totalStableDebt.wadToRay().rayMul(currentAverageStableBorrowRate); - - uint256 overallBorrowRate = (weightedVariableRate + weightedStableRate).rayDiv( - totalDebt.wadToRay() - ); + vars.currentLiquidityRate = vars + .currentVariableBorrowRate + .rayMul(vars.supplyUsageRatio) + .percentMul(PercentageMath.PERCENTAGE_FACTOR - params.reserveFactor); - return overallBorrowRate; + return (vars.currentLiquidityRate, vars.currentVariableBorrowRate); } /** * @dev Doing validations and data update for an asset * @param reserve address of the underlying asset of the reserve - * @param rateData Encoded eserve interest rate data to apply + * @param rateData Encoded reserve interest rate data to apply */ function _setInterestRateParams(address reserve, InterestRateData memory rateData) internal { require(reserve != address(0), Errors.ZERO_ADDRESS_NOT_VALID); diff --git a/src/core/contracts/protocol/pool/L2Pool.sol b/src/core/contracts/protocol/pool/L2Pool.sol index 801c20e8..d8925717 100644 --- a/src/core/contracts/protocol/pool/L2Pool.sol +++ b/src/core/contracts/protocol/pool/L2Pool.sol @@ -79,24 +79,6 @@ abstract contract L2Pool is Pool, IL2Pool { return repayWithATokens(asset, amount, interestRateMode); } - /// @inheritdoc IL2Pool - function swapBorrowRateMode(bytes32 args) external override { - (address asset, uint256 interestRateMode) = CalldataLogic.decodeSwapBorrowRateModeParams( - _reservesList, - args - ); - swapBorrowRateMode(asset, interestRateMode); - } - - /// @inheritdoc IL2Pool - function rebalanceStableBorrowRate(bytes32 args) external override { - (address asset, address user) = CalldataLogic.decodeRebalanceStableBorrowRateParams( - _reservesList, - args - ); - rebalanceStableBorrowRate(asset, user); - } - /// @inheritdoc IL2Pool function setUserUseReserveAsCollateral(bytes32 args) external override { (address asset, bool useAsCollateral) = CalldataLogic.decodeSetUserUseReserveAsCollateralParams( diff --git a/src/core/contracts/protocol/pool/Pool.sol b/src/core/contracts/protocol/pool/Pool.sol index 4397323d..2c2235d3 100644 --- a/src/core/contracts/protocol/pool/Pool.sol +++ b/src/core/contracts/protocol/pool/Pool.sol @@ -28,8 +28,7 @@ import {PoolStorage} from './PoolStorage.sol'; * # Withdraw * # Borrow * # Repay - * # Swap their loans between variable and stable rate - * # Enable/disable their supplied assets as collateral rebalance stable rate borrow positions + * # Enable/disable their supplied assets as collateral * # Liquidate positions * # Execute Flash Loans * @dev To be covered by a proxy contract, owned by the PoolAddressesProvider of the specific market @@ -213,7 +212,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function borrow( address asset, uint256 amount, - uint256 interestRateMode, + uint256, // @notice deprecated interestRateMode uint16 referralCode, address onBehalfOf ) public virtual override { @@ -227,10 +226,8 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { user: msg.sender, onBehalfOf: onBehalfOf, amount: amount, - interestRateMode: DataTypes.InterestRateMode(interestRateMode), referralCode: referralCode, releaseUnderlying: true, - maxStableRateBorrowSizePercent: _maxStableRateBorrowSizePercent, reservesCount: _reservesCount, oracle: ADDRESSES_PROVIDER.getPriceOracle(), userEModeCategory: _usersEModeCategory[onBehalfOf], @@ -243,7 +240,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repay( address asset, uint256 amount, - uint256 interestRateMode, + uint256, // @notice deprecated interestRateMode address onBehalfOf ) public virtual override returns (uint256) { return @@ -254,7 +251,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, - interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: onBehalfOf, useATokens: false }) @@ -265,7 +261,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repayWithPermit( address asset, uint256 amount, - uint256 interestRateMode, + uint256, // @notice deprecated interestRateMode address onBehalfOf, uint256 deadline, uint8 permitV, @@ -288,7 +284,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams memory params = DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, - interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: onBehalfOf, useATokens: false }); @@ -300,7 +295,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repayWithATokens( address asset, uint256 amount, - uint256 interestRateMode + uint256 // @notice deprecated interestRateMode ) public virtual override returns (uint256) { return BorrowLogic.executeRepay( @@ -310,40 +305,12 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, - interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: msg.sender, useATokens: true }) ); } - /// @inheritdoc IPool - function swapBorrowRateMode(address asset, uint256 interestRateMode) public virtual override { - BorrowLogic.executeSwapBorrowRateMode( - _reserves[asset], - _usersConfig[msg.sender], - asset, - msg.sender, - DataTypes.InterestRateMode(interestRateMode) - ); - } - - /// @inheritdoc IPool - function swapToVariable(address asset, address user) public virtual override { - BorrowLogic.executeSwapBorrowRateMode( - _reserves[asset], - _usersConfig[user], - asset, - user, - DataTypes.InterestRateMode.STABLE - ); - } - - /// @inheritdoc IPool - function rebalanceStableBorrowRate(address asset, address user) public virtual override { - BorrowLogic.executeRebalanceStableBorrowRate(_reserves[asset], asset, user); - } - /// @inheritdoc IPool function setUserUseReserveAsCollateral( address asset, @@ -409,7 +376,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { referralCode: referralCode, flashLoanPremiumToProtocol: _flashLoanPremiumToProtocol, flashLoanPremiumTotal: _flashLoanPremiumTotal, - maxStableRateBorrowSizePercent: _maxStableRateBorrowSizePercent, reservesCount: _reservesCount, addressesProvider: address(ADDRESSES_PROVIDER), pool: address(this), @@ -472,11 +438,9 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { res.currentLiquidityRate = reserve.currentLiquidityRate; res.variableBorrowIndex = reserve.variableBorrowIndex; res.currentVariableBorrowRate = reserve.currentVariableBorrowRate; - res.currentStableBorrowRate = reserve.currentStableBorrowRate; res.lastUpdateTimestamp = reserve.lastUpdateTimestamp; res.id = reserve.id; res.aTokenAddress = reserve.aTokenAddress; - res.stableDebtTokenAddress = reserve.stableDebtTokenAddress; res.variableDebtTokenAddress = reserve.variableDebtTokenAddress; res.interestRateStrategyAddress = reserve.interestRateStrategyAddress; res.accruedToTreasury = reserve.accruedToTreasury; @@ -584,8 +548,9 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { } /// @inheritdoc IPool + // @notice stable debt deprecated in v3.2.0 function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view virtual override returns (uint256) { - return _maxStableRateBorrowSizePercent; + return 0; } /// @inheritdoc IPool @@ -641,7 +606,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function initReserve( address asset, address aTokenAddress, - address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external virtual override onlyPoolConfigurator { @@ -652,7 +616,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.InitReserveParams({ asset: asset, aTokenAddress: aTokenAddress, - stableDebtAddress: stableDebtAddress, variableDebtAddress: variableDebtAddress, interestRateStrategyAddress: interestRateStrategyAddress, reservesCount: _reservesCount, diff --git a/src/core/contracts/protocol/pool/PoolConfigurator.sol b/src/core/contracts/protocol/pool/PoolConfigurator.sol index 041943e1..0bd9277a 100644 --- a/src/core/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/core/contracts/protocol/pool/PoolConfigurator.sol @@ -106,13 +106,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ConfiguratorLogic.executeUpdateAToken(_pool, input); } - /// @inheritdoc IPoolConfigurator - function updateStableDebtToken( - ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - ) external override onlyPoolAdmin { - ConfiguratorLogic.executeUpdateStableDebtToken(_pool, input); - } - /// @inheritdoc IPoolConfigurator function updateVariableDebtToken( ConfiguratorInputTypes.UpdateDebtTokenInput calldata input @@ -123,9 +116,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator /// @inheritdoc IPoolConfigurator function setReserveBorrowing(address asset, bool enabled) external override onlyRiskOrPoolAdmins { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - if (!enabled) { - require(!currentConfig.getStableRateBorrowingEnabled(), Errors.STABLE_BORROWING_ENABLED); - } currentConfig.setBorrowingEnabled(enabled); _pool.setConfiguration(asset, currentConfig); emit ReserveBorrowing(asset, enabled); @@ -181,20 +171,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus); } - /// @inheritdoc IPoolConfigurator - function setReserveStableRateBorrowing( - address asset, - bool enabled - ) external override onlyRiskOrPoolAdmins { - DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - if (enabled) { - require(currentConfig.getBorrowingEnabled(), Errors.BORROWING_NOT_ENABLED); - } - currentConfig.setStableRateBorrowingEnabled(enabled); - _pool.setConfiguration(asset, currentConfig); - emit ReserveStableRateBorrowing(asset, enabled); - } - /// @inheritdoc IPoolConfigurator function setReserveFlashLoaning( address asset, @@ -261,6 +237,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator bool paused, uint40 gracePeriod ) public override onlyEmergencyOrPoolAdmin { + // Only setting grace period if the transition is to not paused if (!paused && gracePeriod != 0) { require(gracePeriod <= MAX_GRACE_PERIOD, Errors.INVALID_GRACE_PERIOD); diff --git a/src/core/contracts/protocol/pool/PoolStorage.sol b/src/core/contracts/protocol/pool/PoolStorage.sol index ccf22b3f..9bd4d77c 100644 --- a/src/core/contracts/protocol/pool/PoolStorage.sol +++ b/src/core/contracts/protocol/pool/PoolStorage.sol @@ -44,7 +44,7 @@ contract PoolStorage { uint128 internal _flashLoanPremiumToProtocol; // Available liquidity that can be borrowed at once at stable rate, expressed in bps - uint64 internal _maxStableRateBorrowSizePercent; + uint64 internal __DEPRECATED_maxStableRateBorrowSizePercent; // Maximum number of active reserves there have been in the protocol. It is the upper bound of the reserves list uint16 internal _reservesCount; diff --git a/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol b/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol index a20cd05f..4bca0483 100644 --- a/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol +++ b/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol @@ -41,8 +41,7 @@ abstract contract IncentivizedERC20 is Context, IERC20Detailed { /** * @dev UserState - additionalData is a flexible field. * ATokens and VariableDebtTokens use this field store the index of the - * user's last supply/withdrawal/borrow/repayment. StableDebtTokens use - * this field to store the user's stable rate. + * user's last supply/withdrawal/borrow/repayment. */ struct UserState { uint128 balance; diff --git a/src/core/instances/PoolInstance.sol b/src/core/instances/PoolInstance.sol index 0af51bbe..ea85bec8 100644 --- a/src/core/instances/PoolInstance.sol +++ b/src/core/instances/PoolInstance.sol @@ -19,7 +19,6 @@ contract PoolInstance is Pool { */ function initialize(IPoolAddressesProvider provider) external virtual override initializer { require(provider == ADDRESSES_PROVIDER, Errors.INVALID_ADDRESSES_PROVIDER); - _maxStableRateBorrowSizePercent = 0.25e4; } function getRevision() internal pure virtual override returns (uint256) { diff --git a/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol b/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol index 51668cf8..7febeb3d 100644 --- a/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import {ATokenInstance} from 'aave-v3-core/instances/ATokenInstance.sol'; import {VariableDebtTokenInstance} from 'aave-v3-core/instances/VariableDebtTokenInstance.sol'; -import {StableDebtTokenInstance} from 'aave-v3-core/instances/StableDebtTokenInstance.sol'; import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; @@ -11,7 +10,6 @@ contract AaveV3TokensProcedure { struct TokensReport { address aToken; address variableDebtToken; - address stableDebtToken; } function _deployAaveV3TokensImplementations( @@ -22,7 +20,6 @@ contract AaveV3TokensProcedure { ATokenInstance aToken = new ATokenInstance(IPool(poolProxy)); VariableDebtTokenInstance variableDebtToken = new VariableDebtTokenInstance(IPool(poolProxy)); - StableDebtTokenInstance stableDebtToken = new StableDebtTokenInstance(IPool(poolProxy)); aToken.initialize( IPool(poolProxy), // pool proxy @@ -45,19 +42,8 @@ contract AaveV3TokensProcedure { empty // params ); - stableDebtToken.initialize( - IPool(poolProxy), // initializingPool - address(0), // underlyingAsset - IAaveIncentivesController(address(0)), // incentivesController - 0, // debtTokenDecimals - 'STABLE_DEBT_TOKEN_IMPL', // debtTokenName - 'STABLE_DEBT_TOKEN_IMPL', // debtTokenSymbol - empty // params - ); - tokensReport.aToken = address(aToken); tokensReport.variableDebtToken = address(variableDebtToken); - tokensReport.stableDebtToken = address(stableDebtToken); return tokensReport; } diff --git a/src/deployments/contracts/utilities/MarketReportUtils.sol b/src/deployments/contracts/utilities/MarketReportUtils.sol index 34e10e87..940938c2 100644 --- a/src/deployments/contracts/utilities/MarketReportUtils.sol +++ b/src/deployments/contracts/utilities/MarketReportUtils.sol @@ -40,7 +40,6 @@ library MarketReportUtils { l2Encoder: L2Encoder(report.l2Encoder), aToken: IAToken(report.aToken), variableDebtToken: IVariableDebtToken(report.variableDebtToken), - stableDebtToken: IStableDebtToken(report.stableDebtToken), emissionManager: IEmissionManager(report.emissionManager), rewardsControllerImplementation: IRewardsController(report.rewardsControllerImplementation), rewardsControllerProxy: IRewardsController(report.rewardsControllerProxy) diff --git a/src/deployments/contracts/utilities/MetadataReporter.sol b/src/deployments/contracts/utilities/MetadataReporter.sol index a3a9b8ab..d0cdb40a 100644 --- a/src/deployments/contracts/utilities/MetadataReporter.sol +++ b/src/deployments/contracts/utilities/MetadataReporter.sol @@ -47,7 +47,6 @@ contract MetadataReporter is IMetadataReporter { vm.serializeAddress(jsonReport, 'l2Encoder', report.l2Encoder); vm.serializeAddress(jsonReport, 'aToken', report.aToken); vm.serializeAddress(jsonReport, 'variableDebtToken', report.variableDebtToken); - vm.serializeAddress(jsonReport, 'stableDebtToken', report.stableDebtToken); vm.serializeAddress(jsonReport, 'emissionManager', report.emissionManager); vm.serializeAddress( jsonReport, diff --git a/src/deployments/interfaces/IMarketReportTypes.sol b/src/deployments/interfaces/IMarketReportTypes.sol index 2eb742f9..b92cf73c 100644 --- a/src/deployments/interfaces/IMarketReportTypes.sol +++ b/src/deployments/interfaces/IMarketReportTypes.sol @@ -7,7 +7,6 @@ import 'aave-v3-core/contracts/interfaces/IPoolConfigurator.sol'; import 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; import 'aave-v3-core/contracts/interfaces/IAToken.sol'; import 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; import 'aave-v3-core/contracts/interfaces/IACLManager.sol'; import 'aave-v3-core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; import 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; @@ -48,7 +47,6 @@ struct ContractsReport { L2Encoder l2Encoder; IAToken aToken; IVariableDebtToken variableDebtToken; - IStableDebtToken stableDebtToken; IEmissionManager emissionManager; IRewardsController rewardsControllerImplementation; IRewardsController rewardsControllerProxy; diff --git a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol index 1512596b..32633c34 100644 --- a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol +++ b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol @@ -239,7 +239,6 @@ library AaveV3BatchOrchestration { report.aclManager = setupReport.aclManager; report.aToken = tokensReport.aToken; report.variableDebtToken = tokensReport.variableDebtToken; - report.stableDebtToken = tokensReport.stableDebtToken; report.defaultInterestRateStrategyV2 = peripheryReport.defaultInterestRateStrategyV2; return report; diff --git a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol b/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol index f776c757..1186ca31 100644 --- a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol +++ b/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol @@ -206,13 +206,13 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard { uint256 debtRepayAmount, address initiator ) private view returns (uint256) { + require( + DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE, + 'INVALID_RATE_MODE' + ); DataTypes.ReserveDataLegacy memory debtReserveData = _getReserveData(address(debtAsset)); - address debtToken = DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE - ? debtReserveData.stableDebtTokenAddress - : debtReserveData.variableDebtTokenAddress; - - uint256 currentDebt = IERC20(debtToken).balanceOf(initiator); + uint256 currentDebt = IERC20(debtReserveData.variableDebtTokenAddress).balanceOf(initiator); if (buyAllBalanceOffset != 0) { require(currentDebt <= debtRepayAmount, 'INSUFFICIENT_AMOUNT_TO_REPAY'); diff --git a/src/periphery/contracts/libraries/DataTypesHelper.sol b/src/periphery/contracts/libraries/DataTypesHelper.sol index 492678a5..ec662615 100644 --- a/src/periphery/contracts/libraries/DataTypesHelper.sol +++ b/src/periphery/contracts/libraries/DataTypesHelper.sol @@ -14,16 +14,12 @@ library DataTypesHelper { * @notice Fetches the user current stable and variable debt balances * @param user The user address * @param reserve The reserve data object - * @return The stable debt balance * @return The variable debt balance **/ function getUserCurrentDebt( address user, DataTypes.ReserveDataLegacy memory reserve - ) internal view returns (uint256, uint256) { - return ( - IERC20(reserve.stableDebtTokenAddress).balanceOf(user), - IERC20(reserve.variableDebtTokenAddress).balanceOf(user) - ); + ) internal view returns (uint256) { + return IERC20(reserve.variableDebtTokenAddress).balanceOf(user); } } diff --git a/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol b/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol index 5c8f3e7f..21707d03 100644 --- a/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol +++ b/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol @@ -155,60 +155,6 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { address(vTokenIncentiveController), vRewardsInformation ); - - // Get sTokens rewards information - IRewardsController sTokenIncentiveController = IRewardsController( - address(IncentivizedERC20(baseData.stableDebtTokenAddress).getIncentivesController()) - ); - RewardInfo[] memory sRewardsInformation; - if (address(sTokenIncentiveController) != address(0)) { - address[] memory sTokenRewardAddresses = sTokenIncentiveController.getRewardsByAsset( - baseData.stableDebtTokenAddress - ); - sRewardsInformation = new RewardInfo[](sTokenRewardAddresses.length); - for (uint256 j = 0; j < sTokenRewardAddresses.length; ++j) { - RewardInfo memory rewardInformation; - rewardInformation.rewardTokenAddress = sTokenRewardAddresses[j]; - - ( - rewardInformation.tokenIncentivesIndex, - rewardInformation.emissionPerSecond, - rewardInformation.incentivesLastUpdateTimestamp, - rewardInformation.emissionEndTimestamp - ) = sTokenIncentiveController.getRewardsData( - baseData.stableDebtTokenAddress, - rewardInformation.rewardTokenAddress - ); - - rewardInformation.precision = sTokenIncentiveController.getAssetDecimals( - baseData.stableDebtTokenAddress - ); - rewardInformation.rewardTokenDecimals = IERC20Detailed( - rewardInformation.rewardTokenAddress - ).decimals(); - rewardInformation.rewardTokenSymbol = IERC20Detailed(rewardInformation.rewardTokenAddress) - .symbol(); - - // Get price of reward token from Chainlink Proxy Oracle - rewardInformation.rewardOracleAddress = sTokenIncentiveController.getRewardOracle( - rewardInformation.rewardTokenAddress - ); - rewardInformation.priceFeedDecimals = IEACAggregatorProxy( - rewardInformation.rewardOracleAddress - ).decimals(); - rewardInformation.rewardPriceFeed = IEACAggregatorProxy( - rewardInformation.rewardOracleAddress - ).latestAnswer(); - - sRewardsInformation[j] = rewardInformation; - } - } - - reserveIncentiveData.sIncentiveData = IncentiveData( - baseData.stableDebtTokenAddress, - address(sTokenIncentiveController), - sRewardsInformation - ); } return (reservesIncentiveData); @@ -342,59 +288,6 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { vUserRewardsInformation ); } - - // stable debt token - IRewardsController sTokenIncentiveController = IRewardsController( - address(IncentivizedERC20(baseData.stableDebtTokenAddress).getIncentivesController()) - ); - if (address(sTokenIncentiveController) != address(0)) { - // get all rewards information from the asset - address[] memory sTokenRewardAddresses = sTokenIncentiveController.getRewardsByAsset( - baseData.stableDebtTokenAddress - ); - UserRewardInfo[] memory sUserRewardsInformation = new UserRewardInfo[]( - sTokenRewardAddresses.length - ); - for (uint256 j = 0; j < sTokenRewardAddresses.length; ++j) { - UserRewardInfo memory userRewardInformation; - userRewardInformation.rewardTokenAddress = sTokenRewardAddresses[j]; - - userRewardInformation.tokenIncentivesUserIndex = sTokenIncentiveController - .getUserAssetIndex( - user, - baseData.stableDebtTokenAddress, - userRewardInformation.rewardTokenAddress - ); - - userRewardInformation.userUnclaimedRewards = sTokenIncentiveController - .getUserAccruedRewards(user, userRewardInformation.rewardTokenAddress); - userRewardInformation.rewardTokenDecimals = IERC20Detailed( - userRewardInformation.rewardTokenAddress - ).decimals(); - userRewardInformation.rewardTokenSymbol = IERC20Detailed( - userRewardInformation.rewardTokenAddress - ).symbol(); - - // Get price of reward token from Chainlink Proxy Oracle - userRewardInformation.rewardOracleAddress = sTokenIncentiveController.getRewardOracle( - userRewardInformation.rewardTokenAddress - ); - userRewardInformation.priceFeedDecimals = IEACAggregatorProxy( - userRewardInformation.rewardOracleAddress - ).decimals(); - userRewardInformation.rewardPriceFeed = IEACAggregatorProxy( - userRewardInformation.rewardOracleAddress - ).latestAnswer(); - - sUserRewardsInformation[j] = userRewardInformation; - } - - userReservesIncentivesData[i].sTokenIncentivesUserData = UserIncentiveData( - baseData.stableDebtTokenAddress, - address(aTokenIncentiveController), - sUserRewardsInformation - ); - } } return (userReservesIncentivesData); diff --git a/src/periphery/contracts/misc/UiPoolDataProviderV3.sol b/src/periphery/contracts/misc/UiPoolDataProviderV3.sol index cee7a456..30b7db53 100644 --- a/src/periphery/contracts/misc/UiPoolDataProviderV3.sol +++ b/src/periphery/contracts/misc/UiPoolDataProviderV3.sol @@ -7,7 +7,6 @@ import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; import {IDefaultInterestRateStrategyV2} from 'aave-v3-core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; @@ -71,11 +70,8 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.liquidityRate = baseData.currentLiquidityRate; //the current variable borrow rate. Expressed in ray reserveData.variableBorrowRate = baseData.currentVariableBorrowRate; - //the current stable borrow rate. Expressed in ray - reserveData.stableBorrowRate = baseData.currentStableBorrowRate; reserveData.lastUpdateTimestamp = baseData.lastUpdateTimestamp; reserveData.aTokenAddress = baseData.aTokenAddress; - reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress; reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress; //address of the interest rate strategy reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress; @@ -86,12 +82,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf( reserveData.aTokenAddress ); - ( - reserveData.totalPrincipalStableDebt, - , - reserveData.averageStableRate, - reserveData.stableDebtLastUpdateTimestamp - ) = IStableDebtToken(reserveData.stableDebtTokenAddress).getSupplyData(); reserveData.totalScaledVariableDebt = IVariableDebtToken(reserveData.variableDebtTokenAddress) .scaledTotalSupply(); @@ -123,7 +113,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.isActive, reserveData.isFrozen, reserveData.borrowingEnabled, - reserveData.stableBorrowRateEnabled, reserveData.isPaused ) = reserveConfigurationMap.getFlags(); @@ -138,9 +127,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.variableRateSlope2 = res.variableRateSlope2; reserveData.optimalUsageRatio = res.optimalUsageRatio; } catch {} - reserveData.stableRateSlope1 = 0; - reserveData.stableRateSlope2 = 0; - reserveData.baseStableBorrowRate = 0; // v3 only reserveData.eModeCategoryId = uint8(eModeCategoryId); @@ -237,15 +223,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { userReservesData[i].scaledVariableDebt = IVariableDebtToken( baseData.variableDebtTokenAddress ).scaledBalanceOf(user); - userReservesData[i].principalStableDebt = IStableDebtToken(baseData.stableDebtTokenAddress) - .principalBalanceOf(user); - if (userReservesData[i].principalStableDebt != 0) { - userReservesData[i].stableBorrowRate = IStableDebtToken(baseData.stableDebtTokenAddress) - .getUserStableRate(user); - userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken( - baseData.stableDebtTokenAddress - ).getUserLastUpdated(user); - } } } diff --git a/src/periphery/contracts/misc/WalletBalanceProvider.sol b/src/periphery/contracts/misc/WalletBalanceProvider.sol index f215610c..96d096a8 100644 --- a/src/periphery/contracts/misc/WalletBalanceProvider.sol +++ b/src/periphery/contracts/misc/WalletBalanceProvider.sol @@ -93,7 +93,7 @@ contract WalletBalanceProvider { reservesWithEth[j] ); - (bool isActive, , , , ) = configuration.getFlags(); + (bool isActive, , , ) = configuration.getFlags(); if (!isActive) { balances[j] = 0; diff --git a/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol b/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol index a120eeab..21ccf965 100644 --- a/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol +++ b/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol @@ -71,31 +71,30 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { /** * @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything - * @param rateMode the rate mode to repay * @param onBehalfOf the address for which msg.sender is repaying */ function repayETH( address, uint256 amount, - uint256 rateMode, + uint256, address onBehalfOf ) external payable override { - (uint256 stableDebt, uint256 variableDebt) = DataTypesHelper.getUserCurrentDebt( + uint256 paybackAmount = DataTypesHelper.getUserCurrentDebt( onBehalfOf, POOL.getReserveData(address(WETH)) ); - uint256 paybackAmount = DataTypes.InterestRateMode(rateMode) == - DataTypes.InterestRateMode.STABLE - ? stableDebt - : variableDebt; - if (amount < paybackAmount) { paybackAmount = amount; } require(msg.value >= paybackAmount, 'msg.value is less than repayment amount'); WETH.deposit{value: paybackAmount}(); - POOL.repay(address(WETH), paybackAmount, rateMode, onBehalfOf); + POOL.repay( + address(WETH), + paybackAmount, + uint256(DataTypes.InterestRateMode.VARIABLE), + onBehalfOf + ); // refund remaining dust eth if (msg.value > paybackAmount) _safeTransferETH(msg.sender, msg.value - paybackAmount); @@ -104,16 +103,16 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { /** * @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `Pool.borrow`. * @param amount the amount of ETH to borrow - * @param interestRateMode the interest rate mode * @param referralCode integrators are assigned a referral code and can potentially receive rewards */ - function borrowETH( - address, - uint256 amount, - uint256 interestRateMode, - uint16 referralCode - ) external override { - POOL.borrow(address(WETH), amount, interestRateMode, referralCode, msg.sender); + function borrowETH(address, uint256 amount, uint256, uint16 referralCode) external override { + POOL.borrow( + address(WETH), + amount, + uint256(DataTypes.InterestRateMode.VARIABLE), + referralCode, + msg.sender + ); WETH.withdraw(amount); _safeTransferETH(msg.sender, amount); } diff --git a/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol b/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol index 2d5cd360..7e94d54f 100644 --- a/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol +++ b/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol @@ -30,7 +30,6 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { IAaveOracle public immutable ORACLE; address public immutable ATOKEN_IMPL; address public immutable VTOKEN_IMPL; - address public immutable STOKEN_IMPL; address public immutable REWARDS_CONTROLLER; address public immutable COLLECTOR; address public immutable DEFAULT_INTEREST_RATE_STRATEGY; @@ -47,14 +46,12 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { * @dev Constructor. * @param aTokenImpl The address of default aToken implementation. * @param vTokenImpl The address of default variable debt token implementation. - * @param sTokenImpl The address of default stable debt token implementation. * @param engineConstants The struct containing all the engine constants. * @param engineLibraries The struct containing the addresses of stateless libraries containing the engine logic. */ constructor( address aTokenImpl, address vTokenImpl, - address sTokenImpl, EngineConstants memory engineConstants, EngineLibraries memory engineLibraries ) { @@ -68,10 +65,7 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { 'ONLY_NONZERO_ENGINE_CONSTANTS' ); - require( - aTokenImpl != address(0) && vTokenImpl != address(0) && sTokenImpl != address(0), - 'ONLY_NONZERO_TOKEN_IMPLS' - ); + require(aTokenImpl != address(0) && vTokenImpl != address(0), 'ONLY_NONZERO_TOKEN_IMPLS'); require( engineLibraries.borrowEngine != address(0) && @@ -84,7 +78,6 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { ATOKEN_IMPL = aTokenImpl; VTOKEN_IMPL = vTokenImpl; - STOKEN_IMPL = sTokenImpl; POOL = engineConstants.pool; POOL_CONFIGURATOR = engineConstants.poolConfigurator; ORACLE = engineConstants.oracle; @@ -108,11 +101,7 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { for (uint256 i = 0; i < listings.length; i++) { customListings[i] = ListingWithCustomImpl({ base: listings[i], - implementations: TokenImplementations({ - aToken: ATOKEN_IMPL, - vToken: VTOKEN_IMPL, - sToken: STOKEN_IMPL - }) + implementations: TokenImplementations({aToken: ATOKEN_IMPL, vToken: VTOKEN_IMPL}) }); } diff --git a/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol b/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol index 003d3d3e..3dd59c55 100644 --- a/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol +++ b/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol @@ -18,7 +18,7 @@ import {EngineFlags} from './EngineFlags.sol'; * - Updates of caps (supply cap, borrow cap). * - Updates of price feeds * - Updates of interest rate strategies - * - Updates of borrow parameters (flashloanable, stableRateModeEnabled, borrowableInIsolation, withSiloedBorrowing, reserveFactor) + * - Updates of borrow parameters (flashloanable, borrowableInIsolation, withSiloedBorrowing, reserveFactor) * - Updates of collateral parameters (ltv, liq threshold, liq bonus, liq protocol fee, debt ceiling) * - Updates of emode category parameters (ltv, liq threshold, liq bonus, price source, label) * - Updates of emode category of assets (e-mode id) diff --git a/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol b/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol index ddbcdf13..e1d73898 100644 --- a/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol @@ -67,7 +67,6 @@ interface IAaveV3ConfigEngine { * }), * enabledToBorrow: EngineFlags.ENABLED, * flashloanable: EngineFlags.ENABLED, - * stableRateModeEnabled: EngineFlags.DISABLED, * borrowableInIsolation: EngineFlags.ENABLED, * withSiloedBorrowing:, EngineFlags.DISABLED, * ltv: 70_50, // 70.5% @@ -87,7 +86,6 @@ interface IAaveV3ConfigEngine { address priceFeed; InterestRateInputData rateStrategyParams; // Mandatory, no matter if enabled for borrowing or not uint256 enabledToBorrow; - uint256 stableRateModeEnabled; // Only considered is enabledToBorrow == EngineFlags.ENABLED (true) uint256 borrowableInIsolation; // Only considered is enabledToBorrow == EngineFlags.ENABLED (true) uint256 withSiloedBorrowing; // Only considered if enabledToBorrow == EngineFlags.ENABLED (true) uint256 flashloanable; // Independent from enabled to borrow: an asset can be flashloanble and not enabled to borrow @@ -116,7 +114,6 @@ interface IAaveV3ConfigEngine { struct TokenImplementations { address aToken; address vToken; - address sToken; } struct ListingWithCustomImpl { @@ -176,7 +173,6 @@ interface IAaveV3ConfigEngine { * asset: AaveV3EthereumAssets.AAVE_UNDERLYING, * enabledToBorrow: EngineFlags.ENABLED, * flashloanable: EngineFlags.KEEP_CURRENT, - * stableRateModeEnabled: EngineFlags.KEEP_CURRENT, * borrowableInIsolation: EngineFlags.KEEP_CURRENT, * withSiloedBorrowing: EngineFlags.KEEP_CURRENT, * reserveFactor: 15_00, // 15% @@ -186,7 +182,6 @@ interface IAaveV3ConfigEngine { address asset; uint256 enabledToBorrow; uint256 flashloanable; - uint256 stableRateModeEnabled; uint256 borrowableInIsolation; uint256 withSiloedBorrowing; uint256 reserveFactor; @@ -326,8 +321,6 @@ interface IAaveV3ConfigEngine { function VTOKEN_IMPL() external view returns (address); - function STOKEN_IMPL() external view returns (address); - function REWARDS_CONTROLLER() external view returns (address); function COLLECTOR() external view returns (address); diff --git a/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol b/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol index 4fa237b6..dc81d0e7 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol +++ b/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol @@ -30,19 +30,10 @@ library BorrowEngine { EngineFlags.toBool(updates[i].enabledToBorrow) ); } else { - (, , bool borrowingEnabled, , ) = pool.getConfiguration(updates[i].asset).getFlags(); + (, , bool borrowingEnabled, ) = pool.getConfiguration(updates[i].asset).getFlags(); updates[i].enabledToBorrow = EngineFlags.fromBool(borrowingEnabled); } - if (updates[i].enabledToBorrow == EngineFlags.ENABLED) { - if (updates[i].stableRateModeEnabled != EngineFlags.KEEP_CURRENT) { - poolConfigurator.setReserveStableRateBorrowing( - updates[i].asset, - EngineFlags.toBool(updates[i].stableRateModeEnabled) - ); - } - } - if (updates[i].borrowableInIsolation != EngineFlags.KEEP_CURRENT) { poolConfigurator.setBorrowableInIsolation( updates[i].asset, diff --git a/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol b/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol index 15550697..af21b615 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol +++ b/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol @@ -115,7 +115,6 @@ library ListingEngine { asset: listings[i].base.asset, enabledToBorrow: listings[i].base.enabledToBorrow, flashloanable: listings[i].base.flashloanable, - stableRateModeEnabled: listings[i].base.stableRateModeEnabled, borrowableInIsolation: listings[i].base.borrowableInIsolation, withSiloedBorrowing: listings[i].base.withSiloedBorrowing, reserveFactor: listings[i].base.reserveFactor @@ -182,7 +181,6 @@ library ListingEngine { initReserveInputs[i] = ConfiguratorInputTypes.InitReserveInput({ aTokenImpl: basics[i].implementations.aToken, - stableDebtTokenImpl: basics[i].implementations.sToken, variableDebtTokenImpl: basics[i].implementations.vToken, underlyingAssetDecimals: decimals, interestRateStrategyAddress: rateStrategy, @@ -204,17 +202,6 @@ library ListingEngine { context.networkAbbreviation, basics[i].assetSymbol ), - stableDebtTokenName: string.concat( - 'Aave ', - context.networkName, - ' Stable Debt ', - basics[i].assetSymbol - ), - stableDebtTokenSymbol: string.concat( - 'stableDebt', - context.networkAbbreviation, - basics[i].assetSymbol - ), params: bytes('') }); } diff --git a/tests/core/L2Pool.t.sol b/tests/core/L2Pool.t.sol index 18f73fd3..96b41c7b 100644 --- a/tests/core/L2Pool.t.sol +++ b/tests/core/L2Pool.t.sol @@ -28,9 +28,6 @@ contract L2PoolTests is PoolTests { pool = IPool(report.poolProxy); l2Pool = IL2Pool(report.poolProxy); l2Encoder = L2Encoder(report.l2Encoder); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.usdx, true); } function test_l2_supply() public { @@ -111,7 +108,7 @@ contract L2PoolTests is PoolTests { alice, 0.2e6, DataTypes.InterestRateMode(2), - _calculateInterestRates(0.2e6, 2, tokenList.usdx), + _calculateInterestRates(0.2e6, tokenList.usdx), 0 ); @@ -182,36 +179,6 @@ contract L2PoolTests is PoolTests { l2Pool.repayWithATokens(encodedInput); } - function test_l2_swap_borrow_rate() public { - _seedUsdxLiquidity(); - - vm.startPrank(alice); - - pool.supply(tokenList.wbtc, 1e8, alice, 0); - pool.borrow(tokenList.usdx, 10e6, 2, 0, alice); - - bytes32 encodedInput = l2Encoder.encodeSwapBorrowRateMode(tokenList.usdx, 2); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - l2Pool.swapBorrowRateMode(encodedInput); - vm.stopPrank(); - } - - function test_l2_rebalance_borrow() public { - DataTypes.ReserveDataLegacy memory usdxReserveData = pool.getReserveData(tokenList.usdx); - - vm.mockCall( - address(usdxReserveData.interestRateStrategyAddress), - abi.encodeWithSelector(IReserveInterestRateStrategy.calculateInterestRates.selector), - abi.encode(0, 0, 0) - ); - - bytes32 encodedInput = l2Encoder.encodeRebalanceStableBorrowRate(tokenList.usdx, alice); - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - l2Pool.rebalanceStableBorrowRate(encodedInput); - vm.clearMockedCalls(); - } - function test_l2_set_user_collateral() public { test_l2_supply(); diff --git a/tests/core/Pool.Borrow.t.sol b/tests/core/Pool.Borrow.t.sol index c73a30e8..dc5a6238 100644 --- a/tests/core/Pool.Borrow.t.sol +++ b/tests/core/Pool.Borrow.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; @@ -23,7 +22,6 @@ contract PoolBorrowTests is TestnetProcedures { using UserConfiguration for DataTypes.UserConfigurationMap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - IStableDebtToken internal staDebtUSDX; IVariableDebtToken internal varDebtUSDX; address internal aUSDX; @@ -39,31 +37,21 @@ contract PoolBorrowTests is TestnetProcedures { uint256 borrowRate, uint16 indexed referralCode ); - event RebalanceStableBorrowRate(address indexed reserve, address indexed user); - event SwapBorrowRateMode( - address indexed reserve, - address indexed user, - DataTypes.InterestRateMode interestRateMode - ); event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); function setUp() public { initTestEnvironment(); - (address atoken, address stableDebtUSDX, address variableDebtUSDX) = contracts + (address atoken, , address variableDebtUSDX) = contracts .protocolDataProvider .getReserveTokensAddresses(tokenList.usdx); aUSDX = atoken; - staDebtUSDX = IStableDebtToken(stableDebtUSDX); varDebtUSDX = IVariableDebtToken(variableDebtUSDX); vm.startPrank(carol); contracts.poolProxy.supply(tokenList.usdx, 100_000e6, carol, 0); vm.stopPrank(); - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.usdx, true); - sequencerOracleMock = new SequencerOracle(poolAdmin); priceOracleSentinel = new PriceOracleSentinel( IPoolAddressesProvider(report.poolAddressesProvider), @@ -95,9 +83,7 @@ contract PoolBorrowTests is TestnetProcedures { unbacked: 0, liquidityAdded: 0, liquidityTaken: 800e6, - totalStableDebt: 0, - totalVariableDebt: 800e6, - averageStableBorrowRate: 0, + totalDebt: 800e6, reserveFactor: 1000, reserve: tokenList.usdx, usingVirtualBalance: contracts @@ -107,7 +93,7 @@ contract PoolBorrowTests is TestnetProcedures { virtualUnderlyingBalance: contracts.poolProxy.getVirtualUnderlyingBalance(tokenList.usdx) }); - (, , uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); + (, uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); vm.expectEmit(true, true, true, true, address(contracts.poolProxy)); emit Borrow( @@ -131,19 +117,6 @@ contract PoolBorrowTests is TestnetProcedures { assertEq(contracts.poolProxy.getUserConfiguration(alice).isBorrowing(reserveData.id), true); } - function test_stable_borrow() public { - uint256 amount = 1e8; - uint256 borrowAmount = 800e6; - vm.startPrank(alice); - - contracts.poolProxy.supply(tokenList.wbtc, amount, alice, 0); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - - contracts.poolProxy.borrow(tokenList.usdx, borrowAmount, 1, 0, alice); - vm.stopPrank(); - } - function test_borrow_variable_in_isolation() public { uint256 borrowAmount = 100e6; vm.startPrank(poolAdmin); @@ -157,7 +130,6 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.setUserUseReserveAsCollateral(tokenList.wbtc, true); uint256 balanceBefore = usdx.balanceOf(alice); - uint256 debtBalanceBefore = staDebtUSDX.principalBalanceOf(alice); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); @@ -169,9 +141,7 @@ contract PoolBorrowTests is TestnetProcedures { unbacked: 0, liquidityAdded: 0, liquidityTaken: borrowAmount, - totalStableDebt: 0, - totalVariableDebt: borrowAmount, - averageStableBorrowRate: 0, + totalDebt: borrowAmount, reserveFactor: 1000, reserve: tokenList.usdx, usingVirtualBalance: contracts @@ -181,7 +151,7 @@ contract PoolBorrowTests is TestnetProcedures { virtualUnderlyingBalance: contracts.poolProxy.getVirtualUnderlyingBalance(tokenList.usdx) }); - (, , uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); + (, uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); vm.expectEmit(address(contracts.poolProxy)); emit IsolationModeTotalDebtUpdated(tokenList.wbtc, 100_00); @@ -204,7 +174,7 @@ contract PoolBorrowTests is TestnetProcedures { uint256 debtBalanceAfter = varDebtUSDX.scaledBalanceOf(alice); assertEq(balanceAfter, balanceBefore + borrowAmount); - assertEq(debtBalanceAfter, debtBalanceBefore + borrowAmount); + assertEq(debtBalanceAfter, borrowAmount); assertEq(contracts.poolProxy.getUserConfiguration(alice).isBorrowing(reserveData.id), true); } @@ -243,7 +213,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.expectRevert(bytes(Errors.RESERVE_INACTIVE)); vm.prank(alice); - contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 1, 0, alice); + contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 2, 0, alice); } function test_reverts_borrow_reservePaused() public { @@ -253,7 +223,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.expectRevert(bytes(Errors.RESERVE_PAUSED)); vm.prank(alice); - contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 1, 0, alice); + contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 2, 0, alice); } function test_reverts_borrow_reserveFrozen() public { @@ -263,7 +233,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.expectRevert(bytes(Errors.RESERVE_FROZEN)); vm.prank(alice); - contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 1, 0, alice); + contracts.poolProxy.borrow(tokenList.wbtc, 0.2e8, 2, 0, alice); } function test_reverts_borrow_cap() public { @@ -276,21 +246,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.expectRevert(bytes(Errors.BORROW_CAP_EXCEEDED)); - contracts.poolProxy.borrow(tokenList.wbtc, 10e8, 1, 0, alice); - } - - function test_reverts_borrow_invalid_rate() public { - vm.startPrank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 50e8, alice, 0); - vm.stopPrank(); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setBorrowCap(tokenList.wbtc, 1); - - vm.expectRevert(bytes(Errors.INVALID_INTEREST_RATE_MODE_SELECTED)); - - vm.prank(alice); - contracts.poolProxy.borrow(tokenList.wbtc, 100, 0, 0, alice); + contracts.poolProxy.borrow(tokenList.wbtc, 10e8, 2, 0, alice); } function test_reverts_borrow_sentinel_oracle_down() public { @@ -312,19 +268,6 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.borrow(tokenList.wbtc, 100, 2, 0, alice); } - function test_reverts_borrow_stable_borrow_not_enabled() public { - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.usdx, false); - - vm.prank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 50e8, alice, 0); - - vm.expectRevert(bytes(Errors.STABLE_BORROWING_NOT_ENABLED)); - - vm.prank(alice); - contracts.poolProxy.borrow(tokenList.usdx, 100e6, 1, 0, alice); - } - function test_reverts_borrow_not_borrowable_isolation() public { uint256 borrowAmount = 100e6; vm.startPrank(poolAdmin); @@ -389,7 +332,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.expectRevert(bytes(Errors.COLLATERAL_BALANCE_IS_ZERO)); vm.prank(alice); - contracts.poolProxy.borrow(tokenList.usdx, 0.2e8, 1, 0, alice); + contracts.poolProxy.borrow(tokenList.usdx, 0.2e8, 2, 0, alice); } function test_reverts_borrow_collateral_can_not_cover() public { @@ -425,26 +368,6 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.borrow(tokenList.usdx, 10001e6, 2, 0, alice); } - function test_reverts_borrow_stable_collateral_same_borrow() public { - vm.startPrank(alice); - - contracts.poolProxy.supply(tokenList.usdx, 100e6, alice, 0); - - vm.expectRevert(bytes(Errors.COLLATERAL_SAME_AS_BORROWING_CURRENCY)); - contracts.poolProxy.borrow(tokenList.usdx, 10e6, 1, 0, alice); - vm.stopPrank(); - } - - function test_reverts_borrow_stable_amount_gt_max_loan_size_stable() public { - vm.startPrank(alice); - - contracts.poolProxy.supply(tokenList.wbtc, 100e8, alice, 0); - - vm.expectRevert(bytes(Errors.AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE)); - contracts.poolProxy.borrow(tokenList.usdx, 60_000e6, 1, 0, alice); - vm.stopPrank(); - } - function test_reverts_borrow_sioled_borrowing_violation() public { vm.startPrank(carol); contracts.poolProxy.supply(tokenList.wbtc, 100e8, carol, 0); @@ -491,118 +414,4 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.borrow(tokenList.usdx, 10001e6, 2, 0, alice); vm.stopPrank(); } - - function test_reverts_rebalance_borrow_rate_reserve_inactive() public { - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveActive(tokenList.wbtc, false); - - vm.expectRevert(bytes(Errors.RESERVE_INACTIVE)); - - vm.prank(alice); - contracts.poolProxy.rebalanceStableBorrowRate(tokenList.wbtc, alice); - } - - function test_reverts_rebalance_borrow_rate_reserve_paused() public { - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReservePause(tokenList.wbtc, true, 0); - - vm.expectRevert(bytes(Errors.RESERVE_PAUSED)); - vm.prank(alice); - contracts.poolProxy.rebalanceStableBorrowRate(tokenList.wbtc, alice); - } - - function test_reverts_rebalance_borrow_rate_conditions_not_met() public { - vm.startPrank(alice); - - contracts.poolProxy.supply(tokenList.wbtc, 1e8, alice, 0); - contracts.poolProxy.borrow(tokenList.usdx, 15000e6, 2, 0, alice); - - vm.expectRevert(bytes(Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET)); - contracts.poolProxy.rebalanceStableBorrowRate(tokenList.usdx, alice); - vm.stopPrank(); - } - - function test_rebalance_borrow_rate() public { - DataTypes.ReserveDataLegacy memory usdxReserveData = contracts.poolProxy.getReserveData( - tokenList.usdx - ); - - vm.mockCall( - address(usdxReserveData.interestRateStrategyAddress), - abi.encodeWithSelector(IReserveInterestRateStrategy.calculateInterestRates.selector), - abi.encode(0, 0, 0) - ); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - - contracts.poolProxy.rebalanceStableBorrowRate(tokenList.usdx, alice); - vm.clearMockedCalls(); - } - - function test_swap_borrow_rate_from_variable_to_stable() public { - vm.startPrank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 100e8, alice, 0); - contracts.poolProxy.borrow(tokenList.usdx, 2000e6, 2, 0, alice); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 2); - vm.stopPrank(); - } - - function test_reverts_swap_borrow_rate_reserve_inactive() public { - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveActive(tokenList.wbtc, false); - - vm.expectRevert(bytes(Errors.RESERVE_INACTIVE)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.wbtc, 1); - } - - function test_reverts_swap_borrow_rate_reserve_paused() public { - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReservePause(tokenList.usdx, true, 0); - - vm.expectRevert(bytes(Errors.RESERVE_PAUSED)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 2); - } - - function test_swap_borrow_rate_reserve_frozen() public { - vm.startPrank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 100e8, alice, 0); - contracts.poolProxy.borrow(tokenList.usdx, 2000e6, 2, 0, alice); - vm.stopPrank(); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveFreeze(tokenList.usdx, true); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 2); - } - - function test_reverts_swap_borrow_rate_reserve_variable_no_debt() public { - vm.expectRevert(bytes(Errors.NO_OUTSTANDING_VARIABLE_DEBT)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 2); - } - - function test_reverts_swap_borrow_rate_reserve_stable_no_debt() public { - vm.expectRevert(bytes(Errors.NO_OUTSTANDING_STABLE_DEBT)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 1); - } - - function test_reverts_swap_borrow_rate_reserve_invalid_rate_mode() public { - vm.expectRevert(bytes(Errors.INVALID_INTEREST_RATE_MODE_SELECTED)); - - vm.prank(alice); - contracts.poolProxy.swapBorrowRateMode(tokenList.usdx, 0); - } } diff --git a/tests/core/Pool.FlashLoans.t.sol b/tests/core/Pool.FlashLoans.t.sol index ea9c2e84..cdb40cbd 100644 --- a/tests/core/Pool.FlashLoans.t.sol +++ b/tests/core/Pool.FlashLoans.t.sol @@ -469,7 +469,7 @@ contract PoolFlashLoansTests is TestnetProcedures { alice, amounts[x], DataTypes.InterestRateMode(modes[x]), - _calculateInterestRates(amounts[x], modes[x], assets[x]), + _calculateInterestRates(amounts[x], assets[x]), 0 ); } diff --git a/tests/core/Pool.Liquidations.t.sol b/tests/core/Pool.Liquidations.t.sol index 12c332da..93d2078a 100644 --- a/tests/core/Pool.Liquidations.t.sol +++ b/tests/core/Pool.Liquidations.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; @@ -31,7 +30,6 @@ contract PoolLiquidationTests is TestnetProcedures { using ReserveLogic for DataTypes.ReserveCache; using ReserveLogic for DataTypes.ReserveData; - IStableDebtToken internal staDebtUSDX; IVariableDebtToken internal varDebtUSDX; address internal aUSDX; @@ -45,11 +43,10 @@ contract PoolLiquidationTests is TestnetProcedures { function setUp() public { initTestEnvironment(); - (address atoken, address stableDebtUSDX, address variableDebtUSDX) = contracts + (address atoken, , address variableDebtUSDX) = contracts .protocolDataProvider .getReserveTokensAddresses(tokenList.usdx); aUSDX = atoken; - staDebtUSDX = IStableDebtToken(stableDebtUSDX); varDebtUSDX = IVariableDebtToken(variableDebtUSDX); vm.startPrank(carol); @@ -57,9 +54,6 @@ contract PoolLiquidationTests is TestnetProcedures { contracts.poolProxy.supply(tokenList.weth, 100e18, carol, 0); vm.stopPrank(); - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.usdx, true); - sequencerOracleMock = new SequencerOracle(poolAdmin); priceOracleSentinel = new PriceOracleSentinel( IPoolAddressesProvider(report.poolAddressesProvider), @@ -1100,11 +1094,9 @@ contract PoolLiquidationTests is TestnetProcedures { tempReserveData.currentLiquidityRate = reserveDataLegacy.currentLiquidityRate; tempReserveData.variableBorrowIndex = reserveDataLegacy.variableBorrowIndex; tempReserveData.currentVariableBorrowRate = reserveDataLegacy.currentVariableBorrowRate; - tempReserveData.currentStableBorrowRate = reserveDataLegacy.currentStableBorrowRate; tempReserveData.lastUpdateTimestamp = reserveDataLegacy.lastUpdateTimestamp; tempReserveData.id = reserveDataLegacy.id; tempReserveData.aTokenAddress = reserveDataLegacy.aTokenAddress; - tempReserveData.stableDebtTokenAddress = reserveDataLegacy.stableDebtTokenAddress; tempReserveData.variableDebtTokenAddress = reserveDataLegacy.variableDebtTokenAddress; tempReserveData.interestRateStrategyAddress = reserveDataLegacy.interestRateStrategyAddress; tempReserveData.accruedToTreasury = reserveDataLegacy.accruedToTreasury; diff --git a/tests/core/Pool.Repay.t.sol b/tests/core/Pool.Repay.t.sol index 25530d81..52f71a98 100644 --- a/tests/core/Pool.Repay.t.sol +++ b/tests/core/Pool.Repay.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; import {ISequencerOracle} from 'aave-v3-core/contracts/interfaces/ISequencerOracle.sol'; @@ -20,7 +19,6 @@ import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; contract PoolRepayTests is TestnetProcedures { using UserConfiguration for DataTypes.UserConfigurationMap; - IStableDebtToken internal staDebtUSDX; IVariableDebtToken internal varDebtUSDX; address internal aUSDX; @@ -32,20 +30,16 @@ contract PoolRepayTests is TestnetProcedures { function setUp() public { initTestEnvironment(); - (address atoken, address stableDebtUSDX, address variableDebtUSDX) = contracts + (address atoken, , address variableDebtUSDX) = contracts .protocolDataProvider .getReserveTokensAddresses(tokenList.usdx); aUSDX = atoken; - staDebtUSDX = IStableDebtToken(stableDebtUSDX); varDebtUSDX = IVariableDebtToken(variableDebtUSDX); vm.startPrank(carol); contracts.poolProxy.supply(tokenList.usdx, 100_000e6, carol, 0); vm.stopPrank(); - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.usdx, true); - sequencerOracleMock = new SequencerOracle(poolAdmin); priceOracleSentinel = new PriceOracleSentinel( IPoolAddressesProvider(report.poolAddressesProvider), diff --git a/tests/core/Pool.t.sol b/tests/core/Pool.t.sol index 7ae63020..4a40458d 100644 --- a/tests/core/Pool.t.sol +++ b/tests/core/Pool.t.sol @@ -74,8 +74,6 @@ contract PoolTests is TestnetProcedures { event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); - event RebalanceStableBorrowRate(address indexed reserve, address indexed user); - event FlashLoan( address indexed target, address initiator, @@ -116,7 +114,6 @@ contract PoolTests is TestnetProcedures { p.initialize(IPoolAddressesProvider(report.poolAddressesProvider)); // Default values after deployment and initialized - assertEq(p.MAX_STABLE_RATE_BORROW_SIZE_PERCENT(), 2500); assertEq(p.MAX_NUMBER_RESERVES(), 128); assertEq(address(p.ADDRESSES_PROVIDER()), report.poolAddressesProvider); assertEq(p.FLASHLOAN_PREMIUM_TOTAL(), 0); @@ -129,7 +126,7 @@ contract PoolTests is TestnetProcedures { vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); vm.prank(caller); - pool.initReserve(address(0), address(0), address(0), address(0), address(0)); + pool.initReserve(address(0), address(0), address(0), address(0)); } function test_setUserUseReserveAsCollateral_false() public { @@ -251,7 +248,7 @@ contract PoolTests is TestnetProcedures { DataTypes.EModeCategory memory category; vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); - pool.initReserve(address(0), address(0), address(0), address(0), address(0)); + pool.initReserve(address(0), address(0), address(0), address(0)); vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); pool.dropReserve(address(0)); @@ -283,7 +280,7 @@ contract PoolTests is TestnetProcedures { tokenList.usdx ); assertTrue(pA != address(0)); - assertTrue(pS != address(0)); + assertTrue(pS == address(0)); assertTrue(pV != address(0)); vm.prank(report.poolConfiguratorProxy); @@ -301,7 +298,7 @@ contract PoolTests is TestnetProcedures { uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, - bool stableBorrowRateEnabled, + , bool isActive, bool isFrozen ) = contracts.protocolDataProvider.getReserveConfigurationData(tokenList.usdx); @@ -316,7 +313,6 @@ contract PoolTests is TestnetProcedures { assertEq(reserveFactor, 0); assertEq(usageAsCollateralEnabled, false); assertEq(borrowingEnabled, false); - assertEq(stableBorrowRateEnabled, false); assertEq(isActive, false); assertEq(isFrozen, false); } diff --git a/tests/core/PoolConfigurator.ACLModifiers.t.sol b/tests/core/PoolConfigurator.ACLModifiers.t.sol index aad612d2..f8bc6118 100644 --- a/tests/core/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/core/PoolConfigurator.ACLModifiers.t.sol @@ -64,19 +64,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { contracts.poolConfiguratorProxy.updateVariableDebtToken(input); } - function test_reverts_notAdmin_updateStableDebtToken(address caller) public { - ConfiguratorInputTypes.UpdateDebtTokenInput memory input; - vm.assume( - !contracts.aclManager.isPoolAdmin(caller) && - caller != address(contracts.poolAddressesProvider) - ); - - vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_ADMIN)); - - vm.prank(caller); - contracts.poolConfiguratorProxy.updateStableDebtToken(input); - } - function test_reverts_notAdmin_setReserveActive(address caller) public { vm.assume( !contracts.aclManager.isPoolAdmin(caller) && @@ -139,19 +126,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { contracts.poolConfiguratorProxy.configureReserveAsCollateral(address(0), 1, 1, 1); } - function test_reverts_notRiskAdmin_setReserveStableRateBorrowing(address caller) public { - vm.assume( - !contracts.aclManager.isPoolAdmin(caller) && - !contracts.aclManager.isRiskAdmin(caller) && - caller != address(contracts.poolAddressesProvider) - ); - - vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); - - vm.prank(caller); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(address(0), true); - } - function test_reverts_notRiskOrPoolOrEmergencyAdmin_setReserveFreeze(address caller) public { vm.assume( !contracts.aclManager.isPoolAdmin(caller) && @@ -244,7 +218,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { !contracts.aclManager.isRiskAdmin(caller) && caller != address(contracts.poolAddressesProvider) ); - vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); vm.prank(caller); @@ -290,7 +263,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { ); vm.prank(caller); - vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_OR_EMERGENCY_ADMIN)); contracts.poolConfiguratorProxy.setReservePause(asset, paused, gracePeriod); } diff --git a/tests/core/PoolConfigurator.borrowCaps.t.sol b/tests/core/PoolConfigurator.borrowCaps.t.sol index 6f347905..17a7e78d 100644 --- a/tests/core/PoolConfigurator.borrowCaps.t.sol +++ b/tests/core/PoolConfigurator.borrowCaps.t.sol @@ -92,11 +92,10 @@ contract PoolConfiguratorBorrowCapTests is TestnetProcedures { tokenList.usdx ); - uint256 stableDebt = IERC20(reserveData.stableDebtTokenAddress).totalSupply(); uint256 variableDebt = IERC20(reserveData.variableDebtTokenAddress).totalSupply(); assertEq( - stableDebt + variableDebt, + variableDebt, borrowCapUsdx * 10 ** 6, 'Borrow Cap should match same amount than total debt' ); @@ -119,16 +118,11 @@ contract PoolConfiguratorBorrowCapTests is TestnetProcedures { tokenList.usdx ); - uint256 stableDebt = IERC20(reserveData.stableDebtTokenAddress).totalSupply(); uint256 variableDebt = IERC20(reserveData.variableDebtTokenAddress).totalSupply(); (uint256 borrowCapUsdx, ) = contracts.protocolDataProvider.getReserveCaps(tokenList.usdx); - assertGt( - stableDebt + variableDebt, - borrowCapUsdx * 10 ** 6, - 'Total debt should be greater than cap' - ); + assertGt(variableDebt, borrowCapUsdx * 10 ** 6, 'Total debt should be greater than cap'); } function test_setBorrowCap_them_setBorrowCap_zero() public { diff --git a/tests/core/PoolConfigurator.initReserves.t.sol b/tests/core/PoolConfigurator.initReserves.t.sol index a6159b64..645d3440 100644 --- a/tests/core/PoolConfigurator.initReserves.t.sol +++ b/tests/core/PoolConfigurator.initReserves.t.sol @@ -31,8 +31,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.aTokenSymbol = 'aMISC'; t.variableDebtName = 'Variable Debt Misc'; t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; t.rateStrategy = report.defaultInterestRateStrategyV2; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ @@ -49,7 +47,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { input[0] = ConfiguratorInputTypes.InitReserveInput( report.aToken, - report.stableDebtToken, report.variableDebtToken, newToken.decimals(), isVirtualAccActive, @@ -61,8 +58,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.aTokenSymbol, t.variableDebtName, t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, t.emptyParams, t.interestRateData ); @@ -81,7 +76,7 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { // Perform assertions { - (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts + (address aTokenProxy, , address variableDebtProxy) = contracts .protocolDataProvider .getReserveTokensAddresses(address(newToken)); @@ -95,15 +90,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { report.rewardsControllerProxy ); - assertEq(AToken(stableDebtProxy).name(), t.stableDebtName); - assertEq(AToken(stableDebtProxy).symbol(), t.stableDebtSymbol); - assertEq(AToken(stableDebtProxy).decimals(), newToken.decimals()); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(stableDebtProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - assertEq(AToken(variableDebtProxy).name(), t.variableDebtName); assertEq(AToken(variableDebtProxy).symbol(), t.variableDebtSymbol); assertEq(AToken(variableDebtProxy).decimals(), newToken.decimals()); @@ -127,7 +113,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(c.reserveFactor, 0); assertEq(c.usageAsCollateralEnabled, false); assertEq(c.borrowingEnabled, false); - assertEq(c.stableBorrowRateEnabled, false); assertEq(c.isVirtualAccActive, isVirtualAccActive); assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + 1); @@ -161,7 +146,7 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { ConfiguratorInputTypes.InitReserveInput memory reserveInput = input[y]; { - (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts + (address aTokenProxy, , address variableDebtProxy) = contracts .protocolDataProvider .getReserveTokensAddresses(reserveInput.underlyingAsset); @@ -175,15 +160,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { reserveInput.incentivesController ); - assertEq(AToken(stableDebtProxy).name(), reserveInput.stableDebtTokenName); - assertEq(AToken(stableDebtProxy).symbol(), reserveInput.stableDebtTokenSymbol); - assertEq(AToken(stableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), reserveInput.underlyingAsset); - assertEq( - address(AToken(stableDebtProxy).getIncentivesController()), - reserveInput.incentivesController - ); - assertEq(AToken(variableDebtProxy).name(), reserveInput.variableDebtTokenName); assertEq(AToken(variableDebtProxy).symbol(), reserveInput.variableDebtTokenSymbol); assertEq(AToken(variableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); @@ -213,7 +189,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(c.reserveFactor, 0); assertEq(c.usageAsCollateralEnabled, false); assertEq(c.borrowingEnabled, false); - assertEq(c.stableBorrowRateEnabled, false); } assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + input.length); } @@ -255,8 +230,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.aTokenSymbol = 'aMISC'; t.variableDebtName = 'Variable Debt Misc'; t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; t.rateStrategy = report.defaultInterestRateStrategyV2; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ @@ -272,7 +245,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { input[0] = ConfiguratorInputTypes.InitReserveInput( report.aToken, - report.stableDebtToken, report.variableDebtToken, newToken.decimals(), true, @@ -284,8 +256,6 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.aTokenSymbol, t.variableDebtName, t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, t.emptyParams, t.interestRateData ); diff --git a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol b/tests/core/PoolConfigurator.reserveRiskConfig.t.sol index cd6a28b7..32dccd24 100644 --- a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/core/PoolConfigurator.reserveRiskConfig.t.sol @@ -22,7 +22,6 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { uint256 liquidationThreshold, uint256 liquidationBonus ); - event ReserveStableRateBorrowing(address indexed asset, bool enabled); event ReserveFrozen(address indexed asset, bool frozen); event ReservePaused(address indexed asset, bool paused); event ReserveDropped(address indexed asset); @@ -58,7 +57,6 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { vm.startPrank(poolAdmin); wbtc.mint(bob, 100e8); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(tokenList.wbtc, true); vm.stopPrank(); vm.prank(bob); @@ -234,68 +232,6 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { contracts.poolConfiguratorProxy.configureReserveAsCollateral(tokenList.usdx, 0, 0, 0); } - function test_enableStableBorrowing() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, - report, - poolAdmin - ); - - // Perform action - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.initReserves(input); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveBorrowing(input[0].underlyingAsset, true); - - (, , , , , , , bool borrowingEnabledDefault, , ) = contracts - .protocolDataProvider - .getReserveConfigurationData(input[0].underlyingAsset); - assertEq(borrowingEnabledDefault, false); - - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit ReserveStableRateBorrowing(input[0].underlyingAsset, true); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(input[0].underlyingAsset, true); - - (, , , , , , , bool borrowingEnabledAfter, , ) = contracts - .protocolDataProvider - .getReserveConfigurationData(input[0].underlyingAsset); - assertEq(borrowingEnabledAfter, true); - - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit ReserveStableRateBorrowing(input[0].underlyingAsset, false); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(input[0].underlyingAsset, false); - - (, , , , , , , bool borrowingConfigAfter, , ) = contracts - .protocolDataProvider - .getReserveConfigurationData(input[0].underlyingAsset); - assertEq(borrowingConfigAfter, false); - } - - function test_reverts_enableStableBorrowing_borrowNotEnabled() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, - report, - poolAdmin - ); - - // Perform action - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.initReserves(input); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveBorrowing(input[0].underlyingAsset, false); - - vm.expectRevert(bytes(Errors.BORROWING_NOT_ENABLED)); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setReserveStableRateBorrowing(input[0].underlyingAsset, true); - } - function test_reverts_setReserveActive_false_if_suppliers() public { // Revert due for LQT == 0 there should be no suppliers vm.prank(alice); @@ -575,7 +511,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], true); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(true, 0); + contracts.poolConfiguratorProxy.setPoolPause(true); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -591,7 +527,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], false); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(false, 0); + contracts.poolConfiguratorProxy.setPoolPause(false); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -658,7 +594,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { tokenList.usdx ); assertTrue(pA != address(0)); - assertTrue(pS != address(0)); + assertTrue(pS == address(0)); assertTrue(pV != address(0)); vm.prank(poolAdmin); @@ -676,7 +612,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, - bool stableBorrowRateEnabled, + , bool isActive, bool isFrozen ) = contracts.protocolDataProvider.getReserveConfigurationData(tokenList.usdx); @@ -691,7 +627,6 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(reserveFactor, 0); assertEq(usageAsCollateralEnabled, false); assertEq(borrowingEnabled, false); - assertEq(stableBorrowRateEnabled, false); assertEq(isActive, false); assertEq(isFrozen, false); } diff --git a/tests/core/PoolConfigurator.upgradeabilty.t.sol b/tests/core/PoolConfigurator.upgradeabilty.t.sol index 2c84f556..574c5061 100644 --- a/tests/core/PoolConfigurator.upgradeabilty.t.sol +++ b/tests/core/PoolConfigurator.upgradeabilty.t.sol @@ -5,11 +5,10 @@ import 'forge-std/Test.sol'; import {AToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; import {VariableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/VariableDebtToken.sol'; -import {StableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/StableDebtToken.sol'; import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; import {ConfiguratorInputTypes, IPool, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; import {MockATokenRepayment} from 'aave-v3-core/contracts/mocks/tokens/MockATokenRepayment.sol'; -import {MockVariableDebtToken, MockStableDebtToken} from 'aave-v3-core/contracts/mocks/tokens/MockDebtTokens.sol'; +import {MockVariableDebtToken} from 'aave-v3-core/contracts/mocks/tokens/MockDebtTokens.sol'; import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; import {ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; @@ -31,13 +30,9 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { address newStrategy ); - event ATokenUpgraded( - address indexed asset, - address indexed proxy, - address indexed implementation - ); + event ReserveInterestRateDataChanged(address indexed asset, address indexed strategy, bytes data); - event StableDebtTokenUpgraded( + event ATokenUpgraded( address indexed asset, address indexed proxy, address indexed implementation @@ -85,6 +80,32 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { assertEq(newInterestRateStrategy, updatedInterestsRateStrategy); } + function test_setReserveInterestRateData() public { + address currentInterestRateStrategy = contracts + .protocolDataProvider + .getInterestRateStrategyAddress(tokenList.usdx); + + bytes memory newInterestRateData = _getDefaultInterestRatesStrategyData(); + + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit ReserveInterestRateDataChanged( + tokenList.usdx, + currentInterestRateStrategy, + newInterestRateData + ); + + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setReserveInterestRateData( + tokenList.usdx, + _getDefaultInterestRatesStrategyData() + ); + + address newInterestRateStrategy = contracts.protocolDataProvider.getInterestRateStrategyAddress( + tokenList.usdx + ); + assertEq(currentInterestRateStrategy, newInterestRateStrategy); + } + function test_interestRateStrategy_update() public { vm.prank(carol); contracts.poolProxy.supply(tokenList.usdx, 100_000e6, carol, 0); @@ -131,6 +152,7 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { assertEq(updatedCache.currVariableBorrowRate, 107585394738663515131637198); } + // TODO: deduplicate, reuse in vTokenUpdate too function test_updateAToken() public { ConfiguratorInputTypes.UpdateATokenInput memory input = ConfiguratorInputTypes .UpdateATokenInput({ @@ -215,47 +237,4 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { input.incentivesController ); } - - function test_updateStableDebtToken() public { - (, address stableDebtToken, ) = contracts.protocolDataProvider.getReserveTokensAddresses( - tokenList.usdx - ); - ConfiguratorInputTypes.UpdateDebtTokenInput memory input = ConfiguratorInputTypes - .UpdateDebtTokenInput({ - asset: tokenList.usdx, - incentivesController: report.rewardsControllerProxy, - name: 'New Stable Debt Test USDX', - symbol: 'newTestStaDebtUSDX', - implementation: address(new MockStableDebtToken(IPool(report.poolProxy))), - params: bytes('') - }); - - address previousImplementation = SlotParser.loadAddressFromSlot( - stableDebtToken, - bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) - ); - - vm.startPrank(poolAdmin); - - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit StableDebtTokenUpgraded(tokenList.usdx, stableDebtToken, input.implementation); - - // Perform upgrade - contracts.poolConfiguratorProxy.updateStableDebtToken(input); - vm.stopPrank(); - - address upgradedImplementation = SlotParser.loadAddressFromSlot( - stableDebtToken, - bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) - ); - - assertTrue(upgradedImplementation != previousImplementation); - assertEq(upgradedImplementation, input.implementation); - assertEq(StableDebtToken(stableDebtToken).name(), input.name); - assertEq(StableDebtToken(stableDebtToken).symbol(), input.symbol); - assertEq( - address(StableDebtToken(stableDebtToken).getIncentivesController()), - input.incentivesController - ); - } } diff --git a/tests/core/PoolLogic.initReserves.edge.t.sol b/tests/core/PoolLogic.initReserves.edge.t.sol index d7b6053c..81f988bc 100644 --- a/tests/core/PoolLogic.initReserves.edge.t.sol +++ b/tests/core/PoolLogic.initReserves.edge.t.sol @@ -24,7 +24,6 @@ contract PoolLogicInitReservesTests is TestnetProcedures { DataTypes.InitReserveParams memory params = DataTypes.InitReserveParams( address(new Mock()), report.aToken, - report.stableDebtToken, report.variableDebtToken, address(2), 0, @@ -41,7 +40,6 @@ contract PoolLogicInitReservesTests is TestnetProcedures { DataTypes.InitReserveParams memory params1 = DataTypes.InitReserveParams( address(new Mock()), report.aToken, - report.stableDebtToken, report.variableDebtToken, address(2), 0, @@ -51,7 +49,6 @@ contract PoolLogicInitReservesTests is TestnetProcedures { DataTypes.InitReserveParams memory params2 = DataTypes.InitReserveParams( address(new Mock()), report.aToken, - report.stableDebtToken, report.variableDebtToken, address(2), 1, @@ -61,7 +58,6 @@ contract PoolLogicInitReservesTests is TestnetProcedures { DataTypes.InitReserveParams memory params3 = DataTypes.InitReserveParams( address(new Mock()), report.aToken, - report.stableDebtToken, report.variableDebtToken, address(2), 2, @@ -82,7 +78,6 @@ contract PoolLogicInitReservesTests is TestnetProcedures { DataTypes.InitReserveParams memory params1 = DataTypes.InitReserveParams( address(new Mock()), report.aToken, - report.stableDebtToken, report.variableDebtToken, address(2), 0, diff --git a/tests/core/RateStrategy.calculateRates.t.sol b/tests/core/RateStrategy.calculateRates.t.sol new file mode 100644 index 00000000..9a359866 --- /dev/null +++ b/tests/core/RateStrategy.calculateRates.t.sol @@ -0,0 +1,465 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import './RateStrategy.template.sol'; + +contract RateStrategyCalculateRatesTests is RateStrategyBase { + using WadRayMath for uint256; + using PercentageMath for uint256; + + //---------------------------------------------------------------------------------------------------- + // Test Calculate Rates with specific conditions + //---------------------------------------------------------------------------------------------------- + function test_calculate_rates_80_percent_usage() + public + setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: uint16(80_00), + baseVariableBorrowRate: uint32(1_00), + variableRateSlope1: uint32(4_00), + variableRateSlope2: uint32(60_00) + }), + tokenList.usdx + ) + { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 800000000000000000, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 200000000000000000 + }); + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx); + + assertEq( + params.currentLiquidityRate, + expectedVariableRate.percentMul(8000).percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + assertEq(params.currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + } + + function test_calculate_rates_100_percent_usage() + public + setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: uint16(80_00), + baseVariableBorrowRate: uint32(1_00), + variableRateSlope1: uint32(4_00), + variableRateSlope2: uint32(60_00) + }), + tokenList.usdx + ) + { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 1000000000000000000, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 0 + }); + + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx) + + rateStrategy.getVariableRateSlope2(tokenList.usdx); + + assertEq( + currentLiquidityRate, + expectedVariableRate.percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + } + + function test_calculate_rates_80_percent_usage_and_50_percent_supply_usage_due_minted_tokens() + public + setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: uint16(80_00), + baseVariableBorrowRate: uint32(1_00), + variableRateSlope1: uint32(4_00), + variableRateSlope2: uint32(60_00) + }), + tokenList.usdx + ) + { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 600000000000000000, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 800000000000000000, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 200000000000000000 + }); + + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx); + + assertEq( + currentLiquidityRate, + expectedVariableRate.percentMul(5000).percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + + assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + } + + function test_calculate_rates_80_percent_usage_and_80_bps_supply_usage_due_minted_tokens() + public + setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: uint16(80_00), + baseVariableBorrowRate: uint32(1_00), + variableRateSlope1: uint32(4_00), + variableRateSlope2: uint32(60_00) + }), + tokenList.usdx + ) + { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 800000000000000000 * 124 - 200000000000000000, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 800000000000000000, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 200000000000000000 + }); + + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx); + + assertEq( + currentLiquidityRate, + expectedVariableRate.percentMul(80).percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + + assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + } + + function test_calculate_rates_80_bps_usage() + public + setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: uint16(80_00), + baseVariableBorrowRate: uint32(1_00), + variableRateSlope1: uint32(4_00), + variableRateSlope2: uint32(60_00) + }), + tokenList.usdx + ) + { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 80000000000000000000, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 9920000000000000000000 + }); + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 usageRatio = _bpsToRay(80); + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( + usageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) + ); + assertEq( + currentLiquidityRate, + expectedVariableRate.percentMul(80).percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + } + + function test_fuzz_calculate_rates_80_percent_usage_added_and_virtual_equal( + uint256 virtualBalanceAmount + ) public view { + vm.assume(virtualBalanceAmount <= 200000000000000000); + uint256 liquidityAddedAmount = 200000000000000000 - virtualBalanceAmount; + + // First, calculate using only virtual balance + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + reserve: tokenList.usdx, + unbacked: 0, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 800000000000000000, + reserveFactor: reserveFactor, + usingVirtualBalance: true, + virtualUnderlyingBalance: 200000000000000000 + }); + + (uint256 currentLiquidityRateOne, uint256 currentVariableBorrowRateOne) = rateStrategy + .calculateInterestRates(input); + + // Second, calculate using the fuzzed values, totaling the same utilization + input = DataTypes.CalculateInterestRatesParams({ + reserve: tokenList.usdx, + unbacked: 0, + liquidityAdded: liquidityAddedAmount, + liquidityTaken: 0, + totalDebt: 800000000000000000, + reserveFactor: reserveFactor, + usingVirtualBalance: true, + virtualUnderlyingBalance: virtualBalanceAmount + }); + + (uint256 currentLiquidityRateTwo, uint256 currentVariableBorrowRateTwo) = rateStrategy + .calculateInterestRates(input); + + assertEq(currentLiquidityRateOne, currentLiquidityRateTwo, 'Invalid liquidity rate'); + + assertEq(currentVariableBorrowRateOne, currentVariableBorrowRateTwo, 'Invalid variable rate'); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx); + + assertEq( + currentLiquidityRateTwo, + expectedVariableRate.percentMul(8000).percentMul(100_00 - input.reserveFactor), + 'Invalid liquidity rate' + ); + + assertEq(currentVariableBorrowRateTwo, expectedVariableRate, 'Invalid variable rate'); + } + + //---------------------------------------------------------------------------------------------------- + // Test Calculate Rates with FUZZING + //---------------------------------------------------------------------------------------------------- + function test_calculate_rates_empty_reserve( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public setRateParams(rateData, tokenList.usdx) { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: 0, + liquidityTaken: 0, + totalDebt: 0, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: 0 + }); + + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + assertEq(currentLiquidityRate, 0); + assertEq(currentVariableBorrowRate, rateStrategy.getBaseVariableBorrowRate(tokenList.usdx)); + } + + function test_calculate_rates_when_not_using_virtual_valance( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + uint256 availableLiquidity, + uint256 virtualBalanceAmount + ) public setRateParams(rateData, tokenList.usdx) { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: availableLiquidity, + liquidityTaken: 0, + totalDebt: 0, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: false, + virtualUnderlyingBalance: virtualBalanceAmount + }); + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); + assertEq( + params.currentVariableBorrowRate, + rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), + 'Invalid variable rate' + ); + } + + function test_calculate_rates_when_total_debt_0( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + uint256 availableLiquidity, + uint256 virtualBalanceAmount + ) public setRateParams(rateData, tokenList.usdx) { + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: availableLiquidity, + liquidityTaken: 0, + totalDebt: 0, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: virtualBalanceAmount + }); + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); + assertEq( + params.currentVariableBorrowRate, + rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), + 'Invalid variable rate' + ); + } + + function test_calculate_rates_below_op_usage( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + uint256 totalDebt, + uint256 availableLiquidity, + uint256 virtualBalanceAmount + ) public setRateParams(rateData, tokenList.usdx) { + vm.assume(totalDebt > 0); + vm.assume(totalDebt < availableLiquidity && availableLiquidity < 1e28); + vm.assume(virtualBalanceAmount < 1e28); + uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity + virtualBalanceAmount; + borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); + vm.assume(borrowUsageRatio < (uint256(rateData.optimalUsageRatio) * 1e23)); + + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: availableLiquidity, + liquidityTaken: 0, + totalDebt: totalDebt, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: virtualBalanceAmount + }); + + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( + borrowUsageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) + ); + + assertApproxEqAbs( + params.currentVariableBorrowRate, + expectedVariableRate, + 100, + 'Invalid variable rate' + ); + + assertApproxEqAbs( + params.currentLiquidityRate, + expectedVariableRate.rayMul(input.totalDebt.rayDiv(availableLiquidityPlusDebt)).percentMul( + 100_00 - input.reserveFactor + ), + 100, + 'Invalid liquidity rate' + ); + } + + function test_calculate_rates_below_op_usage_when_no_debt( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + uint256 availableLiquidity, + uint256 virtualBalanceAmount + ) public setRateParams(rateData, tokenList.usdx) { + uint256 totalDebt = 0; + vm.assume(totalDebt < availableLiquidity && availableLiquidity < 1e28); + uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity; + borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); + vm.assume(borrowUsageRatio < (uint256(rateData.optimalUsageRatio) * 1e23)); + + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: availableLiquidity, + liquidityTaken: 0, + totalDebt: totalDebt, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: virtualBalanceAmount + }); + + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( + borrowUsageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) + ); + + assertApproxEqAbs( + params.currentVariableBorrowRate, + expectedVariableRate, + 100, + 'Invalid variable rate' + ); + + assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); + } + + function test_calculate_rates_above_op_usage( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + uint256 totalDebt, + uint256 availableLiquidity, + uint256 virtualBalanceAmount + ) public setRateParams(rateData, tokenList.usdx) { + availableLiquidity = bound(availableLiquidity, 1, 1e28); + totalDebt = bound(totalDebt, 1, availableLiquidity); + vm.assume(virtualBalanceAmount < 1e28); + uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity + virtualBalanceAmount; + + borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); + vm.assume(borrowUsageRatio > (uint256(rateData.optimalUsageRatio) * 1e23)); + + DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ + unbacked: 0, + liquidityAdded: availableLiquidity, + liquidityTaken: 0, + totalDebt: totalDebt, + reserveFactor: reserveFactor, + reserve: tokenList.usdx, + usingVirtualBalance: true, + virtualUnderlyingBalance: virtualBalanceAmount + }); + + (params.currentLiquidityRate, params.currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); + + uint256 excessBorrowUsageRatio = (borrowUsageRatio - + rateStrategy.getOptimalUsageRatio(tokenList.usdx)).rayDiv( + WadRayMath.RAY - rateStrategy.getOptimalUsageRatio(tokenList.usdx) + ); + + uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + + rateStrategy.getVariableRateSlope1(tokenList.usdx) + + rateStrategy.getVariableRateSlope2(tokenList.usdx).rayMul(excessBorrowUsageRatio); + + assertEq(params.currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); + + assertEq( + params.currentLiquidityRate, + expectedVariableRate.rayMul(input.totalDebt.rayDiv(availableLiquidityPlusDebt)).percentMul( + 100_00 - input.reserveFactor + ), + 'Invalid liquidity rate' + ); + } +} diff --git a/tests/core/RateStrategy.setters.t.sol b/tests/core/RateStrategy.setters.t.sol new file mode 100644 index 00000000..dab12d28 --- /dev/null +++ b/tests/core/RateStrategy.setters.t.sol @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import './RateStrategy.template.sol'; + +contract RateStrategySettersTests is RateStrategyBase { + using WadRayMath for uint256; + using PercentageMath for uint256; + + // @dev we override it to test second version of setInterestRateParams later + function _setInterestRateParams( + address token, + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) internal virtual { + rateStrategy.setInterestRateParams(token, abi.encode(rateData)); + } + + //---------------------------------------------------------------------------------------------------- + // Test Set interest Rate params Using FUZZING + //---------------------------------------------------------------------------------------------------- + function test_new_SetReserveInterestRateParams_when_not_configurator( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + _validateSetRateParams(rateData); + + vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); + _setInterestRateParams(tokenList.usdx, rateData); + } + + function test_new_SetReserveInterestRateParams( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + _validateSetRateParams(rateData); + + vm.prank(report.poolConfiguratorProxy); + vm.expectEmit(true, false, false, true); + emit RateDataUpdate( + tokenList.usdx, + rateData.optimalUsageRatio, + rateData.baseVariableBorrowRate, + rateData.variableRateSlope1, + rateData.variableRateSlope2 + ); + _setInterestRateParams(tokenList.usdx, rateData); + + assertEq(address(rateStrategy.ADDRESSES_PROVIDER()), report.poolAddressesProvider); + assertEq( + rateStrategy.getOptimalUsageRatio(tokenList.usdx), + uint256(rateData.optimalUsageRatio) * 1e23 + ); + assertEq( + rateStrategy.getVariableRateSlope1(tokenList.usdx), + uint256(rateData.variableRateSlope1) * 1e23 + ); + assertEq( + rateStrategy.getVariableRateSlope2(tokenList.usdx), + uint256(rateData.variableRateSlope2) * 1e23 + ); + assertEq( + rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), + uint256(rateData.baseVariableBorrowRate) * 1e23 + ); + assertEq( + rateStrategy.getMaxVariableBorrowRate(tokenList.usdx), + uint256( + rateData.baseVariableBorrowRate + rateData.variableRateSlope1 + rateData.variableRateSlope2 + ) * 1e23 + ); + } + + function test_reverts_SetReserveInterestRateParams_when_reserve_0( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + _validateSetRateParams(rateData); + + vm.prank(report.poolConfiguratorProxy); + vm.expectRevert(bytes(Errors.ZERO_ADDRESS_NOT_VALID)); + _setInterestRateParams(address(0), rateData); + } + + function test_reverts_SetReserveInterestRateParams_when_gt_max_op( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + vm.assume(rateData.optimalUsageRatio > rateStrategy.MAX_OPTIMAL_POINT()); + + vm.prank(report.poolConfiguratorProxy); + + vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); + _setInterestRateParams(tokenList.usdx, rateData); + } + + function test_reverts_SetReserveInterestRateParams_when_lt_min_op( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + vm.assume(rateData.optimalUsageRatio < rateStrategy.MIN_OPTIMAL_POINT()); + + vm.prank(report.poolConfiguratorProxy); + + vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); + _setInterestRateParams(tokenList.usdx, rateData); + } + + function test_reverts_SetReserveInterestRateParams_when_gt_maxRate( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + vm.assume( + rateData.optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && + rateData.optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() + ); + + vm.assume(rateData.variableRateSlope1 <= rateData.variableRateSlope2); + vm.assume( + uint256(rateData.baseVariableBorrowRate) + + uint256(rateData.variableRateSlope1) + + uint256(rateData.variableRateSlope2) > + rateStrategy.MAX_BORROW_RATE() + ); + + vm.prank(report.poolConfiguratorProxy); + + vm.expectRevert(bytes(Errors.INVALID_MAXRATE)); + _setInterestRateParams(tokenList.usdx, rateData); + } + + function test_reverts_SetReserveInterestRateParams_when_slope1_gt_slope2( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) public { + vm.assume( + rateData.optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && + rateData.optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() + ); + + vm.assume(rateData.variableRateSlope1 > rateData.variableRateSlope2); + + vm.prank(report.poolConfiguratorProxy); + + vm.expectRevert(bytes(Errors.SLOPE_2_MUST_BE_GTE_SLOPE_1)); + _setInterestRateParams(tokenList.usdx, rateData); + } +} + +contract RateStrategySettersTestsOverride is RateStrategySettersTests { + function _setInterestRateParams( + address token, + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) internal override { + rateStrategy.setInterestRateParams(token, rateData); + } +} diff --git a/tests/core/RateStrategy.t.sol b/tests/core/RateStrategy.t.sol index 9cc3e6bb..9cb150af 100644 --- a/tests/core/RateStrategy.t.sol +++ b/tests/core/RateStrategy.t.sol @@ -1,95 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import 'forge-std/Test.sol'; - -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {DefaultReserveInterestRateStrategyV2, IDefaultInterestRateStrategyV2, PercentageMath, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; - -contract RateStrategyTests is TestnetProcedures { - using WadRayMath for uint256; - using PercentageMath for uint256; - - struct Params { - uint256 currentLiquidityRate; - uint256 currentStableBorrowRate; - uint256 currentVariableBorrowRate; - } - - uint256 public reserveFactor; - address public aToken; - DefaultReserveInterestRateStrategyV2 public rateStrategy; - Params public params; - uint256 public borrowUsageRatio; - - event RateDataUpdate( - address indexed reserve, - uint256 optimalUsageRatio, - uint256 baseVariableBorrowRate, - uint256 variableRateSlope1, - uint256 variableRateSlope2 - ); - - // sets limits for the fuzzing parameters and sets them on the interest rate strategy - modifier setRateParams( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - address token - ) { - _setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - token - ); - _; - } - - function _setRateParams( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - address token - ) internal { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 < variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) <= - rateStrategy.MAX_BORROW_RATE() - ); - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - rateStrategy.setInterestRateParams(token, abi.encode(rateData)); - } - - function setUp() public { - initTestEnvironment(); - - (aToken, , ) = contracts.protocolDataProvider.getReserveTokensAddresses(tokenList.usdx); - rateStrategy = new DefaultReserveInterestRateStrategyV2(report.poolAddressesProvider); - (, , , , reserveFactor, , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( - tokenList.usdx - ); - } +import './RateStrategy.template.sol'; +contract RateStrategyBaseTests is RateStrategyBase { //---------------------------------------------------------------------------------------------------- // INITIALIZATION TESTS //---------------------------------------------------------------------------------------------------- @@ -109,1117 +23,38 @@ contract RateStrategyTests is TestnetProcedures { // Test Getters //---------------------------------------------------------------------------------------------------- function test_getInterestRateDataRay( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { + IDefaultInterestRateStrategyV2.InterestRateData memory rateDataToSet + ) public setRateParams(rateDataToSet, tokenList.usdx) { IDefaultInterestRateStrategyV2.InterestRateDataRay memory rateData = rateStrategy .getInterestRateData(tokenList.usdx); - assertEq(uint256(optimalUsageRatio) * 1e23, rateData.optimalUsageRatio); - assertEq(uint256(baseVariableBorrowRate) * 1e23, rateData.baseVariableBorrowRate); - assertEq(uint256(variableRateSlope1) * 1e23, rateData.variableRateSlope1); - assertEq(uint256(variableRateSlope2) * 1e23, rateData.variableRateSlope2); + assertEq(uint256(rateDataToSet.optimalUsageRatio) * 1e23, rateData.optimalUsageRatio); + assertEq(uint256(rateDataToSet.baseVariableBorrowRate) * 1e23, rateData.baseVariableBorrowRate); + assertEq(uint256(rateDataToSet.variableRateSlope1) * 1e23, rateData.variableRateSlope1); + assertEq(uint256(rateDataToSet.variableRateSlope2) * 1e23, rateData.variableRateSlope2); } function test_getInterestRateDataBps( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { + IDefaultInterestRateStrategyV2.InterestRateData memory rateDataToSet + ) public setRateParams(rateDataToSet, tokenList.usdx) { IDefaultInterestRateStrategyV2.InterestRateData memory rateData = rateStrategy .getInterestRateDataBps(tokenList.usdx); - assertEq(optimalUsageRatio, rateData.optimalUsageRatio); - assertEq(baseVariableBorrowRate, rateData.baseVariableBorrowRate); - assertEq(variableRateSlope1, rateData.variableRateSlope1); - assertEq(variableRateSlope2, rateData.variableRateSlope2); + assertEq(rateDataToSet.optimalUsageRatio, rateData.optimalUsageRatio); + assertEq(rateDataToSet.baseVariableBorrowRate, rateData.baseVariableBorrowRate); + assertEq(rateDataToSet.variableRateSlope1, rateData.variableRateSlope1); + assertEq(rateDataToSet.variableRateSlope2, rateData.variableRateSlope2); } function test_getMaxVariableBorrowRate( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { + IDefaultInterestRateStrategyV2.InterestRateData memory rateDataToSet + ) public setRateParams(rateDataToSet, tokenList.usdx) { uint256 maxVariableBorrowRate = rateStrategy.getMaxVariableBorrowRate(tokenList.usdx); assertEq( - uint256(baseVariableBorrowRate + variableRateSlope1 + variableRateSlope2) * 1e23, - maxVariableBorrowRate - ); - } - - //---------------------------------------------------------------------------------------------------- - // Test Set interest Rate params Using FUZZING - //---------------------------------------------------------------------------------------------------- - function test_new_SetReserveInterestRateParams_override_method_when_not_configurator( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) <= - rateStrategy.MAX_BORROW_RATE() - ); - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); - rateStrategy.setInterestRateParams(tokenList.usdx, rateData); - } - - function test_new_SetReserveInterestRateParams_when_not_configurator( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) <= - rateStrategy.MAX_BORROW_RATE() - ); - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - function test_new_SetReserveInterestRateParams_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) <= - rateStrategy.MAX_BORROW_RATE() - ); - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - vm.expectEmit(true, false, false, true); - emit RateDataUpdate( - tokenList.usdx, - uint256(rateData.optimalUsageRatio), - uint256(rateData.baseVariableBorrowRate), - uint256(rateData.variableRateSlope1), - uint256(rateData.variableRateSlope2) - ); - rateStrategy.setInterestRateParams(tokenList.usdx, rateData); - - assertEq(address(rateStrategy.ADDRESSES_PROVIDER()), report.poolAddressesProvider); - assertEq( - rateStrategy.getOptimalUsageRatio(tokenList.usdx), - uint256(rateData.optimalUsageRatio) * 1e23 - ); - assertEq( - rateStrategy.getVariableRateSlope1(tokenList.usdx), - uint256(rateData.variableRateSlope1) * 1e23 - ); - assertEq( - rateStrategy.getVariableRateSlope2(tokenList.usdx), - uint256(rateData.variableRateSlope2) * 1e23 - ); - assertEq( - rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), - uint256(rateData.baseVariableBorrowRate) * 1e23 - ); - assertEq( - rateStrategy.getMaxVariableBorrowRate(tokenList.usdx), uint256( - rateData.baseVariableBorrowRate + rateData.variableRateSlope1 + rateData.variableRateSlope2 - ) * 1e23 - ); - } - - function test_new_SetReserveInterestRateParams( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) <= - rateStrategy.MAX_BORROW_RATE() - ); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - vm.expectEmit(true, false, false, true); - emit RateDataUpdate( - tokenList.usdx, - uint256(rateData.optimalUsageRatio), - uint256(rateData.baseVariableBorrowRate), - uint256(rateData.variableRateSlope1), - uint256(rateData.variableRateSlope2) - ); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - - assertEq(address(rateStrategy.ADDRESSES_PROVIDER()), report.poolAddressesProvider); - assertEq( - rateStrategy.getOptimalUsageRatio(tokenList.usdx), - uint256(rateData.optimalUsageRatio) * 1e23 - ); - assertEq( - rateStrategy.getVariableRateSlope1(tokenList.usdx), - uint256(rateData.variableRateSlope1) * 1e23 - ); - assertEq( - rateStrategy.getVariableRateSlope2(tokenList.usdx), - uint256(rateData.variableRateSlope2) * 1e23 - ); - assertEq( - rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), - uint256(rateData.baseVariableBorrowRate) * 1e23 - ); - assertEq( - rateStrategy.getMaxVariableBorrowRate(tokenList.usdx), - uint256( - rateData.baseVariableBorrowRate + rateData.variableRateSlope1 + rateData.variableRateSlope2 - ) * 1e23 - ); - } - - function test_reverts_SetReserveInterestRateParams_when_reserve_0( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.ZERO_ADDRESS_NOT_VALID)); - rateStrategy.setInterestRateParams(address(0), abi.encode(rateData)); - } - - function test_reverts_SetReserveInterestRateParams_when_reserve_0_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.ZERO_ADDRESS_NOT_VALID)); - rateStrategy.setInterestRateParams(address(0), rateData); - } - - function test_reverts_SetReserveInterestRateParams_when_gt_max_op( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume(optimalUsageRatio > rateStrategy.MAX_OPTIMAL_POINT()); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - function test_reverts_SetReserveInterestRateParams_when_gt_max_op_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume(optimalUsageRatio > rateStrategy.MAX_OPTIMAL_POINT()); - - //<<<<<<< HEAD - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - //======= - // DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - // unbacked: 0, - // liquidityAdded: 0, - // liquidityTaken: 0, - // totalStableDebt: 0, - // totalVariableDebt: 0, - // averageStableBorrowRate: 0, - // reserveFactor: reserveFactor, - // reserve: tokenList.usdx, - // usingVirtualBalance: true, - // virtualUnderlyingBalance: 0 - // }); - //>>>>>>> 44cf8077687ba552e6cbcbba7c7cdbbb4c68e34f - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); - rateStrategy.setInterestRateParams(tokenList.usdx, rateData); - } - - function test_reverts_SetReserveInterestRateParams_when_lt_min_op( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume(optimalUsageRatio < rateStrategy.MIN_OPTIMAL_POINT()); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - function test_reverts_SetReserveInterestRateParams_when_lt_min_op_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume(optimalUsageRatio < rateStrategy.MIN_OPTIMAL_POINT()); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_OPTIMAL_USAGE_RATIO)); - rateStrategy.setInterestRateParams(tokenList.usdx, rateData); - } - - function test_reverts_SetReserveInterestRateParams_when_gt_maxRate( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) > - rateStrategy.MAX_BORROW_RATE() - ); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_MAXRATE)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - function test_reverts_SetReserveInterestRateParams_when_gt_maxRate_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 <= variableRateSlope2); - vm.assume( - uint256(baseVariableBorrowRate) + uint256(variableRateSlope1) + uint256(variableRateSlope2) > - rateStrategy.MAX_BORROW_RATE() - ); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.INVALID_MAXRATE)); - rateStrategy.setInterestRateParams(tokenList.usdx, rateData); - } - - function test_reverts_SetReserveInterestRateParams_when_slope1_gt_slope2( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 > variableRateSlope2); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.SLOPE_2_MUST_BE_GTE_SLOPE_1)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - function test_reverts_SetReserveInterestRateParams_when_slope1_gt_slope2_override_method( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) public { - vm.assume( - optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && - optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() - ); - - vm.assume(variableRateSlope1 > variableRateSlope2); - - IDefaultInterestRateStrategyV2.InterestRateData memory rateData = IDefaultInterestRateStrategyV2 - .InterestRateData({ - optimalUsageRatio: optimalUsageRatio, - baseVariableBorrowRate: baseVariableBorrowRate, - variableRateSlope1: variableRateSlope1, - variableRateSlope2: variableRateSlope2 - }); - - vm.prank(report.poolConfiguratorProxy); - - vm.expectRevert(bytes(Errors.SLOPE_2_MUST_BE_GTE_SLOPE_1)); - rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); - } - - //---------------------------------------------------------------------------------------------------- - // Test Calculate Rates with specific conditions - //---------------------------------------------------------------------------------------------------- - function test_calculate_rates_80_percent_usage() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 800000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 200000000000000000 - }); - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx); - - assertEq( - params.currentLiquidityRate, - expectedVariableRate.percentMul(8000).percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - assertEq(params.currentStableBorrowRate, 0); - assertEq(params.currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - } - - function test_calculate_rates_100_percent_usage() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 1000000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 0 - }); - - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx) + - rateStrategy.getVariableRateSlope2(tokenList.usdx); - - assertEq( - currentLiquidityRate, - expectedVariableRate.percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - assertEq(currentStableBorrowRate, 0); - assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - } - - function test_calculate_rates_100_percent_usage_50_percent_stable_debt_50_percent_variable_debt_10_percent_avg_stable_rate() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 400000000000000000, - totalVariableDebt: 400000000000000000, - averageStableBorrowRate: 100000000000000000000000000, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 0 - }); - - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx) + - rateStrategy.getVariableRateSlope2(tokenList.usdx); - - uint256 expectedLiquidityRate = ((currentVariableBorrowRate + 1e26) / 2).percentMul( - 100_00 - input.reserveFactor - ); - - assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - assertEq(currentStableBorrowRate, 0); - - assertEq(currentLiquidityRate, expectedLiquidityRate, 'Invalid liquidity rate'); - } - - function test_calculate_rates_80_percent_usage_and_50_percent_supply_usage_due_minted_tokens() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 600000000000000000, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 800000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 200000000000000000 - }); - - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx); - - assertEq( - currentLiquidityRate, - expectedVariableRate.percentMul(5000).percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - - assertEq(currentStableBorrowRate, 0); - assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - } - - function test_calculate_rates_80_percent_usage_and_80_bps_supply_usage_due_minted_tokens() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 800000000000000000 * 124 - 200000000000000000, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 800000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 200000000000000000 - }); - - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx); - - assertEq( - currentLiquidityRate, - expectedVariableRate.percentMul(80).percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - - assertEq(currentStableBorrowRate, 0); - assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - } - - function test_calculate_rates_80_bps_usage() - public - setRateParams(uint16(80_00), uint32(1_00), uint32(4_00), uint32(60_00), tokenList.usdx) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 80000000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 9920000000000000000000 - }); - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 usageRatio = _bpsToRay(80); - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( - usageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) - ); - assertEq( - currentLiquidityRate, - expectedVariableRate.percentMul(80).percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - assertEq(currentStableBorrowRate, 0); - assertEq(currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - } - - function test_fuzz_calculate_rates_80_percent_usage_added_and_virtual_equal( - uint256 virtualBalanceAmount - ) public view { - vm.assume(virtualBalanceAmount <= 200000000000000000); - uint256 liquidityAddedAmount = 200000000000000000 - virtualBalanceAmount; - - // First, calculate using only virtual balance - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - reserve: tokenList.usdx, - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 800000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - usingVirtualBalance: true, - virtualUnderlyingBalance: 200000000000000000 - }); - - ( - uint256 currentLiquidityRateOne, - uint256 currentStableBorrowRateOne, - uint256 currentVariableBorrowRateOne - ) = rateStrategy.calculateInterestRates(input); - - // Second, calculate using the fuzzed values, totaling the same utilization - input = DataTypes.CalculateInterestRatesParams({ - reserve: tokenList.usdx, - unbacked: 0, - liquidityAdded: liquidityAddedAmount, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 800000000000000000, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - usingVirtualBalance: true, - virtualUnderlyingBalance: virtualBalanceAmount - }); - - ( - uint256 currentLiquidityRateTwo, - uint256 currentStableBorrowRateTwo, - uint256 currentVariableBorrowRateTwo - ) = rateStrategy.calculateInterestRates(input); - - assertEq(currentLiquidityRateOne, currentLiquidityRateTwo, 'Invalid liquidity rate'); - - assertEq(currentStableBorrowRateOne, currentStableBorrowRateTwo, 'Invalid stable rate'); - - assertEq(currentVariableBorrowRateOne, currentVariableBorrowRateTwo, 'Invalid variable rate'); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx); - - assertEq( - currentLiquidityRateTwo, - expectedVariableRate.percentMul(8000).percentMul(100_00 - input.reserveFactor), - 'Invalid liquidity rate' - ); - - assertEq(currentVariableBorrowRateTwo, expectedVariableRate, 'Invalid variable rate'); - } - - //---------------------------------------------------------------------------------------------------- - // Test Calculate Rates with FUZZING - //---------------------------------------------------------------------------------------------------- - function test_calculate_rates_empty_reserve( - uint16 optimalUsageRatio, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2 - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: 0, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 0, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: 0 - }); - - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - assertEq(currentLiquidityRate, 0); - assertEq(currentStableBorrowRate, 0); - assertEq(currentVariableBorrowRate, rateStrategy.getBaseVariableBorrowRate(tokenList.usdx)); - } - - function test_calculate_rates_when_not_using_virtual_valance( - uint16 optimalUsageRatio, - uint256 availableLiquidity, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - uint256 virtualBalanceAmount - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: availableLiquidity, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 0, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: false, - virtualUnderlyingBalance: virtualBalanceAmount - }); - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); - assertEq(params.currentStableBorrowRate, 0); - assertEq( - params.currentVariableBorrowRate, - rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), - 'Invalid variable rate' - ); - } - - function test_calculate_rates_when_total_debt_0( - uint16 optimalUsageRatio, - uint256 availableLiquidity, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - uint256 virtualBalanceAmount - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: availableLiquidity, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 0, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: virtualBalanceAmount - }); - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); - assertEq(params.currentStableBorrowRate, 0); - assertEq( - params.currentVariableBorrowRate, - rateStrategy.getBaseVariableBorrowRate(tokenList.usdx), - 'Invalid variable rate' - ); - } - - function test_calculate_rates_below_op_usage( - uint16 optimalUsageRatio, - uint256 totalDebt, - uint256 availableLiquidity, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - uint256 virtualBalanceAmount - ) public { - _setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ); - vm.assume(totalDebt > 0); - vm.assume(totalDebt < availableLiquidity && availableLiquidity < 1e28); - vm.assume(virtualBalanceAmount < 1e28); - uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity + virtualBalanceAmount; - borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); - vm.assume(borrowUsageRatio < (uint256(optimalUsageRatio) * 1e23)); - - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: availableLiquidity, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: totalDebt, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: virtualBalanceAmount - }); - - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( - borrowUsageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) - ); - - assertApproxEqAbs( - params.currentVariableBorrowRate, - expectedVariableRate, - 100, - 'Invalid variable rate' - ); - assertEq(params.currentStableBorrowRate, 0); - - assertApproxEqAbs( - params.currentLiquidityRate, - ( - input.totalVariableDebt.wadToRay().rayMul(expectedVariableRate).rayDiv( - input.totalVariableDebt.wadToRay() - ) - ).rayMul(input.totalVariableDebt.rayDiv(availableLiquidityPlusDebt)).percentMul( - 100_00 - input.reserveFactor - ), - 100, - 'Invalid liquidity rate' - ); - } - - function test_calculate_rates_below_op_usage_when_no_debt( - uint16 optimalUsageRatio, - uint256 availableLiquidity, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - uint256 virtualBalanceAmount - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { - uint256 totalDebt = 0; - vm.assume(totalDebt < availableLiquidity && availableLiquidity < 1e28); - uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity; - borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); - vm.assume(borrowUsageRatio < (uint256(optimalUsageRatio) * 1e23)); - - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: availableLiquidity, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: totalDebt, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: virtualBalanceAmount - }); - - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx).rayMul( - borrowUsageRatio.rayDiv(rateStrategy.getOptimalUsageRatio(tokenList.usdx)) - ); - - assertApproxEqAbs( - params.currentVariableBorrowRate, - expectedVariableRate, - 100, - 'Invalid variable rate' - ); - assertEq(params.currentStableBorrowRate, 0); - - assertEq(params.currentLiquidityRate, 0, 'Invalid liquidity rate'); - } - - function test_calculate_rates_above_op_usage( - uint16 optimalUsageRatio, - uint256 totalDebt, - uint256 availableLiquidity, - uint32 baseVariableBorrowRate, - uint32 variableRateSlope1, - uint32 variableRateSlope2, - uint256 virtualBalanceAmount - ) - public - setRateParams( - optimalUsageRatio, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - tokenList.usdx - ) - { - availableLiquidity = bound(availableLiquidity, 1, 1e28); - totalDebt = bound(totalDebt, 1, availableLiquidity); - vm.assume(virtualBalanceAmount < 1e28); - uint256 availableLiquidityPlusDebt = totalDebt + availableLiquidity + virtualBalanceAmount; - - borrowUsageRatio = totalDebt.rayDiv(availableLiquidityPlusDebt); - vm.assume(borrowUsageRatio > (uint256(optimalUsageRatio) * 1e23)); - - DataTypes.CalculateInterestRatesParams memory input = DataTypes.CalculateInterestRatesParams({ - unbacked: 0, - liquidityAdded: availableLiquidity, - liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: totalDebt, - averageStableBorrowRate: 0, - reserveFactor: reserveFactor, - reserve: tokenList.usdx, - usingVirtualBalance: true, - virtualUnderlyingBalance: virtualBalanceAmount - }); - - ( - params.currentLiquidityRate, - params.currentStableBorrowRate, - params.currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); - - uint256 excessBorrowUsageRatio = (borrowUsageRatio - - rateStrategy.getOptimalUsageRatio(tokenList.usdx)).rayDiv( - WadRayMath.RAY - rateStrategy.getOptimalUsageRatio(tokenList.usdx) - ); - - uint256 expectedVariableRate = rateStrategy.getBaseVariableBorrowRate(tokenList.usdx) + - rateStrategy.getVariableRateSlope1(tokenList.usdx) + - rateStrategy.getVariableRateSlope2(tokenList.usdx).rayMul(excessBorrowUsageRatio); - - assertEq(params.currentVariableBorrowRate, expectedVariableRate, 'Invalid variable rate'); - - assertEq(params.currentStableBorrowRate, 0); - assertEq( - params.currentLiquidityRate, - ( - input.totalVariableDebt.wadToRay().rayMul(expectedVariableRate).rayDiv( - input.totalVariableDebt.wadToRay() - ) - ).rayMul(input.totalVariableDebt.rayDiv(availableLiquidityPlusDebt)).percentMul( - 100_00 - input.reserveFactor - ), - 'Invalid liquidity rate' + rateDataToSet.baseVariableBorrowRate + + rateDataToSet.variableRateSlope1 + + rateDataToSet.variableRateSlope2 + ) * 1e23, + maxVariableBorrowRate ); } } diff --git a/tests/core/RateStrategy.template.sol b/tests/core/RateStrategy.template.sol new file mode 100644 index 00000000..4690003d --- /dev/null +++ b/tests/core/RateStrategy.template.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; + +import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; +import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; +import {DefaultReserveInterestRateStrategyV2, IDefaultInterestRateStrategyV2, PercentageMath, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; +import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; + +contract RateStrategyBase is TestnetProcedures { + using WadRayMath for uint256; + using PercentageMath for uint256; + + struct Params { + uint256 currentLiquidityRate; + uint256 currentVariableBorrowRate; + } + + uint256 public reserveFactor; + address public aToken; + DefaultReserveInterestRateStrategyV2 public rateStrategy; + Params public params; + uint256 public borrowUsageRatio; + + event RateDataUpdate( + address indexed reserve, + uint256 optimalUsageRatio, + uint256 baseVariableBorrowRate, + uint256 variableRateSlope1, + uint256 variableRateSlope2 + ); + + // sets limits for the fuzzing parameters and sets them on the interest rate strategy + modifier setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + address token + ) { + _setRateParams(rateData, token); + _; + } + + function _validateSetRateParams( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData + ) internal view { + vm.assume( + rateData.optimalUsageRatio >= rateStrategy.MIN_OPTIMAL_POINT() && + rateData.optimalUsageRatio <= rateStrategy.MAX_OPTIMAL_POINT() + ); + + vm.assume(rateData.variableRateSlope1 < rateData.variableRateSlope2); + vm.assume( + uint256(rateData.baseVariableBorrowRate) + + uint256(rateData.variableRateSlope1) + + uint256(rateData.variableRateSlope2) <= + rateStrategy.MAX_BORROW_RATE() + ); + } + + function _setRateParams( + IDefaultInterestRateStrategyV2.InterestRateData memory rateData, + address token + ) internal { + _validateSetRateParams(rateData); + + vm.prank(report.poolConfiguratorProxy); + rateStrategy.setInterestRateParams(token, abi.encode(rateData)); + } + + function setUp() public { + initTestEnvironment(); + + (aToken, , ) = contracts.protocolDataProvider.getReserveTokensAddresses(tokenList.usdx); + rateStrategy = new DefaultReserveInterestRateStrategyV2(report.poolAddressesProvider); + (, , , , reserveFactor, , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( + tokenList.usdx + ); + } +} diff --git a/tests/core/RatesOverflow.t.sol b/tests/core/RatesOverflow.t.sol index bb99d58f..1dfbaf9d 100644 --- a/tests/core/RatesOverflow.t.sol +++ b/tests/core/RatesOverflow.t.sol @@ -27,11 +27,6 @@ contract RatesOverflowCheckTests is TestnetProcedures { address(mockRateStrategy), _getDefaultInterestRatesStrategyData() ); - - IPoolConfigurator(report.poolConfiguratorProxy).setReserveStableRateBorrowing( - tokenList.usdx, - true - ); vm.stopPrank(); } diff --git a/tests/core/StableDebtToken.t.sol b/tests/core/StableDebtToken.t.sol deleted file mode 100644 index 2394d4b6..00000000 --- a/tests/core/StableDebtToken.t.sol +++ /dev/null @@ -1,419 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import 'forge-std/Test.sol'; - -import {StableDebtTokenHarness as StableDebtTokenInstance} from '../harness/StableDebtToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {PoolConfigurator, ConfiguratorInputTypes, IPool} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; - -contract StableDebtTokenEventsTests is TestnetProcedures { - StableDebtTokenInstance public stableDebtToken; - - event Initialized( - address indexed underlyingAsset, - address indexed pool, - address incentivesController, - uint8 debtTokenDecimals, - string debtTokenName, - string debtTokenSymbol, - bytes params - ); - - event BorrowAllowanceDelegated( - address indexed fromUser, - address indexed toUser, - address indexed asset, - uint256 amount - ); - - function setUp() public { - initTestEnvironment(); - - (, address stableDebtUsdx, ) = contracts.protocolDataProvider.getReserveTokensAddresses( - tokenList.usdx - ); - - stableDebtToken = StableDebtTokenInstance(stableDebtUsdx); - - vm.prank(bob); - contracts.poolProxy.supply(tokenList.usdx, 10000e6, bob, 0); - vm.prank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 100e8, alice, 0); - vm.prank(bob); - contracts.poolProxy.supply(tokenList.wbtc, 100e8, alice, 0); - // Allow USDX for stable borrow - vm.prank(poolAdmin); - PoolConfigurator(report.poolConfiguratorProxy).setReserveStableRateBorrowing( - tokenList.usdx, - true - ); - } - - function test_new_StableDebtToken_implementation() public returns (StableDebtTokenInstance) { - StableDebtTokenInstance stDebtToken = new StableDebtTokenInstance(IPool(report.poolProxy)); - - assertEq(stDebtToken.name(), 'STABLE_DEBT_TOKEN_IMPL'); - assertEq(stDebtToken.symbol(), 'STABLE_DEBT_TOKEN_IMPL'); - assertEq(stDebtToken.decimals(), 0); - assertEq(address(stDebtToken.POOL()), address(report.poolProxy)); - assertEq(address(stDebtToken.getIncentivesController()), address(0)); - assertEq(stDebtToken.UNDERLYING_ASSET_ADDRESS(), address(0)); - assertEq(stDebtToken.DEBT_TOKEN_REVISION(), 0x1); - assertEq(stDebtToken.getAverageStableRate(), 0); - - return stDebtToken; - } - - function test_reverts_initialize_twice() public { - StableDebtTokenInstance staDebtToken = test_initialize_StableDebtToken(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; - - uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); - - vm.expectRevert(bytes('Contract instance has already been initialized')); - - staDebtToken.initialize( - IPool(report.poolProxy), - listing.underlyingAsset, - IAaveIncentivesController(listing.incentivesController), - decimals, - listing.stableDebtTokenSymbol, - listing.stableDebtTokenSymbol, - listing.params - ); - } - - function test_initialize_StableDebtToken() public returns (StableDebtTokenInstance) { - StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; - - vm.expectEmit(address(stDebtToken)); - emit Initialized( - listing.underlyingAsset, - report.poolProxy, - report.rewardsControllerProxy, - TestnetERC20(listing.underlyingAsset).decimals(), - listing.stableDebtTokenName, - listing.stableDebtTokenSymbol, - listing.params - ); - - stDebtToken.initialize( - IPool(report.poolProxy), - listing.underlyingAsset, - IAaveIncentivesController(listing.incentivesController), - TestnetERC20(listing.underlyingAsset).decimals(), - listing.stableDebtTokenName, - listing.stableDebtTokenSymbol, - listing.params - ); - - assertEq(stDebtToken.name(), listing.stableDebtTokenName); - assertEq(stDebtToken.symbol(), listing.stableDebtTokenSymbol); - assertEq(stDebtToken.decimals(), TestnetERC20(listing.underlyingAsset).decimals()); - assertEq(address(stDebtToken.POOL()), address(report.poolProxy)); - assertEq(address(stDebtToken.getIncentivesController()), listing.incentivesController); - assertEq(stDebtToken.UNDERLYING_ASSET_ADDRESS(), listing.underlyingAsset); - assertEq(stDebtToken.DEBT_TOKEN_REVISION(), 0x1); - - return stDebtToken; - } - - function test_reverts_initialize_pool_do_not_match() public { - StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; - - uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); - - vm.expectRevert(bytes(Errors.POOL_ADDRESSES_DO_NOT_MATCH)); - - stDebtToken.initialize( - IPool(makeAddr('ANY_OTHER_POOL')), - listing.underlyingAsset, - IAaveIncentivesController(listing.incentivesController), - decimals, - listing.stableDebtTokenName, - listing.stableDebtTokenSymbol, - listing.params - ); - } - - function test_mint_stableDebt_caller_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - - vm.prank(report.poolProxy); - debtToken.mint(alice, alice, 0, 0); - } - - function test_mint_stableDebt_caller_bob_onBehalf_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); - TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); - uint8 decimals = asset.decimals(); - uint256 amount = 1200 * 10 ** decimals; - - vm.expectEmit(address(debtToken)); - emit BorrowAllowanceDelegated(alice, bob, address(asset), amount); - - vm.prank(alice); - debtToken.approveDelegation(bob, amount); - - vm.prank(report.poolProxy); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - debtToken.mint(bob, alice, amount, 1e27); - } - - function test_reverts_operation_not_supported() public { - StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.transfer(address(0), 0); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.allowance(address(0), address(0)); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.approve(address(0), 0); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.transferFrom(address(0), address(0), 0); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.increaseAllowance(address(0), 0); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.decreaseAllowance(address(0), 0); - - vm.prank(report.poolProxy); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.mint(address(0), address(0), 0, 0); - - vm.prank(report.poolProxy); - - vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); - stDebtToken.burn(address(0), 0); - } - - function test_default_revision() public { - StableDebtTokenInstance stDebtToken = new StableDebtTokenInstance(IPool(report.poolProxy)); - assertEq(stDebtToken._getRevision(), stDebtToken.DEBT_TOKEN_REVISION()); - } - - function test_getAverageStableRate() public view { - uint256 avgStableRate = stableDebtToken.getAverageStableRate(); - assertEq(avgStableRate, 0); - } - - function test_getUserLastUpdated() public view { - uint256 lastUpdated = stableDebtToken.getUserLastUpdated(alice); - assertEq(lastUpdated, 0); - } - - function test_getUserStableRate() public view { - uint256 userStableRate = stableDebtToken.getUserStableRate(alice); - assertEq(userStableRate, 0); - } - - function test_balanceOf() public view { - uint256 balance = stableDebtToken.balanceOf(alice); - assertEq(balance, 0); - } - - function test_totalSupply() public view { - uint256 scaledTotalSupply = stableDebtToken.totalSupply(); - assertEq(scaledTotalSupply, 0); - } - - function test_getTotalSupplyLastUpdated() public view { - uint256 totalSupplyLastUpdated = stableDebtToken.getTotalSupplyLastUpdated(); - assertEq(totalSupplyLastUpdated, 0); - } - - function test_principalBalanceOf() public view { - uint256 principalBalanceOf = stableDebtToken.principalBalanceOf(alice); - assertEq(principalBalanceOf, 0); - } - - function test_getTotalSupplyAndAvgRate() public view { - (uint256 totalSupply, uint256 avgRate) = stableDebtToken.getTotalSupplyAndAvgRate(); - assertEq(totalSupply, 0); - assertEq(avgRate, 0); - } - - function test_getSupplyData() public view { - ( - uint256 principal, - uint256 totalSupply, - uint256 avgStableRate, - uint40 lastUpdatedTimestamp - ) = stableDebtToken.getSupplyData(); - - assertEq(principal, 0); - assertEq(totalSupply, 0); - assertEq(avgStableRate, 0); - assertEq(lastUpdatedTimestamp, 0); - } - - function test_delegationWithSig() public { - uint256 amount = 120e6; - uint256 deadline = block.timestamp + 30 days; - - EIP712SigUtils.CreditDelegation memory delegation = EIP712SigUtils.CreditDelegation({ - delegatee: bob, - value: amount, - nonce: 0, - deadline: deadline - }); - - bytes32 digest = EIP712SigUtils.getCreditDelegationTypedDataHash( - delegation, - bytes(stableDebtToken.name()), - bytes('1'), - address(stableDebtToken) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest); - - vm.expectEmit(address(stableDebtToken)); - emit BorrowAllowanceDelegated(alice, bob, address(tokenList.usdx), amount); - - vm.prank(alice); - stableDebtToken.delegationWithSig(alice, bob, amount, deadline, v, r, s); - - assertEq(stableDebtToken.borrowAllowance(alice, bob), amount); - } - - function test_cancel_delegationWithSig() public { - // Submit permit by Alice to Bob - test_delegationWithSig(); - - uint256 deadline = block.timestamp + 30 days; - - EIP712SigUtils.CreditDelegation memory delegation = EIP712SigUtils.CreditDelegation({ - delegatee: bob, - value: 0, - nonce: 1, - deadline: deadline - }); - - bytes32 digest = EIP712SigUtils.getCreditDelegationTypedDataHash( - delegation, - bytes(stableDebtToken.name()), - bytes('1'), - address(stableDebtToken) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest); - - assertGt( - stableDebtToken.borrowAllowance(alice, bob), - 0, - 'Alice borrow allowance to bob should be > 0 before cancelling the credit delegation' - ); - - vm.prank(alice); - stableDebtToken.delegationWithSig(alice, bob, delegation.value, deadline, v, r, s); - - assertEq( - stableDebtToken.borrowAllowance(alice, bob), - 0, - 'Alice allowance to bob should be zero' - ); - assertEq(stableDebtToken.nonces(alice), 2, 'Alice nonce does not match expected nonce'); - } - - function test_reverts_bad_nonce_delegationWithSig() public { - // Submit permit by Alice to Bob - test_delegationWithSig(); - - uint256 deadline = block.timestamp + 30 days; - - EIP712SigUtils.CreditDelegation memory delegation = EIP712SigUtils.CreditDelegation({ - delegatee: bob, - value: 0, - nonce: 0, // Wrong nonce, should be 1 - deadline: deadline - }); - - bytes32 digest = EIP712SigUtils.getCreditDelegationTypedDataHash( - delegation, - bytes(stableDebtToken.name()), - bytes('1'), - address(stableDebtToken) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest); - - vm.expectRevert(bytes(Errors.INVALID_SIGNATURE)); - - vm.prank(alice); - stableDebtToken.delegationWithSig(alice, bob, delegation.value, deadline, v, r, s); - } - - function test_reverts_bad_expiration_delegationWithSig() public { - uint256 amount = 120e6; - uint256 deadline = block.timestamp + 30 days; - - EIP712SigUtils.CreditDelegation memory delegation = EIP712SigUtils.CreditDelegation({ - delegatee: bob, - value: amount, - nonce: 0, - deadline: deadline - }); - - bytes32 digest = EIP712SigUtils.getCreditDelegationTypedDataHash( - delegation, - bytes(stableDebtToken.name()), - bytes('1'), - address(stableDebtToken) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest); - - vm.warp(delegation.deadline + 1); - vm.expectRevert(bytes(Errors.INVALID_EXPIRATION)); - - vm.prank(alice); - stableDebtToken.delegationWithSig(alice, bob, amount, deadline, v, r, s); - } - - function test_reverts_zero_address_delegationWithSig() public { - uint256 amount = 120e6; - uint256 deadline = block.timestamp + 30 days; - - EIP712SigUtils.CreditDelegation memory delegation = EIP712SigUtils.CreditDelegation({ - delegatee: bob, - value: amount, - nonce: 0, - deadline: deadline - }); - - bytes32 digest = EIP712SigUtils.getCreditDelegationTypedDataHash( - delegation, - bytes(stableDebtToken.name()), - bytes('1'), - address(stableDebtToken) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest); - - vm.expectRevert(bytes(Errors.ZERO_ADDRESS_NOT_VALID)); - - vm.prank(alice); - stableDebtToken.delegationWithSig(address(0), bob, amount, deadline, v, r, s); - } -} diff --git a/tests/core/ZeroInteresRateStrategy.t.sol b/tests/core/ZeroInteresRateStrategy.t.sol index 0ce57a59..a6f1d01a 100644 --- a/tests/core/ZeroInteresRateStrategy.t.sol +++ b/tests/core/ZeroInteresRateStrategy.t.sol @@ -46,23 +46,17 @@ contract ZeroReserveInterestRateStrategyTests is TestnetProcedures { unbacked: 0, liquidityAdded: 0, liquidityTaken: 0, - totalStableDebt: 0, - totalVariableDebt: 0, - averageStableBorrowRate: 0, + totalDebt: 0, reserveFactor: reserveFactor, reserve: tokenList.usdx, usingVirtualBalance: true, virtualUnderlyingBalance: 0 }); - ( - uint256 currentLiquidityRate, - uint256 currentStableBorrowRate, - uint256 currentVariableBorrowRate - ) = rateStrategy.calculateInterestRates(input); + (uint256 currentLiquidityRate, uint256 currentVariableBorrowRate) = rateStrategy + .calculateInterestRates(input); assertEq(currentLiquidityRate, 0); - assertEq(currentStableBorrowRate, 0); assertEq(currentVariableBorrowRate, 0); } } diff --git a/tests/mocks/AaveV3TestListing.sol b/tests/mocks/AaveV3TestListing.sol index 95714b0f..79c35ba2 100644 --- a/tests/mocks/AaveV3TestListing.sol +++ b/tests/mocks/AaveV3TestListing.sol @@ -27,7 +27,6 @@ contract AaveV3TestListing is AaveV3Payload { address immutable ATOKEN_IMPLEMENTATION; address immutable VARIABLE_DEBT_TOKEN_IMPLEMENTATION; - address immutable STABLE_DEBT_TOKEN_IMPLEMENTATION; ACLManager immutable ACL_MANAGER; @@ -48,7 +47,6 @@ contract AaveV3TestListing is AaveV3Payload { ATOKEN_IMPLEMENTATION = report.aToken; VARIABLE_DEBT_TOKEN_IMPLEMENTATION = report.variableDebtToken; - STABLE_DEBT_TOKEN_IMPLEMENTATION = report.stableDebtToken; ACL_MANAGER = ACLManager(report.aclManager); } @@ -75,7 +73,6 @@ contract AaveV3TestListing is AaveV3Payload { priceFeed: USDX_MOCK_PRICE_FEED, rateStrategyParams: rateParams, enabledToBorrow: EngineFlags.ENABLED, - stableRateModeEnabled: EngineFlags.DISABLED, borrowableInIsolation: EngineFlags.DISABLED, withSiloedBorrowing: EngineFlags.DISABLED, flashloanable: EngineFlags.ENABLED, @@ -91,8 +88,7 @@ contract AaveV3TestListing is AaveV3Payload { }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, - vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION, - sToken: STABLE_DEBT_TOKEN_IMPLEMENTATION + vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION }) ); @@ -103,7 +99,6 @@ contract AaveV3TestListing is AaveV3Payload { priceFeed: WBTC_MOCK_PRICE_FEED, rateStrategyParams: rateParams, enabledToBorrow: EngineFlags.ENABLED, - stableRateModeEnabled: EngineFlags.DISABLED, borrowableInIsolation: EngineFlags.DISABLED, withSiloedBorrowing: EngineFlags.DISABLED, flashloanable: EngineFlags.ENABLED, @@ -119,8 +114,7 @@ contract AaveV3TestListing is AaveV3Payload { }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, - vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION, - sToken: STABLE_DEBT_TOKEN_IMPLEMENTATION + vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION }) ); @@ -131,7 +125,6 @@ contract AaveV3TestListing is AaveV3Payload { priceFeed: WETH_MOCK_PRICE_FEED, rateStrategyParams: rateParams, enabledToBorrow: EngineFlags.ENABLED, - stableRateModeEnabled: EngineFlags.DISABLED, borrowableInIsolation: EngineFlags.DISABLED, withSiloedBorrowing: EngineFlags.DISABLED, flashloanable: EngineFlags.ENABLED, @@ -147,8 +140,7 @@ contract AaveV3TestListing is AaveV3Payload { }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, - vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION, - sToken: STABLE_DEBT_TOKEN_IMPLEMENTATION + vToken: VARIABLE_DEBT_TOKEN_IMPLEMENTATION }) ); diff --git a/tests/periphery/WrappedTokenGateway.t.sol b/tests/periphery/WrappedTokenGateway.t.sol index 4b97b910..5def6c56 100644 --- a/tests/periphery/WrappedTokenGateway.t.sol +++ b/tests/periphery/WrappedTokenGateway.t.sol @@ -6,7 +6,6 @@ import {AaveOracle} from 'aave-v3-core/contracts/misc/AaveOracle.sol'; import {WrappedTokenGatewayV3} from 'aave-v3-periphery/contracts/misc/WrappedTokenGatewayV3.sol'; import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; import {AToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {StableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/StableDebtToken.sol'; import {VariableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/VariableDebtToken.sol'; import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; @@ -46,10 +45,8 @@ contract WrappedTokenGatewayTests is TestnetProcedures { WrappedTokenGatewayV3 internal wrappedTokenGatewayV3; AToken internal aWEth; - StableDebtToken internal wEthStableDebtToken; VariableDebtToken internal wEthVariableDebtToken; AToken internal aUsdx; - StableDebtToken internal usdxStableDebtToken; VariableDebtToken internal usdxVariableDebtToken; uint256 internal depositSize = 5e18; uint256 internal usdxSize = 10000e18; @@ -68,17 +65,15 @@ contract WrappedTokenGatewayTests is TestnetProcedures { ); wrappedTokenGatewayV3 = WrappedTokenGatewayV3(payable(report.wrappedTokenGateway)); contracts.protocolDataProvider = AaveProtocolDataProvider(report.protocolDataProvider); - (address aWEthAddr, address wEthStableDebt, address wEthVariableDebt) = contracts + (address aWEthAddr, , address wEthVariableDebt) = contracts .protocolDataProvider .getReserveTokensAddresses(tokenList.weth); aWEth = AToken(aWEthAddr); - wEthStableDebtToken = StableDebtToken(wEthStableDebt); wEthVariableDebtToken = VariableDebtToken(wEthVariableDebt); - (address aUsdxAddr, address usdxStableDebt, address usdxVariableDebt) = contracts + (address aUsdxAddr, , address usdxVariableDebt) = contracts .protocolDataProvider .getReserveTokensAddresses(tokenList.usdx); aUsdx = AToken(aUsdxAddr); - usdxStableDebtToken = StableDebtToken(usdxStableDebt); usdxVariableDebtToken = VariableDebtToken(usdxVariableDebt); } diff --git a/tests/utils/BatchTestProcedures.sol b/tests/utils/BatchTestProcedures.sol index 00b9efa3..7ddd6230 100644 --- a/tests/utils/BatchTestProcedures.sol +++ b/tests/utils/BatchTestProcedures.sol @@ -197,7 +197,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput assertTrue(r.aToken != address(0), 'report.aToken'); assertTrue(r.variableDebtToken != address(0), 'report.variableDebtToken'); - assertTrue(r.stableDebtToken != address(0), 'report.stableDebtToken'); assertTrue(r.emissionManager != address(0), 'report.emissionManager'); assertTrue( r.rewardsControllerImplementation != address(0), @@ -264,8 +263,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput t.aTokenName = _concatStr('a ', x); t.variableDebtName = _concatStr('Variable Debt Misc', x); t.variableDebtSymbol = _concatStr('varDebtMISC ', x); - t.stableDebtName = _concatStr('Stable Debt Misc ', x); - t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); t.rateStrategy = r.defaultInterestRateStrategyV2; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ @@ -278,7 +275,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput input[x] = ConfiguratorInputTypes.InitReserveInput( r.aToken, - r.stableDebtToken, r.variableDebtToken, listingToken.decimals(), true, @@ -290,8 +286,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput t.aTokenSymbol, t.variableDebtName, t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, t.emptyParams, t.interestRateData ); diff --git a/tests/utils/ConfigEngineDeployer.sol b/tests/utils/ConfigEngineDeployer.sol index 1c25da03..1eb47875 100644 --- a/tests/utils/ConfigEngineDeployer.sol +++ b/tests/utils/ConfigEngineDeployer.sol @@ -51,7 +51,6 @@ library ConfigEngineDeployer { new AaveV3ConfigEngine( report.aToken, report.variableDebtToken, - report.stableDebtToken, engineConstants, engineLibraries ) diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 8f4aabad..51f34017 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -448,7 +448,6 @@ contract ProtocolV3TestBase is DiffUtils { localConfig.isActive, localConfig.isFrozen, localConfig.borrowingEnabled, - localConfig.stableBorrowRateEnabled, localConfig.isPaused ) = configuration.getFlags(); localConfig.symbol = reserve.symbol; diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 5d6f39c2..0adf79bc 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -310,7 +310,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { input[x] = ConfiguratorInputTypes.InitReserveInput( r.aToken, - r.stableDebtToken, r.variableDebtToken, listingToken.decimals(), true, @@ -322,8 +321,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { t.aTokenSymbol, t.variableDebtName, t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, t.emptyParams, t.interestRateData ); @@ -352,7 +349,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { function _calculateInterestRates( uint256 borrowAmount, - uint256 borrowMode, address token ) internal view returns (uint256) { DataTypes.ReserveDataLegacy memory reserveData = IPool(report.poolProxy).getReserveData(token); @@ -365,22 +361,15 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { unbacked: 0, liquidityAdded: 0, liquidityTaken: borrowAmount, - totalStableDebt: borrowMode == 1 ? borrowAmount : 0, - totalVariableDebt: borrowMode == 2 ? borrowAmount : 0, - averageStableBorrowRate: 0, + totalDebt: borrowAmount, reserveFactor: reserveConfig.reserveFactor, reserve: token, usingVirtualBalance: IPool(report.poolProxy).getConfiguration(token).getIsVirtualAccActive(), virtualUnderlyingBalance: IPool(report.poolProxy).getVirtualUnderlyingBalance(token) }); - if (borrowMode == 2) { - (, , uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); - return expectedVariableBorrowRate; - } else { - (, uint256 stableRate, ) = rateStrategy.calculateInterestRates(input); - return stableRate; - } + (, uint256 expectedVariableBorrowRate) = rateStrategy.calculateInterestRates(input); + return expectedVariableBorrowRate; } function _deployInterestRateStrategy() internal returns (address) { From cf0fec2194809cd58094f8e722c46b2481aa94ab Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 24 Apr 2024 11:48:08 +0300 Subject: [PATCH 02/88] more cleanup --- certora/conf/NEW-pool-no-summarizations.conf | 2 - certora/conf/NEW-pool-simple-properties.conf | 2 - certora/conf/StableDebtToken.conf | 18 - certora/harness/PoolHarness.sol | 7 +- .../harness/ReserveConfigurationHarness.sol | 20 +- certora/harness/StableDebtTokenHarness.sol | 17 - certora/specs/NEW-pool-base.spec | 5 - certora/specs/NEW-pool-no-summarizations.spec | 6 +- certora/specs/ReserveConfiguration.spec | 8 - certora/specs/StableDebtToken.spec | 327 ------------------ src/core/contracts/interfaces/IPool.sol | 18 +- .../interfaces/IPoolConfigurator.sol | 2 +- .../contracts/interfaces/IStableDebtToken.sol | 139 -------- src/core/contracts/misc/L2Encoder.sol | 30 +- .../upgradeability/MockStableDebtToken.sol | 13 - .../configuration/ReserveConfiguration.sol | 2 - .../protocol/libraries/helpers/Errors.sol | 5 - .../protocol/libraries/helpers/Helpers.sol | 2 +- .../protocol/libraries/logic/BorrowLogic.sol | 6 - .../libraries/logic/CalldataLogic.sol | 28 +- .../protocol/libraries/types/DataTypes.sol | 17 +- src/core/contracts/protocol/pool/Pool.sol | 6 - .../contracts/protocol/pool/PoolStorage.sol | 2 +- .../protocol/tokenization/StableDebtToken.sol | 141 -------- .../tokenization/base/DebtTokenBase.sol | 2 +- .../instances/StableDebtTokenInstance.sol | 46 --- .../contracts/libraries/DataTypesHelper.sol | 2 +- tests/harness/StableDebtToken.sol | 12 - tests/utils/TestnetProcedures.sol | 8 +- 29 files changed, 30 insertions(+), 863 deletions(-) delete mode 100644 certora/conf/StableDebtToken.conf delete mode 100644 certora/harness/StableDebtTokenHarness.sol delete mode 100644 certora/specs/StableDebtToken.spec delete mode 100644 src/core/contracts/interfaces/IStableDebtToken.sol delete mode 100644 src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol delete mode 100644 src/core/contracts/protocol/tokenization/StableDebtToken.sol delete mode 100644 src/core/instances/StableDebtTokenInstance.sol delete mode 100644 tests/harness/StableDebtToken.sol diff --git a/certora/conf/NEW-pool-no-summarizations.conf b/certora/conf/NEW-pool-no-summarizations.conf index 11f62350..69d2c271 100644 --- a/certora/conf/NEW-pool-no-summarizations.conf +++ b/certora/conf/NEW-pool-no-summarizations.conf @@ -2,7 +2,6 @@ "files": [ "certora/harness/ATokenHarness.sol", "certora/harness/PoolHarness.sol", - "certora/harness/StableDebtTokenHarness.sol", "certora/harness/SimpleERC20.sol", "src/core/instances/VariableDebtTokenInstance.sol", "src/core/contracts/misc/AaveProtocolDataProvider.sol", @@ -20,7 +19,6 @@ ], "struct_link": [ "PoolHarness:aTokenAddress=ATokenHarness", - "PoolHarness:stableDebtTokenAddress=StableDebtTokenHarness", "PoolHarness:variableDebtTokenAddress=VariableDebtTokenInstance", "PoolHarness:interestRateStrategyAddress=DefaultReserveInterestRateStrategyV2", ], diff --git a/certora/conf/NEW-pool-simple-properties.conf b/certora/conf/NEW-pool-simple-properties.conf index 96a78c78..a68ecda4 100644 --- a/certora/conf/NEW-pool-simple-properties.conf +++ b/certora/conf/NEW-pool-simple-properties.conf @@ -2,7 +2,6 @@ "files": [ "certora/harness/ATokenHarness.sol", "certora/harness/PoolHarness.sol", - "certora/harness/StableDebtTokenHarness.sol", "certora/harness/SimpleERC20.sol", "src/core/instances/VariableDebtTokenInstance.sol", "src/core/contracts/misc/AaveProtocolDataProvider.sol", @@ -17,7 +16,6 @@ ], "struct_link": [ "PoolHarness:aTokenAddress=ATokenHarness", - "PoolHarness:stableDebtTokenAddress=StableDebtTokenHarness", "PoolHarness:variableDebtTokenAddress=VariableDebtTokenInstance", "PoolHarness:interestRateStrategyAddress=DefaultReserveInterestRateStrategyV2", ], diff --git a/certora/conf/StableDebtToken.conf b/certora/conf/StableDebtToken.conf deleted file mode 100644 index 1480d348..00000000 --- a/certora/conf/StableDebtToken.conf +++ /dev/null @@ -1,18 +0,0 @@ -//=================================================================================== -// IMPORTANT: -// This file can be DELETED, since Stable coins are removed. -// In the implementation all the function either revert or return 0 -// =================================================================================== - -{ - "cache": "StableToken", - "files": [ - "certora/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness" - ], - "loop_iter": "4", - "msg": "stableTokenCLI", - "optimistic_loop": true, - "process": "emv", - "solc": "solc8.19", - "verify": "StableDebtTokenHarness:certora/specs/StableDebtToken.spec" -} diff --git a/certora/harness/PoolHarness.sol b/certora/harness/PoolHarness.sol index 70deadf9..f3f63fa9 100644 --- a/certora/harness/PoolHarness.sol +++ b/certora/harness/PoolHarness.sol @@ -23,8 +23,7 @@ contract PoolHarness is PoolInstance { function getTotalDebt(address asset) public view returns (uint256) { uint256 totalVariable = IERC20(_reserves[asset].variableDebtTokenAddress).totalSupply(); - uint256 totalStable = IERC20(_reserves[asset].stableDebtTokenAddress).totalSupply(); - return totalVariable + totalStable; + return totalVariable; } function getTotalATokenSupply(address asset) public view returns (uint256) { @@ -35,10 +34,6 @@ contract PoolHarness is PoolInstance { return _reserves[asset].liquidityIndex; } - function getReserveStableBorrowRate(address asset) public view returns (uint256) { - return _reserves[asset].currentStableBorrowRate; - } - function getReserveVariableBorrowIndex(address asset) public view returns (uint256) { return _reserves[asset].variableBorrowIndex; } diff --git a/certora/harness/ReserveConfigurationHarness.sol b/certora/harness/ReserveConfigurationHarness.sol index d4edade2..d7ad331f 100644 --- a/certora/harness/ReserveConfigurationHarness.sol +++ b/certora/harness/ReserveConfigurationHarness.sol @@ -130,18 +130,6 @@ contract ReserveConfigurationHarness { return ReserveConfiguration.getBorrowingEnabled(reservesConfig); } - // Enables or disables stable rate borrowing on the reserve - function setStableRateBorrowingEnabled(bool enabled) public { - DataTypes.ReserveConfigurationMap memory configNew = reservesConfig; - ReserveConfiguration.setStableRateBorrowingEnabled(configNew, enabled); - reservesConfig.data = configNew.data; - } - - // Gets the stable rate borrowing state of the reserve - function getStableRateBorrowingEnabled() public view returns (bool) { - return ReserveConfiguration.getStableRateBorrowingEnabled(reservesConfig); - } - // Sets the reserve factor of the reserve function setReserveFactor(uint256 reserveFactor) public { DataTypes.ReserveConfigurationMap memory configNew = reservesConfig; @@ -301,7 +289,7 @@ contract ReserveConfigurationHarness { // Executes a setter of a bool parameter according to the given id function executeBoolSetterById(uint256 id, bool val) public { - require(id >= 0 && id <= 5); + require(id >= 0 && id <= 4); if (id == 0) { setActive(val); } else if (id == 1) { @@ -309,8 +297,6 @@ contract ReserveConfigurationHarness { } else if (id == 2) { setBorrowingEnabled(val); } else if (id == 3) { - setStableRateBorrowingEnabled(val); - } else if (id == 4) { setPaused(val); } else { setBorrowableInIsolation(val); @@ -319,7 +305,7 @@ contract ReserveConfigurationHarness { // Executes a getter of a bool parameter according to the given id function executeBoolGetterById(uint256 id) public view returns (bool) { - require(id >= 0 && id <= 5); + require(id >= 0 && id <= 4); if (id == 0) { return getActive(); } else if (id == 1) { @@ -327,8 +313,6 @@ contract ReserveConfigurationHarness { } else if (id == 2) { return getBorrowingEnabled(); } else if (id == 3) { - return getStableRateBorrowingEnabled(); - } else if (id == 4) { return getPaused(); } else { return getBorrowableInIsolation(); diff --git a/certora/harness/StableDebtTokenHarness.sol b/certora/harness/StableDebtTokenHarness.sol deleted file mode 100644 index 99ce3355..00000000 --- a/certora/harness/StableDebtTokenHarness.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity ^0.8.19; - -import {StableDebtTokenInstance} from '../munged/core/instances/StableDebtTokenInstance.sol'; -import {IncentivizedERC20} from '../munged/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol'; -import {IPool} from '../munged/core/contracts/interfaces/IPool.sol'; - -contract StableDebtTokenHarness is StableDebtTokenInstance { - constructor(IPool pool) public StableDebtTokenInstance(pool) {} - - function additionalData(address user) public view returns (uint128) { - return _userState[user].additionalData; - } - - function debtTotalSupply() public view returns (uint256) { - return super.totalSupply(); - } -} diff --git a/certora/specs/NEW-pool-base.spec b/certora/specs/NEW-pool-base.spec index ac7cfdf0..ae91d288 100644 --- a/certora/specs/NEW-pool-base.spec +++ b/certora/specs/NEW-pool-base.spec @@ -64,11 +64,6 @@ methods { function _.getACLManager() external => DISPATCHER(true); function _.isBridge(address) external => DISPATCHER(true); - // StableDebt - function _.mint(address user, address onBehalfOf, uint256 amount, uint256 rate) external => DISPATCHER(true); - function _.burn(address user, uint256 amount) external => DISPATCHER(true); - function _.getSupplyData() external => DISPATCHER(true); - // variableDebt function _.burn(address user, uint256 amount, uint256 index) external => DISPATCHER(true); diff --git a/certora/specs/NEW-pool-no-summarizations.spec b/certora/specs/NEW-pool-no-summarizations.spec index d4dcbe68..cacca548 100644 --- a/certora/specs/NEW-pool-no-summarizations.spec +++ b/certora/specs/NEW-pool-no-summarizations.spec @@ -11,7 +11,6 @@ methods { function _.executeOperation(address[] a, uint256[]b, uint256[]c, address d, bytes e) external => DISPATCHER(true); - function _.getAverageStableRate() external => DISPATCHER(true); function _.isPoolAdmin(address a) external => DISPATCHER(true); function _.getConfiguration(address a) external => DISPATCHER(true); @@ -37,11 +36,10 @@ function ghostUpdate() returns bool { } -function calculateInterestRatesMock(DataTypes.CalculateInterestRatesParams params) returns (uint256, uint256, uint256) { +function calculateInterestRatesMock(DataTypes.CalculateInterestRatesParams params) returns (uint256, uint256) { uint256 liquidityRate = 1; - uint256 stableBorrowRate = 1; uint256 variableBorrowRate = 1; - return (liquidityRate, stableBorrowRate, variableBorrowRate); + return (liquidityRate, variableBorrowRate); } diff --git a/certora/specs/ReserveConfiguration.spec b/certora/specs/ReserveConfiguration.spec index cb13162c..b927763b 100644 --- a/certora/specs/ReserveConfiguration.spec +++ b/certora/specs/ReserveConfiguration.spec @@ -19,8 +19,6 @@ methods { function getSiloedBorrowing() external returns (bool) envfree; function setBorrowingEnabled(bool) external envfree; function getBorrowingEnabled() external returns (bool) envfree; - function setStableRateBorrowingEnabled(bool) external envfree; - function getStableRateBorrowingEnabled() external returns (bool) envfree; function setReserveFactor(uint256) external envfree; function getReserveFactor() external returns (uint256) envfree; function setBorrowCap(uint256) external envfree; @@ -104,12 +102,6 @@ rule setBorrowingEnabledIntegrity(bool enabled) { assert getBorrowingEnabled() == enabled; } -// checks the integrity of set StableRateBorrowingEnabled function and correct retrieval of the corresponding getter. -rule setStableRateBorrowingEnabledIntegrity(bool enabled) { - setStableRateBorrowingEnabled(enabled); - assert getStableRateBorrowingEnabled() == enabled; -} - // checks the integrity of set ReserveFactor function and correct retrieval of the corresponding getter. rule setReserveFactorIntegrity(uint256 reserveFactor) { setReserveFactor(reserveFactor); diff --git a/certora/specs/StableDebtToken.spec b/certora/specs/StableDebtToken.spec deleted file mode 100644 index 00937585..00000000 --- a/certora/specs/StableDebtToken.spec +++ /dev/null @@ -1,327 +0,0 @@ -/*=================================================================================== - IMPORTANT: - This file can be DELETED, since Stable coins are removed. - In the implementation all the function either revert or return 0 - ===================================================================================*/ - -methods { - function _.calculateCompoundedInterest(uint256 r, uint40 t0, uint256 t1) internal => - calculateCompoundedInterestSummary(r, t0, t1) expect uint256 ALL; - function additionalData(address) external returns uint128 envfree; - function getAverageStableRate() external returns uint256 envfree; - function _.handleAction(address, uint256, uint256) external => NONDET; - - function _.rayMul(uint256 x, uint256 y) internal => rayMulSummariztion(x, y) expect uint256 ALL; - function _.rayDiv(uint256 x, uint256 y) internal => rayDivSummariztion(x, y) expect uint256 ALL; -} - -function PLUS256(uint256 x, uint256 y) returns uint256 { - return (assert_uint256( (x+y) % 2^256) ); -} - -definition RAY() returns uint = 1000000000000000000000000000; - -definition disAllowedFunctions(method f) returns bool = - f.selector == sig:transfer(address, uint256).selector || - f.selector == sig:allowance(address, address).selector || - f.selector == sig:approve(address, uint256).selector || - f.selector == sig:transferFrom(address, address, uint256).selector || - f.selector == sig:increaseAllowance(address, uint256).selector || - f.selector == sig:decreaseAllowance(address, uint256).selector; - -ghost mapping(uint256 => mapping(uint256 => uint256)) calculateCompoundedInterestSummaryValues; -function calculateCompoundedInterestSummary(uint256 rate, uint40 t0, uint256 t1) returns uint256 { - uint256 deltaT = assert_uint256( (t1-t0) % 2^256 ); - - if (deltaT == 0) { - return RAY(); - } - if (rate == RAY()) { - return RAY(); - } - if (rate >= RAY()) { - require calculateCompoundedInterestSummaryValues[rate][deltaT] >= rate; - } - else { - require calculateCompoundedInterestSummaryValues[rate][deltaT] < rate; - } - return calculateCompoundedInterestSummaryValues[rate][deltaT]; -} - -ghost mapping(uint256 => mapping(uint256 => uint256)) rayMulSummariztionValues; -function rayMulSummariztion(uint256 x, uint256 y) returns uint256 { - if ((x == 0) || (y == 0)) { - return 0; - } - if (x == RAY()) { - return y; - } - if (y == RAY()) { - return x; - } - - if (y > x) { - if (y > RAY()) { - require rayMulSummariztionValues[y][x] >= x; - } - if (x > RAY()) { - require rayMulSummariztionValues[y][x] >= y; - } - return rayMulSummariztionValues[y][x]; - } - else { - if (x > RAY()) { - require rayMulSummariztionValues[x][y] >= y; - } - if (y > RAY()) { - require rayMulSummariztionValues[x][y] >= x; - } - return rayMulSummariztionValues[x][y]; - } -} - -ghost mapping(uint256 => mapping(uint256 => uint256)) rayDivSummariztionValues; -function rayDivSummariztion(uint256 x, uint256 y) returns uint256 { - if (x == 0) { - return 0; - } - if (y == RAY()) { - return x; - } - if (y == x) { - return RAY(); - } - require y > RAY() => rayDivSummariztionValues[x][y] <= x; - return rayDivSummariztionValues[x][y]; -} - - -ghost symbolicCompundInterest(uint256, uint40) returns uint256 { - axiom forall uint256 x. forall uint40 t. symbolicCompundInterest(x, t) >= 1; -} - - -ghost sumAllBalance() returns mathint { - init_state axiom sumAllBalance() == 0; -} -hook Sstore _userState[KEY address a].balance uint128 balance (uint128 old_balance) { - havoc sumAllBalance assuming sumAllBalance@new() == sumAllBalance@old() + balance - old_balance; -} -hook Sload uint128 balance _userState[KEY address a].balance { - require sumAllBalance() >= to_mathint(balance); -} - -invariant principalLessThanBalance(env e, address user) - principalBalanceOf(e, user) <= balanceOf(e, user) - filtered { f -> !disAllowedFunctions(f) } - -/** - Burning user u amount of x tokens, decreases his balanceOf the user by x. - (balance is decreased by x and not scaled x because of the summarization to one ray) -*/ -rule integrityBurn(address a, uint256 x) { - env e; - require getIncentivesController(e) == 0; - uint256 index; - uint256 balancebefore = balanceOf(e, a); - burn(e,a,x); - - uint256 balanceAfter = balanceOf(e, a); - assert to_mathint(balanceAfter) == balancebefore - x; -} - -/** - Mint to user u amount of x tokens, increases his balanceOf the user by x. - (balance is increased by x and not scaled x because of the summarization to one ray) -*/ -rule integrityMint(address a, uint256 x) { - env e; - address delegatedUser; - require getIncentivesController(e) == 0; - uint256 index; - uint256 balancebefore = balanceOf(e,a); - mint(e, delegatedUser, a, x, index); - - uint256 balanceAfter = balanceOf(e,a); - assert to_mathint(balanceAfter) == balancebefore+x; -} - -// lastUpdated timestamp must be in the past. -rule integrityTimeStamp(address user, method f) - filtered { f -> !f.isView && !disAllowedFunctions(f) } -{ - env e; - require assert_uint256(getUserLastUpdated(e, user)) <= e.block.timestamp; - calldataarg arg; - f(e,arg); - assert assert_uint256(getUserLastUpdated(e, user)) <= e.block.timestamp; -} - -rule integrityDelegationWithSig(address delegator, address delegatee, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) { - env e; - uint256 oldNonce = nonces(e, delegator); - delegationWithSig(e, delegator, delegatee, value, deadline, v, r, s); - assert to_mathint(nonces(e, delegator)) == oldNonce + 1 && - borrowAllowance(e, delegator, delegatee) == value; -} - -/* - Burn is additive, can performed either all at once or gradually - burn(from,to,x,index); burn(from,to,y,index) ~ burn(from,to,x+y,index) at the same initial state -*/ -rule additiveBurn(address a, uint256 x, uint256 y) { - env e; - storage initialStorage = lastStorage; - burn(e, a, x); - burn(e, a, y); - uint256 balanceScenario1 = balanceOf(e, a); - uint256 t = PLUS256(x,y); - burn(e, a, t) at initialStorage; - - uint256 balanceScenario2 = balanceOf(e, a); - assert balanceScenario1 == balanceScenario2, "burn is not additive"; -} - -// minting and then buring Variable Debt Token should have no effect on the users balance -rule inverseMintBurn(address a, address delegatedUser, uint256 amount, uint256 rate) { - env e; - uint256 balancebefore = balanceOf(e, a); - mint(e, delegatedUser, a, amount, rate); - burn(e, a, amount); - uint256 balanceAfter = balanceOf(e, a); - assert balancebefore == balanceAfter, "burn is not the inverse of mint"; -} - -// Only the pool with burn or mint operation can change the total supply. (assuming the getReserveNormalizedVariableDebt is not changed) -rule whoChangeTotalSupply(method f) - filtered { f -> !f.isView && !disAllowedFunctions(f) } -{ - env e; - uint256 oldTotalSupply = totalSupply(e); - calldataarg args; - f(e, args); - uint256 newTotalSupply = totalSupply(e); - assert oldTotalSupply != newTotalSupply => - (e.msg.sender == POOL(e) && - (f.selector == sig:burn(address, uint256).selector || - f.selector == sig:mint(address, address, uint256, uint256).selector)); -} - -// only delegationWithSig operation can change the nonce. -rule nonceChangePermits(method f) - filtered { f -> !f.isView && !disAllowedFunctions(f) } -{ - env e; - address user; - uint256 oldNonce = nonces(e, user); - calldataarg args; - f(e, args); - uint256 newNonce = nonces(e, user); - assert oldNonce != newNonce => f.selector == sig:delegationWithSig(address, address, uint256, uint256, uint8, bytes32, bytes32).selector; -} - -/* - Mint is additive, can performed either all at once or gradually - mint(u,x,index); mint(u,y,index) ~ mint(u,x+y,index) at the same initial state -*/ -rule additiveMint(address a, uint256 x, uint256 y) { - env e; - address delegatedUser; - require getIncentivesController(e) == 0; - require getUserStableRate(e, a) == 0; - uint256 index; - storage initialStorage = lastStorage; - mint(e, delegatedUser, a, x, index); - mint(e, delegatedUser, a, y, index); - uint256 balanceScenario1 = balanceOf(e, a); - - uint256 t = PLUS256(x,y); - mint(e, delegatedUser, a, t ,index) at initialStorage; - - uint256 balanceScenario2 = balanceOf(e, a); - assert balanceScenario1 == balanceScenario2, "mint is not additive"; -} - -/* - Each operation of Stable Debt Token can change at most one user's balance. -*/ -rule balanceOfChange(address a, address b, method f) - filtered { f -> !f.isView && !disAllowedFunctions(f) } -{ - env e; - require a != b; - uint256 balanceABefore = balanceOf(e, a); - uint256 balanceBBefore = balanceOf(e, b); - - calldataarg arg; - f(e, arg); - - uint256 balanceAAfter = balanceOf(e, a); - uint256 balanceBAfter = balanceOf(e, b); - - assert (balanceABefore == balanceAAfter || balanceBBefore == balanceBAfter); -} - -// Buring zero amount of tokens should have no effect. -rule burnZeroDoesntChangeBalance(address u) { - env e; - uint256 balanceBefore = balanceOf(e, u); - burn(e, u, 0); - uint256 balanceAfter = balanceOf(e, u); - assert balanceBefore == balanceAfter; -} - -/* - Burning one user atokens should have no effect on other users that are not involved in the action. -*/ -rule burnNoChangeToOther(address user, uint256 amount, address other) { - require other != user; - env e; - uint256 otherDataBefore = additionalData(other); - uint256 otherBalanceBefore = balanceOf(e, other); - - burn(e, user, amount); - - uint256 otherDataAfter = additionalData(other); - uint256 otherBalanceAfter = balanceOf(e, other); - - assert otherDataBefore == otherDataAfter && - otherBalanceBefore == otherBalanceAfter; -} - -/* - Minting ATokens for a user should have no effect on other users that are not involved in the action. -*/ -rule mintNoChangeToOther(address user, address onBehalfOf, uint256 amount, uint256 rate, address other) { - require other != user && other != onBehalfOf; - - env e; - uint128 userDataBefore = additionalData(user); - uint128 otherDataBefore = additionalData(other); - uint256 userBalanceBefore = balanceOf(e, user); - uint256 otherBalanceBefore = balanceOf(e, other); - - mint(e, user, onBehalfOf, amount, rate); - - uint128 userDataAfter = additionalData(user); - uint128 otherDataAfter = additionalData(other); - uint256 userBalanceAfter = balanceOf(e, user); - uint256 otherBalanceAfter = balanceOf(e, other); - - if (user != onBehalfOf) { - assert userBalanceBefore == userBalanceAfter && userDataBefore == userDataAfter; - } - - assert otherBalanceBefore == otherBalanceAfter && otherDataBefore == otherDataAfter; -} - -/* - Ensuring that the defined disallowed functions revert in any case. -*/ -rule disallowedFunctionalities(method f) filtered { f -> disAllowedFunctions(f) } -{ - env e; calldataarg args; - f@withrevert(e, args); - assert lastReverted; -} - diff --git a/src/core/contracts/interfaces/IPool.sol b/src/core/contracts/interfaces/IPool.sol index 4ba36bdc..db286ec7 100644 --- a/src/core/contracts/interfaces/IPool.sol +++ b/src/core/contracts/interfaces/IPool.sol @@ -67,7 +67,7 @@ interface IPool { * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out - * @param interestRateMode The rate mode: 1 for Stable, 2 for Variable + * @param interestRateMode The rate mode: 1 and 2 for Variable (changed on v3.2.0) * @param borrowRate The numeric rate at which the user has borrowed, expressed in ray * @param referralCode The referral code used */ @@ -98,7 +98,7 @@ interface IPool { ); /** - * @dev Emitted on swapBorrowRateMode() + * @dev Emitted on swapBorrowRateMode(), DEPRECATED on v3.2.0 * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable @@ -138,7 +138,7 @@ interface IPool { event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** - * @dev Emitted on rebalanceStableBorrowRate() + * @dev Emitted on rebalanceStableBorrowRate(), DEPRECATED on v3.2.0 * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed */ @@ -150,7 +150,7 @@ interface IPool { * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed - * @param interestRateMode The flashloan mode: 0 for regular flashloan, 1 for Stable debt, 2 for Variable debt + * @param interestRateMode The flashloan mode: 0 for regular flashloan, 1 and 2 for Variable debt (changed on v3.2.0) * @param premium The fee flash borrowed * @param referralCode The referral code used */ @@ -310,7 +310,7 @@ interface IPool { /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned - * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address + * - E.g. User repays 100 USDC, burning 100 variabledebt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` @@ -357,7 +357,7 @@ interface IPool { /** * @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the * equivalent debt tokens - * - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable/stable debt tokens + * - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable debt tokens * @dev Passing uint256.max as amount will clean up any residual aToken dust balance, if the user aToken * balance is not enough to cover the whole debt * @param asset The address of the borrowed underlying asset previously borrowed @@ -710,12 +710,6 @@ interface IPool { **/ 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 - */ - function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() external view returns (uint256); - /** * @notice Returns the total fee on flash loans * @return The total fee on flashloans diff --git a/src/core/contracts/interfaces/IPoolConfigurator.sol b/src/core/contracts/interfaces/IPoolConfigurator.sol index d33aa9ae..52311580 100644 --- a/src/core/contracts/interfaces/IPoolConfigurator.sol +++ b/src/core/contracts/interfaces/IPoolConfigurator.sol @@ -14,7 +14,7 @@ interface IPoolConfigurator { * @dev Emitted when a reserve is initialized. * @param asset The address of the underlying asset of the reserve * @param aToken The address of the associated aToken contract - * @param stableDebtToken DEPRECATED in v3.2.0 + * @param stableDebtToken, DEPRECATED in v3.2.0 * @param variableDebtToken The address of the associated variable rate debt token * @param interestRateStrategyAddress The address of the interest rate strategy for the reserve */ diff --git a/src/core/contracts/interfaces/IStableDebtToken.sol b/src/core/contracts/interfaces/IStableDebtToken.sol deleted file mode 100644 index fa976676..00000000 --- a/src/core/contracts/interfaces/IStableDebtToken.sol +++ /dev/null @@ -1,139 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {IInitializableDebtToken} from './IInitializableDebtToken.sol'; - -/** - * @title IStableDebtToken - * @author Aave - * @notice Defines the interface for the stable debt token - * @dev It does not inherit from IERC20 to save in code size - */ -interface IStableDebtToken is IInitializableDebtToken { - /** - * @dev Emitted when new stable debt is minted - * @param user The address of the user who triggered the minting - * @param onBehalfOf The recipient of stable debt tokens - * @param amount The amount minted (user entered amount + balance increase from interest) - * @param currentBalance The balance of the user based on the previous balance and balance increase from interest - * @param balanceIncrease The increase in balance since the last action of the user 'onBehalfOf' - * @param newRate The rate of the debt after the minting - * @param avgStableRate The next average stable rate after the minting - * @param newTotalSupply The next total supply of the stable debt token after the action - */ - event Mint( - address indexed user, - address indexed onBehalfOf, - uint256 amount, - uint256 currentBalance, - uint256 balanceIncrease, - uint256 newRate, - uint256 avgStableRate, - uint256 newTotalSupply - ); - - /** - * @dev Emitted when new stable debt is burned - * @param from The address from which the debt will be burned - * @param amount The amount being burned (user entered amount - balance increase from interest) - * @param currentBalance The balance of the user based on the previous balance and balance increase from interest - * @param balanceIncrease The increase in balance since the last action of 'from' - * @param avgStableRate The next average stable rate after the burning - * @param newTotalSupply The next total supply of the stable debt token after the action - */ - event Burn( - address indexed from, - uint256 amount, - uint256 currentBalance, - uint256 balanceIncrease, - uint256 avgStableRate, - uint256 newTotalSupply - ); - - /** - * @notice Mints debt token to the `onBehalfOf` address. - * @dev The resulting rate is the weighted average between the rate of the new debt - * and the rate of the previous debt - * @param user The address receiving the borrowed underlying, being the delegatee in case - * of credit delegate, or same as `onBehalfOf` otherwise - * @param onBehalfOf The address receiving the debt tokens - * @param amount The amount of debt tokens to mint - * @param rate The rate of the debt being minted - * @return True if it is the first borrow, false otherwise - * @return The total stable debt - * @return The average stable borrow rate - */ - function mint( - address user, - address onBehalfOf, - uint256 amount, - uint256 rate - ) external returns (bool, uint256, uint256); - - /** - * @notice Burns debt of `user` - * @dev The resulting rate is the weighted average between the rate of the new debt - * and the rate of the previous debt - * @dev In some instances, a burn transaction will emit a mint event - * if the amount to burn is less than the interest the user earned - * @param from The address from which the debt will be burned - * @param amount The amount of debt tokens getting burned - * @return The total stable debt - * @return The average stable borrow rate - */ - function burn(address from, uint256 amount) external returns (uint256, uint256); - - /** - * @notice Returns the average rate of all the stable rate loans. - * @return The average stable rate - */ - function getAverageStableRate() external view returns (uint256); - - /** - * @notice Returns the stable rate of the user debt - * @param user The address of the user - * @return The stable rate of the user - */ - function getUserStableRate(address user) external view returns (uint256); - - /** - * @notice Returns the timestamp of the last update of the user - * @param user The address of the user - * @return The timestamp - */ - function getUserLastUpdated(address user) external view returns (uint40); - - /** - * @notice Returns the principal, the total supply, the average stable rate and the timestamp for the last update - * @return The principal - * @return The total supply - * @return The average stable rate - * @return The timestamp of the last update - */ - function getSupplyData() external view returns (uint256, uint256, uint256, uint40); - - /** - * @notice Returns the timestamp of the last update of the total supply - * @return The timestamp - */ - function getTotalSupplyLastUpdated() external view returns (uint40); - - /** - * @notice Returns the total supply and the average stable rate - * @return The total supply - * @return The average rate - */ - function getTotalSupplyAndAvgRate() external view returns (uint256, uint256); - - /** - * @notice Returns the principal debt balance of the user - * @return The debt balance of the user since the last burn/mint action - */ - function principalBalanceOf(address user) external view returns (uint256); - - /** - * @notice Returns the address of the underlying asset of this stableDebtToken (E.g. WETH for stableDebtWETH) - * @return The address of the underlying asset - */ - function UNDERLYING_ASSET_ADDRESS() external view returns (address); -} diff --git a/src/core/contracts/misc/L2Encoder.sol b/src/core/contracts/misc/L2Encoder.sol index bdcd225e..5be76302 100644 --- a/src/core/contracts/misc/L2Encoder.sol +++ b/src/core/contracts/misc/L2Encoder.sol @@ -118,7 +118,7 @@ contract L2Encoder { * @dev Without an onBehalfOf parameter as the compact calls to L2Pool will use msg.sender as onBehalfOf * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed - * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 and 2 for Variable (changed on v3.2.0) * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @return compact representation of withdraw parameters @@ -153,7 +153,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `interestRateMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) * @return compact representation of repay parameters */ function encodeRepayParams( @@ -180,7 +180,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) * @param deadline The deadline timestamp that the permit is valid * @param permitV The V parameter of ERC712 permit sig * @param permitR The R parameter of ERC712 permit sig @@ -226,7 +226,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) * @return compact representation of repay with aToken parameters */ function encodeRepayWithATokensParams( @@ -240,7 +240,7 @@ contract L2Encoder { /** * @notice Encodes swap borrow rate mode parameters from standard input to compact representation of 1 bytes32 * @param asset The address of the underlying asset borrowed - * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable + * @param interestRateMode The current interest rate mode of the position being swapped: 1 and 2 for Variable (changed on v3.2.0) * @return compact representation of swap borrow rate mode parameters */ function encodeSwapBorrowRateMode( @@ -257,26 +257,6 @@ contract L2Encoder { return res; } - /** - * @notice Encodes rebalance stable borrow rate parameters from standard input to compact representation of 1 bytes32 - * @param asset The address of the underlying asset borrowed - * @param user The address of the user to be rebalanced - * @return compact representation of rebalance stable borrow rate parameters - */ - function encodeRebalanceStableBorrowRate( - address asset, - address user - ) external view returns (bytes32) { - DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); - uint16 assetId = data.id; - - bytes32 res; - assembly { - res := add(assetId, shl(16, user)) - } - return res; - } - /** * @notice Encodes set user use reserve as collateral parameters from standard input to compact representation of 1 bytes32 * @param asset The address of the underlying asset borrowed diff --git a/src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol b/src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol deleted file mode 100644 index ea9d5cca..00000000 --- a/src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -import {StableDebtTokenInstance} from '../../../instances/StableDebtTokenInstance.sol'; -import {IPool} from '../../interfaces/IPool.sol'; - -contract MockStableDebtToken is StableDebtTokenInstance { - constructor(IPool pool) StableDebtTokenInstance(pool) {} - - function getRevision() internal pure override returns (uint256) { - return 0x2; - } -} diff --git a/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol index 57d961c0..0d81e134 100644 --- a/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol +++ b/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol @@ -17,7 +17,6 @@ library ReserveConfiguration { uint256 internal constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore - uint256 internal constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant PAUSED_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant BORROWABLE_IN_ISOLATION_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SILOED_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFF; // prettier-ignore @@ -38,7 +37,6 @@ library ReserveConfiguration { uint256 internal constant IS_ACTIVE_START_BIT_POSITION = 56; uint256 internal constant IS_FROZEN_START_BIT_POSITION = 57; uint256 internal constant BORROWING_ENABLED_START_BIT_POSITION = 58; - uint256 internal constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59; uint256 internal constant IS_PAUSED_START_BIT_POSITION = 60; uint256 internal constant BORROWABLE_IN_ISOLATION_START_BIT_POSITION = 61; uint256 internal constant SILOED_BORROWING_START_BIT_POSITION = 62; diff --git a/src/core/contracts/protocol/libraries/helpers/Errors.sol b/src/core/contracts/protocol/libraries/helpers/Errors.sol index 2e4521b4..59f9d833 100644 --- a/src/core/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/core/contracts/protocol/libraries/helpers/Errors.sol @@ -37,17 +37,14 @@ library Errors { string public constant RESERVE_FROZEN = '28'; // 'Action cannot be performed because the reserve is frozen' string public constant RESERVE_PAUSED = '29'; // 'Action cannot be performed because the reserve is paused' string public constant BORROWING_NOT_ENABLED = '30'; // 'Borrowing is not enabled' - string public constant STABLE_BORROWING_NOT_ENABLED = '31'; // 'Stable borrowing is not enabled' string public constant NOT_ENOUGH_AVAILABLE_USER_BALANCE = '32'; // 'User cannot withdraw more than the available balance' string public constant INVALID_INTEREST_RATE_MODE_SELECTED = '33'; // 'Invalid interest rate mode selected' string public constant COLLATERAL_BALANCE_IS_ZERO = '34'; // 'The collateral balance is 0' string public constant HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '35'; // 'Health factor is lesser than the liquidation threshold' string public constant COLLATERAL_CANNOT_COVER_NEW_BORROW = '36'; // 'There is not enough collateral to cover a new borrow' string public constant COLLATERAL_SAME_AS_BORROWING_CURRENCY = '37'; // 'Collateral is (mostly) the same currency that is being borrowed' - string public constant AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '38'; // 'The requested amount is greater than the max loan size in stable rate mode' string public constant NO_DEBT_OF_SELECTED_TYPE = '39'; // 'For repayment of a specific type of debt, the user needs to have debt that type' string public constant NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '40'; // 'To repay on behalf of a user an explicit amount to repay is needed' - string public constant NO_OUTSTANDING_STABLE_DEBT = '41'; // 'User does not have outstanding stable rate debt on this reserve' string public constant NO_OUTSTANDING_VARIABLE_DEBT = '42'; // 'User does not have outstanding variable rate debt on this reserve' string public constant UNDERLYING_BALANCE_ZERO = '43'; // 'The underlying balance needs to be greater than 0' string public constant INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '44'; // 'Interest rate rebalance conditions were not met' @@ -89,11 +86,9 @@ library Errors { string public constant DEBT_CEILING_NOT_ZERO = '81'; // 'Debt ceiling is not zero' string public constant ASSET_NOT_LISTED = '82'; // 'Asset is not listed' string public constant INVALID_OPTIMAL_USAGE_RATIO = '83'; // 'Invalid optimal usage ratio' - string public constant INVALID_OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO = '84'; // 'Invalid optimal stable to total debt ratio' string public constant UNDERLYING_CANNOT_BE_RESCUED = '85'; // 'The underlying asset cannot be rescued' string public constant ADDRESSES_PROVIDER_ALREADY_ADDED = '86'; // 'Reserve has already been added to reserve list' string public constant POOL_ADDRESSES_DO_NOT_MATCH = '87'; // 'The token implementation pool address and the pool address provided by the initializing pool do not match' - string public constant STABLE_BORROWING_ENABLED = '88'; // 'Stable borrowing is enabled' string public constant SILOED_BORROWING_VIOLATION = '89'; // 'User is trying to borrow multiple assets including a siloed one' string public constant RESERVE_DEBT_NOT_ZERO = '90'; // the total debt of the reserve needs to be 0 string public constant FLASHLOAN_DISABLED = '91'; // FlashLoaning for this asset is disabled diff --git a/src/core/contracts/protocol/libraries/helpers/Helpers.sol b/src/core/contracts/protocol/libraries/helpers/Helpers.sol index 29a6e8c1..fe6b07cb 100644 --- a/src/core/contracts/protocol/libraries/helpers/Helpers.sol +++ b/src/core/contracts/protocol/libraries/helpers/Helpers.sol @@ -10,7 +10,7 @@ import {DataTypes} from '../types/DataTypes.sol'; */ library Helpers { /** - * @notice Fetches the user current stable and variable debt balances + * @notice Fetches the user current variable debt balance * @param user The user address * @param reserveCache The reserve cache data object * @return The variable debt balance diff --git a/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol b/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol index 1d5eddca..14affd10 100644 --- a/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol @@ -44,12 +44,6 @@ library BorrowLogic { uint256 amount, bool useATokens ); - event RebalanceStableBorrowRate(address indexed reserve, address indexed user); - event SwapBorrowRateMode( - address indexed reserve, - address indexed user, - DataTypes.InterestRateMode interestRateMode - ); event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); diff --git a/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol b/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol index 505a2541..abc65626 100644 --- a/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol @@ -86,7 +86,7 @@ library CalldataLogic { * @param args The packed borrow params * @return The address of the underlying reserve * @return The amount to borrow - * @return The interestRateMode, 1 for stable or 2 for variable debt + * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) * @return The referralCode */ function decodeBorrowParams( @@ -114,7 +114,7 @@ library CalldataLogic { * @param args The packed repay params * @return The address of the underlying reserve * @return The amount to repay - * @return The interestRateMode, 1 for stable or 2 for variable debt + * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) */ function decodeRepayParams( mapping(uint256 => address) storage reservesList, @@ -143,7 +143,7 @@ library CalldataLogic { * @param args The packed repay with permit params * @return The address of the underlying reserve * @return The amount to repay - * @return The interestRateMode, 1 for stable or 2 for variable debt + * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) * @return The deadline of the permit * @return The V value of the permit signature */ @@ -172,7 +172,7 @@ library CalldataLogic { * @param reservesList The addresses of all the active reserves * @param args The packed swap borrow rate mode params * @return The address of the underlying reserve - * @return The interest rate mode, 1 for stable 2 for variable debt + * @return The interest rate mode, 1 and 2 for variable debt (changed on v3.2.0) */ function decodeSwapBorrowRateModeParams( mapping(uint256 => address) storage reservesList, @@ -189,26 +189,6 @@ library CalldataLogic { return (reservesList[assetId], interestRateMode); } - /** - * @notice Decodes compressed rebalance stable borrow rate params to standard params - * @param reservesList The addresses of all the active reserves - * @param args The packed rabalance stable borrow rate params - * @return The address of the underlying reserve - * @return The address of the user to rebalance - */ - function decodeRebalanceStableBorrowRateParams( - mapping(uint256 => address) storage reservesList, - bytes32 args - ) internal view returns (address, address) { - uint16 assetId; - address user; - assembly { - assetId := and(args, 0xFFFF) - user := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - } - return (reservesList[assetId], user); - } - /** * @notice Decodes compressed set user use reserve as collateral params to standard params * @param reservesList The addresses of all the active reserves diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/core/contracts/protocol/libraries/types/DataTypes.sol index 6a09eb5a..d2da4b80 100644 --- a/src/core/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/core/contracts/protocol/libraries/types/DataTypes.sol @@ -17,6 +17,7 @@ library DataTypes { uint128 variableBorrowIndex; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; + // DEPRECATED on v3.2.0 uint128 __deprecatedStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; @@ -24,6 +25,7 @@ library DataTypes { uint16 id; //aToken address address aTokenAddress; + // DEPRECATED on v3.2.0 address __deprecatedStableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; @@ -48,6 +50,7 @@ library DataTypes { uint128 variableBorrowIndex; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; + // DEPRECATED on v3.2.0 uint128 __deprecatedStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; @@ -57,6 +60,7 @@ library DataTypes { uint40 liquidationGracePeriodUntil; //aToken address address aTokenAddress; + // DEPRECATED on v3.2.0 address __deprecatedStableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; @@ -126,11 +130,6 @@ library DataTypes { struct ReserveCache { uint256 currScaledVariableDebt; uint256 nextScaledVariableDebt; - // uint256 currPrincipalStableDebt; - // uint256 currAvgStableBorrowRate; TODO: cleanup - // uint256 currTotalStableDebt; - // uint256 nextAvgStableBorrowRate; - // uint256 nextTotalStableDebt; uint256 currLiquidityIndex; uint256 nextLiquidityIndex; uint256 currVariableBorrowIndex; @@ -140,10 +139,8 @@ library DataTypes { uint256 reserveFactor; ReserveConfigurationMap reserveConfiguration; address aTokenAddress; - // address stableDebtTokenAddress; TODO: cleanup address variableDebtTokenAddress; uint40 reserveLastUpdateTimestamp; - // uint40 stableDebtLastUpdateTimestamp; TODO: cleanup } struct ExecuteLiquidationCallParams { @@ -170,10 +167,8 @@ library DataTypes { address user; address onBehalfOf; uint256 amount; - // InterestRateMode interestRateMode; uint16 referralCode; bool releaseUnderlying; - // uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; @@ -225,7 +220,6 @@ library DataTypes { uint16 referralCode; uint256 flashLoanPremiumToProtocol; uint256 flashLoanPremiumTotal; - // uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address addressesProvider; address pool; @@ -266,8 +260,6 @@ library DataTypes { address asset; address userAddress; uint256 amount; - // InterestRateMode interestRateMode; - // uint256 maxStableLoanPercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; @@ -298,7 +290,6 @@ library DataTypes { struct InitReserveParams { address asset; address aTokenAddress; - // address stableDebtAddress; address variableDebtAddress; address interestRateStrategyAddress; uint16 reservesCount; diff --git a/src/core/contracts/protocol/pool/Pool.sol b/src/core/contracts/protocol/pool/Pool.sol index 2c2235d3..cda1c8f9 100644 --- a/src/core/contracts/protocol/pool/Pool.sol +++ b/src/core/contracts/protocol/pool/Pool.sol @@ -547,12 +547,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { return _reservesList[id]; } - /// @inheritdoc IPool - // @notice stable debt deprecated in v3.2.0 - function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view virtual override returns (uint256) { - return 0; - } - /// @inheritdoc IPool function BRIDGE_PROTOCOL_FEE() public view virtual override returns (uint256) { return _bridgeProtocolFee; diff --git a/src/core/contracts/protocol/pool/PoolStorage.sol b/src/core/contracts/protocol/pool/PoolStorage.sol index 9bd4d77c..719461e4 100644 --- a/src/core/contracts/protocol/pool/PoolStorage.sol +++ b/src/core/contracts/protocol/pool/PoolStorage.sol @@ -43,7 +43,7 @@ contract PoolStorage { // FlashLoan premium paid to protocol treasury, expressed in bps uint128 internal _flashLoanPremiumToProtocol; - // Available liquidity that can be borrowed at once at stable rate, expressed in bps + // DEPRECATED on v3.2.0 uint64 internal __DEPRECATED_maxStableRateBorrowSizePercent; // Maximum number of active reserves there have been in the protocol. It is the upper bound of the reserves list diff --git a/src/core/contracts/protocol/tokenization/StableDebtToken.sol b/src/core/contracts/protocol/tokenization/StableDebtToken.sol deleted file mode 100644 index e7c785e6..00000000 --- a/src/core/contracts/protocol/tokenization/StableDebtToken.sol +++ /dev/null @@ -1,141 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; -import {Errors} from '../libraries/helpers/Errors.sol'; -import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; -import {IInitializableDebtToken} from '../../interfaces/IInitializableDebtToken.sol'; -import {IStableDebtToken} from '../../interfaces/IStableDebtToken.sol'; -import {IPool} from '../../interfaces/IPool.sol'; -import {EIP712Base} from './base/EIP712Base.sol'; -import {DebtTokenBase} from './base/DebtTokenBase.sol'; -import {IncentivizedERC20} from './base/IncentivizedERC20.sol'; - -/** - * @title StableDebtToken - * @author Aave - * @notice Implements a stable debt token to track the borrowing positions of users - * at stable rate mode - * @dev Transfer and approve functionalities are disabled since its a non-transferable token - */ -abstract contract StableDebtToken is DebtTokenBase, IncentivizedERC20, IStableDebtToken { - /** - * @dev Constructor. - * @param pool The address of the Pool contract - */ - constructor( - IPool pool - ) DebtTokenBase() IncentivizedERC20(pool, 'STABLE_DEBT_TOKEN_IMPL', 'STABLE_DEBT_TOKEN_IMPL', 0) { - // Intentionally left blank - } - - /// @inheritdoc IInitializableDebtToken - function initialize( - IPool initializingPool, - address underlyingAsset, - IAaveIncentivesController incentivesController, - uint8 debtTokenDecimals, - string memory debtTokenName, - string memory debtTokenSymbol, - bytes calldata params - ) external virtual; - - /// @inheritdoc IStableDebtToken - function getAverageStableRate() external pure virtual override returns (uint256) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function getUserLastUpdated(address) external pure virtual override returns (uint40) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function getUserStableRate(address) external pure virtual override returns (uint256) { - return 0; - } - - /// @inheritdoc IERC20 - function balanceOf(address) public pure virtual override returns (uint256) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function mint( - address, - address, - uint256, - uint256 - ) external virtual override onlyPool returns (bool, uint256, uint256) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - /// @inheritdoc IStableDebtToken - function burn(address, uint256) external virtual override onlyPool returns (uint256, uint256) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - /// @inheritdoc IStableDebtToken - function getSupplyData() external pure override returns (uint256, uint256, uint256, uint40) { - return (0, 0, 0, 0); - } - - /// @inheritdoc IStableDebtToken - function getTotalSupplyAndAvgRate() external pure override returns (uint256, uint256) { - return (0, 0); - } - - /// @inheritdoc IERC20 - function totalSupply() public pure virtual override returns (uint256) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function getTotalSupplyLastUpdated() external pure override returns (uint40) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function principalBalanceOf(address) external pure virtual override returns (uint256) { - return 0; - } - - /// @inheritdoc IStableDebtToken - function UNDERLYING_ASSET_ADDRESS() external view override returns (address) { - return _underlyingAsset; - } - - /// @inheritdoc EIP712Base - function _EIP712BaseId() internal view override returns (string memory) { - return name(); - } - - /** - * @dev Being non transferrable, the debt token does not implement any of the - * standard ERC20 functions for transfer and allowance. - */ - function transfer(address, uint256) external virtual override returns (bool) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - function allowance(address, address) external view virtual override returns (uint256) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - function approve(address, uint256) external virtual override returns (bool) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - function transferFrom(address, address, uint256) external virtual override returns (bool) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - function increaseAllowance(address, uint256) external virtual override returns (bool) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } - - function decreaseAllowance(address, uint256) external virtual override returns (bool) { - revert(Errors.OPERATION_NOT_SUPPORTED); - } -} diff --git a/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol b/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol index 8dc79203..ff0d4e49 100644 --- a/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol +++ b/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol @@ -10,7 +10,7 @@ import {EIP712Base} from './EIP712Base.sol'; /** * @title DebtTokenBase * @author Aave - * @notice Base contract for different types of debt tokens, like StableDebtToken or VariableDebtToken + * @notice Base contract for different types of debt tokens, like VariableDebtToken */ abstract contract DebtTokenBase is VersionedInitializable, diff --git a/src/core/instances/StableDebtTokenInstance.sol b/src/core/instances/StableDebtTokenInstance.sol deleted file mode 100644 index 00f91a58..00000000 --- a/src/core/instances/StableDebtTokenInstance.sol +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {StableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../contracts/protocol/tokenization/StableDebtToken.sol'; - -contract StableDebtTokenInstance is StableDebtToken { - uint256 public constant DEBT_TOKEN_REVISION = 1; - - constructor(IPool pool) StableDebtToken(pool) {} - - /// @inheritdoc VersionedInitializable - function getRevision() internal pure virtual override returns (uint256) { - return DEBT_TOKEN_REVISION; - } - - /// @inheritdoc IInitializableDebtToken - function initialize( - IPool initializingPool, - address underlyingAsset, - IAaveIncentivesController incentivesController, - uint8 debtTokenDecimals, - string memory debtTokenName, - string memory debtTokenSymbol, - bytes calldata params - ) external override initializer { - require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH); - _setName(debtTokenName); - _setSymbol(debtTokenSymbol); - _setDecimals(debtTokenDecimals); - - _underlyingAsset = underlyingAsset; - _incentivesController = incentivesController; - - _domainSeparator = _calculateDomainSeparator(); - - emit Initialized( - underlyingAsset, - address(POOL), - address(incentivesController), - debtTokenDecimals, - debtTokenName, - debtTokenSymbol, - params - ); - } -} diff --git a/src/periphery/contracts/libraries/DataTypesHelper.sol b/src/periphery/contracts/libraries/DataTypesHelper.sol index ec662615..17f666e4 100644 --- a/src/periphery/contracts/libraries/DataTypesHelper.sol +++ b/src/periphery/contracts/libraries/DataTypesHelper.sol @@ -11,7 +11,7 @@ import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTyp */ library DataTypesHelper { /** - * @notice Fetches the user current stable and variable debt balances + * @notice Fetches the user current variable debt balances * @param user The user address * @param reserve The reserve data object * @return The variable debt balance diff --git a/tests/harness/StableDebtToken.sol b/tests/harness/StableDebtToken.sol deleted file mode 100644 index c841b9ef..00000000 --- a/tests/harness/StableDebtToken.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {StableDebtTokenInstance, IPool} from 'aave-v3-core/instances/StableDebtTokenInstance.sol'; - -contract StableDebtTokenHarness is StableDebtTokenInstance { - constructor(IPool pool) StableDebtTokenInstance(pool) {} - - function _getRevision() public pure returns (uint256) { - return super.getRevision(); - } -} diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 0adf79bc..0ede1e50 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -27,8 +27,6 @@ struct TestVars { string aTokenSymbol; string variableDebtName; string variableDebtSymbol; - string stableDebtName; - string stableDebtSymbol; address rateStrategy; bytes interestRateData; bytes emptyParams; @@ -42,7 +40,6 @@ struct TestReserveConfig { uint256 reserveFactor; bool usageAsCollateralEnabled; bool borrowingEnabled; - bool stableBorrowRateEnabled; bool isActive; bool isFrozen; bool isPaused; @@ -252,7 +249,7 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, - bool stableBorrowRateEnabled, + , bool isActive, bool isFrozen ) = IPoolDataProvider(dataProvider).getReserveConfigurationData(reserve); @@ -263,7 +260,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { c.reserveFactor = reserveFactor; c.usageAsCollateralEnabled = usageAsCollateralEnabled; c.borrowingEnabled = borrowingEnabled; - c.stableBorrowRateEnabled = stableBorrowRateEnabled; c.isActive = isActive; c.isFrozen = isFrozen; c.isPaused = IPoolDataProvider(dataProvider).getPaused(reserve); @@ -296,8 +292,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { t.aTokenName = _concatStr('a ', x); t.variableDebtName = _concatStr('Variable Debt Misc', x); t.variableDebtSymbol = _concatStr('varDebtMISC ', x); - t.stableDebtName = _concatStr('Stable Debt Misc ', x); - t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); t.rateStrategy = r.defaultInterestRateStrategyV2; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ From 04d762ab1e5390cc2bfc246ca229a9a66bf8165c Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 24 Apr 2024 15:57:01 +0300 Subject: [PATCH 03/88] fix backwords capability of getReserveData --- src/core/contracts/protocol/libraries/types/DataTypes.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/core/contracts/protocol/libraries/types/DataTypes.sol index d2da4b80..109e8f1c 100644 --- a/src/core/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/core/contracts/protocol/libraries/types/DataTypes.sol @@ -18,7 +18,7 @@ library DataTypes { //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; // DEPRECATED on v3.2.0 - uint128 __deprecatedStableBorrowRate; + uint128 stableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; //the id of the reserve. Represents the position in the list of the active reserves @@ -26,7 +26,7 @@ library DataTypes { //aToken address address aTokenAddress; // DEPRECATED on v3.2.0 - address __deprecatedStableDebtTokenAddress; + address stableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; //address of the interest rate strategy From 57129acb5ed5379715403cd667f1ad5aa9cd0f63 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 24 Apr 2024 16:07:14 +0300 Subject: [PATCH 04/88] DRAFT: Add intensive init reserve tests --- .../core/PoolConfigurator.initReserves.t.sol | 240 ++++-------------- .../PoolConfigurator.reserveRiskConfig.t.sol | 88 +++---- tests/core/StableDebtToken.t.sol | 72 +++--- tests/core/VariableDebtToken.t.sol | 68 ++--- tests/utils/TestnetProcedures.sol | 112 ++++---- 5 files changed, 224 insertions(+), 356 deletions(-) diff --git a/tests/core/PoolConfigurator.initReserves.t.sol b/tests/core/PoolConfigurator.initReserves.t.sol index a6159b64..c418d9ac 100644 --- a/tests/core/PoolConfigurator.initReserves.t.sol +++ b/tests/core/PoolConfigurator.initReserves.t.sol @@ -23,189 +23,76 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { initTestEnvironment(); } - function test_initReserves_singleAsset(bool isVirtualAccActive) public { - TestnetERC20 newToken = new TestnetERC20('Misc Token', 'MISC', 18, poolAdmin); - - TestVars memory t; - t.aTokenName = 'Misc AToken'; - t.aTokenSymbol = 'aMISC'; - t.variableDebtName = 'Variable Debt Misc'; - t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategyV2; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); + function test_initReserves_singleAsset(TestVars[128] memory t, uint8 length) public { + vm.assume(length > 0 && length < 128); uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; + uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; + vm.assume(length < maxListings); ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](1); - - input[0] = ConfiguratorInputTypes.InitReserveInput( - report.aToken, - report.stableDebtToken, - report.variableDebtToken, - newToken.decimals(), - isVirtualAccActive, - t.rateStrategy, - address(newToken), - report.treasury, - report.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData - ); - vm.expectEmit(true, false, false, false, address(contracts.poolConfiguratorProxy)); - emit ReserveInitialized( - input[0].underlyingAsset, - address(0), - address(0), - address(0), - input[0].interestRateStrategyAddress - ); - - // Perform action - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.initReserves(input); - - // Perform assertions - { - (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts - .protocolDataProvider - .getReserveTokensAddresses(address(newToken)); - - assertEq(AToken(aTokenProxy).name(), t.aTokenName); - assertEq(AToken(aTokenProxy).symbol(), t.aTokenSymbol); - assertEq(AToken(aTokenProxy).decimals(), newToken.decimals()); - assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), report.treasury); - assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(aTokenProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - - assertEq(AToken(stableDebtProxy).name(), t.stableDebtName); - assertEq(AToken(stableDebtProxy).symbol(), t.stableDebtSymbol); - assertEq(AToken(stableDebtProxy).decimals(), newToken.decimals()); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(stableDebtProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - - assertEq(AToken(variableDebtProxy).name(), t.variableDebtName); - assertEq(AToken(variableDebtProxy).symbol(), t.variableDebtSymbol); - assertEq(AToken(variableDebtProxy).decimals(), newToken.decimals()); - assertEq(AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(variableDebtProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - } - // Perform default asset checks - TestReserveConfig memory c = _getReserveConfig(address(newToken), report.protocolDataProvider); - - assertEq(c.isActive, true); - assertEq(c.isFrozen, false); - assertEq(c.isPaused, false); - assertEq(c.decimals, newToken.decimals()); - - assertEq(c.ltv, 0); - assertEq(c.liquidationThreshold, 0); - assertEq(c.liquidationBonus, 0); - assertEq(c.reserveFactor, 0); - assertEq(c.usageAsCollateralEnabled, false); - assertEq(c.borrowingEnabled, false); - assertEq(c.stableBorrowRateEnabled, false); - assertEq(c.isVirtualAccActive, isVirtualAccActive); + memory input = new ConfiguratorInputTypes.InitReserveInput[](length); + for (uint i = 0; i < length; i++) { + input[i] = _generateInitReserveInput(t[i], report, poolAdmin, true); - assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + 1); - } - - function test_initReserves_multipleAssets() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 4, - report, - poolAdmin - ); - uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; - - for (uint256 y; y < input.length; ++y) { vm.expectEmit(true, false, false, false, address(contracts.poolConfiguratorProxy)); emit ReserveInitialized( - input[y].underlyingAsset, + input[i].underlyingAsset, address(0), address(0), address(0), - input[y].interestRateStrategyAddress + input[i].interestRateStrategyAddress ); } - // Perform action vm.prank(poolAdmin); contracts.poolConfiguratorProxy.initReserves(input); - // Perform assertions - for (uint256 y; y < input.length; ++y) { - ConfiguratorInputTypes.InitReserveInput memory reserveInput = input[y]; - + for (uint i = 0; i < length; i++) { + ConfiguratorInputTypes.InitReserveInput memory initConfig = input[i]; + // Perform assertions { (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts .protocolDataProvider - .getReserveTokensAddresses(reserveInput.underlyingAsset); + .getReserveTokensAddresses(initConfig.underlyingAsset); - assertEq(AToken(aTokenProxy).name(), reserveInput.aTokenName); - assertEq(AToken(aTokenProxy).symbol(), reserveInput.aTokenSymbol); - assertEq(AToken(aTokenProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), reserveInput.treasury); - assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), reserveInput.underlyingAsset); + assertEq(AToken(aTokenProxy).name(), initConfig.aTokenName); + assertEq(AToken(aTokenProxy).symbol(), initConfig.aTokenSymbol); + assertEq(AToken(aTokenProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), initConfig.treasury); + assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(aTokenProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); - assertEq(AToken(stableDebtProxy).name(), reserveInput.stableDebtTokenName); - assertEq(AToken(stableDebtProxy).symbol(), reserveInput.stableDebtTokenSymbol); - assertEq(AToken(stableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), reserveInput.underlyingAsset); + assertEq(AToken(stableDebtProxy).name(), initConfig.stableDebtTokenName); + assertEq(AToken(stableDebtProxy).symbol(), initConfig.stableDebtTokenSymbol); + assertEq(AToken(stableDebtProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(stableDebtProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); - assertEq(AToken(variableDebtProxy).name(), reserveInput.variableDebtTokenName); - assertEq(AToken(variableDebtProxy).symbol(), reserveInput.variableDebtTokenSymbol); - assertEq(AToken(variableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq( - AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), - reserveInput.underlyingAsset - ); + assertEq(AToken(variableDebtProxy).name(), initConfig.variableDebtTokenName); + assertEq(AToken(variableDebtProxy).symbol(), initConfig.variableDebtTokenSymbol); + assertEq(AToken(variableDebtProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(variableDebtProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); } // Perform default asset checks TestReserveConfig memory c = _getReserveConfig( - reserveInput.underlyingAsset, + initConfig.underlyingAsset, report.protocolDataProvider ); assertEq(c.isActive, true); assertEq(c.isFrozen, false); assertEq(c.isPaused, false); - assertEq(c.decimals, reserveInput.underlyingAssetDecimals); + assertEq(c.decimals, initConfig.underlyingAssetDecimals); assertEq(c.ltv, 0); assertEq(c.liquidationThreshold, 0); @@ -214,8 +101,9 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(c.usageAsCollateralEnabled, false); assertEq(c.borrowingEnabled, false); assertEq(c.stableBorrowRateEnabled, false); + assertEq(c.isVirtualAccActive, initConfig.useVirtualBalance); } - assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + input.length); + assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + length); } function test_initReserves_zeroAssets() public { @@ -230,14 +118,16 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets); } - function test_reverts_initReserves_maxAssets() public { + function test_reverts_initReserves_maxAssets(TestVars[500] memory t, uint8 length) public { uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; + uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - maxListings, - report, - poolAdmin - ); + length += uint8(maxListings); + + ConfiguratorInputTypes.InitReserveInput[] + memory input = new ConfiguratorInputTypes.InitReserveInput[](length); + for (uint256 i = 0; i < length; i++) + input[i] = _generateInitReserveInput(t[i], report, poolAdmin, true); vm.expectRevert(bytes(Errors.NO_MORE_RESERVES_ALLOWED)); vm.prank(poolAdmin); @@ -246,48 +136,14 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets); } - function test_initReserves_notEnoughDecimal(uint8 decimals) public { - vm.assume(decimals < 6); - TestnetERC20 newToken = new TestnetERC20('Misc Token', 'MISC', decimals, poolAdmin); + function test_initReserves_notEnoughDecimal(TestVars memory t) public { + vm.assume(t.underlyingDecimals < 6); - TestVars memory t; - t.aTokenName = 'Misc AToken'; - t.aTokenSymbol = 'aMISC'; - t.variableDebtName = 'Variable Debt Misc'; - t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategyV2; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); - - ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](1); - - input[0] = ConfiguratorInputTypes.InitReserveInput( - report.aToken, - report.stableDebtToken, - report.variableDebtToken, - newToken.decimals(), - true, - t.rateStrategy, - address(newToken), - report.treasury, - report.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, + report, + poolAdmin, + false ); vm.expectRevert(bytes(Errors.INVALID_DECIMALS)); diff --git a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol b/tests/core/PoolConfigurator.reserveRiskConfig.t.sol index cd6a28b7..fb254ccf 100644 --- a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/core/PoolConfigurator.reserveRiskConfig.t.sol @@ -65,11 +65,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { contracts.poolProxy.supply(tokenList.wbtc, 100e8, bob, 0); } - function test_enableBorrowing() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableBorrowing(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -103,11 +104,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(borrowingConfigAfter, false); } - function test_enableFlashBorrow() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableFlashBorrow(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -130,15 +132,16 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(valueAfter, false); } - function test_setCollateralConfig() public { + function test_setCollateralConfig(TestVars memory t) public { uint256 ltv = 80_00; uint256 liquidationThreshold = 85_00; uint256 liquidationBonus = 105_00; - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -169,11 +172,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(liqBonus, liquidationBonus); } - function test_reverts_setCollateralConfig_invalidParams() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_reverts_setCollateralConfig_invalidParams(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -234,11 +238,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { contracts.poolConfiguratorProxy.configureReserveAsCollateral(tokenList.usdx, 0, 0, 0); } - function test_enableStableBorrowing() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableStableBorrowing(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -276,11 +281,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(borrowingConfigAfter, false); } - function test_reverts_enableStableBorrowing_borrowNotEnabled() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_reverts_enableStableBorrowing_borrowNotEnabled(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -734,38 +740,20 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { } function test_setLiquidationGracePeriodReserve(uint40 gracePeriod) public { - vm.assume( - gracePeriod <= contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0 - ); + vm.assume(gracePeriod <= contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD()); address asset = tokenList.usdx; uint40 until = uint40(block.timestamp) + gracePeriod; - vm.startPrank(poolAdmin); - - // reserve unpause -> unpause, liquidationGracePeriod would be set - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit LiquidationGracePeriodChanged(asset, until); - contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - - // reserve unpause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - assertTrue(contracts.protocolDataProvider.getPaused(asset)); - - // reserve pause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - - // reserve pause -> unpause, liquidationGracePeriod would be set - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit LiquidationGracePeriodChanged(asset, until + 1); - contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until + 1); + vm.prank(poolAdmin); - vm.stopPrank(); + if (gracePeriod != 0) { + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit LiquidationGracePeriodChanged(asset, until); + contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod); + assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); + } } function test_setLiquidationGracePeriodPool(uint40 gracePeriod) public { diff --git a/tests/core/StableDebtToken.t.sol b/tests/core/StableDebtToken.t.sol index 2394d4b6..2b513554 100644 --- a/tests/core/StableDebtToken.t.sol +++ b/tests/core/StableDebtToken.t.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {StableDebtTokenHarness as StableDebtTokenInstance} from '../harness/StableDebtToken.sol'; +import {StableDebtTokenInstance} from 'aave-v3-core/instances/StableDebtTokenInstance.sol'; import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; import {PoolConfigurator, ConfiguratorInputTypes, IPool} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../utils/TestnetProcedures.sol'; contract StableDebtTokenEventsTests is TestnetProcedures { StableDebtTokenInstance public stableDebtToken; @@ -69,11 +69,14 @@ contract StableDebtTokenEventsTests is TestnetProcedures { return stDebtToken; } - function test_reverts_initialize_twice() public { - StableDebtTokenInstance staDebtToken = test_initialize_StableDebtToken(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + function test_reverts_initialize_twice(TestVars memory t) public { + StableDebtTokenInstance staDebtToken = test_initialize_StableDebtToken(t); + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -90,11 +93,16 @@ contract StableDebtTokenEventsTests is TestnetProcedures { ); } - function test_initialize_StableDebtToken() public returns (StableDebtTokenInstance) { + function test_initialize_StableDebtToken( + TestVars memory t + ) public returns (StableDebtTokenInstance) { StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); vm.expectEmit(address(stDebtToken)); emit Initialized( @@ -128,11 +136,14 @@ contract StableDebtTokenEventsTests is TestnetProcedures { return stDebtToken; } - function test_reverts_initialize_pool_do_not_match() public { + function test_reverts_initialize_pool_do_not_match(TestVars memory t) public { StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -149,8 +160,8 @@ contract StableDebtTokenEventsTests is TestnetProcedures { ); } - function test_mint_stableDebt_caller_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); + function test_mint_stableDebt_caller_alice(TestVars memory t) public { + StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(t); vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); @@ -158,8 +169,8 @@ contract StableDebtTokenEventsTests is TestnetProcedures { debtToken.mint(alice, alice, 0, 0); } - function test_mint_stableDebt_caller_bob_onBehalf_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); + function test_mint_stableDebt_caller_bob_onBehalf_alice(TestVars memory t) public { + StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -208,53 +219,48 @@ contract StableDebtTokenEventsTests is TestnetProcedures { stDebtToken.burn(address(0), 0); } - function test_default_revision() public { - StableDebtTokenInstance stDebtToken = new StableDebtTokenInstance(IPool(report.poolProxy)); - assertEq(stDebtToken._getRevision(), stDebtToken.DEBT_TOKEN_REVISION()); - } - - function test_getAverageStableRate() public view { + function test_getAverageStableRate() public { uint256 avgStableRate = stableDebtToken.getAverageStableRate(); assertEq(avgStableRate, 0); } - function test_getUserLastUpdated() public view { + function test_getUserLastUpdated() public { uint256 lastUpdated = stableDebtToken.getUserLastUpdated(alice); assertEq(lastUpdated, 0); } - function test_getUserStableRate() public view { + function test_getUserStableRate() public { uint256 userStableRate = stableDebtToken.getUserStableRate(alice); assertEq(userStableRate, 0); } - function test_balanceOf() public view { + function test_balanceOf() public { uint256 balance = stableDebtToken.balanceOf(alice); assertEq(balance, 0); } - function test_totalSupply() public view { + function test_totalSupply() public { uint256 scaledTotalSupply = stableDebtToken.totalSupply(); assertEq(scaledTotalSupply, 0); } - function test_getTotalSupplyLastUpdated() public view { + function test_getTotalSupplyLastUpdated() public { uint256 totalSupplyLastUpdated = stableDebtToken.getTotalSupplyLastUpdated(); assertEq(totalSupplyLastUpdated, 0); } - function test_principalBalanceOf() public view { + function test_principalBalanceOf() public { uint256 principalBalanceOf = stableDebtToken.principalBalanceOf(alice); assertEq(principalBalanceOf, 0); } - function test_getTotalSupplyAndAvgRate() public view { + function test_getTotalSupplyAndAvgRate() public { (uint256 totalSupply, uint256 avgRate) = stableDebtToken.getTotalSupplyAndAvgRate(); assertEq(totalSupply, 0); assertEq(avgRate, 0); } - function test_getSupplyData() public view { + function test_getSupplyData() public { ( uint256 principal, uint256 totalSupply, diff --git a/tests/core/VariableDebtToken.t.sol b/tests/core/VariableDebtToken.t.sol index 9435b543..db98c01b 100644 --- a/tests/core/VariableDebtToken.t.sol +++ b/tests/core/VariableDebtToken.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {VariableDebtTokenHarness as VariableDebtTokenInstance} from '../harness/VariableDebtToken.sol'; +import {VariableDebtTokenInstance} from 'aave-v3-core/instances/VariableDebtTokenInstance.sol'; import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; @@ -11,7 +11,7 @@ import {ReserveLogic, DataTypes} from 'aave-v3-core/contracts/protocol/libraries import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; import {ConfiguratorInputTypes, IPool} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../utils/TestnetProcedures.sol'; contract VariableDebtTokenEventsTests is TestnetProcedures { using WadRayMath for uint256; @@ -82,18 +82,23 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { return varDebtToken; } - function test_initialize_VariableDebtToken() public returns (VariableDebtTokenInstance) { + function test_initialize_VariableDebtToken( + TestVars memory t + ) public returns (VariableDebtTokenInstance) { VariableDebtTokenInstance varDebtToken = test_new_VariableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); vm.expectEmit(address(varDebtToken)); emit Initialized( listing.underlyingAsset, report.poolProxy, - report.rewardsControllerProxy, - TestnetERC20(listing.underlyingAsset).decimals(), + listing.incentivesController, + listing.underlyingAssetDecimals, listing.variableDebtTokenName, listing.variableDebtTokenSymbol, listing.params @@ -103,7 +108,7 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { IPool(report.poolProxy), listing.underlyingAsset, IAaveIncentivesController(listing.incentivesController), - TestnetERC20(listing.underlyingAsset).decimals(), + listing.underlyingAssetDecimals, listing.variableDebtTokenName, listing.variableDebtTokenSymbol, listing.params @@ -120,11 +125,14 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { return varDebtToken; } - function test_reverts_initialize_twice() public { - VariableDebtTokenInstance varDebtToken = test_initialize_VariableDebtToken(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + function test_reverts_initialize_twice(TestVars memory t) public { + VariableDebtTokenInstance varDebtToken = test_initialize_VariableDebtToken(t); + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -141,11 +149,14 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { ); } - function test_reverts_initialize_pool_do_not_match() public { + function test_reverts_initialize_pool_do_not_match(TestVars memory t) public { VariableDebtTokenInstance varDebtToken = test_new_VariableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -162,13 +173,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { ); } - function test_default_revision() public { - VariableDebtTokenInstance varDebtToken = new VariableDebtTokenInstance(IPool(report.poolProxy)); - assertEq(varDebtToken._getRevision(), varDebtToken.DEBT_TOKEN_REVISION()); - } - - function test_mint_variableDebt_caller_alice() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_mint_variableDebt_caller_alice(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -182,8 +188,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), amount); } - function test_mint_variableDebt_caller_bob_onBehalf_alice() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_mint_variableDebt_caller_bob_onBehalf_alice(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -203,8 +209,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), amount); } - function test_partial_burn_variableDebt() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_partial_burn_variableDebt(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -229,8 +235,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), balanceScaled - repaymentScaled); } - function test_total_burn_variableDebt() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_total_burn_variableDebt(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 5d6f39c2..fb35e4c6 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -23,6 +23,7 @@ import {MarketReportUtils} from '../../src/deployments/contracts/utilities/Marke import {AaveV3ConfigEngine, IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol'; struct TestVars { + uint8 underlyingDecimals; string aTokenName; string aTokenSymbol; string variableDebtName; @@ -30,10 +31,11 @@ struct TestVars { string stableDebtName; string stableDebtSymbol; address rateStrategy; - bytes interestRateData; - bytes emptyParams; - uint256 previousReservesLength; + address incentivesController; + address treasury; + bool useVirtualBalance; } + struct TestReserveConfig { uint256 decimals; uint256 ltv; @@ -276,59 +278,69 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { return string(abi.encodePacked(a, vm.toString(b))); } - function _generateListingInput( - uint256 listings, + function _generateInitConfig( + TestVars memory t, + MarketReport memory r, + address poolAdminUser, + bool isValidDecimals + ) internal returns (ConfiguratorInputTypes.InitReserveInput[] memory) { + TestVars[] memory tArray = new TestVars[](1); + tArray[0] = t; + return _generateInitConfig(tArray, r, poolAdminUser, isValidDecimals); + } + + function _generateInitConfig( + TestVars[] memory t, MarketReport memory r, - address poolAdminUser + address poolAdminUser, + bool isValidDecimals ) internal returns (ConfiguratorInputTypes.InitReserveInput[] memory) { ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](listings); - - for (uint256 x; x < listings; ++x) { - TestnetERC20 listingToken = new TestnetERC20( - _concatStr('Token', x), - _concatStr('T', x), - uint8(10 + x), - poolAdminUser - ); - TestVars memory t; - t.aTokenName = _concatStr('AToken ', x); - t.aTokenName = _concatStr('a ', x); - t.variableDebtName = _concatStr('Variable Debt Misc', x); - t.variableDebtSymbol = _concatStr('varDebtMISC ', x); - t.stableDebtName = _concatStr('Stable Debt Misc ', x); - t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); - t.rateStrategy = r.defaultInterestRateStrategyV2; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); + memory configurations = new ConfiguratorInputTypes.InitReserveInput[](t.length); + for (uint256 i = 0; i < t.length; i++) { + configurations[i] = _generateInitReserveInput(t[i], r, poolAdminUser, isValidDecimals); + } + return configurations; + } - input[x] = ConfiguratorInputTypes.InitReserveInput( - r.aToken, - r.stableDebtToken, - r.variableDebtToken, - listingToken.decimals(), - true, - t.rateStrategy, - address(listingToken), - r.treasury, - r.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData - ); + function _generateInitReserveInput( + TestVars memory t, + MarketReport memory r, + address poolAdminUser, + bool isValidDecimals + ) internal returns (ConfiguratorInputTypes.InitReserveInput memory) { + if (isValidDecimals) { + vm.assume(t.underlyingDecimals > 5); } + ConfiguratorInputTypes.InitReserveInput memory input; + input.aTokenImpl = report.aToken; + input.underlyingAsset = address( + new TestnetERC20('Misc Token', 'MISC', t.underlyingDecimals, poolAdminUser) + ); + input.stableDebtTokenImpl = report.stableDebtToken; + input.variableDebtTokenImpl = report.variableDebtToken; + input.underlyingAssetDecimals = t.underlyingDecimals; + input.useVirtualBalance = t.useVirtualBalance; + input.interestRateStrategyAddress = report.defaultInterestRateStrategyV2; + input.treasury = t.treasury; + input.incentivesController = report.rewardsControllerProxy; + input.aTokenName = t.aTokenName; + input.aTokenSymbol = t.aTokenSymbol; + input.variableDebtTokenName = t.variableDebtName; + input.variableDebtTokenSymbol = t.variableDebtSymbol; + input.stableDebtTokenName = t.stableDebtName; + input.stableDebtTokenSymbol = t.stableDebtSymbol; + input.params = bytes(''); + input.interestRateData = abi.encode( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: 80_00, + baseVariableBorrowRate: 1_00, + variableRateSlope1: 4_00, + variableRateSlope2: 60_00 + }) + ); + return input; } From ebefc49802cffe1f70edbf2c4c6af8dd1d378394 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Thu, 25 Apr 2024 15:45:54 +0300 Subject: [PATCH 05/88] fix underlying decimals with bound --- tests/utils/TestnetProcedures.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index fb35e4c6..81f8cfbf 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -310,7 +310,9 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { bool isValidDecimals ) internal returns (ConfiguratorInputTypes.InitReserveInput memory) { if (isValidDecimals) { - vm.assume(t.underlyingDecimals > 5); + t.underlyingDecimals = uint8(bound(t.underlyingDecimals, 6, 25)); + } else { + t.underlyingDecimals = uint8(bound(t.underlyingDecimals, 0, 5)); } ConfiguratorInputTypes.InitReserveInput memory input; From f2f62377bbe2dd44a19aaba40f7b3482b656465e Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Thu, 25 Apr 2024 16:42:15 +0300 Subject: [PATCH 06/88] fix of test_reverts_initReserves_maxAssets test --- tests/core/PoolConfigurator.initReserves.t.sol | 8 ++++---- tests/utils/TestnetProcedures.sol | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/core/PoolConfigurator.initReserves.t.sol b/tests/core/PoolConfigurator.initReserves.t.sol index c418d9ac..3ce9b98b 100644 --- a/tests/core/PoolConfigurator.initReserves.t.sol +++ b/tests/core/PoolConfigurator.initReserves.t.sol @@ -23,7 +23,7 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { initTestEnvironment(); } - function test_initReserves_singleAsset(TestVars[128] memory t, uint8 length) public { + function test_initReserves_validNumberOfAssets(TestVars[128] memory t, uint8 length) public { vm.assume(length > 0 && length < 128); uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; @@ -118,16 +118,16 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets); } - function test_reverts_initReserves_maxAssets(TestVars[500] memory t, uint8 length) public { + function test_reverts_initReserves_maxAssets(TestVars memory t, uint8 lengthSeed) public { uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; - length += uint8(maxListings); + uint256 length = maxListings + lengthSeed; ConfiguratorInputTypes.InitReserveInput[] memory input = new ConfiguratorInputTypes.InitReserveInput[](length); for (uint256 i = 0; i < length; i++) - input[i] = _generateInitReserveInput(t[i], report, poolAdmin, true); + input[i] = _generateInitReserveInput(t, report, poolAdmin, true); vm.expectRevert(bytes(Errors.NO_MORE_RESERVES_ALLOWED)); vm.prank(poolAdmin); diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 81f8cfbf..db95ed2f 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -316,17 +316,17 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { } ConfiguratorInputTypes.InitReserveInput memory input; - input.aTokenImpl = report.aToken; + input.aTokenImpl = r.aToken; input.underlyingAsset = address( new TestnetERC20('Misc Token', 'MISC', t.underlyingDecimals, poolAdminUser) ); - input.stableDebtTokenImpl = report.stableDebtToken; - input.variableDebtTokenImpl = report.variableDebtToken; + input.stableDebtTokenImpl = r.stableDebtToken; + input.variableDebtTokenImpl = r.variableDebtToken; input.underlyingAssetDecimals = t.underlyingDecimals; input.useVirtualBalance = t.useVirtualBalance; - input.interestRateStrategyAddress = report.defaultInterestRateStrategyV2; + input.interestRateStrategyAddress = r.defaultInterestRateStrategyV2; input.treasury = t.treasury; - input.incentivesController = report.rewardsControllerProxy; + input.incentivesController = r.rewardsControllerProxy; input.aTokenName = t.aTokenName; input.aTokenSymbol = t.aTokenSymbol; input.variableDebtTokenName = t.variableDebtName; From 0102427cb0265c16b91ce42127ed8b0c04ed8e9d Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 11:52:05 +0300 Subject: [PATCH 07/88] add fuzing to notAdmin_initReserves test --- tests/core/PoolConfigurator.ACLModifiers.t.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/core/PoolConfigurator.ACLModifiers.t.sol b/tests/core/PoolConfigurator.ACLModifiers.t.sol index aad612d2..0301d7ab 100644 --- a/tests/core/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/core/PoolConfigurator.ACLModifiers.t.sol @@ -5,15 +5,20 @@ import 'forge-std/Test.sol'; import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; import {ConfiguratorInputTypes} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../utils/TestnetProcedures.sol'; contract PoolConfiguratorACLModifiersTest is TestnetProcedures { function setUp() public { initTestEnvironment(); } - function test_reverts_notAdmin_initReserves(address caller) public { - ConfiguratorInputTypes.InitReserveInput[] memory input; + function test_reverts_notAdmin_initReserves(TestVars memory t, address caller) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, + report, + poolAdmin, + true + ); vm.assume( !contracts.aclManager.isPoolAdmin(caller) && !contracts.aclManager.isAssetListingAdmin(caller) && From bbb7aea67487515762837a8430f1408b8ee5e470 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 13:06:05 +0300 Subject: [PATCH 08/88] remove i from vars in flashLoan --- .../libraries/logic/FlashLoanLogic.sol | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol b/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol index ffd2a13c..13223c59 100644 --- a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol @@ -47,7 +47,6 @@ library FlashLoanLogic { // Helper struct for internal variables used in the `executeFlashLoan` function struct FlashLoanLocalVars { IFlashLoanReceiver receiver; - uint256 i; address currentAsset; uint256 currentAmount; uint256[] totalPremiums; @@ -90,20 +89,18 @@ library FlashLoanLogic { ? (0, 0) : (params.flashLoanPremiumTotal, params.flashLoanPremiumToProtocol); - for (vars.i = 0; vars.i < params.assets.length; vars.i++) { - vars.currentAmount = params.amounts[vars.i]; - vars.totalPremiums[vars.i] = DataTypes.InterestRateMode(params.interestRateModes[vars.i]) == + for (uint256 i = 0; i < params.assets.length; i++) { + vars.currentAmount = params.amounts[i]; + vars.totalPremiums[i] = DataTypes.InterestRateMode(params.interestRateModes[i]) == DataTypes.InterestRateMode.NONE ? vars.currentAmount.percentMul(vars.flashloanPremiumTotal) : 0; - if (reservesData[params.assets[vars.i]].configuration.getIsVirtualAccActive()) { - reservesData[params.assets[vars.i]].virtualUnderlyingBalance -= vars - .currentAmount - .toUint128(); + if (reservesData[params.assets[i]].configuration.getIsVirtualAccActive()) { + reservesData[params.assets[i]].virtualUnderlyingBalance -= vars.currentAmount.toUint128(); } - IAToken(reservesData[params.assets[vars.i]].aTokenAddress).transferUnderlyingTo( + IAToken(reservesData[params.assets[i]].aTokenAddress).transferUnderlyingTo( params.receiverAddress, vars.currentAmount ); @@ -120,14 +117,12 @@ library FlashLoanLogic { Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN ); - // TODO: try to remove i from vars - for (vars.i = 0; vars.i < params.assets.length; vars.i++) { - vars.currentAsset = params.assets[vars.i]; - vars.currentAmount = params.amounts[vars.i]; + for (uint256 i = 0; i < params.assets.length; i++) { + vars.currentAsset = params.assets[i]; + vars.currentAmount = params.amounts[i]; if ( - DataTypes.InterestRateMode(params.interestRateModes[vars.i]) == - DataTypes.InterestRateMode.NONE + DataTypes.InterestRateMode(params.interestRateModes[i]) == DataTypes.InterestRateMode.NONE ) { _handleFlashLoanRepayment( reservesData[vars.currentAsset], @@ -135,7 +130,7 @@ library FlashLoanLogic { asset: vars.currentAsset, receiverAddress: params.receiverAddress, amount: vars.currentAmount, - totalPremium: vars.totalPremiums[vars.i], + totalPremium: vars.totalPremiums[i], flashLoanPremiumToProtocol: vars.flashloanPremiumToProtocol, referralCode: params.referralCode }) @@ -168,7 +163,7 @@ library FlashLoanLogic { msg.sender, vars.currentAsset, vars.currentAmount, - DataTypes.InterestRateMode(params.interestRateModes[vars.i]), + DataTypes.InterestRateMode(params.interestRateModes[i]), 0, params.referralCode ); From 9ec96c52a124de4f18fc4d4b813f78bcd7da093c Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 13:09:36 +0300 Subject: [PATCH 09/88] renamed stableBorrowRate back on ReserveDataLegacy --- src/core/contracts/protocol/libraries/types/DataTypes.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/core/contracts/protocol/libraries/types/DataTypes.sol index 109e8f1c..f2da7116 100644 --- a/src/core/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/core/contracts/protocol/libraries/types/DataTypes.sol @@ -18,7 +18,7 @@ library DataTypes { //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; // DEPRECATED on v3.2.0 - uint128 stableBorrowRate; + uint128 currentStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; //the id of the reserve. Represents the position in the list of the active reserves From 6d91b62c5e4d219f0c4c643c19c9df7612fbe1e3 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 13:21:10 +0300 Subject: [PATCH 10/88] removed local vars in updateInterestRatesAndVirtualBalance --- .../protocol/libraries/logic/ReserveLogic.sol | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol b/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol index 80ed2965..8e27cdc0 100644 --- a/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol +++ b/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol @@ -171,20 +171,18 @@ library ReserveLogic { uint256 liquidityAdded, uint256 liquidityTaken ) internal { - UpdateInterestRatesAndVirtualBalanceLocalVars memory vars; - //TODO: check, maybe local vars can be removed - vars.totalVariableDebt = reserveCache.nextScaledVariableDebt.rayMul( + uint256 totalVariableDebt = reserveCache.nextScaledVariableDebt.rayMul( reserveCache.nextVariableBorrowIndex ); - (vars.nextLiquidityRate, vars.nextVariableRate) = IReserveInterestRateStrategy( + (uint256 nextLiquidityRate, uint256 nextVariableRate) = IReserveInterestRateStrategy( reserve.interestRateStrategyAddress ).calculateInterestRates( DataTypes.CalculateInterestRatesParams({ unbacked: reserve.unbacked, liquidityAdded: liquidityAdded, liquidityTaken: liquidityTaken, - totalDebt: vars.totalVariableDebt, + totalDebt: totalVariableDebt, reserveFactor: reserveCache.reserveFactor, reserve: reserveAddress, usingVirtualBalance: reserve.configuration.getIsVirtualAccActive(), @@ -192,8 +190,8 @@ library ReserveLogic { }) ); - reserve.currentLiquidityRate = vars.nextLiquidityRate.toUint128(); - reserve.currentVariableBorrowRate = vars.nextVariableRate.toUint128(); + reserve.currentLiquidityRate = nextLiquidityRate.toUint128(); + reserve.currentVariableBorrowRate = nextVariableRate.toUint128(); // Only affect virtual balance if the reserve uses it if (reserve.configuration.getIsVirtualAccActive()) { @@ -207,9 +205,9 @@ library ReserveLogic { emit ReserveDataUpdated( reserveAddress, - vars.nextLiquidityRate, + nextLiquidityRate, 0, - vars.nextVariableRate, + nextVariableRate, reserveCache.nextLiquidityIndex, reserveCache.nextVariableBorrowIndex ); From acd27e74a5979a0ee978356637fb9697f4464152 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 13:23:27 +0300 Subject: [PATCH 11/88] change require to not NONE in getDebtRepayAmount --- .../contracts/adapters/paraswap/ParaSwapRepayAdapter.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol b/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol index 1186ca31..80f356fa 100644 --- a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol +++ b/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol @@ -207,7 +207,7 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard { address initiator ) private view returns (uint256) { require( - DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE, + DataTypes.InterestRateMode(rateMode) != DataTypes.InterestRateMode.NONE, 'INVALID_RATE_MODE' ); DataTypes.ReserveDataLegacy memory debtReserveData = _getReserveData(address(debtAsset)); From 305834e1571996c93a41f5df8e40560bac682f08 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 26 Apr 2024 13:25:48 +0300 Subject: [PATCH 12/88] remove unused comment --- src/core/contracts/protocol/libraries/types/DataTypes.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/core/contracts/protocol/libraries/types/DataTypes.sol index f2da7116..89ebaa50 100644 --- a/src/core/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/core/contracts/protocol/libraries/types/DataTypes.sol @@ -178,7 +178,6 @@ library DataTypes { struct ExecuteRepayParams { address asset; uint256 amount; - // InterestRateMode interestRateMode; address onBehalfOf; bool useATokens; } From 1c797847cdaba013549ab182ff459873c91dfd82 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 29 Apr 2024 13:59:17 +0530 Subject: [PATCH 13/88] feat: repo refactor --- certora/applyHarness.patch | 20 +- certora/conf/NEW-pool-no-summarizations.conf | 14 +- certora/conf/NEW-pool-simple-properties.conf | 10 +- certora/harness/ATokenHarness.sol | 12 +- certora/harness/PoolHarness.sol | 12 +- .../harness/ReserveConfigurationHarness.sol | 5 +- certora/harness/SimpleERC20.sol | 4 +- certora/harness/StableDebtTokenHarness.sol | 7 +- certora/harness/SymbolicPriceOracle.sol | 3 +- certora/harness/UserConfigurationHarness.sol | 7 +- certora/harness/VariableDebtTokenHarness.sol | 6 +- .../misc/DeployAaveV3MarketBatchedBase.sol | 12 +- scripts/misc/LibraryPreCompileOne.sol | 8 +- scripts/misc/LibraryPreCompileTwo.sol | 8 +- .../chainlink/AggregatorInterface.sol | 0 .../gnosis/contracts/GPv2SafeERC20.sol | 0 .../openzeppelin/ReentrancyGuard.sol | 0 .../openzeppelin/contracts/AccessControl.sol | 0 .../openzeppelin/contracts/Address.sol | 0 .../openzeppelin/contracts/Context.sol | 0 .../openzeppelin/contracts/ECDSA.sol | 180 +++++ .../openzeppelin/contracts/ERC165.sol | 0 .../openzeppelin/contracts/ERC20.sol | 0 .../openzeppelin/contracts/IAccessControl.sol | 0 .../openzeppelin/contracts/IERC165.sol | 0 .../openzeppelin/contracts/IERC20.sol | 0 .../openzeppelin/contracts/IERC20Detailed.sol | 0 .../openzeppelin/contracts/Ownable.sol | 0 .../openzeppelin/contracts/SafeCast.sol | 0 .../openzeppelin/contracts/SafeERC20.sol | 0 .../openzeppelin/contracts/SafeMath.sol | 0 .../openzeppelin/contracts/Strings.sol | 0 .../AdminUpgradeabilityProxy.sol | 0 .../BaseAdminUpgradeabilityProxy.sol | 0 .../BaseUpgradeabilityProxy.sol | 0 .../upgradeability/Initializable.sol | 0 .../InitializableAdminUpgradeabilityProxy.sol | 0 .../InitializableUpgradeabilityProxy.sol | 0 .../openzeppelin/upgradeability/Proxy.sol | 0 .../upgradeability/UpgradeabilityProxy.sol | 0 src/contracts/dependencies/solmate/ERC20.sol | 207 +++++ .../contracts/dependencies/weth/WETH9.sol | 0 .../AaveParaSwapFeeClaimer.sol | 2 +- .../BaseParaSwapAdapter.sol | 20 +- .../BaseParaSwapBuyAdapter.sol | 10 +- .../BaseParaSwapSellAdapter.sol | 10 +- .../ParaSwapLiquiditySwapAdapter.sol | 10 +- .../ParaSwapRepayAdapter.sol | 14 +- .../ParaSwapWithdrawSwapAdapter.sol | 8 +- .../interfaces/IFeeClaimer.sol | 2 +- .../interfaces/IParaSwapAugustus.sol | 0 .../interfaces/IParaSwapAugustusRegistry.sol | 0 .../extensions/static-a-token/README.md | 38 + .../extensions/static-a-token/StataOracle.sol | 41 + .../static-a-token/StaticATokenErrors.sol | 14 + .../static-a-token/StaticATokenFactory.sol | 86 +++ .../static-a-token/StaticATokenLM.sol | 712 ++++++++++++++++++ .../static-a-token/interfaces/IAToken.sol | 16 + .../static-a-token/interfaces/IERC4626.sol | 241 ++++++ .../IInitializableStaticATokenLM.sol | 32 + .../interfaces/IStataOracle.sol | 31 + .../interfaces/IStaticATokenFactory.sol | 24 + .../interfaces/IStaticATokenLM.sol | 214 ++++++ .../v3-config-engine/AaveV3ConfigEngine.sol | 2 +- .../v3-config-engine/AaveV3Payload.sol | 4 +- .../v3-config-engine/EngineFlags.sol | 2 +- .../v3-config-engine/IAaveV3ConfigEngine.sol | 8 +- .../extensions/v3-config-engine/README.md | 62 ++ .../libraries/BorrowEngine.sol | 6 +- .../v3-config-engine/libraries/CapsEngine.sol | 2 +- .../libraries/CollateralEngine.sol | 8 +- .../libraries/EModeEngine.sol | 6 +- .../libraries/ListingEngine.sol | 6 +- .../libraries/PriceFeedEngine.sol | 4 +- .../v3-config-engine/libraries/RateEngine.sol | 6 +- .../helpers}/AaveProtocolDataProvider.sol | 0 .../misc => contracts/helpers}/L2Encoder.sol | 0 .../helpers}/UiIncentiveDataProviderV3.sol | 12 +- .../helpers}/UiPoolDataProviderV3.sol | 26 +- .../helpers}/WalletBalanceProvider.sol | 16 +- .../helpers}/WrappedTokenGatewayV3.sol | 20 +- .../interfaces/IEACAggregatorProxy.sol | 0 .../interfaces/IERC20DetailedBytes.sol | 2 +- .../interfaces/IUiIncentiveDataProviderV3.sol | 2 +- .../interfaces/IUiPoolDataProviderV3.sol | 2 +- .../helpers}/interfaces/IWETH.sol | 0 .../interfaces/IWrappedTokenGatewayV3.sol | 0 .../instances/ATokenInstance.sol | 2 +- .../instances/L2PoolInstance.sol | 4 +- .../instances/PoolConfiguratorInstance.sol | 2 +- .../instances/PoolInstance.sol | 6 +- .../instances/StableDebtTokenInstance.sol | 2 +- .../instances/VariableDebtTokenInstance.sol | 2 +- .../contracts/interfaces/IACLManager.sol | 0 .../contracts/interfaces/IAToken.sol | 0 .../interfaces/IAaveIncentivesController.sol | 0 .../contracts/interfaces/IAaveOracle.sol | 0 .../interfaces/ICreditDelegationToken.sol | 0 .../IDefaultInterestRateStrategyV2.sol | 0 .../contracts/interfaces/IDelegationToken.sol | 0 .../contracts/interfaces/IERC20WithPermit.sol | 0 .../interfaces/IInitializableAToken.sol | 0 .../interfaces/IInitializableDebtToken.sol | 0 .../contracts/interfaces/IL2Pool.sol | 0 src/{core => }/contracts/interfaces/IPool.sol | 0 .../interfaces/IPoolAddressesProvider.sol | 0 .../IPoolAddressesProviderRegistry.sol | 0 .../interfaces/IPoolConfigurator.sol | 0 .../interfaces/IPoolDataProvider.sol | 0 .../contracts/interfaces/IPriceOracle.sol | 0 .../interfaces/IPriceOracleGetter.sol | 0 .../interfaces/IPriceOracleSentinel.sol | 0 .../IReserveInterestRateStrategy.sol | 0 .../interfaces/IScaledBalanceToken.sol | 0 .../contracts/interfaces/ISequencerOracle.sol | 0 .../contracts/interfaces/IStableDebtToken.sol | 0 .../interfaces/IVariableDebtToken.sol | 0 src/{core => }/contracts/misc/AaveOracle.sol | 0 .../DefaultReserveInterestRateStrategyV2.sol | 16 +- .../misc}/PriceOracleSentinel.sol | 10 +- .../BaseImmutableAdminUpgradeabilityProxy.sol | 2 +- ...zableImmutableAdminUpgradeabilityProxy.sol | 4 +- .../VersionedInitializable.sol | 0 .../flashloan/base/FlashLoanReceiverBase.sol | 4 +- .../base/FlashLoanSimpleReceiverBase.sol | 4 +- .../interfaces/IFlashLoanReceiver.sol | 4 +- .../interfaces/IFlashLoanSimpleReceiver.sol | 4 +- .../misc}/libraries/DataTypesHelper.sol | 4 +- .../libraries/RayMathExplicitRounding.sol | 42 ++ .../contracts/mocks/ATokenMock.sol | 0 .../mocks/MockBadTransferStrategy.sol | 4 +- .../contracts/mocks/WETH9Mock.sol | 4 +- .../mocks/flashloan/MockFlashLoanReceiver.sol | 2 +- .../flashloan/MockSimpleFlashLoanReceiver.sol | 2 +- .../helpers/MockIncentivesController.sol | 0 .../contracts/mocks/helpers/MockL2Pool.sol | 4 +- .../mocks/helpers/MockPeripheryContract.sol | 0 .../contracts/mocks/helpers/MockPool.sol | 2 +- .../helpers/MockReserveConfiguration.sol | 0 .../oracle/CLAggregators/MockAggregator.sol | 0 .../contracts/mocks/oracle/PriceOracle.sol | 0 .../mocks/oracle/SequencerOracle.sol | 0 .../mocks/swap/MockParaSwapAugustus.sol | 6 +- .../swap/MockParaSwapAugustusRegistry.sol | 2 +- .../mocks/swap/MockParaSwapFeeClaimer.sol | 6 +- .../swap/MockParaSwapTokenTransferProxy.sol | 4 +- .../mocks/testnet-helpers/Faucet.sol | 2 +- .../mocks/testnet-helpers/IFaucet.sol | 0 .../mocks/testnet-helpers/TestnetERC20.sol | 6 +- .../mocks/tests/FlashloanAttacker.sol | 2 +- .../mocks/tests/MathUtilsWrapper.sol | 0 .../tests/MockReserveInterestRateStrategy.sol | 2 +- .../mocks/tests/PercentageMathWrapper.sol | 0 .../mocks/tests/WadRayMathWrapper.sol | 0 .../mocks/tokens/MintableDelegationERC20.sol | 0 .../contracts/mocks/tokens/MintableERC20.sol | 0 .../mocks/tokens/MockATokenRepayment.sol | 2 +- .../contracts/mocks/tokens/MockDebtTokens.sol | 4 +- .../mocks/tokens/MockScaledToken.sol | 5 +- .../contracts/mocks/tokens/WETH9Mocked.sol | 0 .../mocks/upgradeability/MockAToken.sol | 2 +- .../MockInitializableImplementation.sol | 2 +- .../upgradeability/MockStableDebtToken.sol | 2 +- .../upgradeability/MockVariableDebtToken.sol | 2 +- .../protocol/configuration/ACLManager.sol | 0 .../configuration/PoolAddressesProvider.sol | 2 +- .../PoolAddressesProviderRegistry.sol | 0 .../configuration/ReserveConfiguration.sol | 0 .../configuration/UserConfiguration.sol | 0 .../protocol/libraries/helpers/Errors.sol | 0 .../protocol/libraries/helpers/Helpers.sol | 0 .../protocol/libraries/logic/BorrowLogic.sol | 0 .../protocol/libraries/logic/BridgeLogic.sol | 0 .../libraries/logic/CalldataLogic.sol | 0 .../libraries/logic/ConfiguratorLogic.sol | 2 +- .../protocol/libraries/logic/EModeLogic.sol | 0 .../libraries/logic/FlashLoanLogic.sol | 4 +- .../protocol/libraries/logic/GenericLogic.sol | 0 .../libraries/logic/IsolationModeLogic.sol | 0 .../libraries/logic/LiquidationLogic.sol | 0 .../protocol/libraries/logic/PoolLogic.sol | 0 .../protocol/libraries/logic/ReserveLogic.sol | 0 .../protocol/libraries/logic/SupplyLogic.sol | 0 .../libraries/logic/ValidationLogic.sol | 0 .../protocol/libraries/math/MathUtils.sol | 0 .../libraries/math/PercentageMath.sol | 0 .../protocol/libraries/math/WadRayMath.sol | 0 .../types/ConfiguratorInputTypes.sol | 0 .../protocol/libraries/types/DataTypes.sol | 0 .../contracts/protocol/pool/L2Pool.sol | 0 .../contracts/protocol/pool/Pool.sol | 2 +- .../protocol/pool/PoolConfigurator.sol | 2 +- .../contracts/protocol/pool/PoolStorage.sol | 0 .../protocol/tokenization/AToken.sol | 2 +- .../protocol/tokenization/StableDebtToken.sol | 2 +- .../tokenization/VariableDebtToken.sol | 2 +- .../tokenization/base/DebtTokenBase.sol | 2 +- .../protocol/tokenization/base/EIP712Base.sol | 0 .../tokenization/base/IncentivizedERC20.sol | 0 .../base/MintableIncentivizedERC20.sol | 0 .../base/ScaledBalanceTokenBase.sol | 0 .../contracts/rewards/EmissionManager.sol | 4 +- .../contracts/rewards/RewardsController.sol | 8 +- .../contracts/rewards/RewardsDistributor.sol | 6 +- .../rewards/interfaces/IEmissionManager.sol | 2 +- .../IPullRewardsTransferStrategy.sol | 0 .../rewards/interfaces/IRewardsController.sol | 2 +- .../interfaces/IRewardsDistributor.sol | 0 .../rewards/interfaces/IStakedToken.sol | 0 .../IStakedTokenTransferStrategy.sol | 0 .../interfaces/ITransferStrategyBase.sol | 0 .../rewards/libraries/RewardsDataTypes.sol | 2 +- .../PullRewardsTransferStrategy.sol | 4 +- .../StakedTokenTransferStrategy.sol | 4 +- .../TransferStrategyBase.sol | 4 +- .../contracts/treasury/Collector.sol | 8 +- .../contracts/treasury/ICollector.sol | 2 +- src/core/contracts/flashloan/base/LICENSE.md | 12 - .../contracts/flashloan/interfaces/LICENSE.md | 12 - src/core/contracts/interfaces/LICENSE.md | 12 - src/core/contracts/misc/interfaces/LICENSE.md | 12 - .../AaveV3DefaultRateStrategyProcedure.sol | 2 +- .../procedures/AaveV3GettersProcedureOne.sol | 12 +- .../procedures/AaveV3GettersProcedureTwo.sol | 6 +- .../procedures/AaveV3HelpersProcedureOne.sol | 63 ++ .../procedures/AaveV3HelpersProcedureTwo.sol | 42 ++ .../procedures/AaveV3IncentiveProcedure.sol | 4 +- .../procedures/AaveV3L2PoolProcedure.sol | 6 +- .../procedures/AaveV3MiscProcedure.sol | 34 + .../procedures/AaveV3OracleProcedure.sol | 2 +- .../procedures/AaveV3ParaswapProcedure.sol | 12 +- .../procedures/AaveV3PoolConfigProcedure.sol | 8 +- .../procedures/AaveV3PoolProcedure.sol | 6 +- .../procedures/AaveV3SetupProcedure.sol | 27 +- .../procedures/AaveV3TokensProcedure.sol | 10 +- .../procedures/AaveV3TreasuryProcedure.sol | 2 +- .../contracts/utilities/MarketReportUtils.sol | 4 +- .../contracts/utilities/MetadataReporter.sol | 8 + src/deployments/interfaces/IErrors.sol | 1 + .../interfaces/IMarketReportTypes.sol | 81 +- .../AaveV3BatchOrchestration.sol | 95 ++- .../batches/AaveV3HelpersBatchOne.sol | 37 + .../batches/AaveV3HelpersBatchTwo.sol | 25 + .../batches/AaveV3MiscBatch.sol | 29 + .../batches/AaveV3PeripheryBatch.sol | 6 +- .../batches/AaveV3SetupBatch.sol | 8 +- .../AaveV3LibrariesBatch1.sol | 8 +- .../AaveV3LibrariesBatch2.sol | 8 +- src/periphery/contracts/libraries/LICENSE.md | 12 - src/periphery/contracts/misc/LICENSE.md | 12 - .../contracts/misc/interfaces/IWETH.sol | 12 - .../contracts/misc/interfaces/LICENSE.md | 12 - src/periphery/contracts/mocks/LICENSE.md | 12 - .../contracts/rewards/interfaces/LICENSE.md | 12 - .../contracts/rewards/libraries/LICENSE.md | 12 - .../rewards/transfer-strategies/LICENSE.md | 12 - tests/AaveV3BatchTests.t.sol | 158 ---- .../AaveV3BatchDeployment.t.sol | 39 +- tests/deployments/AaveV3BatchTests.t.sol | 213 ++++++ .../AaveV3PermissionsTest.t.sol | 20 +- .../DeploymentsGasLimits.t.sol | 115 ++- .../paraswap-adapters}/ParaswapAdapters.t.sol | 30 +- .../static-a-token/StataOracle.t.sol | 54 ++ .../static-a-token/StaticATokenLM.t.sol | 613 +++++++++++++++ .../StaticATokenMetaTransactions.t.sol | 251 ++++++ .../static-a-token/StaticATokenNoLM.t.sol | 51 ++ tests/extensions/static-a-token/TestBase.sol | 94 +++ .../AaveV3ConfigEngineTest.t.sol | 644 ++++++++++++++++ .../mocks/AaveV3MockAssetEModeUpdate.sol | 32 + .../mocks/AaveV3MockBorrowUpdate.sol | 38 + .../mocks/AaveV3MockBorrowUpdateNoChange.sol | 36 + .../mocks/AaveV3MockCapUpdate.sol | 33 + .../mocks/AaveV3MockCollateralUpdate.sol | 36 + .../AaveV3MockCollateralUpdateNoChange.sol | 36 + .../AaveV3MockCollateralUpdateWrongBonus.sol | 68 ++ .../mocks/AaveV3MockEModeCategoryUpdate.sol | 72 ++ .../AaveV3MockEModeCategoryUpdateNoChange.sol | 37 + .../mocks/AaveV3MockListing.sol | 56 ++ .../mocks/AaveV3MockListingCustom.sol | 74 ++ .../mocks/AaveV3MockPriceFeedUpdate.sol | 35 + .../mocks/AaveV3MockRatesUpdate.sol | 42 ++ tests/harness/StableDebtToken.sol | 2 +- tests/harness/VariableDebtToken.sol | 2 +- .../WrappedTokenGateway.t.sol | 14 +- tests/{core => misc}/AaveOracle.t.sol | 8 +- .../{core => misc}/PriceOracleSentinel.t.sol | 10 +- ...bleImmutableAdminUpgradeabilityProxy.t.sol | 6 +- tests/{core => misc/rates}/RateStrategy.t.sol | 10 +- .../{core => misc/rates}/RatesOverflow.t.sol | 10 +- .../rates}/ZeroInteresRateStrategy.t.sol | 7 +- tests/mocks/AaveV3TestListing.sol | 12 +- tests/mocks/MockFlashLoanATokenReceiver.sol | 8 +- tests/{periphery => }/mocks/StakeMock.sol | 0 .../configuration}/ACLManager.t.sol | 8 +- .../AddressesProviderRegistry.t.sol | 4 +- .../PoolAddressesProvider.t.sol | 16 +- .../libraries/logic}/BridgeLogic.t.sol | 18 +- .../logic}/PoolLogic.initReserves.edge.t.sol | 4 +- .../libraries/math}/MathUtils.t.sol | 4 +- .../libraries/math}/PercentageMath.t.sol | 4 +- .../libraries/math}/WadRayMath.t.sol | 2 +- tests/{core => protocol/pool}/L2Pool.t.sol | 20 +- .../{core => protocol/pool}/Pool.Borrow.t.sol | 30 +- .../pool}/Pool.FlashLoans.t.sol | 28 +- .../pool}/Pool.Liquidations.t.sol | 34 +- .../{core => protocol/pool}/Pool.Repay.t.sol | 26 +- .../{core => protocol/pool}/Pool.Supply.t.sol | 12 +- .../pool}/Pool.Withdraw.t.sol | 6 +- tests/{core => protocol/pool}/Pool.t.sol | 18 +- .../PoolConfigurator.ACLModifiers.t.sol | 8 +- .../PoolConfigurator.borrowCaps.t.sol | 8 +- .../PoolConfigurator.eMode.sol | 8 +- .../PoolConfigurator.initReserves.t.sol | 16 +- .../PoolConfigurator.liquidationFee.t.sol | 4 +- .../PoolConfigurator.pendingLTV.t.sol | 8 +- .../PoolConfigurator.reserveRiskConfig.t.sol | 12 +- .../PoolConfigurator.supplyCaps.t.sol | 6 +- .../PoolConfigurator.upgradeabilty.t.sol | 52 +- .../tokenization}/ATokenEdgeCases.t.sol | 8 +- .../tokenization}/ATokenEvents.t.sol | 12 +- .../tokenization}/ATokenModifiers.t.sol | 6 +- .../tokenization}/ATokenPermit.t.sol | 8 +- .../tokenization}/ATokenRepay.t.sol | 8 +- .../tokenization}/ATokenRescueTokens.sol | 6 +- .../tokenization}/ATokenTransfers.t.sol | 16 +- .../ScaledBalanceTokenBase.t.sol | 7 +- .../tokenization}/StableDebtToken.t.sol | 14 +- .../tokenization}/VariableDebtToken.t.sol | 18 +- .../EmissionsManager.t.sol | 19 +- .../RewardsController.t.sol | 19 +- .../StakedTokenTransferStrategy.t.sol | 4 +- tests/utils/BatchTestProcedures.sol | 63 +- tests/utils/ConfigEngineDeployer.sol | 60 -- tests/utils/ProtocolV3TestBase.sol | 36 +- tests/utils/SigUtils.sol | 117 +++ tests/utils/TestnetProcedures.sol | 34 +- 336 files changed, 5820 insertions(+), 1128 deletions(-) rename src/{core => }/contracts/dependencies/chainlink/AggregatorInterface.sol (100%) rename src/{core => }/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol (100%) rename src/{periphery => }/contracts/dependencies/openzeppelin/ReentrancyGuard.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/AccessControl.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/Address.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/Context.sol (100%) create mode 100644 src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol rename src/{core => }/contracts/dependencies/openzeppelin/contracts/ERC165.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/ERC20.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/IERC165.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/IERC20.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/Ownable.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/SafeCast.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/SafeMath.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/contracts/Strings.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol (100%) rename src/{core => }/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol (100%) create mode 100644 src/contracts/dependencies/solmate/ERC20.sol rename src/{core => }/contracts/dependencies/weth/WETH9.sol (100%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/AaveParaSwapFeeClaimer.sol (95%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/BaseParaSwapAdapter.sol (79%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/BaseParaSwapBuyAdapter.sol (89%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/BaseParaSwapSellAdapter.sol (89%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/ParaSwapLiquiditySwapAdapter.sol (94%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/ParaSwapRepayAdapter.sol (92%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/ParaSwapWithdrawSwapAdapter.sol (87%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/interfaces/IFeeClaimer.sol (97%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/interfaces/IParaSwapAugustus.sol (100%) rename src/{periphery/contracts/adapters/paraswap => contracts/extensions/paraswap-adapters}/interfaces/IParaSwapAugustusRegistry.sol (100%) create mode 100644 src/contracts/extensions/static-a-token/README.md create mode 100644 src/contracts/extensions/static-a-token/StataOracle.sol create mode 100644 src/contracts/extensions/static-a-token/StaticATokenErrors.sol create mode 100644 src/contracts/extensions/static-a-token/StaticATokenFactory.sol create mode 100644 src/contracts/extensions/static-a-token/StaticATokenLM.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IAToken.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IERC4626.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol create mode 100644 src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/AaveV3ConfigEngine.sol (99%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/AaveV3Payload.sol (98%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/EngineFlags.sol (97%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/IAaveV3ConfigEngine.sol (97%) create mode 100644 src/contracts/extensions/v3-config-engine/README.md rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/BorrowEngine.sol (91%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/CapsEngine.sol (96%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/CollateralEngine.sol (91%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/EModeEngine.sol (94%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/ListingEngine.sol (96%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/PriceFeedEngine.sol (88%) rename src/{periphery/contracts => contracts/extensions}/v3-config-engine/libraries/RateEngine.sol (93%) rename src/{core/contracts/misc => contracts/helpers}/AaveProtocolDataProvider.sol (100%) rename src/{core/contracts/misc => contracts/helpers}/L2Encoder.sol (100%) rename src/{periphery/contracts/misc => contracts/helpers}/UiIncentiveDataProviderV3.sol (96%) rename src/{periphery/contracts/misc => contracts/helpers}/UiPoolDataProviderV3.sol (89%) rename src/{periphery/contracts/misc => contracts/helpers}/WalletBalanceProvider.sol (83%) rename src/{periphery/contracts/misc => contracts/helpers}/WrappedTokenGatewayV3.sol (89%) rename src/{periphery/contracts/misc => contracts/helpers}/interfaces/IEACAggregatorProxy.sol (100%) rename src/{periphery/contracts/misc => contracts/helpers}/interfaces/IERC20DetailedBytes.sol (73%) rename src/{periphery/contracts/misc => contracts/helpers}/interfaces/IUiIncentiveDataProviderV3.sol (95%) rename src/{periphery/contracts/misc => contracts/helpers}/interfaces/IUiPoolDataProviderV3.sol (96%) rename src/{core/contracts/misc => contracts/helpers}/interfaces/IWETH.sol (100%) rename src/{periphery/contracts/misc => contracts/helpers}/interfaces/IWrappedTokenGatewayV3.sol (100%) rename src/{core => contracts}/instances/ATokenInstance.sol (93%) rename src/{core => contracts}/instances/L2PoolInstance.sol (60%) rename src/{core => contracts}/instances/PoolConfiguratorInstance.sol (87%) rename src/{core => contracts}/instances/PoolInstance.sol (80%) rename src/{core => contracts}/instances/StableDebtTokenInstance.sol (91%) rename src/{core => contracts}/instances/VariableDebtTokenInstance.sol (91%) rename src/{core => }/contracts/interfaces/IACLManager.sol (100%) rename src/{core => }/contracts/interfaces/IAToken.sol (100%) rename src/{core => }/contracts/interfaces/IAaveIncentivesController.sol (100%) rename src/{core => }/contracts/interfaces/IAaveOracle.sol (100%) rename src/{core => }/contracts/interfaces/ICreditDelegationToken.sol (100%) rename src/{core => }/contracts/interfaces/IDefaultInterestRateStrategyV2.sol (100%) rename src/{core => }/contracts/interfaces/IDelegationToken.sol (100%) rename src/{core => }/contracts/interfaces/IERC20WithPermit.sol (100%) rename src/{core => }/contracts/interfaces/IInitializableAToken.sol (100%) rename src/{core => }/contracts/interfaces/IInitializableDebtToken.sol (100%) rename src/{core => }/contracts/interfaces/IL2Pool.sol (100%) rename src/{core => }/contracts/interfaces/IPool.sol (100%) rename src/{core => }/contracts/interfaces/IPoolAddressesProvider.sol (100%) rename src/{core => }/contracts/interfaces/IPoolAddressesProviderRegistry.sol (100%) rename src/{core => }/contracts/interfaces/IPoolConfigurator.sol (100%) rename src/{core => }/contracts/interfaces/IPoolDataProvider.sol (100%) rename src/{core => }/contracts/interfaces/IPriceOracle.sol (100%) rename src/{core => }/contracts/interfaces/IPriceOracleGetter.sol (100%) rename src/{core => }/contracts/interfaces/IPriceOracleSentinel.sol (100%) rename src/{core => }/contracts/interfaces/IReserveInterestRateStrategy.sol (100%) rename src/{core => }/contracts/interfaces/IScaledBalanceToken.sol (100%) rename src/{core => }/contracts/interfaces/ISequencerOracle.sol (100%) rename src/{core => }/contracts/interfaces/IStableDebtToken.sol (100%) rename src/{core => }/contracts/interfaces/IVariableDebtToken.sol (100%) rename src/{core => }/contracts/misc/AaveOracle.sol (100%) rename src/{core/contracts/protocol/pool => contracts/misc}/DefaultReserveInterestRateStrategyV2.sol (93%) rename src/{core/contracts/protocol/configuration => contracts/misc}/PriceOracleSentinel.sol (89%) rename src/{core/contracts/protocol/libraries => contracts/misc}/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol (95%) rename src/{core/contracts/protocol/libraries => contracts/misc}/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol (79%) rename src/{core/contracts/protocol/libraries => contracts/misc}/aave-upgradeability/VersionedInitializable.sol (100%) rename src/{core/contracts => contracts/misc}/flashloan/base/FlashLoanReceiverBase.sol (79%) rename src/{core/contracts => contracts/misc}/flashloan/base/FlashLoanSimpleReceiverBase.sol (80%) rename src/{core/contracts => contracts/misc}/flashloan/interfaces/IFlashLoanReceiver.sol (90%) rename src/{core/contracts => contracts/misc}/flashloan/interfaces/IFlashLoanSimpleReceiver.sol (89%) rename src/{periphery/contracts => contracts/misc}/libraries/DataTypesHelper.sol (80%) create mode 100644 src/contracts/misc/libraries/RayMathExplicitRounding.sol rename src/{periphery => }/contracts/mocks/ATokenMock.sol (100%) rename src/{periphery => }/contracts/mocks/MockBadTransferStrategy.sol (82%) rename src/{periphery => }/contracts/mocks/WETH9Mock.sol (72%) rename src/{core => }/contracts/mocks/flashloan/MockFlashLoanReceiver.sol (96%) rename src/{core => }/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol (95%) rename src/{core => }/contracts/mocks/helpers/MockIncentivesController.sol (100%) rename src/{core => }/contracts/mocks/helpers/MockL2Pool.sol (68%) rename src/{core => }/contracts/mocks/helpers/MockPeripheryContract.sol (100%) rename src/{core => }/contracts/mocks/helpers/MockPool.sol (92%) rename src/{core => }/contracts/mocks/helpers/MockReserveConfiguration.sol (100%) rename src/{core => }/contracts/mocks/oracle/CLAggregators/MockAggregator.sol (100%) rename src/{core => }/contracts/mocks/oracle/PriceOracle.sol (100%) rename src/{core => }/contracts/mocks/oracle/SequencerOracle.sol (100%) rename src/{periphery => }/contracts/mocks/swap/MockParaSwapAugustus.sol (91%) rename src/{periphery => }/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol (74%) rename src/{periphery => }/contracts/mocks/swap/MockParaSwapFeeClaimer.sol (88%) rename src/{periphery => }/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol (60%) rename src/{periphery => }/contracts/mocks/testnet-helpers/Faucet.sol (95%) rename src/{periphery => }/contracts/mocks/testnet-helpers/IFaucet.sol (100%) rename src/{periphery => }/contracts/mocks/testnet-helpers/TestnetERC20.sol (90%) rename src/{core => }/contracts/mocks/tests/FlashloanAttacker.sol (95%) rename src/{core => }/contracts/mocks/tests/MathUtilsWrapper.sol (100%) rename src/{core => }/contracts/mocks/tests/MockReserveInterestRateStrategy.sol (88%) rename src/{core => }/contracts/mocks/tests/PercentageMathWrapper.sol (100%) rename src/{core => }/contracts/mocks/tests/WadRayMathWrapper.sol (100%) rename src/{core => }/contracts/mocks/tokens/MintableDelegationERC20.sol (100%) rename src/{core => }/contracts/mocks/tokens/MintableERC20.sol (100%) rename src/{core => }/contracts/mocks/tokens/MockATokenRepayment.sol (88%) rename src/{core => }/contracts/mocks/tokens/MockDebtTokens.sol (74%) rename src/{core => }/contracts/mocks/tokens/MockScaledToken.sol (85%) rename src/{core => }/contracts/mocks/tokens/WETH9Mocked.sol (100%) rename src/{core => }/contracts/mocks/upgradeability/MockAToken.sol (80%) rename src/{core => }/contracts/mocks/upgradeability/MockInitializableImplementation.sol (96%) rename src/{core => }/contracts/mocks/upgradeability/MockStableDebtToken.sol (78%) rename src/{core => }/contracts/mocks/upgradeability/MockVariableDebtToken.sol (77%) rename src/{core => }/contracts/protocol/configuration/ACLManager.sol (100%) rename src/{core => }/contracts/protocol/configuration/PoolAddressesProvider.sol (98%) rename src/{core => }/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol (100%) rename src/{core => }/contracts/protocol/libraries/configuration/ReserveConfiguration.sol (100%) rename src/{core => }/contracts/protocol/libraries/configuration/UserConfiguration.sol (100%) rename src/{core => }/contracts/protocol/libraries/helpers/Errors.sol (100%) rename src/{core => }/contracts/protocol/libraries/helpers/Helpers.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/BorrowLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/BridgeLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/CalldataLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/ConfiguratorLogic.sol (99%) rename src/{core => }/contracts/protocol/libraries/logic/EModeLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/FlashLoanLogic.sol (98%) rename src/{core => }/contracts/protocol/libraries/logic/GenericLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/IsolationModeLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/LiquidationLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/PoolLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/ReserveLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/SupplyLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/logic/ValidationLogic.sol (100%) rename src/{core => }/contracts/protocol/libraries/math/MathUtils.sol (100%) rename src/{core => }/contracts/protocol/libraries/math/PercentageMath.sol (100%) rename src/{core => }/contracts/protocol/libraries/math/WadRayMath.sol (100%) rename src/{core => }/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol (100%) rename src/{core => }/contracts/protocol/libraries/types/DataTypes.sol (100%) rename src/{core => }/contracts/protocol/pool/L2Pool.sol (100%) rename src/{core => }/contracts/protocol/pool/Pool.sol (99%) rename src/{core => }/contracts/protocol/pool/PoolConfigurator.sol (99%) rename src/{core => }/contracts/protocol/pool/PoolStorage.sol (100%) rename src/{core => }/contracts/protocol/tokenization/AToken.sol (98%) rename src/{core => }/contracts/protocol/tokenization/StableDebtToken.sol (97%) rename src/{core => }/contracts/protocol/tokenization/VariableDebtToken.sol (97%) rename src/{core => }/contracts/protocol/tokenization/base/DebtTokenBase.sol (97%) rename src/{core => }/contracts/protocol/tokenization/base/EIP712Base.sol (100%) rename src/{core => }/contracts/protocol/tokenization/base/IncentivizedERC20.sol (100%) rename src/{core => }/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol (100%) rename src/{core => }/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol (100%) rename src/{periphery => }/contracts/rewards/EmissionManager.sol (95%) rename src/{periphery => }/contracts/rewards/RewardsController.sol (96%) rename src/{periphery => }/contracts/rewards/RewardsDistributor.sol (98%) rename src/{periphery => }/contracts/rewards/interfaces/IEmissionManager.sol (98%) rename src/{periphery => }/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol (100%) rename src/{periphery => }/contracts/rewards/interfaces/IRewardsController.sol (99%) rename src/{periphery => }/contracts/rewards/interfaces/IRewardsDistributor.sol (100%) rename src/{periphery => }/contracts/rewards/interfaces/IStakedToken.sol (100%) rename src/{periphery => }/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol (100%) rename src/{periphery => }/contracts/rewards/interfaces/ITransferStrategyBase.sol (100%) rename src/{periphery => }/contracts/rewards/libraries/RewardsDataTypes.sol (94%) rename src/{periphery => }/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol (88%) rename src/{periphery => }/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol (92%) rename src/{periphery => }/contracts/rewards/transfer-strategies/TransferStrategyBase.sol (89%) rename src/{periphery => }/contracts/treasury/Collector.sol (96%) rename src/{periphery => }/contracts/treasury/ICollector.sol (98%) delete mode 100644 src/core/contracts/flashloan/base/LICENSE.md delete mode 100644 src/core/contracts/flashloan/interfaces/LICENSE.md delete mode 100644 src/core/contracts/interfaces/LICENSE.md delete mode 100644 src/core/contracts/misc/interfaces/LICENSE.md create mode 100644 src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol create mode 100644 src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol create mode 100644 src/deployments/contracts/procedures/AaveV3MiscProcedure.sol create mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol create mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol create mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol delete mode 100644 src/periphery/contracts/libraries/LICENSE.md delete mode 100644 src/periphery/contracts/misc/LICENSE.md delete mode 100644 src/periphery/contracts/misc/interfaces/IWETH.sol delete mode 100644 src/periphery/contracts/misc/interfaces/LICENSE.md delete mode 100644 src/periphery/contracts/mocks/LICENSE.md delete mode 100644 src/periphery/contracts/rewards/interfaces/LICENSE.md delete mode 100644 src/periphery/contracts/rewards/libraries/LICENSE.md delete mode 100644 src/periphery/contracts/rewards/transfer-strategies/LICENSE.md delete mode 100644 tests/AaveV3BatchTests.t.sol rename tests/{ => deployments}/AaveV3BatchDeployment.t.sol (62%) create mode 100644 tests/deployments/AaveV3BatchTests.t.sol rename tests/{ => deployments}/AaveV3PermissionsTest.t.sol (86%) rename tests/{ => deployments}/DeploymentsGasLimits.t.sol (54%) rename tests/{periphery => extensions/paraswap-adapters}/ParaswapAdapters.t.sol (95%) create mode 100644 tests/extensions/static-a-token/StataOracle.t.sol create mode 100644 tests/extensions/static-a-token/StaticATokenLM.t.sol create mode 100644 tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol create mode 100644 tests/extensions/static-a-token/StaticATokenNoLM.t.sol create mode 100644 tests/extensions/static-a-token/TestBase.sol create mode 100644 tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol create mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol rename tests/{periphery => helpers}/WrappedTokenGateway.t.sol (95%) rename tests/{core => misc}/AaveOracle.t.sol (95%) rename tests/{core => misc}/PriceOracleSentinel.t.sol (89%) rename tests/{core => misc/aave-upgradeability}/InitializableImmutableAdminUpgradeabilityProxy.t.sol (96%) rename tests/{core => misc/rates}/RateStrategy.t.sol (99%) rename tests/{core => misc/rates}/RatesOverflow.t.sol (83%) rename tests/{core => misc/rates}/ZeroInteresRateStrategy.t.sol (86%) rename tests/{periphery => }/mocks/StakeMock.sol (100%) rename tests/{core => protocol/configuration}/ACLManager.t.sol (96%) rename tests/{core => protocol/configuration}/AddressesProviderRegistry.t.sol (97%) rename tests/{core => protocol/configuration}/PoolAddressesProvider.t.sol (95%) rename tests/{core => protocol/libraries/logic}/BridgeLogic.t.sol (92%) rename tests/{core => protocol/libraries/logic}/PoolLogic.initReserves.edge.t.sol (94%) rename tests/{core => protocol/libraries/math}/MathUtils.t.sol (88%) rename tests/{core => protocol/libraries/math}/PercentageMath.t.sol (89%) rename tests/{core => protocol/libraries/math}/WadRayMath.t.sol (97%) rename tests/{core => protocol/pool}/L2Pool.t.sol (92%) rename tests/{core => protocol/pool}/Pool.Borrow.t.sol (95%) rename tests/{core => protocol/pool}/Pool.FlashLoans.t.sol (92%) rename tests/{core => protocol/pool}/Pool.Liquidations.t.sol (96%) rename tests/{core => protocol/pool}/Pool.Repay.t.sol (95%) rename tests/{core => protocol/pool}/Pool.Supply.t.sol (95%) rename tests/{core => protocol/pool}/Pool.Withdraw.t.sol (97%) rename tests/{core => protocol/pool}/Pool.t.sol (97%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.ACLModifiers.t.sol (97%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.borrowCaps.t.sol (93%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.eMode.sol (96%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.initReserves.t.sol (94%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.liquidationFee.t.sol (94%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.pendingLTV.t.sol (92%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.reserveRiskConfig.t.sol (98%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.supplyCaps.t.sol (94%) rename tests/{core => protocol/pool/pool-configurator}/PoolConfigurator.upgradeabilty.t.sol (81%) rename tests/{core => protocol/tokenization}/ATokenEdgeCases.t.sol (95%) rename tests/{core => protocol/tokenization}/ATokenEvents.t.sol (96%) rename tests/{core => protocol/tokenization}/ATokenModifiers.t.sol (85%) rename tests/{core => protocol/tokenization}/ATokenPermit.t.sol (96%) rename tests/{core => protocol/tokenization}/ATokenRepay.t.sol (91%) rename tests/{core => protocol/tokenization}/ATokenRescueTokens.sol (90%) rename tests/{core => protocol/tokenization}/ATokenTransfers.t.sol (95%) rename tests/{core => protocol/tokenization}/ScaledBalanceTokenBase.t.sol (94%) rename tests/{core => protocol/tokenization}/StableDebtToken.t.sol (96%) rename tests/{core => protocol/tokenization}/VariableDebtToken.t.sol (96%) rename tests/{periphery => rewards}/EmissionsManager.t.sol (76%) rename tests/{periphery => rewards}/RewardsController.t.sol (94%) rename tests/{periphery => rewards}/StakedTokenTransferStrategy.t.sol (94%) delete mode 100644 tests/utils/ConfigEngineDeployer.sol create mode 100644 tests/utils/SigUtils.sol diff --git a/certora/applyHarness.patch b/certora/applyHarness.patch index 62c1705e..06b4e1ca 100644 --- a/certora/applyHarness.patch +++ b/certora/applyHarness.patch @@ -1,22 +1,22 @@ -diff -ruN core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol ---- core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-27 12:57:15.497294747 +0200 -+++ core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-27 13:08:22.155984803 +0200 +diff -ruN contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol +--- contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-27 12:57:15.497294747 +0200 ++++ contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-27 13:08:22.155984803 +0200 @@ -34,7 +34,7 @@ } - + /// @inheritdoc IScaledBalanceToken - function scaledBalanceOf(address user) external view override returns (uint256) { + function scaledBalanceOf(address user) public view override returns (uint256) { return super.balanceOf(user); } - -diff -ruN core/instances/ATokenInstance.sol core/instances/ATokenInstance.sol ---- core/instances/ATokenInstance.sol 2024-03-27 12:57:15.497294747 +0200 -+++ core/instances/ATokenInstance.sol 2024-03-27 13:14:17.971198372 +0200 + +diff -ruN contracts/instances/ATokenInstance.sol contracts/instances/ATokenInstance.sol +--- contracts/instances/ATokenInstance.sol 2024-03-27 12:57:15.497294747 +0200 ++++ contracts/instances/ATokenInstance.sol 2024-03-27 13:14:17.971198372 +0200 @@ -35,15 +35,15 @@ - + _domainSeparator = _calculateDomainSeparator(); - + - emit Initialized( - underlyingAsset, - address(POOL), diff --git a/certora/conf/NEW-pool-no-summarizations.conf b/certora/conf/NEW-pool-no-summarizations.conf index 11f62350..cd2365aa 100644 --- a/certora/conf/NEW-pool-no-summarizations.conf +++ b/certora/conf/NEW-pool-no-summarizations.conf @@ -4,13 +4,13 @@ "certora/harness/PoolHarness.sol", "certora/harness/StableDebtTokenHarness.sol", "certora/harness/SimpleERC20.sol", - "src/core/instances/VariableDebtTokenInstance.sol", - "src/core/contracts/misc/AaveProtocolDataProvider.sol", - "src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol", - "src/core/contracts/protocol/configuration/ACLManager.sol", - "src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol", - "src/core/contracts/protocol/configuration/PriceOracleSentinel.sol", - "src/core/contracts/protocol/configuration/PoolAddressesProvider.sol", + "src/contracts/instances/VariableDebtTokenInstance.sol", + "src/contracts/helpers/AaveProtocolDataProvider.sol", + "src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol", + "src/contracts/protocol/configuration/ACLManager.sol", + "src/contracts/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol", + "src/contracts/misc/PriceOracleSentinel.sol", + "src/contracts/protocol/configuration/PoolAddressesProvider.sol", ], "link": [ "ATokenHarness:POOL=PoolHarness", diff --git a/certora/conf/NEW-pool-simple-properties.conf b/certora/conf/NEW-pool-simple-properties.conf index 96a78c78..e5606325 100644 --- a/certora/conf/NEW-pool-simple-properties.conf +++ b/certora/conf/NEW-pool-simple-properties.conf @@ -4,11 +4,11 @@ "certora/harness/PoolHarness.sol", "certora/harness/StableDebtTokenHarness.sol", "certora/harness/SimpleERC20.sol", - "src/core/instances/VariableDebtTokenInstance.sol", - "src/core/contracts/misc/AaveProtocolDataProvider.sol", - "src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol", - "src/core/contracts/protocol/libraries/types/DataTypes.sol", - "src/core/contracts/protocol/configuration/PoolAddressesProvider.sol", + "src/contracts/instances/VariableDebtTokenInstance.sol", + "src/contracts/helpers/AaveProtocolDataProvider.sol", + "src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol", + "src/contracts/protocol/libraries/types/DataTypes.sol", + "src/contracts/protocol/configuration/PoolAddressesProvider.sol", ], "link": [ "ATokenHarness:POOL=PoolHarness", diff --git a/certora/harness/ATokenHarness.sol b/certora/harness/ATokenHarness.sol index cc23245c..bcb5d32a 100644 --- a/certora/harness/ATokenHarness.sol +++ b/certora/harness/ATokenHarness.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.19; -import {Pool} from '../munged/core/contracts/protocol/pool/Pool.sol'; -import {ATokenInstance} from '../munged/core/instances/ATokenInstance.sol'; -import {WadRayMath} from '../munged/core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {ScaledBalanceTokenBase} from '../munged/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol'; -import {IScaledBalanceToken} from '../munged/core/contracts/interfaces/IScaledBalanceToken.sol'; +import {Pool} from '../munged/contracts/protocol/pool/Pool.sol'; +import {ATokenInstance} from '../munged/contracts/instances/ATokenInstance.sol'; +import {WadRayMath} from '../munged/contracts/protocol/libraries/math/WadRayMath.sol'; +import {ScaledBalanceTokenBase} from '../munged/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol'; +import {IScaledBalanceToken} from '../munged/contracts/interfaces/IScaledBalanceToken.sol'; -/** +/* * @title Certora harness for Aave ERC20 AToken * * @dev Certora's harness contract for the verification of Aave ERC20 AToken. diff --git a/certora/harness/PoolHarness.sol b/certora/harness/PoolHarness.sol index 70deadf9..a914b868 100644 --- a/certora/harness/PoolHarness.sol +++ b/certora/harness/PoolHarness.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; -import {PoolInstance} from '../munged/core/instances/PoolInstance.sol'; -import {DataTypes} from '../munged/core/contracts/protocol/libraries/types/DataTypes.sol'; -import {ReserveLogic} from '../munged/core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import {IPoolAddressesProvider} from '../munged/core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {PoolInstance} from '../munged/contracts/instances/PoolInstance.sol'; +import {DataTypes} from '../munged/contracts/protocol/libraries/types/DataTypes.sol'; +import {ReserveLogic} from '../munged/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import {IPoolAddressesProvider} from '../munged/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IERC20} from '../../src/core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {ReserveConfiguration} from '../munged/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IERC20} from '../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {ReserveConfiguration} from '../munged/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; contract PoolHarness is PoolInstance { using ReserveLogic for DataTypes.ReserveData; diff --git a/certora/harness/ReserveConfigurationHarness.sol b/certora/harness/ReserveConfigurationHarness.sol index d4edade2..c4c35d96 100644 --- a/certora/harness/ReserveConfigurationHarness.sol +++ b/certora/harness/ReserveConfigurationHarness.sol @@ -1,8 +1,9 @@ +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; pragma experimental ABIEncoderV2; -import {ReserveConfiguration} from '../munged/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {DataTypes} from '../munged/core/contracts/protocol/libraries/types/DataTypes.sol'; +import {ReserveConfiguration} from '../munged/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {DataTypes} from '../munged/contracts/protocol/libraries/types/DataTypes.sol'; contract ReserveConfigurationHarness { DataTypes.ReserveConfigurationMap public reservesConfig; diff --git a/certora/harness/SimpleERC20.sol b/certora/harness/SimpleERC20.sol index 81d12bad..68733603 100644 --- a/certora/harness/SimpleERC20.sol +++ b/certora/harness/SimpleERC20.sol @@ -1,7 +1,7 @@ -// SPDX-License-Identifier: agpl-3.0 +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; -import {IERC20} from '../munged/core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../munged/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; /** A simple ERC implementation used as the underlying_asset for the verification process. diff --git a/certora/harness/StableDebtTokenHarness.sol b/certora/harness/StableDebtTokenHarness.sol index 99ce3355..8702fe24 100644 --- a/certora/harness/StableDebtTokenHarness.sol +++ b/certora/harness/StableDebtTokenHarness.sol @@ -1,8 +1,9 @@ +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; -import {StableDebtTokenInstance} from '../munged/core/instances/StableDebtTokenInstance.sol'; -import {IncentivizedERC20} from '../munged/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol'; -import {IPool} from '../munged/core/contracts/interfaces/IPool.sol'; +import {StableDebtTokenInstance} from '../munged/contracts/instances/StableDebtTokenInstance.sol'; +import {IncentivizedERC20} from '../munged/contracts/protocol/tokenization/base/IncentivizedERC20.sol'; +import {IPool} from '../munged/contracts/interfaces/IPool.sol'; contract StableDebtTokenHarness is StableDebtTokenInstance { constructor(IPool pool) public StableDebtTokenInstance(pool) {} diff --git a/certora/harness/SymbolicPriceOracle.sol b/certora/harness/SymbolicPriceOracle.sol index b90e21dd..d268e5d0 100644 --- a/certora/harness/SymbolicPriceOracle.sol +++ b/certora/harness/SymbolicPriceOracle.sol @@ -1,6 +1,7 @@ +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; -import {IPriceOracleGetter} from '../munged/interfaces/IPriceOracleGetter.sol'; +import {IPriceOracleGetter} from '../munged/contracts/interfaces/IPriceOracleGetter.sol'; contract SymbolicPriceOracle is IPriceOracleGetter { address public base; diff --git a/certora/harness/UserConfigurationHarness.sol b/certora/harness/UserConfigurationHarness.sol index 4c82a29b..3f1637ea 100644 --- a/certora/harness/UserConfigurationHarness.sol +++ b/certora/harness/UserConfigurationHarness.sol @@ -1,9 +1,10 @@ +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; pragma experimental ABIEncoderV2; -import {UserConfiguration} from '../munged/core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {DataTypes} from '../munged/core/contracts/protocol/libraries/types/DataTypes.sol'; -import {PoolStorage} from '../munged/core/contracts/protocol/pool/PoolStorage.sol'; +import {UserConfiguration} from '../munged/contracts/protocol/libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../munged/contracts/protocol/libraries/types/DataTypes.sol'; +import {PoolStorage} from '../munged/contracts/protocol/pool/PoolStorage.sol'; /* A wrapper contract for calling functions from the library UserConfiguration. diff --git a/certora/harness/VariableDebtTokenHarness.sol b/certora/harness/VariableDebtTokenHarness.sol index 33da454f..ca2696a6 100644 --- a/certora/harness/VariableDebtTokenHarness.sol +++ b/certora/harness/VariableDebtTokenHarness.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; -import {VariableDebtTokenInstance} from '../munged/core/instances/VariableDebtTokenInstance.sol'; -import {WadRayMath} from '../munged/core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {IPool} from '../munged/core/contracts/interfaces/IPool.sol'; +import {VariableDebtTokenInstance} from '../munged/contracts/instances/VariableDebtTokenInstance.sol'; +import {WadRayMath} from '../munged/contracts/protocol/libraries/math/WadRayMath.sol'; +import {IPool} from '../munged/contracts/interfaces/IPool.sol'; contract VariableDebtTokenHarness is VariableDebtTokenInstance { using WadRayMath for uint256; diff --git a/scripts/misc/DeployAaveV3MarketBatchedBase.sol b/scripts/misc/DeployAaveV3MarketBatchedBase.sol index e6fddd33..961b0f38 100644 --- a/scripts/misc/DeployAaveV3MarketBatchedBase.sol +++ b/scripts/misc/DeployAaveV3MarketBatchedBase.sol @@ -25,7 +25,7 @@ abstract contract DeployAaveV3MarketBatchedBase is DeployUtils, MarketInput, Scr (roles, config, flags, report) = _getMarketInput(msg.sender); - _loadWarnings(config); + _loadWarnings(config, flags); vm.startBroadcast(); report = AaveV3BatchOrchestration.deployAaveV3(msg.sender, roles, config, flags, report); @@ -38,12 +38,20 @@ abstract contract DeployAaveV3MarketBatchedBase is DeployUtils, MarketInput, Scr metadataReporter.writeJsonReportMarket(report); } - function _loadWarnings(MarketConfig memory config) internal view { + function _loadWarnings(MarketConfig memory config, DeployFlags memory flags) internal view { if (config.paraswapAugustusRegistry == address(0)) { console.log( 'Warning: Paraswap Adapters will be skipped at deployment due missing config.paraswapAugustusRegistry' ); } + if ( + (flags.l2 && + (config.l2SequencerUptimeFeed == address(0) || config.l2PriceOracleSentinelGracePeriod == 0)) + ) { + console.log( + 'Warning: L2 Sequencer uptime feed wont be set at deployment due missing config.l2SequencerUptimeFeed config.l2PriceOracleSentinelGracePeriod' + ); + } if ( config.networkBaseTokenPriceInUsdProxyAggregator == address(0) || config.marketReferenceCurrencyPriceInUsdProxyAggregator == address(0) diff --git a/scripts/misc/LibraryPreCompileOne.sol b/scripts/misc/LibraryPreCompileOne.sol index 502b5cdf..746a7920 100644 --- a/scripts/misc/LibraryPreCompileOne.sol +++ b/scripts/misc/LibraryPreCompileOne.sol @@ -71,16 +71,16 @@ contract LibraryPreCompileOne is FfiUtils, Script, DeployUtils { return string( abi.encodePacked( - 'aave-v3-core/contracts/protocol/libraries/logic/BorrowLogic.sol:BorrowLogic:', + 'src/contracts/protocol/libraries/logic/BorrowLogic.sol:BorrowLogic:', vm.toString(report.borrowLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/BridgeLogic.sol:BridgeLogic:', + 'src/contracts/protocol/libraries/logic/BridgeLogic.sol:BridgeLogic:', vm.toString(report.bridgeLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol:ConfiguratorLogic:', + 'src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol:ConfiguratorLogic:', vm.toString(report.configuratorLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/EModeLogic.sol:EModeLogic:', + 'src/contracts/protocol/libraries/logic/EModeLogic.sol:EModeLogic:', vm.toString(report.eModeLogic) ) ); diff --git a/scripts/misc/LibraryPreCompileTwo.sol b/scripts/misc/LibraryPreCompileTwo.sol index cab49cec..9b381a66 100644 --- a/scripts/misc/LibraryPreCompileTwo.sol +++ b/scripts/misc/LibraryPreCompileTwo.sol @@ -71,16 +71,16 @@ contract LibraryPreCompileTwo is FfiUtils, Script, DeployUtils { string( abi.encodePacked( ',', - 'aave-v3-core/contracts/protocol/libraries/logic/FlashLoanLogic.sol:FlashLoanLogic:', + 'src/contracts/protocol/libraries/logic/FlashLoanLogic.sol:FlashLoanLogic:', vm.toString(report.flashLoanLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/LiquidationLogic.sol:LiquidationLogic:', + 'src/contracts/protocol/libraries/logic/LiquidationLogic.sol:LiquidationLogic:', vm.toString(report.liquidationLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/PoolLogic.sol:PoolLogic:', + 'src/contracts/protocol/libraries/logic/PoolLogic.sol:PoolLogic:', vm.toString(report.poolLogic), ',', - 'aave-v3-core/contracts/protocol/libraries/logic/SupplyLogic.sol:SupplyLogic:', + 'src/contracts/protocol/libraries/logic/SupplyLogic.sol:SupplyLogic:', vm.toString(report.supplyLogic) ) ); diff --git a/src/core/contracts/dependencies/chainlink/AggregatorInterface.sol b/src/contracts/dependencies/chainlink/AggregatorInterface.sol similarity index 100% rename from src/core/contracts/dependencies/chainlink/AggregatorInterface.sol rename to src/contracts/dependencies/chainlink/AggregatorInterface.sol diff --git a/src/core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol b/src/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol similarity index 100% rename from src/core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol rename to src/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol diff --git a/src/periphery/contracts/dependencies/openzeppelin/ReentrancyGuard.sol b/src/contracts/dependencies/openzeppelin/ReentrancyGuard.sol similarity index 100% rename from src/periphery/contracts/dependencies/openzeppelin/ReentrancyGuard.sol rename to src/contracts/dependencies/openzeppelin/ReentrancyGuard.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/AccessControl.sol b/src/contracts/dependencies/openzeppelin/contracts/AccessControl.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/AccessControl.sol rename to src/contracts/dependencies/openzeppelin/contracts/AccessControl.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/Address.sol b/src/contracts/dependencies/openzeppelin/contracts/Address.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/Address.sol rename to src/contracts/dependencies/openzeppelin/contracts/Address.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/Context.sol b/src/contracts/dependencies/openzeppelin/contracts/Context.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/Context.sol rename to src/contracts/dependencies/openzeppelin/contracts/Context.sol diff --git a/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol b/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol new file mode 100644 index 00000000..e58805c6 --- /dev/null +++ b/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: MIT +// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) +pragma solidity ^0.8.0; + +/** + * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. + * + * These functions can be used to verify that a message was signed by the holder + * of the private keys of a given address. + */ +library ECDSA { + enum RecoverError { + NoError, + InvalidSignature, + InvalidSignatureLength, + InvalidSignatureS + } + + /** + * @dev The signature derives the `address(0)`. + */ + error ECDSAInvalidSignature(); + + /** + * @dev The signature has an invalid length. + */ + error ECDSAInvalidSignatureLength(uint256 length); + + /** + * @dev The signature has an S value that is in the upper half order. + */ + error ECDSAInvalidSignatureS(bytes32 s); + + /** + * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not + * return address(0) without also returning an error description. Errors are documented using an enum (error type) + * and a bytes32 providing additional information about the error. + * + * If no error is returned, then the address can be used for verification purposes. + * + * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: + * this function rejects them by requiring the `s` value to be in the lower + * half order, and the `v` value to be either 27 or 28. + * + * IMPORTANT: `hash` _must_ be the result of a hash operation for the + * verification to be secure: it is possible to craft signatures that + * recover to arbitrary addresses for non-hashed data. A safe way to ensure + * this is by receiving a hash of the original message (which may otherwise + * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. + * + * Documentation for signature generation: + * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] + * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] + */ + function tryRecover( + bytes32 hash, + bytes memory signature + ) internal pure returns (address, RecoverError, bytes32) { + if (signature.length == 65) { + bytes32 r; + bytes32 s; + uint8 v; + // ecrecover takes the signature parameters, and the only way to get them + // currently is to use assembly. + /// @solidity memory-safe-assembly + assembly { + r := mload(add(signature, 0x20)) + s := mload(add(signature, 0x40)) + v := byte(0, mload(add(signature, 0x60))) + } + return tryRecover(hash, v, r, s); + } else { + return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); + } + } + + /** + * @dev Returns the address that signed a hashed message (`hash`) with + * `signature`. This address can then be used for verification purposes. + * + * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: + * this function rejects them by requiring the `s` value to be in the lower + * half order, and the `v` value to be either 27 or 28. + * + * IMPORTANT: `hash` _must_ be the result of a hash operation for the + * verification to be secure: it is possible to craft signatures that + * recover to arbitrary addresses for non-hashed data. A safe way to ensure + * this is by receiving a hash of the original message (which may otherwise + * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. + */ + function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { + (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); + _throwError(error, errorArg); + return recovered; + } + + /** + * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. + * + * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] + */ + function tryRecover( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address, RecoverError, bytes32) { + unchecked { + bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); + // We do not check for an overflow here since the shift operation results in 0 or 1. + uint8 v = uint8((uint256(vs) >> 255) + 27); + return tryRecover(hash, v, r, s); + } + } + + /** + * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. + */ + function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { + (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); + _throwError(error, errorArg); + return recovered; + } + + /** + * @dev Overload of {ECDSA-tryRecover} that receives the `v`, + * `r` and `s` signature fields separately. + */ + function tryRecover( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal pure returns (address, RecoverError, bytes32) { + // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature + // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines + // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most + // signatures from current libraries generate a unique signature with an s-value in the lower half order. + // + // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value + // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or + // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept + // these malleable signatures as well. + if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { + return (address(0), RecoverError.InvalidSignatureS, s); + } + + // If the signature is valid (and not malleable), return the signer address + address signer = ecrecover(hash, v, r, s); + if (signer == address(0)) { + return (address(0), RecoverError.InvalidSignature, bytes32(0)); + } + + return (signer, RecoverError.NoError, bytes32(0)); + } + + /** + * @dev Overload of {ECDSA-recover} that receives the `v`, + * `r` and `s` signature fields separately. + */ + function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { + (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); + _throwError(error, errorArg); + return recovered; + } + + /** + * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. + */ + function _throwError(RecoverError error, bytes32 errorArg) private pure { + if (error == RecoverError.NoError) { + return; // no error: do nothing + } else if (error == RecoverError.InvalidSignature) { + revert ECDSAInvalidSignature(); + } else if (error == RecoverError.InvalidSignatureLength) { + revert ECDSAInvalidSignatureLength(uint256(errorArg)); + } else if (error == RecoverError.InvalidSignatureS) { + revert ECDSAInvalidSignatureS(errorArg); + } + } +} diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/ERC165.sol b/src/contracts/dependencies/openzeppelin/contracts/ERC165.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/ERC165.sol rename to src/contracts/dependencies/openzeppelin/contracts/ERC165.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/ERC20.sol b/src/contracts/dependencies/openzeppelin/contracts/ERC20.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/ERC20.sol rename to src/contracts/dependencies/openzeppelin/contracts/ERC20.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol b/src/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol rename to src/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/IERC165.sol b/src/contracts/dependencies/openzeppelin/contracts/IERC165.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/IERC165.sol rename to src/contracts/dependencies/openzeppelin/contracts/IERC165.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/IERC20.sol b/src/contracts/dependencies/openzeppelin/contracts/IERC20.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/IERC20.sol rename to src/contracts/dependencies/openzeppelin/contracts/IERC20.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol b/src/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol rename to src/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/Ownable.sol b/src/contracts/dependencies/openzeppelin/contracts/Ownable.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/Ownable.sol rename to src/contracts/dependencies/openzeppelin/contracts/Ownable.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol b/src/contracts/dependencies/openzeppelin/contracts/SafeCast.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol rename to src/contracts/dependencies/openzeppelin/contracts/SafeCast.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol b/src/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol rename to src/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol b/src/contracts/dependencies/openzeppelin/contracts/SafeMath.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol rename to src/contracts/dependencies/openzeppelin/contracts/SafeMath.sol diff --git a/src/core/contracts/dependencies/openzeppelin/contracts/Strings.sol b/src/contracts/dependencies/openzeppelin/contracts/Strings.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/contracts/Strings.sol rename to src/contracts/dependencies/openzeppelin/contracts/Strings.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol b/src/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol diff --git a/src/core/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol b/src/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol similarity index 100% rename from src/core/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol rename to src/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol diff --git a/src/contracts/dependencies/solmate/ERC20.sol b/src/contracts/dependencies/solmate/ERC20.sol new file mode 100644 index 00000000..47d7b549 --- /dev/null +++ b/src/contracts/dependencies/solmate/ERC20.sol @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: AGPL-3.0-only +pragma solidity >=0.8.0; + +import {ECDSA} from '../openzeppelin/contracts/ECDSA.sol'; + +/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. +/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) +/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) +/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. +abstract contract ERC20 { + bytes32 public constant PERMIT_TYPEHASH = + keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); + + /* ////////////////////////////////////////////////////////////// + EVENTS + ////////////////////////////////////////////////////////////// */ + + event Transfer(address indexed from, address indexed to, uint256 amount); + + event Approval(address indexed owner, address indexed spender, uint256 amount); + + /* ////////////////////////////////////////////////////////////// + METADATA STORAGE + ////////////////////////////////////////////////////////////// */ + + string public name; + + string public symbol; + + uint8 public decimals; + + /* ////////////////////////////////////////////////////////////// + ERC20 STORAGE + ////////////////////////////////////////////////////////////// */ + + uint256 public totalSupply; + + mapping(address => uint256) public balanceOf; + + mapping(address => mapping(address => uint256)) public allowance; + + /* ////////////////////////////////////////////////////////////// + EIP-2612 STORAGE + ////////////////////////////////////////////////////////////// */ + + mapping(address => uint256) public nonces; + + /* ////////////////////////////////////////////////////////////// + CONSTRUCTOR + ////////////////////////////////////////////////////////////// */ + + constructor(string memory _name, string memory _symbol, uint8 _decimals) { + name = _name; + symbol = _symbol; + decimals = _decimals; + } + + /* ////////////////////////////////////////////////////////////// + ERC20 LOGIC + ////////////////////////////////////////////////////////////// */ + + function approve(address spender, uint256 amount) public virtual returns (bool) { + allowance[msg.sender][spender] = amount; + + emit Approval(msg.sender, spender, amount); + + return true; + } + + function transfer(address to, uint256 amount) public virtual returns (bool) { + _beforeTokenTransfer(msg.sender, to, amount); + balanceOf[msg.sender] -= amount; + + // Cannot overflow because the sum of all user + // balances can't exceed the max uint256 value. + unchecked { + balanceOf[to] += amount; + } + + emit Transfer(msg.sender, to, amount); + + return true; + } + + function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { + _beforeTokenTransfer(from, to, amount); + uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. + + if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; + + balanceOf[from] -= amount; + + // Cannot overflow because the sum of all user + // balances can't exceed the max uint256 value. + unchecked { + balanceOf[to] += amount; + } + + emit Transfer(from, to, amount); + + return true; + } + + /* ////////////////////////////////////////////////////////////// + EIP-2612 LOGIC + ////////////////////////////////////////////////////////////// */ + + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) public virtual { + require(deadline >= block.timestamp, 'PERMIT_DEADLINE_EXPIRED'); + + // Unchecked because the only math done is incrementing + // the owner's nonce which cannot realistically overflow. + unchecked { + address signer = ECDSA.recover( + keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR(), + keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) + ) + ), + v, + r, + s + ); + + require(signer == owner, 'INVALID_SIGNER'); + + allowance[signer][spender] = value; + } + + emit Approval(owner, spender, value); + } + + function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { + return computeDomainSeparator(); + } + + function computeDomainSeparator() internal view virtual returns (bytes32) { + return + keccak256( + abi.encode( + keccak256( + 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)' + ), + keccak256(bytes(name)), + keccak256('1'), + block.chainid, + address(this) + ) + ); + } + + /* ////////////////////////////////////////////////////////////// + INTERNAL MINT/BURN LOGIC + ////////////////////////////////////////////////////////////// */ + + function _mint(address to, uint256 amount) internal virtual { + _beforeTokenTransfer(address(0), to, amount); + totalSupply += amount; + + // Cannot overflow because the sum of all user + // balances can't exceed the max uint256 value. + unchecked { + balanceOf[to] += amount; + } + + emit Transfer(address(0), to, amount); + } + + function _burn(address from, uint256 amount) internal virtual { + _beforeTokenTransfer(from, address(0), amount); + balanceOf[from] -= amount; + + // Cannot underflow because a user's balance + // will never be larger than the total supply. + unchecked { + totalSupply -= amount; + } + + emit Transfer(from, address(0), amount); + } + + /** + * @dev Hook that is called before any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * will be to transferred to `to`. + * - when `from` is zero, `amount` tokens will be minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens will be burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} +} diff --git a/src/core/contracts/dependencies/weth/WETH9.sol b/src/contracts/dependencies/weth/WETH9.sol similarity index 100% rename from src/core/contracts/dependencies/weth/WETH9.sol rename to src/contracts/dependencies/weth/WETH9.sol diff --git a/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol b/src/contracts/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol similarity index 95% rename from src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol rename to src/contracts/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol index 5a0bb34a..2d47b182 100644 --- a/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol +++ b/src/contracts/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import {IFeeClaimer} from './interfaces/IFeeClaimer.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title AaveParaSwapFeeClaimer diff --git a/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol b/src/contracts/extensions/paraswap-adapters/BaseParaSwapAdapter.sol similarity index 79% rename from src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol rename to src/contracts/extensions/paraswap-adapters/BaseParaSwapAdapter.sol index 247f4437..45988edf 100644 --- a/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/BaseParaSwapAdapter.sol @@ -1,16 +1,16 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {FlashLoanSimpleReceiverBase} from 'aave-v3-core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPriceOracleGetter} from 'aave-v3-core/contracts/interfaces/IPriceOracleGetter.sol'; -import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; +import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; +import {FlashLoanSimpleReceiverBase} from '../../misc/flashloan/base/FlashLoanSimpleReceiverBase.sol'; +import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; /** * @title BaseParaSwapAdapter diff --git a/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol b/src/contracts/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol similarity index 89% rename from src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol rename to src/contracts/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol index 9fcfdc11..5d9db556 100644 --- a/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; -import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {PercentageMath} from '../../protocol/libraries/math/PercentageMath.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; import {BaseParaSwapAdapter} from './BaseParaSwapAdapter.sol'; diff --git a/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol b/src/contracts/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol similarity index 89% rename from src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol rename to src/contracts/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol index 8086a5c0..5292a3b8 100644 --- a/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; -import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {PercentageMath} from '../../protocol/libraries/math/PercentageMath.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; import {BaseParaSwapAdapter} from './BaseParaSwapAdapter.sol'; diff --git a/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol b/src/contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol similarity index 94% rename from src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol rename to src/contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol index 7852f16e..db855a33 100644 --- a/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; -import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {BaseParaSwapSellAdapter} from './BaseParaSwapSellAdapter.sol'; import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; diff --git a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol b/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol similarity index 92% rename from src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol rename to src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol index f776c757..6cfb3f22 100644 --- a/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; -import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; +import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {BaseParaSwapBuyAdapter} from './BaseParaSwapBuyAdapter.sol'; import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; diff --git a/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol b/src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol similarity index 87% rename from src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol rename to src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol index 499c7d6a..2522ee88 100644 --- a/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.10; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; import {BaseParaSwapSellAdapter} from './BaseParaSwapSellAdapter.sol'; import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; -import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; import {ReentrancyGuard} from '../../dependencies/openzeppelin/ReentrancyGuard.sol'; diff --git a/src/periphery/contracts/adapters/paraswap/interfaces/IFeeClaimer.sol b/src/contracts/extensions/paraswap-adapters/interfaces/IFeeClaimer.sol similarity index 97% rename from src/periphery/contracts/adapters/paraswap/interfaces/IFeeClaimer.sol rename to src/contracts/extensions/paraswap-adapters/interfaces/IFeeClaimer.sol index 5fd9d59a..161bcd51 100644 --- a/src/periphery/contracts/adapters/paraswap/interfaces/IFeeClaimer.sol +++ b/src/contracts/extensions/paraswap-adapters/interfaces/IFeeClaimer.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: ISC pragma solidity ^0.8.0; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; interface IFeeClaimer { /** diff --git a/src/periphery/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol b/src/contracts/extensions/paraswap-adapters/interfaces/IParaSwapAugustus.sol similarity index 100% rename from src/periphery/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol rename to src/contracts/extensions/paraswap-adapters/interfaces/IParaSwapAugustus.sol diff --git a/src/periphery/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol b/src/contracts/extensions/paraswap-adapters/interfaces/IParaSwapAugustusRegistry.sol similarity index 100% rename from src/periphery/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol rename to src/contracts/extensions/paraswap-adapters/interfaces/IParaSwapAugustusRegistry.sol diff --git a/src/contracts/extensions/static-a-token/README.md b/src/contracts/extensions/static-a-token/README.md new file mode 100644 index 00000000..9ced57a6 --- /dev/null +++ b/src/contracts/extensions/static-a-token/README.md @@ -0,0 +1,38 @@ +# stataToken - Static aToken vault/wrapper + +

+ +

+ +## About + +The static-a-token contains an [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626) generic token vault/wrapper for all Aave v3 pools. + +## Features + +- **Full [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626) compatibility.** +- **Accounting for any potential liquidity mining rewards.** Let’s say some team of the Aave ecosystem (or the Aave community itself) decides to incentivize deposits of USDC on Aave v3 Ethereum. By holding `stataUSDC`, the user will still be eligible for those incentives. + It is important to highlight that while currently the wrapper supports infinite reward tokens by design (e.g. AAVE incentivizing stETH & Lido incentivizing stETH as well), each reward needs to be permissionlessly registered which bears some [⁽¹⁾](#limitations). +- **Meta-transactions support.** To enable interfaces to offer gas-less transactions to deposit/withdraw on the wrapper/Aave protocol (also supported on Aave v3). Including permit() for transfers of the `stataAToken` itself. +- **Upgradable by the Aave governance.** Similar to other contracts of the Aave ecosystem, the Level 1 executor (short executor) will be able to add new features to the deployed instances of the `stataTokens`. +- **Powered by a stataToken Factory.** Whenever a token will be listed on Aave v3, anybody will be able to call the stataToken Factory to deploy an instance for the new asset, permissionless, but still assuring the code used and permissions are properly configured without any extra headache. + +See [IStaticATokenLM.sol](./interfaces/IStaticATokenLM.sol) for detailed method documentation. + +## Deployed Addresses + +The staticATokenFactory is deployed for all major Aave v3 pools. +An up to date address can be fetched from the respective [address-book pool library](https://github.com/bgd-labs/aave-address-book/blob/main/src/AaveV3Ethereum.sol). + +## Limitations + +The `stataToken` is not natively integrated into the aave protocol and therefore cannot hook into the emissionManager. +This means a `reward` added **after** `statToken` creation needs to be registered manually on the token via the permissionless `refreshRewardTokens()` method. +As this process is not currently automated users might be missing out on rewards until the method is called. + +## Security procedures + +For this project, the security procedures applied/being finished are: + +- The test suite of the codebase itself. +- Certora audit/property checking for all the dynamics of the `stataToken`, including respecting all the specs of [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626). diff --git a/src/contracts/extensions/static-a-token/StataOracle.sol b/src/contracts/extensions/static-a-token/StataOracle.sol new file mode 100644 index 00000000..50715593 --- /dev/null +++ b/src/contracts/extensions/static-a-token/StataOracle.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IAaveOracle} from '../../interfaces/IAaveOracle.sol'; +import {IStataOracle} from './interfaces/IStataOracle.sol'; +import {IERC4626} from './interfaces/IERC4626.sol'; + +/** + * @title StataOracle + * @author BGD Labs + * @notice Contract to get asset prices of stata tokens + */ +contract StataOracle is IStataOracle { + /// @inheritdoc IStataOracle + IPool public immutable POOL; + /// @inheritdoc IStataOracle + IAaveOracle public immutable AAVE_ORACLE; + + constructor(IPoolAddressesProvider provider) { + POOL = IPool(provider.getPool()); + AAVE_ORACLE = IAaveOracle(provider.getPriceOracle()); + } + + /// @inheritdoc IStataOracle + function getAssetPrice(address asset) public view returns (uint256) { + address underlying = IERC4626(asset).asset(); + return + (AAVE_ORACLE.getAssetPrice(underlying) * POOL.getReserveNormalizedIncome(underlying)) / 1e27; + } + + /// @inheritdoc IStataOracle + function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory) { + uint256[] memory prices = new uint256[](assets.length); + for (uint256 i = 0; i < assets.length; i++) { + prices[i] = getAssetPrice(assets[i]); + } + return prices; + } +} diff --git a/src/contracts/extensions/static-a-token/StaticATokenErrors.sol b/src/contracts/extensions/static-a-token/StaticATokenErrors.sol new file mode 100644 index 00000000..bec417df --- /dev/null +++ b/src/contracts/extensions/static-a-token/StaticATokenErrors.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +library StaticATokenErrors { + string public constant INVALID_OWNER = '1'; + string public constant INVALID_EXPIRATION = '2'; + string public constant INVALID_SIGNATURE = '3'; + string public constant INVALID_DEPOSITOR = '4'; + string public constant INVALID_RECIPIENT = '5'; + string public constant INVALID_CLAIMER = '6'; + string public constant ONLY_ONE_AMOUNT_FORMAT_ALLOWED = '7'; + string public constant INVALID_ZERO_AMOUNT = '8'; + string public constant REWARD_NOT_INITIALIZED = '9'; +} diff --git a/src/contracts/extensions/static-a-token/StaticATokenFactory.sol b/src/contracts/extensions/static-a-token/StaticATokenFactory.sol new file mode 100644 index 00000000..bf307197 --- /dev/null +++ b/src/contracts/extensions/static-a-token/StaticATokenFactory.sol @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {IPool, DataTypes} from '../../interfaces/IPool.sol'; +import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; +import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol'; +import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; +import {StaticATokenLM} from './StaticATokenLM.sol'; +import {IStaticATokenFactory} from './interfaces/IStaticATokenFactory.sol'; + +/** + * @title StaticATokenFactory + * @notice Factory contract that keeps track of all deployed static aToken wrappers for a specified pool. + * This registry also acts as a factory, allowing to deploy new static aTokens on demand. + * There can only be one static aToken per underlying on the registry at a time. + * @author BGD labs + */ +contract StaticATokenFactory is Initializable, IStaticATokenFactory { + IPool public immutable POOL; + address public immutable ADMIN; + ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY; + address public immutable STATIC_A_TOKEN_IMPL; + + mapping(address => address) internal _underlyingToStaticAToken; + address[] internal _staticATokens; + + event StaticTokenCreated(address indexed staticAToken, address indexed underlying); + + constructor( + IPool pool, + address proxyAdmin, + ITransparentProxyFactory transparentProxyFactory, + address staticATokenImpl + ) { + POOL = pool; + ADMIN = proxyAdmin; + TRANSPARENT_PROXY_FACTORY = transparentProxyFactory; + STATIC_A_TOKEN_IMPL = staticATokenImpl; + } + + function initialize() external initializer {} + + ///@inheritdoc IStaticATokenFactory + function createStaticATokens(address[] memory underlyings) external returns (address[] memory) { + address[] memory staticATokens = new address[](underlyings.length); + for (uint256 i = 0; i < underlyings.length; i++) { + address cachedStaticAToken = _underlyingToStaticAToken[underlyings[i]]; + if (cachedStaticAToken == address(0)) { + DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(underlyings[i]); + require(reserveData.aTokenAddress != address(0), 'UNDERLYING_NOT_LISTED'); + bytes memory symbol = abi.encodePacked( + 'stat', + IERC20Metadata(reserveData.aTokenAddress).symbol() + ); + address staticAToken = TRANSPARENT_PROXY_FACTORY.createDeterministic( + STATIC_A_TOKEN_IMPL, + ADMIN, + abi.encodeWithSelector( + StaticATokenLM.initialize.selector, + reserveData.aTokenAddress, + string(abi.encodePacked('Static ', IERC20Metadata(reserveData.aTokenAddress).name())), + string(symbol) + ), + bytes32(uint256(uint160(underlyings[i]))) + ); + _underlyingToStaticAToken[underlyings[i]] = staticAToken; + staticATokens[i] = staticAToken; + _staticATokens.push(staticAToken); + emit StaticTokenCreated(staticAToken, underlyings[i]); + } else { + staticATokens[i] = cachedStaticAToken; + } + } + return staticATokens; + } + + ///@inheritdoc IStaticATokenFactory + function getStaticATokens() external view returns (address[] memory) { + return _staticATokens; + } + + ///@inheritdoc IStaticATokenFactory + function getStaticAToken(address underlying) external view returns (address) { + return _underlyingToStaticAToken[underlying]; + } +} diff --git a/src/contracts/extensions/static-a-token/StaticATokenLM.sol b/src/contracts/extensions/static-a-token/StaticATokenLM.sol new file mode 100644 index 00000000..cb74ee88 --- /dev/null +++ b/src/contracts/extensions/static-a-token/StaticATokenLM.sol @@ -0,0 +1,712 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {IPool} from '../../interfaces/IPool.sol'; +import {DataTypes, ReserveConfiguration} from '../../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IRewardsController} from '../../rewards/interfaces/IRewardsController.sol'; +import {WadRayMath} from '../../protocol/libraries/math/WadRayMath.sol'; +import {MathUtils} from '../../protocol/libraries/math/MathUtils.sol'; +import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol'; +import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; +import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; +import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IERC20WithPermit.sol'; + +import {IStaticATokenLM} from './interfaces/IStaticATokenLM.sol'; +import {IAToken} from './interfaces/IAToken.sol'; +import {ERC20} from '../../dependencies/solmate/ERC20.sol'; +import {IInitializableStaticATokenLM} from './interfaces/IInitializableStaticATokenLM.sol'; +import {StaticATokenErrors} from './StaticATokenErrors.sol'; +import {RayMathExplicitRounding, Rounding} from '../../misc/libraries/RayMathExplicitRounding.sol'; +import {IERC4626} from './interfaces/IERC4626.sol'; + +/** + * @title StaticATokenLM + * @notice Wrapper smart contract that allows to deposit tokens on the Aave protocol and receive + * a token which balance doesn't increase automatically, but uses an ever-increasing exchange rate. + * It supports claiming liquidity mining rewards from the Aave system. + * @author BGD labs + */ +contract StaticATokenLM is + Initializable, + ERC20('STATIC__aToken_IMPL', 'STATIC__aToken_IMPL', 18), + IStaticATokenLM, + IERC4626 +{ + using SafeERC20 for IERC20; + using SafeCast for uint256; + using WadRayMath for uint256; + using RayMathExplicitRounding for uint256; + + bytes32 public constant METADEPOSIT_TYPEHASH = + keccak256( + 'Deposit(address depositor,address receiver,uint256 assets,uint16 referralCode,bool depositToAave,uint256 nonce,uint256 deadline,PermitParams permit)' + ); + bytes32 public constant METAWITHDRAWAL_TYPEHASH = + keccak256( + 'Withdraw(address owner,address receiver,uint256 shares,uint256 assets,bool withdrawFromAave,uint256 nonce,uint256 deadline)' + ); + + uint256 public constant STATIC__ATOKEN_LM_REVISION = 2; + + IPool public immutable POOL; + IRewardsController public immutable INCENTIVES_CONTROLLER; + + IERC20 internal _aToken; + address internal _aTokenUnderlying; + address[] internal _rewardTokens; + mapping(address => RewardIndexCache) internal _startIndex; + mapping(address => mapping(address => UserRewardsData)) internal _userRewardsData; + + constructor(IPool pool, IRewardsController rewardsController) { + POOL = pool; + INCENTIVES_CONTROLLER = rewardsController; + } + + ///@inheritdoc IInitializableStaticATokenLM + function initialize( + address newAToken, + string calldata staticATokenName, + string calldata staticATokenSymbol + ) external initializer { + require(IAToken(newAToken).POOL() == address(POOL)); + _aToken = IERC20(newAToken); + + name = staticATokenName; + symbol = staticATokenSymbol; + decimals = IERC20Metadata(newAToken).decimals(); + + _aTokenUnderlying = IAToken(newAToken).UNDERLYING_ASSET_ADDRESS(); + IERC20(_aTokenUnderlying).forceApprove(address(POOL), type(uint256).max); + + if (INCENTIVES_CONTROLLER != IRewardsController(address(0))) { + refreshRewardTokens(); + } + + emit Initialized(newAToken, staticATokenName, staticATokenSymbol); + } + + ///@inheritdoc IStaticATokenLM + function refreshRewardTokens() public override { + address[] memory rewards = INCENTIVES_CONTROLLER.getRewardsByAsset(address(_aToken)); + for (uint256 i = 0; i < rewards.length; i++) { + _registerRewardToken(rewards[i]); + } + } + + ///@inheritdoc IStaticATokenLM + function isRegisteredRewardToken(address reward) public view override returns (bool) { + return _startIndex[reward].isRegistered; + } + + ///@inheritdoc IStaticATokenLM + function deposit( + uint256 assets, + address receiver, + uint16 referralCode, + bool depositToAave + ) external returns (uint256) { + (uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, referralCode, depositToAave); + return shares; + } + + ///@inheritdoc IStaticATokenLM + function metaDeposit( + address depositor, + address receiver, + uint256 assets, + uint16 referralCode, + bool depositToAave, + uint256 deadline, + PermitParams calldata permit, + SignatureParams calldata sigParams + ) external returns (uint256) { + require(depositor != address(0), StaticATokenErrors.INVALID_DEPOSITOR); + //solium-disable-next-line + require(deadline >= block.timestamp, StaticATokenErrors.INVALID_EXPIRATION); + uint256 nonce = nonces[depositor]; + + // Unchecked because the only math done is incrementing + // the owner's nonce which cannot realistically overflow. + unchecked { + bytes32 digest = keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR(), + keccak256( + abi.encode( + METADEPOSIT_TYPEHASH, + depositor, + receiver, + assets, + referralCode, + depositToAave, + nonce, + deadline, + permit + ) + ) + ) + ); + nonces[depositor] = nonce + 1; + require( + depositor == ecrecover(digest, sigParams.v, sigParams.r, sigParams.s), + StaticATokenErrors.INVALID_SIGNATURE + ); + } + // assume if deadline 0 no permit was supplied + if (permit.deadline != 0) { + try + IERC20WithPermit(depositToAave ? address(_aTokenUnderlying) : address(_aToken)).permit( + depositor, + address(this), + permit.value, + permit.deadline, + permit.v, + permit.r, + permit.s + ) + {} catch {} + } + (uint256 shares, ) = _deposit(depositor, receiver, 0, assets, referralCode, depositToAave); + return shares; + } + + ///@inheritdoc IStaticATokenLM + function metaWithdraw( + address owner, + address receiver, + uint256 shares, + uint256 assets, + bool withdrawFromAave, + uint256 deadline, + SignatureParams calldata sigParams + ) external returns (uint256, uint256) { + require(owner != address(0), StaticATokenErrors.INVALID_OWNER); + //solium-disable-next-line + require(deadline >= block.timestamp, StaticATokenErrors.INVALID_EXPIRATION); + uint256 nonce = nonces[owner]; + // Unchecked because the only math done is incrementing + // the owner's nonce which cannot realistically overflow. + unchecked { + bytes32 digest = keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR(), + keccak256( + abi.encode( + METAWITHDRAWAL_TYPEHASH, + owner, + receiver, + shares, + assets, + withdrawFromAave, + nonce, + deadline + ) + ) + ) + ); + nonces[owner] = nonce + 1; + require( + owner == ecrecover(digest, sigParams.v, sigParams.r, sigParams.s), + StaticATokenErrors.INVALID_SIGNATURE + ); + } + return _withdraw(owner, receiver, shares, assets, withdrawFromAave); + } + + ///@inheritdoc IERC4626 + function previewRedeem(uint256 shares) public view virtual returns (uint256) { + return _convertToAssets(shares, Rounding.DOWN); + } + + ///@inheritdoc IERC4626 + function previewMint(uint256 shares) public view virtual returns (uint256) { + return _convertToAssets(shares, Rounding.UP); + } + + ///@inheritdoc IERC4626 + function previewWithdraw(uint256 assets) public view virtual returns (uint256) { + return _convertToShares(assets, Rounding.UP); + } + + ///@inheritdoc IERC4626 + function previewDeposit(uint256 assets) public view virtual returns (uint256) { + return _convertToShares(assets, Rounding.DOWN); + } + + ///@inheritdoc IStaticATokenLM + function rate() public view returns (uint256) { + return POOL.getReserveNormalizedIncome(_aTokenUnderlying); + } + + ///@inheritdoc IStaticATokenLM + function collectAndUpdateRewards(address reward) public returns (uint256) { + if (reward == address(0)) { + return 0; + } + + address[] memory assets = new address[](1); + assets[0] = address(_aToken); + + return INCENTIVES_CONTROLLER.claimRewards(assets, type(uint256).max, address(this), reward); + } + + ///@inheritdoc IStaticATokenLM + function claimRewardsOnBehalf( + address onBehalfOf, + address receiver, + address[] memory rewards + ) external { + require( + msg.sender == onBehalfOf || msg.sender == INCENTIVES_CONTROLLER.getClaimer(onBehalfOf), + StaticATokenErrors.INVALID_CLAIMER + ); + _claimRewardsOnBehalf(onBehalfOf, receiver, rewards); + } + + ///@inheritdoc IStaticATokenLM + function claimRewards(address receiver, address[] memory rewards) external { + _claimRewardsOnBehalf(msg.sender, receiver, rewards); + } + + ///@inheritdoc IStaticATokenLM + function claimRewardsToSelf(address[] memory rewards) external { + _claimRewardsOnBehalf(msg.sender, msg.sender, rewards); + } + + ///@inheritdoc IStaticATokenLM + function getCurrentRewardsIndex(address reward) public view returns (uint256) { + if (address(reward) == address(0)) { + return 0; + } + (, uint256 nextIndex) = INCENTIVES_CONTROLLER.getAssetIndex(address(_aToken), reward); + return nextIndex; + } + + ///@inheritdoc IStaticATokenLM + function getTotalClaimableRewards(address reward) external view returns (uint256) { + if (reward == address(0)) { + return 0; + } + + address[] memory assets = new address[](1); + assets[0] = address(_aToken); + uint256 freshRewards = INCENTIVES_CONTROLLER.getUserRewards(assets, address(this), reward); + return IERC20(reward).balanceOf(address(this)) + freshRewards; + } + + ///@inheritdoc IStaticATokenLM + function getClaimableRewards(address user, address reward) external view returns (uint256) { + return _getClaimableRewards(user, reward, balanceOf[user], getCurrentRewardsIndex(reward)); + } + + ///@inheritdoc IStaticATokenLM + function getUnclaimedRewards(address user, address reward) external view returns (uint256) { + return _userRewardsData[user][reward].unclaimedRewards; + } + + ///@inheritdoc IERC4626 + function asset() external view returns (address) { + return address(_aTokenUnderlying); + } + + ///@inheritdoc IStaticATokenLM + function aToken() external view returns (IERC20) { + return _aToken; + } + + ///@inheritdoc IStaticATokenLM + function rewardTokens() external view returns (address[] memory) { + return _rewardTokens; + } + + ///@inheritdoc IERC4626 + function totalAssets() external view returns (uint256) { + return _aToken.balanceOf(address(this)); + } + + ///@inheritdoc IERC4626 + function convertToShares(uint256 assets) external view returns (uint256) { + return _convertToShares(assets, Rounding.DOWN); + } + + ///@inheritdoc IERC4626 + function convertToAssets(uint256 shares) external view returns (uint256) { + return _convertToAssets(shares, Rounding.DOWN); + } + + ///@inheritdoc IERC4626 + function maxMint(address) public view virtual returns (uint256) { + uint256 assets = maxDeposit(address(0)); + if (assets == type(uint256).max) return type(uint256).max; + return _convertToShares(assets, Rounding.DOWN); + } + + ///@inheritdoc IERC4626 + function maxWithdraw(address owner) public view virtual returns (uint256) { + uint256 shares = maxRedeem(owner); + return _convertToAssets(shares, Rounding.DOWN); + } + + ///@inheritdoc IERC4626 + function maxRedeem(address owner) public view virtual returns (uint256) { + address cachedATokenUnderlying = _aTokenUnderlying; + DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(cachedATokenUnderlying); + + // if paused or inactive users cannot withdraw underlying + if ( + !ReserveConfiguration.getActive(reserveData.configuration) || + ReserveConfiguration.getPaused(reserveData.configuration) + ) { + return 0; + } + + // otherwise users can withdraw up to the available amount + uint256 underlyingTokenBalanceInShares = _convertToShares( + IERC20(cachedATokenUnderlying).balanceOf(reserveData.aTokenAddress), + Rounding.DOWN + ); + uint256 cachedUserBalance = balanceOf[owner]; + return + underlyingTokenBalanceInShares >= cachedUserBalance + ? cachedUserBalance + : underlyingTokenBalanceInShares; + } + + ///@inheritdoc IERC4626 + function maxDeposit(address) public view virtual returns (uint256) { + DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(_aTokenUnderlying); + + // if inactive, paused or frozen users cannot deposit underlying + if ( + !ReserveConfiguration.getActive(reserveData.configuration) || + ReserveConfiguration.getPaused(reserveData.configuration) || + ReserveConfiguration.getFrozen(reserveData.configuration) + ) { + return 0; + } + + uint256 supplyCap = ReserveConfiguration.getSupplyCap(reserveData.configuration) * + (10 ** ReserveConfiguration.getDecimals(reserveData.configuration)); + // if no supply cap deposit is unlimited + if (supplyCap == 0) return type(uint256).max; + // return remaining supply cap margin + uint256 currentSupply = (IAToken(reserveData.aTokenAddress).scaledTotalSupply() + + reserveData.accruedToTreasury).rayMulRoundUp(_getNormalizedIncome(reserveData)); + return currentSupply > supplyCap ? 0 : supplyCap - currentSupply; + } + + ///@inheritdoc IERC4626 + function deposit(uint256 assets, address receiver) external virtual returns (uint256) { + (uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, 0, true); + return shares; + } + + ///@inheritdoc IERC4626 + function mint(uint256 shares, address receiver) external virtual returns (uint256) { + (, uint256 assets) = _deposit(msg.sender, receiver, shares, 0, 0, true); + + return assets; + } + + ///@inheritdoc IERC4626 + function withdraw( + uint256 assets, + address receiver, + address owner + ) external virtual returns (uint256) { + (uint256 shares, ) = _withdraw(owner, receiver, 0, assets, true); + + return shares; + } + + ///@inheritdoc IERC4626 + function redeem( + uint256 shares, + address receiver, + address owner + ) external virtual returns (uint256) { + (, uint256 assets) = _withdraw(owner, receiver, shares, 0, true); + + return assets; + } + + ///@inheritdoc IStaticATokenLM + function redeem( + uint256 shares, + address receiver, + address owner, + bool withdrawFromAave + ) external virtual returns (uint256, uint256) { + return _withdraw(owner, receiver, shares, 0, withdrawFromAave); + } + + function _deposit( + address depositor, + address receiver, + uint256 _shares, + uint256 _assets, + uint16 referralCode, + bool depositToAave + ) internal returns (uint256, uint256) { + require(receiver != address(0), StaticATokenErrors.INVALID_RECIPIENT); + require(_shares == 0 || _assets == 0, StaticATokenErrors.ONLY_ONE_AMOUNT_FORMAT_ALLOWED); + + uint256 assets = _assets; + uint256 shares = _shares; + if (shares > 0) { + if (depositToAave) { + require(shares <= maxMint(receiver), 'ERC4626: mint more than max'); + } + assets = previewMint(shares); + } else { + if (depositToAave) { + require(assets <= maxDeposit(receiver), 'ERC4626: deposit more than max'); + } + shares = previewDeposit(assets); + } + require(shares != 0, StaticATokenErrors.INVALID_ZERO_AMOUNT); + + if (depositToAave) { + address cachedATokenUnderlying = _aTokenUnderlying; + IERC20(cachedATokenUnderlying).safeTransferFrom(depositor, address(this), assets); + POOL.deposit(cachedATokenUnderlying, assets, address(this), referralCode); + } else { + _aToken.safeTransferFrom(depositor, address(this), assets); + } + + _mint(receiver, shares); + + emit Deposit(depositor, receiver, assets, shares); + + return (shares, assets); + } + + function _withdraw( + address owner, + address receiver, + uint256 _shares, + uint256 _assets, + bool withdrawFromAave + ) internal returns (uint256, uint256) { + require(receiver != address(0), StaticATokenErrors.INVALID_RECIPIENT); + require(_shares == 0 || _assets == 0, StaticATokenErrors.ONLY_ONE_AMOUNT_FORMAT_ALLOWED); + require(_shares != _assets, StaticATokenErrors.INVALID_ZERO_AMOUNT); + + uint256 assets = _assets; + uint256 shares = _shares; + + if (shares > 0) { + if (withdrawFromAave) { + require(shares <= maxRedeem(owner), 'ERC4626: redeem more than max'); + } + assets = previewRedeem(shares); + } else { + if (withdrawFromAave) { + require(assets <= maxWithdraw(owner), 'ERC4626: withdraw more than max'); + } + shares = previewWithdraw(assets); + } + + if (msg.sender != owner) { + uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. + + if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; + } + + _burn(owner, shares); + + emit Withdraw(msg.sender, receiver, owner, assets, shares); + + if (withdrawFromAave) { + POOL.withdraw(_aTokenUnderlying, assets, receiver); + } else { + _aToken.safeTransfer(receiver, assets); + } + + return (shares, assets); + } + + /** + * @notice Updates rewards for senders and receiver in a transfer (not updating rewards for address(0)) + * @param from The address of the sender of tokens + * @param to The address of the receiver of tokens + */ + function _beforeTokenTransfer(address from, address to, uint256) internal override { + for (uint256 i = 0; i < _rewardTokens.length; i++) { + address rewardToken = address(_rewardTokens[i]); + uint256 rewardsIndex = getCurrentRewardsIndex(rewardToken); + if (from != address(0)) { + _updateUser(from, rewardsIndex, rewardToken); + } + if (to != address(0) && from != to) { + _updateUser(to, rewardsIndex, rewardToken); + } + } + } + + /** + * @notice Adding the pending rewards to the unclaimed for specific user and updating user index + * @param user The address of the user to update + * @param currentRewardsIndex The current rewardIndex + * @param rewardToken The address of the reward token + */ + function _updateUser(address user, uint256 currentRewardsIndex, address rewardToken) internal { + uint256 balance = balanceOf[user]; + if (balance > 0) { + _userRewardsData[user][rewardToken].unclaimedRewards = _getClaimableRewards( + user, + rewardToken, + balance, + currentRewardsIndex + ).toUint128(); + } + _userRewardsData[user][rewardToken].rewardsIndexOnLastInteraction = currentRewardsIndex + .toUint128(); + } + + /** + * @notice Compute the pending in WAD. Pending is the amount to add (not yet unclaimed) rewards in WAD. + * @param balance The balance of the user + * @param rewardsIndexOnLastInteraction The index which was on the last interaction of the user + * @param currentRewardsIndex The current rewards index in the system + * @param assetUnit One unit of asset (10**decimals) + * @return The amount of pending rewards in WAD + */ + function _getPendingRewards( + uint256 balance, + uint256 rewardsIndexOnLastInteraction, + uint256 currentRewardsIndex, + uint256 assetUnit + ) internal pure returns (uint256) { + if (balance == 0) { + return 0; + } + return (balance * (currentRewardsIndex - rewardsIndexOnLastInteraction)) / assetUnit; + } + + /** + * @notice Compute the claimable rewards for a user + * @param user The address of the user + * @param reward The address of the reward + * @param balance The balance of the user in WAD + * @param currentRewardsIndex The current rewards index + * @return The total rewards that can be claimed by the user (if `fresh` flag true, after updating rewards) + */ + function _getClaimableRewards( + address user, + address reward, + uint256 balance, + uint256 currentRewardsIndex + ) internal view returns (uint256) { + RewardIndexCache memory rewardsIndexCache = _startIndex[reward]; + require(rewardsIndexCache.isRegistered == true, StaticATokenErrors.REWARD_NOT_INITIALIZED); + UserRewardsData memory currentUserRewardsData = _userRewardsData[user][reward]; + uint256 assetUnit = 10 ** decimals; + return + currentUserRewardsData.unclaimedRewards + + _getPendingRewards( + balance, + currentUserRewardsData.rewardsIndexOnLastInteraction == 0 + ? rewardsIndexCache.lastUpdatedIndex + : currentUserRewardsData.rewardsIndexOnLastInteraction, + currentRewardsIndex, + assetUnit + ); + } + + /** + * @notice Claim rewards on behalf of a user and send them to a receiver + * @param onBehalfOf The address to claim on behalf of + * @param rewards The addresses of the rewards + * @param receiver The address to receive the rewards + */ + function _claimRewardsOnBehalf( + address onBehalfOf, + address receiver, + address[] memory rewards + ) internal { + for (uint256 i = 0; i < rewards.length; i++) { + if (address(rewards[i]) == address(0)) { + continue; + } + uint256 currentRewardsIndex = getCurrentRewardsIndex(rewards[i]); + uint256 balance = balanceOf[onBehalfOf]; + uint256 userReward = _getClaimableRewards( + onBehalfOf, + rewards[i], + balance, + currentRewardsIndex + ); + uint256 totalRewardTokenBalance = IERC20(rewards[i]).balanceOf(address(this)); + uint256 unclaimedReward = 0; + + if (userReward > totalRewardTokenBalance) { + totalRewardTokenBalance += collectAndUpdateRewards(address(rewards[i])); + } + + if (userReward > totalRewardTokenBalance) { + unclaimedReward = userReward - totalRewardTokenBalance; + userReward = totalRewardTokenBalance; + } + if (userReward > 0) { + _userRewardsData[onBehalfOf][rewards[i]].unclaimedRewards = unclaimedReward.toUint128(); + _userRewardsData[onBehalfOf][rewards[i]].rewardsIndexOnLastInteraction = currentRewardsIndex + .toUint128(); + IERC20(rewards[i]).safeTransfer(receiver, userReward); + } + } + } + + function _convertToShares(uint256 assets, Rounding rounding) internal view returns (uint256) { + if (rounding == Rounding.UP) return assets.rayDivRoundUp(rate()); + return assets.rayDivRoundDown(rate()); + } + + function _convertToAssets(uint256 shares, Rounding rounding) internal view returns (uint256) { + if (rounding == Rounding.UP) return shares.rayMulRoundUp(rate()); + return shares.rayMulRoundDown(rate()); + } + + /** + * @notice Initializes a new rewardToken + * @param reward The reward token to be registered + */ + function _registerRewardToken(address reward) internal { + if (isRegisteredRewardToken(reward)) return; + uint256 startIndex = getCurrentRewardsIndex(reward); + + _rewardTokens.push(reward); + _startIndex[reward] = RewardIndexCache(true, startIndex.toUint240()); + + emit RewardTokenRegistered(reward, startIndex); + } + + /** + * Copy of https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ReserveLogic.sol#L47 with memory instead of calldata + * @notice Returns the ongoing normalized income for the reserve. + * @dev A value of 1e27 means there is no income. As time passes, the income is accrued + * @dev A value of 2*1e27 means for each unit of asset one unit of income has been accrued + * @param reserve The reserve object + * @return The normalized income, expressed in ray + */ + function _getNormalizedIncome( + DataTypes.ReserveDataLegacy memory reserve + ) internal view returns (uint256) { + uint40 timestamp = reserve.lastUpdateTimestamp; + + //solium-disable-next-line + if (timestamp == block.timestamp) { + //if the index was updated in the same block, no need to perform any calculation + return reserve.liquidityIndex; + } else { + return + MathUtils.calculateLinearInterest(reserve.currentLiquidityRate, timestamp).rayMul( + reserve.liquidityIndex + ); + } + } +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IAToken.sol b/src/contracts/extensions/static-a-token/interfaces/IAToken.sol new file mode 100644 index 00000000..31e9a805 --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IAToken.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.10; + +interface IAToken { + function POOL() external view returns (address); + + function getIncentivesController() external view returns (address); + + function UNDERLYING_ASSET_ADDRESS() external view returns (address); + + /** + * @notice Returns the scaled total supply of the scaled balance token. Represents sum(debt/index) + * @return The scaled total supply + */ + function scaledTotalSupply() external view returns (uint256); +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol b/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol new file mode 100644 index 00000000..08f14f90 --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: MIT +// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol) + +pragma solidity ^0.8.10; + +/** + * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in + * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. + * + * _Available since v4.7._ + */ +interface IERC4626 { + event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); + + event Withdraw( + address indexed sender, + address indexed receiver, + address indexed owner, + uint256 assets, + uint256 shares + ); + + /** + * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. + * + * - MUST be an ERC-20 token contract. + * - MUST NOT revert. + */ + function asset() external view returns (address assetTokenAddress); + + /** + * @dev Returns the total amount of the underlying asset that is “managed” by Vault. + * + * - SHOULD include any compounding that occurs from yield. + * - MUST be inclusive of any fees that are charged against assets in the Vault. + * - MUST NOT revert. + */ + function totalAssets() external view returns (uint256 totalManagedAssets); + + /** + * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal + * scenario where all the conditions are met. + * + * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. + * - MUST NOT show any variations depending on the caller. + * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. + * - MUST NOT revert. + * + * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the + * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and + * from. + */ + function convertToShares(uint256 assets) external view returns (uint256 shares); + + /** + * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal + * scenario where all the conditions are met. + * + * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. + * - MUST NOT show any variations depending on the caller. + * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. + * + * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the + * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and + * from. + */ + function convertToAssets(uint256 shares) external view returns (uint256 assets); + + /** + * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, + * through a deposit call. + * While deposit of aToken is not affected by aave pool configrations, deposit of the aTokenUnderlying will need to deposit to aave + * so it is affected by current aave pool configuration. + * Reference: https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ValidationLogic.sol#L57 + * - MUST return a limited value if receiver is subject to some deposit limit. + * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. + */ + function maxDeposit(address receiver) external view returns (uint256 maxAssets); + + /** + * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given + * current on-chain conditions. + * + * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit + * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called + * in the same transaction. + * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the + * deposit would be accepted, regardless if the user has enough tokens approved, etc. + * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. + * - MUST NOT revert. + * + * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in + * share price or some other type of condition, meaning the depositor will lose assets by depositing. + */ + function previewDeposit(uint256 assets) external view returns (uint256 shares); + + /** + * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. + * + * - MUST emit the Deposit event. + * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the + * deposit execution, and are accounted for during deposit. + * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not + * approving enough underlying tokens to the Vault contract, etc). + * + * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. + */ + function deposit(uint256 assets, address receiver) external returns (uint256 shares); + + /** + * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. + * - MUST return a limited value if receiver is subject to some mint limit. + * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. + * - MUST NOT revert. + */ + function maxMint(address receiver) external view returns (uint256 maxShares); + + /** + * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given + * current on-chain conditions. + * + * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call + * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the + * same transaction. + * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint + * would be accepted, regardless if the user has enough tokens approved, etc. + * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. + * - MUST NOT revert. + * + * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in + * share price or some other type of condition, meaning the depositor will lose assets by minting. + */ + function previewMint(uint256 shares) external view returns (uint256 assets); + + /** + * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. + * + * - MUST emit the Deposit event. + * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint + * execution, and are accounted for during mint. + * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not + * approving enough underlying tokens to the Vault contract, etc). + * + * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. + */ + function mint(uint256 shares, address receiver) external returns (uint256 assets); + + /** + * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the + * Vault, through a withdraw call. + * + * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. + * - MUST NOT revert. + */ + function maxWithdraw(address owner) external view returns (uint256 maxAssets); + + /** + * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, + * given current on-chain conditions. + * + * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw + * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if + * called + * in the same transaction. + * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though + * the withdrawal would be accepted, regardless if the user has enough shares, etc. + * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. + * - MUST NOT revert. + * + * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in + * share price or some other type of condition, meaning the depositor will lose assets by depositing. + */ + function previewWithdraw(uint256 assets) external view returns (uint256 shares); + + /** + * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. + * + * - MUST emit the Withdraw event. + * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the + * withdraw execution, and are accounted for during withdraw. + * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner + * not having enough shares, etc). + * + * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. + * Those methods should be performed separately. + */ + function withdraw( + uint256 assets, + address receiver, + address owner + ) external returns (uint256 shares); + + /** + * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, + * through a redeem call to the aToken underlying. + * While redeem of aToken is not affected by aave pool configrations, redeeming of the aTokenUnderlying will need to redeem from aave + * so it is affected by current aave pool configuration. + * Reference: https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ValidationLogic.sol#L87 + * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. + * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. + * - MUST NOT revert. + */ + function maxRedeem(address owner) external view returns (uint256 maxShares); + + /** + * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, + * given current on-chain conditions. + * + * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call + * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the + * same transaction. + * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the + * redemption would be accepted, regardless if the user has enough shares, etc. + * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. + * - MUST NOT revert. + * + * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in + * share price or some other type of condition, meaning the depositor will lose assets by redeeming. + */ + function previewRedeem(uint256 shares) external view returns (uint256 assets); + + /** + * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. + * + * - MUST emit the Withdraw event. + * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the + * redeem execution, and are accounted for during redeem. + * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner + * not having enough shares, etc). + * + * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. + * Those methods should be performed separately. + */ + function redeem( + uint256 shares, + address receiver, + address owner + ) external returns (uint256 assets); +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol new file mode 100644 index 00000000..586a935a --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.10; + +import {IPool} from '../../../interfaces/IPool.sol'; +import {IAaveIncentivesController} from '../../../interfaces/IAaveIncentivesController.sol'; + +/** + * @title IInitializableStaticATokenLM + * @notice Interface for the initialize function on StaticATokenLM + * @author Aave + **/ +interface IInitializableStaticATokenLM { + /** + * @dev Emitted when a StaticATokenLM is initialized + * @param aToken The address of the underlying aToken (aWETH) + * @param staticATokenName The name of the Static aToken + * @param staticATokenSymbol The symbol of the Static aToken + **/ + event Initialized(address indexed aToken, string staticATokenName, string staticATokenSymbol); + + /** + * @dev Initializes the StaticATokenLM + * @param aToken The address of the underlying aToken (aWETH) + * @param staticATokenName The name of the Static aToken + * @param staticATokenSymbol The symbol of the Static aToken + */ + function initialize( + address aToken, + string calldata staticATokenName, + string calldata staticATokenSymbol + ) external; +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol b/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol new file mode 100644 index 00000000..d08f2a29 --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.10; + +import {IPool} from '../../../interfaces/IPool.sol'; +import {IAaveOracle} from '../../../interfaces/IAaveOracle.sol'; + +interface IStataOracle { + /** + * @return The pool used for fetching the rate on the aggregator oracle + */ + function POOL() external view returns (IPool); + + /** + * @return The aave oracle used for fetching the price of the underlying + */ + function AAVE_ORACLE() external view returns (IAaveOracle); + + /** + * @notice Returns the prices of an asset address + * @param asset The asset address + * @return The prices of the given asset + */ + function getAssetPrice(address asset) external view returns (uint256); + + /** + * @notice Returns a list of prices from a list of assets addresses + * @param assets The list of assets addresses + * @return The prices of the given assets + */ + function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory); +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol new file mode 100644 index 00000000..7532e92c --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.10; + +interface IStaticATokenFactory { + /** + * @notice Creates new staticATokens + * @param underlyings the addresses of the underlyings to create. + * @return address[] addresses of the new staticATokens. + */ + function createStaticATokens(address[] memory underlyings) external returns (address[] memory); + + /** + * @notice Returns all tokens deployed via this registry. + * @return address[] list of tokens + */ + function getStaticATokens() external view returns (address[] memory); + + /** + * @notice Returns the staticAToken for a given underlying. + * @param underlying the address of the underlying. + * @return address the staticAToken address. + */ + function getStaticAToken(address underlying) external view returns (address); +} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol new file mode 100644 index 00000000..eed469f3 --- /dev/null +++ b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.10; + +import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {IInitializableStaticATokenLM} from './IInitializableStaticATokenLM.sol'; + +interface IStaticATokenLM is IInitializableStaticATokenLM { + struct SignatureParams { + uint8 v; + bytes32 r; + bytes32 s; + } + + struct PermitParams { + address owner; + address spender; + uint256 value; + uint256 deadline; + uint8 v; + bytes32 r; + bytes32 s; + } + + struct UserRewardsData { + uint128 rewardsIndexOnLastInteraction; // (in RAYs) + uint128 unclaimedRewards; // (in RAYs) + } + + struct RewardIndexCache { + bool isRegistered; + uint248 lastUpdatedIndex; + } + + event RewardTokenRegistered(address indexed reward, uint256 startIndex); + + /** + * @notice Burns `amount` of static aToken, with receiver receiving the corresponding amount of `ASSET` + * @param shares The amount to withdraw, in static balance of StaticAToken + * @param receiver The address that will receive the amount of `ASSET` withdrawn from the Aave protocol + * @param withdrawFromAave bool + * - `true` for the receiver to get underlying tokens (e.g. USDC) + * - `false` for the receiver to get aTokens (e.g. aUSDC) + * @return amountToBurn: StaticATokens burnt, static balance + * @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance + **/ + function redeem( + uint256 shares, + address receiver, + address owner, + bool withdrawFromAave + ) external returns (uint256, uint256); + + /** + * @notice Deposits `ASSET` in the Aave protocol and mints static aTokens to msg.sender + * @param assets The amount of underlying `ASSET` to deposit (e.g. deposit of 100 USDC) + * @param receiver The address that will receive the static aTokens + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param depositToAave bool + * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) + * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) + * @return uint256 The amount of StaticAToken minted, static balance + **/ + function deposit( + uint256 assets, + address receiver, + uint16 referralCode, + bool depositToAave + ) external returns (uint256); + + /** + * @notice Allows to deposit on Aave via meta-transaction + * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param depositor Address from which the funds to deposit are going to be pulled + * @param receiver Address that will receive the staticATokens, in the average case, same as the `depositor` + * @param assets The amount to deposit + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param depositToAave bool + * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) + * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) + * @param deadline The deadline timestamp, type(uint256).max for max deadline + * @param sigParams Signature params: v,r,s + * @return uint256 The amount of StaticAToken minted, static balance + */ + function metaDeposit( + address depositor, + address receiver, + uint256 assets, + uint16 referralCode, + bool depositToAave, + uint256 deadline, + PermitParams calldata permit, + SignatureParams calldata sigParams + ) external returns (uint256); + + /** + * @notice Allows to withdraw from Aave via meta-transaction + * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param owner Address owning the staticATokens + * @param receiver Address that will receive the underlying withdrawn from Aave + * @param shares The amount of staticAToken to withdraw. If > 0, `assets` needs to be 0 + * @param assets The amount of underlying/aToken to withdraw. If > 0, `shares` needs to be 0 + * @param withdrawFromAave bool + * - `true` for the receiver to get underlying tokens (e.g. USDC) + * - `false` for the receiver to get aTokens (e.g. aUSDC) + * @param deadline The deadline timestamp, type(uint256).max for max deadline + * @param sigParams Signature params: v,r,s + * @return amountToBurn: StaticATokens burnt, static balance + * @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance + */ + function metaWithdraw( + address owner, + address receiver, + uint256 shares, + uint256 assets, + bool withdrawFromAave, + uint256 deadline, + SignatureParams calldata sigParams + ) external returns (uint256, uint256); + + /** + * @notice Returns the Aave liquidity index of the underlying aToken, denominated rate here + * as it can be considered as an ever-increasing exchange rate + * @return The liquidity index + **/ + function rate() external view returns (uint256); + + /** + * @notice Claims rewards from `INCENTIVES_CONTROLLER` and updates internal accounting of rewards. + * @param reward The reward to claim + * @return uint256 Amount collected + */ + function collectAndUpdateRewards(address reward) external returns (uint256); + + /** + * @notice Claim rewards on behalf of a user and send them to a receiver + * @dev Only callable by if sender is onBehalfOf or sender is approved claimer + * @param onBehalfOf The address to claim on behalf of + * @param receiver The address to receive the rewards + * @param rewards The rewards to claim + */ + function claimRewardsOnBehalf( + address onBehalfOf, + address receiver, + address[] memory rewards + ) external; + + /** + * @notice Claim rewards and send them to a receiver + * @param receiver The address to receive the rewards + * @param rewards The rewards to claim + */ + function claimRewards(address receiver, address[] memory rewards) external; + + /** + * @notice Claim rewards + * @param rewards The rewards to claim + */ + function claimRewardsToSelf(address[] memory rewards) external; + + /** + * @notice Get the total claimable rewards of the contract. + * @param reward The reward to claim + * @return uint256 The current balance + pending rewards from the `_incentivesController` + */ + function getTotalClaimableRewards(address reward) external view returns (uint256); + + /** + * @notice Get the total claimable rewards for a user in WAD + * @param user The address of the user + * @param reward The reward to claim + * @return uint256 The claimable amount of rewards in WAD + */ + function getClaimableRewards(address user, address reward) external view returns (uint256); + + /** + * @notice The unclaimed rewards for a user in WAD + * @param user The address of the user + * @param reward The reward to claim + * @return uint256 The unclaimed amount of rewards in WAD + */ + function getUnclaimedRewards(address user, address reward) external view returns (uint256); + + /** + * @notice The underlying asset reward index in RAY + * @param reward The reward to claim + * @return uint256 The underlying asset reward index in RAY + */ + function getCurrentRewardsIndex(address reward) external view returns (uint256); + + /** + * @notice The aToken used inside the 4626 vault. + * @return IERC20 The aToken IERC20. + */ + function aToken() external view returns (IERC20); + + /** + * @notice The IERC20s that are currently rewarded to addresses of the vault via LM on incentivescontroller. + * @return IERC20 The IERC20s of the rewards. + */ + function rewardTokens() external view returns (address[] memory); + + /** + * @notice Fetches all rewardTokens from the incentivecontroller and registers the missing ones. + */ + function refreshRewardTokens() external; + + /** + * @notice Checks if the passed token is a registered reward. + * @return bool signaling if token is a registered reward. + */ + function isRegisteredRewardToken(address reward) external view returns (bool); +} diff --git a/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol similarity index 99% rename from src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol rename to src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol index 2d5cd360..25b07174 100644 --- a/src/periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {CapsEngine} from './libraries/CapsEngine.sol'; diff --git a/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol similarity index 98% rename from src/periphery/contracts/v3-config-engine/AaveV3Payload.sol rename to src/contracts/extensions/v3-config-engine/AaveV3Payload.sol index 003d3d3e..065263b1 100644 --- a/src/periphery/contracts/v3-config-engine/AaveV3Payload.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol @@ -1,8 +1,8 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import {Address} from 'solidity-utils/contracts/oz-common/Address.sol'; -import {WadRayMath} from '../../../core/contracts/protocol/libraries/math/WadRayMath.sol'; +import {WadRayMath} from '../../protocol/libraries/math/WadRayMath.sol'; import {IAaveV3ConfigEngine as IEngine} from './IAaveV3ConfigEngine.sol'; import {EngineFlags} from './EngineFlags.sol'; diff --git a/src/periphery/contracts/v3-config-engine/EngineFlags.sol b/src/contracts/extensions/v3-config-engine/EngineFlags.sol similarity index 97% rename from src/periphery/contracts/v3-config-engine/EngineFlags.sol rename to src/contracts/extensions/v3-config-engine/EngineFlags.sol index de54c40d..822292a6 100644 --- a/src/periphery/contracts/v3-config-engine/EngineFlags.sol +++ b/src/contracts/extensions/v3-config-engine/EngineFlags.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; library EngineFlags { diff --git a/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol similarity index 97% rename from src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol rename to src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index ddbcdf13..c2007d35 100644 --- a/src/periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IPool} from '../../../core/contracts/interfaces/IPool.sol'; -import {IPoolConfigurator} from '../../../core/contracts/interfaces/IPoolConfigurator.sol'; -import {IAaveOracle} from '../../../core/contracts/interfaces/IAaveOracle.sol'; -import {IDefaultInterestRateStrategyV2} from '../../../core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; +import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolConfigurator} from '../../interfaces/IPoolConfigurator.sol'; +import {IAaveOracle} from '../../interfaces/IAaveOracle.sol'; +import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; /// @dev Examples here assume the usage of the `AaveV3Payload` base contracts /// contained in this same repository diff --git a/src/contracts/extensions/v3-config-engine/README.md b/src/contracts/extensions/v3-config-engine/README.md new file mode 100644 index 00000000..7308dde5 --- /dev/null +++ b/src/contracts/extensions/v3-config-engine/README.md @@ -0,0 +1,62 @@ +## Aave v3 config engine + +![Config Engine Diagram](../../../../resources/configs-engine.svg) + +## What is the AaveV3ConfigEngine? + +The `AaveV3ConfigEngine` is a helper smart contract to abstract good practices when doing "admin" interactions with the Aave v3 protocol, but built on top, without touching the core contracts. + +At the same time, it defines a new interface oriented to simplify developer experience when coding proposal payloads: the `AaveV3ConfigEngine` is built from our experience supervising governance payloads review, for actions like full cycle of listing assets, modify caps (supply/borrow), changing collateral or borrow related parameters and changing the price feeds of assets. + +_Note: In an effort for unification and streamlining deployment procedures, the config engine has been migrated from the [aave-helpers](https://github.com/bgd-labs/aave-helpers) repository to this location._ + +## How to use the engine? + +The engine is not designed to be used directly when writing a payload, but through abstract contracts that we will call `Base Aave v3 Payloads`. + +This [aave-helpers](https://github.com/bgd-labs/aave-helpers) repository contains `Base Aave v3 Payloads` for all the Aave v3 instances, under the hood powered by this config engine and aave-address-book, and abstracting all the complexity: ordering of execution of actions, extra validations, deciding when to keep a current configured parameter and how to get it, etc. + +As base for any payload, you only need to inherit from the corresponding (per pool) `Base Aave v3 Payload`, for example inheriting from `AaveV3PayloadEthereum` in the case of Ethereum, `AaveV3PayloadAvalanche` in the case of Avalanche, and so on. + +If you want just to do one or multiple listings, you only need to define the listing within a `newListings()` function, and the base payload will take care of executing it correctly for you. + +Do you want instead to update supply/borrow caps? Same approach as with the listings, you only need to define the update of caps within a `capsUpdates()` function, and the base payload will take care of the rest. + +Do you want to update the price-feed of an asset? You only need to define the update of price feed within a `priceFeedsUpdates()` function, and the base payload will take care of the rest. + +Change collateral-related parameters? Same approach as previous, you only need to define the update within a `collateralsUpdates()` function, and the base payload will take care of the rest. + +Change Borrow-related parameters? Same as previous, just define the update within a `borrowsUpdates()` function, and the base payload will take care of the rest. + +Change eMode category configuration? Same as previous, just define the update within a `eModeCategoriesUpdates()` function, and the base payload will take care of the rest. + +Change eMode category of a particular asset? Same as previous, just define the update within a `assetsEModeUpdates()` function, and the base payload will take care of the rest. + +### Internal aspects to consider + +- Frequently, at the same time that you want to do an update of parameters or listing, you also want to do something extra before or after. +The `Base Aave v3 Payload` defines `_preExecute()` and `_postExecute()` hook functions, that you can redefine on your payload and will the execute before and after all configs changes/listings you define. + +- The payload also allow you to group changes of parameters and listings, just by defining at the same time the aforementioned `newListings()`, `capsUpdate()` and/or `collateralsUpdates()` and so on. For reference, the execution ordering is the following: + 1. `_preExecute()` + 2. `eModeCategoriesUpdates()` + 3. `newListings()` + 4. `newListingsCustom()` + 5. `borrowsUpdates()` + 6. `collateralsUpdates()` + 7. `rateStrategiesUpdates()` + 8. `priceFeedsUpdates()` + 9. `assetsEModeUpdates()` + 10. `capsUpdates()` + 11. `_postExecute()` + +## Links to examples +- [Simple mock listing on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockListing.sol) +- [Simple custom mock listing on Aave V3 with custom token impl](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockListingCustom.sol) +- [Mock e-mode category update on Aave V3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol) +- [Mock e-mode asset update on Aave V3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol) +- [Mock caps updates (only supply, keeping current borrow cap) on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockCapUpdate.sol) +- [Mock collateral updates (changing some, keeping current values on others), on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol) +- [Mock borrow updates (changing some, keeping current values on others), on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol) +- [Mock rates updates (changing some, keeping current values on others), on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol) +- [Mock price feed updates on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol) diff --git a/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/BorrowEngine.sol similarity index 91% rename from src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/BorrowEngine.sol index 4fa237b6..7a9d2ddf 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/BorrowEngine.sol @@ -1,9 +1,9 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {EngineFlags} from '../EngineFlags.sol'; -import {DataTypes} from '../../../../core/contracts/protocol/libraries/types/DataTypes.sol'; -import {ReserveConfiguration} from '../../../../core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {DataTypes} from '../../../protocol/libraries/types/DataTypes.sol'; +import {ReserveConfiguration} from '../../../protocol/libraries/configuration/ReserveConfiguration.sol'; import {IAaveV3ConfigEngine as IEngine, IPoolConfigurator, IPool} from '../IAaveV3ConfigEngine.sol'; library BorrowEngine { diff --git a/src/periphery/contracts/v3-config-engine/libraries/CapsEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/CapsEngine.sol similarity index 96% rename from src/periphery/contracts/v3-config-engine/libraries/CapsEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/CapsEngine.sol index b06c61fc..084ebc26 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/CapsEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/CapsEngine.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {EngineFlags} from '../EngineFlags.sol'; diff --git a/src/periphery/contracts/v3-config-engine/libraries/CollateralEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol similarity index 91% rename from src/periphery/contracts/v3-config-engine/libraries/CollateralEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol index 73e9a7f0..174068bd 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/CollateralEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol @@ -1,10 +1,10 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; -import {DataTypes} from '../../../../core/contracts/protocol/libraries/types/DataTypes.sol'; -import {ReserveConfiguration} from '../../../../core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {DataTypes} from '../../../protocol/libraries/types/DataTypes.sol'; +import {ReserveConfiguration} from '../../../protocol/libraries/configuration/ReserveConfiguration.sol'; import {IAaveV3ConfigEngine as IEngine, IPoolConfigurator, IPool} from '../IAaveV3ConfigEngine.sol'; -import {PercentageMath} from '../../../../core/contracts/protocol/libraries/math/PercentageMath.sol'; +import {PercentageMath} from '../../../protocol/libraries/math/PercentageMath.sol'; import {EngineFlags} from '../EngineFlags.sol'; library CollateralEngine { diff --git a/src/periphery/contracts/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol similarity index 94% rename from src/periphery/contracts/v3-config-engine/libraries/EModeEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index 5ccf4231..6780a9f6 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -1,10 +1,10 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {EngineFlags} from '../EngineFlags.sol'; -import {DataTypes} from '../../../../core/contracts/protocol/libraries/types/DataTypes.sol'; +import {DataTypes} from '../../../protocol/libraries/types/DataTypes.sol'; import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol'; -import {PercentageMath} from '../../../../core/contracts/protocol/libraries/math/PercentageMath.sol'; +import {PercentageMath} from '../../../protocol/libraries/math/PercentageMath.sol'; import {IAaveV3ConfigEngine as IEngine, IPoolConfigurator, IPool} from '../IAaveV3ConfigEngine.sol'; library EModeEngine { diff --git a/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol similarity index 96% rename from src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol index 15550697..861491be 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/ListingEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; @@ -8,9 +8,9 @@ import {CapsEngine} from './CapsEngine.sol'; import {BorrowEngine} from './BorrowEngine.sol'; import {CollateralEngine} from './CollateralEngine.sol'; import {EModeEngine} from './EModeEngine.sol'; -import {ConfiguratorInputTypes} from '../../../../core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol'; +import {ConfiguratorInputTypes} from '../../../protocol/libraries/types/ConfiguratorInputTypes.sol'; import {Address} from 'solidity-utils/contracts/oz-common/Address.sol'; -import {SafeCast} from '../../../../core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; +import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol'; library ListingEngine { using Address for address; diff --git a/src/periphery/contracts/v3-config-engine/libraries/PriceFeedEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/PriceFeedEngine.sol similarity index 88% rename from src/periphery/contracts/v3-config-engine/libraries/PriceFeedEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/PriceFeedEngine.sol index d7186082..75cc49f4 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/PriceFeedEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/PriceFeedEngine.sol @@ -1,8 +1,8 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import {IAaveV3ConfigEngine as IEngine, IAaveOracle} from '../IAaveV3ConfigEngine.sol'; -import {IEACAggregatorProxy} from '../../../../periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol'; +import {IEACAggregatorProxy} from '../../../helpers/interfaces/IEACAggregatorProxy.sol'; library PriceFeedEngine { function executePriceFeedsUpdate( diff --git a/src/periphery/contracts/v3-config-engine/libraries/RateEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/RateEngine.sol similarity index 93% rename from src/periphery/contracts/v3-config-engine/libraries/RateEngine.sol rename to src/contracts/extensions/v3-config-engine/libraries/RateEngine.sol index db9c37d3..8ae88e2b 100644 --- a/src/periphery/contracts/v3-config-engine/libraries/RateEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/RateEngine.sol @@ -1,8 +1,8 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; -import {IDefaultInterestRateStrategyV2} from '../../../../core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; -import {SafeCast} from '../../../../core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; +import {IDefaultInterestRateStrategyV2} from '../../../interfaces/IDefaultInterestRateStrategyV2.sol'; +import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol'; import {EngineFlags} from '../EngineFlags.sol'; import {IAaveV3ConfigEngine as IEngine, IPoolConfigurator} from '../IAaveV3ConfigEngine.sol'; diff --git a/src/core/contracts/misc/AaveProtocolDataProvider.sol b/src/contracts/helpers/AaveProtocolDataProvider.sol similarity index 100% rename from src/core/contracts/misc/AaveProtocolDataProvider.sol rename to src/contracts/helpers/AaveProtocolDataProvider.sol diff --git a/src/core/contracts/misc/L2Encoder.sol b/src/contracts/helpers/L2Encoder.sol similarity index 100% rename from src/core/contracts/misc/L2Encoder.sol rename to src/contracts/helpers/L2Encoder.sol diff --git a/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol b/src/contracts/helpers/UiIncentiveDataProviderV3.sol similarity index 96% rename from src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol rename to src/contracts/helpers/UiIncentiveDataProviderV3.sol index 5c8f3e7f..d5d620d9 100644 --- a/src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol +++ b/src/contracts/helpers/UiIncentiveDataProviderV3.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IncentivizedERC20} from 'aave-v3-core/contracts/protocol/tokenization/base/IncentivizedERC20.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../interfaces/IPool.sol'; +import {IncentivizedERC20} from '../protocol/tokenization/base/IncentivizedERC20.sol'; +import {UserConfiguration} from '../../contracts/protocol/libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {IRewardsController} from '../rewards/interfaces/IRewardsController.sol'; import {IEACAggregatorProxy} from './interfaces/IEACAggregatorProxy.sol'; import {IUiIncentiveDataProviderV3} from './interfaces/IUiIncentiveDataProviderV3.sol'; diff --git a/src/periphery/contracts/misc/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol similarity index 89% rename from src/periphery/contracts/misc/UiPoolDataProviderV3.sol rename to src/contracts/helpers/UiPoolDataProviderV3.sol index cee7a456..343855bf 100644 --- a/src/periphery/contracts/misc/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; -import {IDefaultInterestRateStrategyV2} from 'aave-v3-core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; -import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../interfaces/IPool.sol'; +import {IAaveOracle} from '../interfaces/IAaveOracle.sol'; +import {IAToken} from '../interfaces/IAToken.sol'; +import {IVariableDebtToken} from '../interfaces/IVariableDebtToken.sol'; +import {IStableDebtToken} from '../interfaces/IStableDebtToken.sol'; +import {IDefaultInterestRateStrategyV2} from '../interfaces/IDefaultInterestRateStrategyV2.sol'; +import {AaveProtocolDataProvider} from './AaveProtocolDataProvider.sol'; +import {WadRayMath} from '../protocol/libraries/math/WadRayMath.sol'; +import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {IEACAggregatorProxy} from './interfaces/IEACAggregatorProxy.sol'; import {IERC20DetailedBytes} from './interfaces/IERC20DetailedBytes.sol'; import {IUiPoolDataProviderV3} from './interfaces/IUiPoolDataProviderV3.sol'; diff --git a/src/periphery/contracts/misc/WalletBalanceProvider.sol b/src/contracts/helpers/WalletBalanceProvider.sol similarity index 83% rename from src/periphery/contracts/misc/WalletBalanceProvider.sol rename to src/contracts/helpers/WalletBalanceProvider.sol index f215610c..c074ac3f 100644 --- a/src/periphery/contracts/misc/WalletBalanceProvider.sol +++ b/src/contracts/helpers/WalletBalanceProvider.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {Address} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Address.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; - -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {Address} from '../dependencies/openzeppelin/contracts/Address.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; + +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../interfaces/IPool.sol'; +import {GPv2SafeERC20} from '../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; /** * @title WalletBalanceProvider contract diff --git a/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol b/src/contracts/helpers/WrappedTokenGatewayV3.sol similarity index 89% rename from src/periphery/contracts/misc/WrappedTokenGatewayV3.sol rename to src/contracts/helpers/WrappedTokenGatewayV3.sol index a120eeab..eb2c6dd3 100644 --- a/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/WrappedTokenGatewayV3.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IWETH} from 'aave-v3-core/contracts/misc/interfaces/IWETH.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; +import {GPv2SafeERC20} from '../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IWETH} from './interfaces/IWETH.sol'; +import {IPool} from '../interfaces/IPool.sol'; +import {IAToken} from '../interfaces/IAToken.sol'; +import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {IWrappedTokenGatewayV3} from './interfaces/IWrappedTokenGatewayV3.sol'; -import {DataTypesHelper} from '../libraries/DataTypesHelper.sol'; +import {DataTypesHelper} from '../misc/libraries/DataTypesHelper.sol'; /** * @dev This contract is an upgrade of the WrappedTokenGatewayV3 contract, with immutable pool address. diff --git a/src/periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol b/src/contracts/helpers/interfaces/IEACAggregatorProxy.sol similarity index 100% rename from src/periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol rename to src/contracts/helpers/interfaces/IEACAggregatorProxy.sol diff --git a/src/periphery/contracts/misc/interfaces/IERC20DetailedBytes.sol b/src/contracts/helpers/interfaces/IERC20DetailedBytes.sol similarity index 73% rename from src/periphery/contracts/misc/interfaces/IERC20DetailedBytes.sol rename to src/contracts/helpers/interfaces/IERC20DetailedBytes.sol index 3e213158..0541f0da 100644 --- a/src/periphery/contracts/misc/interfaces/IERC20DetailedBytes.sol +++ b/src/contracts/helpers/interfaces/IERC20DetailedBytes.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; interface IERC20DetailedBytes is IERC20 { function name() external view returns (bytes32); diff --git a/src/periphery/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol similarity index 95% rename from src/periphery/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol rename to src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol index fb3bb00c..910c662b 100644 --- a/src/periphery/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; interface IUiIncentiveDataProviderV3 { struct AggregatedReserveIncentiveData { diff --git a/src/periphery/contracts/misc/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol similarity index 96% rename from src/periphery/contracts/misc/interfaces/IUiPoolDataProviderV3.sol rename to src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index 42944eb8..9ee2402a 100644 --- a/src/periphery/contracts/misc/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; interface IUiPoolDataProviderV3 { struct InterestRates { diff --git a/src/core/contracts/misc/interfaces/IWETH.sol b/src/contracts/helpers/interfaces/IWETH.sol similarity index 100% rename from src/core/contracts/misc/interfaces/IWETH.sol rename to src/contracts/helpers/interfaces/IWETH.sol diff --git a/src/periphery/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol b/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol similarity index 100% rename from src/periphery/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol rename to src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol diff --git a/src/core/instances/ATokenInstance.sol b/src/contracts/instances/ATokenInstance.sol similarity index 93% rename from src/core/instances/ATokenInstance.sol rename to src/contracts/instances/ATokenInstance.sol index e778f91e..8e646385 100644 --- a/src/core/instances/ATokenInstance.sol +++ b/src/contracts/instances/ATokenInstance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {AToken, IPool, IAaveIncentivesController, IInitializableAToken, Errors, VersionedInitializable} from '../contracts/protocol/tokenization/AToken.sol'; +import {AToken, IPool, IAaveIncentivesController, IInitializableAToken, Errors, VersionedInitializable} from '../protocol/tokenization/AToken.sol'; contract ATokenInstance is AToken { uint256 public constant ATOKEN_REVISION = 1; diff --git a/src/core/instances/L2PoolInstance.sol b/src/contracts/instances/L2PoolInstance.sol similarity index 60% rename from src/core/instances/L2PoolInstance.sol rename to src/contracts/instances/L2PoolInstance.sol index 80bd406f..0c61f19e 100644 --- a/src/core/instances/L2PoolInstance.sol +++ b/src/contracts/instances/L2PoolInstance.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {L2Pool} from '../contracts/protocol/pool/L2Pool.sol'; -import {IPoolAddressesProvider} from '../contracts/interfaces/IPoolAddressesProvider.sol'; +import {L2Pool} from '../protocol/pool/L2Pool.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; import {PoolInstance} from './PoolInstance.sol'; contract L2PoolInstance is L2Pool, PoolInstance { diff --git a/src/core/instances/PoolConfiguratorInstance.sol b/src/contracts/instances/PoolConfiguratorInstance.sol similarity index 87% rename from src/core/instances/PoolConfiguratorInstance.sol rename to src/contracts/instances/PoolConfiguratorInstance.sol index 03ae6105..fefcc236 100644 --- a/src/core/instances/PoolConfiguratorInstance.sol +++ b/src/contracts/instances/PoolConfiguratorInstance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {PoolConfigurator, IPoolAddressesProvider, IPool, VersionedInitializable} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; +import {PoolConfigurator, IPoolAddressesProvider, IPool, VersionedInitializable} from '../protocol/pool/PoolConfigurator.sol'; contract PoolConfiguratorInstance is PoolConfigurator { uint256 public constant CONFIGURATOR_REVISION = 3; diff --git a/src/core/instances/PoolInstance.sol b/src/contracts/instances/PoolInstance.sol similarity index 80% rename from src/core/instances/PoolInstance.sol rename to src/contracts/instances/PoolInstance.sol index 0af51bbe..88b0744a 100644 --- a/src/core/instances/PoolInstance.sol +++ b/src/contracts/instances/PoolInstance.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {Pool} from '../contracts/protocol/pool/Pool.sol'; -import {IPoolAddressesProvider} from '../contracts/interfaces/IPoolAddressesProvider.sol'; -import {Errors} from '../contracts/protocol/libraries/helpers/Errors.sol'; +import {Pool} from '../protocol/pool/Pool.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; +import {Errors} from '../protocol/libraries/helpers/Errors.sol'; contract PoolInstance is Pool { uint256 public constant POOL_REVISION = 4; diff --git a/src/core/instances/StableDebtTokenInstance.sol b/src/contracts/instances/StableDebtTokenInstance.sol similarity index 91% rename from src/core/instances/StableDebtTokenInstance.sol rename to src/contracts/instances/StableDebtTokenInstance.sol index 00f91a58..a4913414 100644 --- a/src/core/instances/StableDebtTokenInstance.sol +++ b/src/contracts/instances/StableDebtTokenInstance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {StableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../contracts/protocol/tokenization/StableDebtToken.sol'; +import {StableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../protocol/tokenization/StableDebtToken.sol'; contract StableDebtTokenInstance is StableDebtToken { uint256 public constant DEBT_TOKEN_REVISION = 1; diff --git a/src/core/instances/VariableDebtTokenInstance.sol b/src/contracts/instances/VariableDebtTokenInstance.sol similarity index 91% rename from src/core/instances/VariableDebtTokenInstance.sol rename to src/contracts/instances/VariableDebtTokenInstance.sol index 11ac68e6..b2c3dc89 100644 --- a/src/core/instances/VariableDebtTokenInstance.sol +++ b/src/contracts/instances/VariableDebtTokenInstance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {VariableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../contracts/protocol/tokenization/VariableDebtToken.sol'; +import {VariableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../protocol/tokenization/VariableDebtToken.sol'; contract VariableDebtTokenInstance is VariableDebtToken { uint256 public constant DEBT_TOKEN_REVISION = 1; diff --git a/src/core/contracts/interfaces/IACLManager.sol b/src/contracts/interfaces/IACLManager.sol similarity index 100% rename from src/core/contracts/interfaces/IACLManager.sol rename to src/contracts/interfaces/IACLManager.sol diff --git a/src/core/contracts/interfaces/IAToken.sol b/src/contracts/interfaces/IAToken.sol similarity index 100% rename from src/core/contracts/interfaces/IAToken.sol rename to src/contracts/interfaces/IAToken.sol diff --git a/src/core/contracts/interfaces/IAaveIncentivesController.sol b/src/contracts/interfaces/IAaveIncentivesController.sol similarity index 100% rename from src/core/contracts/interfaces/IAaveIncentivesController.sol rename to src/contracts/interfaces/IAaveIncentivesController.sol diff --git a/src/core/contracts/interfaces/IAaveOracle.sol b/src/contracts/interfaces/IAaveOracle.sol similarity index 100% rename from src/core/contracts/interfaces/IAaveOracle.sol rename to src/contracts/interfaces/IAaveOracle.sol diff --git a/src/core/contracts/interfaces/ICreditDelegationToken.sol b/src/contracts/interfaces/ICreditDelegationToken.sol similarity index 100% rename from src/core/contracts/interfaces/ICreditDelegationToken.sol rename to src/contracts/interfaces/ICreditDelegationToken.sol diff --git a/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol b/src/contracts/interfaces/IDefaultInterestRateStrategyV2.sol similarity index 100% rename from src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol rename to src/contracts/interfaces/IDefaultInterestRateStrategyV2.sol diff --git a/src/core/contracts/interfaces/IDelegationToken.sol b/src/contracts/interfaces/IDelegationToken.sol similarity index 100% rename from src/core/contracts/interfaces/IDelegationToken.sol rename to src/contracts/interfaces/IDelegationToken.sol diff --git a/src/core/contracts/interfaces/IERC20WithPermit.sol b/src/contracts/interfaces/IERC20WithPermit.sol similarity index 100% rename from src/core/contracts/interfaces/IERC20WithPermit.sol rename to src/contracts/interfaces/IERC20WithPermit.sol diff --git a/src/core/contracts/interfaces/IInitializableAToken.sol b/src/contracts/interfaces/IInitializableAToken.sol similarity index 100% rename from src/core/contracts/interfaces/IInitializableAToken.sol rename to src/contracts/interfaces/IInitializableAToken.sol diff --git a/src/core/contracts/interfaces/IInitializableDebtToken.sol b/src/contracts/interfaces/IInitializableDebtToken.sol similarity index 100% rename from src/core/contracts/interfaces/IInitializableDebtToken.sol rename to src/contracts/interfaces/IInitializableDebtToken.sol diff --git a/src/core/contracts/interfaces/IL2Pool.sol b/src/contracts/interfaces/IL2Pool.sol similarity index 100% rename from src/core/contracts/interfaces/IL2Pool.sol rename to src/contracts/interfaces/IL2Pool.sol diff --git a/src/core/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol similarity index 100% rename from src/core/contracts/interfaces/IPool.sol rename to src/contracts/interfaces/IPool.sol diff --git a/src/core/contracts/interfaces/IPoolAddressesProvider.sol b/src/contracts/interfaces/IPoolAddressesProvider.sol similarity index 100% rename from src/core/contracts/interfaces/IPoolAddressesProvider.sol rename to src/contracts/interfaces/IPoolAddressesProvider.sol diff --git a/src/core/contracts/interfaces/IPoolAddressesProviderRegistry.sol b/src/contracts/interfaces/IPoolAddressesProviderRegistry.sol similarity index 100% rename from src/core/contracts/interfaces/IPoolAddressesProviderRegistry.sol rename to src/contracts/interfaces/IPoolAddressesProviderRegistry.sol diff --git a/src/core/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol similarity index 100% rename from src/core/contracts/interfaces/IPoolConfigurator.sol rename to src/contracts/interfaces/IPoolConfigurator.sol diff --git a/src/core/contracts/interfaces/IPoolDataProvider.sol b/src/contracts/interfaces/IPoolDataProvider.sol similarity index 100% rename from src/core/contracts/interfaces/IPoolDataProvider.sol rename to src/contracts/interfaces/IPoolDataProvider.sol diff --git a/src/core/contracts/interfaces/IPriceOracle.sol b/src/contracts/interfaces/IPriceOracle.sol similarity index 100% rename from src/core/contracts/interfaces/IPriceOracle.sol rename to src/contracts/interfaces/IPriceOracle.sol diff --git a/src/core/contracts/interfaces/IPriceOracleGetter.sol b/src/contracts/interfaces/IPriceOracleGetter.sol similarity index 100% rename from src/core/contracts/interfaces/IPriceOracleGetter.sol rename to src/contracts/interfaces/IPriceOracleGetter.sol diff --git a/src/core/contracts/interfaces/IPriceOracleSentinel.sol b/src/contracts/interfaces/IPriceOracleSentinel.sol similarity index 100% rename from src/core/contracts/interfaces/IPriceOracleSentinel.sol rename to src/contracts/interfaces/IPriceOracleSentinel.sol diff --git a/src/core/contracts/interfaces/IReserveInterestRateStrategy.sol b/src/contracts/interfaces/IReserveInterestRateStrategy.sol similarity index 100% rename from src/core/contracts/interfaces/IReserveInterestRateStrategy.sol rename to src/contracts/interfaces/IReserveInterestRateStrategy.sol diff --git a/src/core/contracts/interfaces/IScaledBalanceToken.sol b/src/contracts/interfaces/IScaledBalanceToken.sol similarity index 100% rename from src/core/contracts/interfaces/IScaledBalanceToken.sol rename to src/contracts/interfaces/IScaledBalanceToken.sol diff --git a/src/core/contracts/interfaces/ISequencerOracle.sol b/src/contracts/interfaces/ISequencerOracle.sol similarity index 100% rename from src/core/contracts/interfaces/ISequencerOracle.sol rename to src/contracts/interfaces/ISequencerOracle.sol diff --git a/src/core/contracts/interfaces/IStableDebtToken.sol b/src/contracts/interfaces/IStableDebtToken.sol similarity index 100% rename from src/core/contracts/interfaces/IStableDebtToken.sol rename to src/contracts/interfaces/IStableDebtToken.sol diff --git a/src/core/contracts/interfaces/IVariableDebtToken.sol b/src/contracts/interfaces/IVariableDebtToken.sol similarity index 100% rename from src/core/contracts/interfaces/IVariableDebtToken.sol rename to src/contracts/interfaces/IVariableDebtToken.sol diff --git a/src/core/contracts/misc/AaveOracle.sol b/src/contracts/misc/AaveOracle.sol similarity index 100% rename from src/core/contracts/misc/AaveOracle.sol rename to src/contracts/misc/AaveOracle.sol diff --git a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol b/src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol similarity index 93% rename from src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol rename to src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol index 40a25683..a723e331 100644 --- a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol +++ b/src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {WadRayMath} from '../libraries/math/WadRayMath.sol'; -import {PercentageMath} from '../libraries/math/PercentageMath.sol'; -import {DataTypes} from '../libraries/types/DataTypes.sol'; -import {Errors} from '../libraries/helpers/Errors.sol'; -import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; -import {IReserveInterestRateStrategy} from '../../interfaces/IReserveInterestRateStrategy.sol'; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; +import {WadRayMath} from '../protocol/libraries/math/WadRayMath.sol'; +import {PercentageMath} from '../protocol/libraries/math/PercentageMath.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; +import {Errors} from '../protocol/libraries/helpers/Errors.sol'; +import {IDefaultInterestRateStrategyV2} from '../interfaces/IDefaultInterestRateStrategyV2.sol'; +import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; /** * @title DefaultReserveInterestRateStrategyV2 contract diff --git a/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol b/src/contracts/misc/PriceOracleSentinel.sol similarity index 89% rename from src/core/contracts/protocol/configuration/PriceOracleSentinel.sol rename to src/contracts/misc/PriceOracleSentinel.sol index 2ff1584f..69d5f772 100644 --- a/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol +++ b/src/contracts/misc/PriceOracleSentinel.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {Errors} from '../libraries/helpers/Errors.sol'; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IPriceOracleSentinel} from '../../interfaces/IPriceOracleSentinel.sol'; -import {ISequencerOracle} from '../../interfaces/ISequencerOracle.sol'; -import {IACLManager} from '../../interfaces/IACLManager.sol'; +import {Errors} from '../protocol/libraries/helpers/Errors.sol'; +import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; +import {IPriceOracleSentinel} from '../interfaces/IPriceOracleSentinel.sol'; +import {ISequencerOracle} from '../interfaces/ISequencerOracle.sol'; +import {IACLManager} from '../interfaces/IACLManager.sol'; /** * @title PriceOracleSentinel diff --git a/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol b/src/contracts/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol similarity index 95% rename from src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol rename to src/contracts/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol index 06d2f827..252b4a4b 100644 --- a/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol +++ b/src/contracts/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {BaseUpgradeabilityProxy} from '../../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; +import {BaseUpgradeabilityProxy} from '../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; /** * @title BaseImmutableAdminUpgradeabilityProxy diff --git a/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol b/src/contracts/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol similarity index 79% rename from src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol rename to src/contracts/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol index 0deceb5b..6913a19d 100644 --- a/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol +++ b/src/contracts/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {InitializableUpgradeabilityProxy} from '../../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; -import {Proxy} from '../../../dependencies/openzeppelin/upgradeability/Proxy.sol'; +import {InitializableUpgradeabilityProxy} from '../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; +import {Proxy} from '../../dependencies/openzeppelin/upgradeability/Proxy.sol'; import {BaseImmutableAdminUpgradeabilityProxy} from './BaseImmutableAdminUpgradeabilityProxy.sol'; /** diff --git a/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol b/src/contracts/misc/aave-upgradeability/VersionedInitializable.sol similarity index 100% rename from src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol rename to src/contracts/misc/aave-upgradeability/VersionedInitializable.sol diff --git a/src/core/contracts/flashloan/base/FlashLoanReceiverBase.sol b/src/contracts/misc/flashloan/base/FlashLoanReceiverBase.sol similarity index 79% rename from src/core/contracts/flashloan/base/FlashLoanReceiverBase.sol rename to src/contracts/misc/flashloan/base/FlashLoanReceiverBase.sol index cd43c2e1..55fbe6d2 100644 --- a/src/core/contracts/flashloan/base/FlashLoanReceiverBase.sol +++ b/src/contracts/misc/flashloan/base/FlashLoanReceiverBase.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.10; import {IFlashLoanReceiver} from '../interfaces/IFlashLoanReceiver.sol'; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../interfaces/IPool.sol'; /** * @title FlashLoanReceiverBase diff --git a/src/core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol b/src/contracts/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol similarity index 80% rename from src/core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol rename to src/contracts/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol index 25af62b2..2980a0cc 100644 --- a/src/core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol +++ b/src/contracts/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.10; import {IFlashLoanSimpleReceiver} from '../interfaces/IFlashLoanSimpleReceiver.sol'; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../interfaces/IPool.sol'; /** * @title FlashLoanSimpleReceiverBase diff --git a/src/core/contracts/flashloan/interfaces/IFlashLoanReceiver.sol b/src/contracts/misc/flashloan/interfaces/IFlashLoanReceiver.sol similarity index 90% rename from src/core/contracts/flashloan/interfaces/IFlashLoanReceiver.sol rename to src/contracts/misc/flashloan/interfaces/IFlashLoanReceiver.sol index fae79a9f..a3a55684 100644 --- a/src/core/contracts/flashloan/interfaces/IFlashLoanReceiver.sol +++ b/src/contracts/misc/flashloan/interfaces/IFlashLoanReceiver.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../interfaces/IPool.sol'; /** * @title IFlashLoanReceiver diff --git a/src/core/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol b/src/contracts/misc/flashloan/interfaces/IFlashLoanSimpleReceiver.sol similarity index 89% rename from src/core/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol rename to src/contracts/misc/flashloan/interfaces/IFlashLoanSimpleReceiver.sol index 05c45739..bff21ae4 100644 --- a/src/core/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol +++ b/src/contracts/misc/flashloan/interfaces/IFlashLoanSimpleReceiver.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../interfaces/IPool.sol'; /** * @title IFlashLoanSimpleReceiver diff --git a/src/periphery/contracts/libraries/DataTypesHelper.sol b/src/contracts/misc/libraries/DataTypesHelper.sol similarity index 80% rename from src/periphery/contracts/libraries/DataTypesHelper.sol rename to src/contracts/misc/libraries/DataTypesHelper.sol index 492678a5..eed218ec 100644 --- a/src/periphery/contracts/libraries/DataTypesHelper.sol +++ b/src/contracts/misc/libraries/DataTypesHelper.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; /** * @title DataTypesHelper diff --git a/src/contracts/misc/libraries/RayMathExplicitRounding.sol b/src/contracts/misc/libraries/RayMathExplicitRounding.sol new file mode 100644 index 00000000..8d3f3dcb --- /dev/null +++ b/src/contracts/misc/libraries/RayMathExplicitRounding.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.8.10; + +enum Rounding { + UP, + DOWN +} + +/** + * Simplified version of RayMath that instead of half-up rounding does explicit rounding in a specified direction. + * This is needed to have a 4626 complient implementation, that always predictable rounds in favor of the vault / static a token. + */ +library RayMathExplicitRounding { + uint256 internal constant RAY = 1e27; + uint256 internal constant WAD_RAY_RATIO = 1e9; + + function rayMulRoundDown(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0 || b == 0) { + return 0; + } + return (a * b) / RAY; + } + + function rayMulRoundUp(uint256 a, uint256 b) internal pure returns (uint256) { + if (a == 0 || b == 0) { + return 0; + } + return ((a * b) + RAY - 1) / RAY; + } + + function rayDivRoundDown(uint256 a, uint256 b) internal pure returns (uint256) { + return (a * RAY) / b; + } + + function rayDivRoundUp(uint256 a, uint256 b) internal pure returns (uint256) { + return ((a * RAY) + b - 1) / b; + } + + function rayToWadRoundDown(uint256 a) internal pure returns (uint256) { + return a / WAD_RAY_RATIO; + } +} diff --git a/src/periphery/contracts/mocks/ATokenMock.sol b/src/contracts/mocks/ATokenMock.sol similarity index 100% rename from src/periphery/contracts/mocks/ATokenMock.sol rename to src/contracts/mocks/ATokenMock.sol diff --git a/src/periphery/contracts/mocks/MockBadTransferStrategy.sol b/src/contracts/mocks/MockBadTransferStrategy.sol similarity index 82% rename from src/periphery/contracts/mocks/MockBadTransferStrategy.sol rename to src/contracts/mocks/MockBadTransferStrategy.sol index 2f62c89d..696b3396 100644 --- a/src/periphery/contracts/mocks/MockBadTransferStrategy.sol +++ b/src/contracts/mocks/MockBadTransferStrategy.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../rewards/interfaces/ITransferStrategyBase.sol'; import {TransferStrategyBase} from '../rewards/transfer-strategies/TransferStrategyBase.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {GPv2SafeERC20} from '../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title MockBadTransferStrategy diff --git a/src/periphery/contracts/mocks/WETH9Mock.sol b/src/contracts/mocks/WETH9Mock.sol similarity index 72% rename from src/periphery/contracts/mocks/WETH9Mock.sol rename to src/contracts/mocks/WETH9Mock.sol index 1bc1bc48..2372ffeb 100644 --- a/src/periphery/contracts/mocks/WETH9Mock.sol +++ b/src/contracts/mocks/WETH9Mock.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; +import {WETH9} from '../dependencies/weth/WETH9.sol'; +import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; contract WETH9Mock is WETH9, Ownable { constructor(string memory mockName, string memory mockSymbol, address owner) { diff --git a/src/core/contracts/mocks/flashloan/MockFlashLoanReceiver.sol b/src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol similarity index 96% rename from src/core/contracts/mocks/flashloan/MockFlashLoanReceiver.sol rename to src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol index 516b4b38..f8877274 100644 --- a/src/core/contracts/mocks/flashloan/MockFlashLoanReceiver.sol +++ b/src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.10; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {FlashLoanReceiverBase} from '../../flashloan/base/FlashLoanReceiverBase.sol'; +import {FlashLoanReceiverBase} from '../../misc/flashloan/base/FlashLoanReceiverBase.sol'; import {MintableERC20} from '../tokens/MintableERC20.sol'; contract MockFlashLoanReceiver is FlashLoanReceiverBase { diff --git a/src/core/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol b/src/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol similarity index 95% rename from src/core/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol rename to src/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol index 1edd24a2..b3be47bc 100644 --- a/src/core/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol +++ b/src/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol @@ -6,7 +6,7 @@ import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {FlashLoanSimpleReceiverBase} from '../../flashloan/base/FlashLoanSimpleReceiverBase.sol'; +import {FlashLoanSimpleReceiverBase} from '../../misc/flashloan/base/FlashLoanSimpleReceiverBase.sol'; import {MintableERC20} from '../tokens/MintableERC20.sol'; contract MockFlashLoanSimpleReceiver is FlashLoanSimpleReceiverBase { diff --git a/src/core/contracts/mocks/helpers/MockIncentivesController.sol b/src/contracts/mocks/helpers/MockIncentivesController.sol similarity index 100% rename from src/core/contracts/mocks/helpers/MockIncentivesController.sol rename to src/contracts/mocks/helpers/MockIncentivesController.sol diff --git a/src/core/contracts/mocks/helpers/MockL2Pool.sol b/src/contracts/mocks/helpers/MockL2Pool.sol similarity index 68% rename from src/core/contracts/mocks/helpers/MockL2Pool.sol rename to src/contracts/mocks/helpers/MockL2Pool.sol index c37a7f70..9035cddd 100644 --- a/src/core/contracts/mocks/helpers/MockL2Pool.sol +++ b/src/contracts/mocks/helpers/MockL2Pool.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.10; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {L2PoolInstance, PoolInstance} from '../../../instances/L2PoolInstance.sol'; -import {VersionedInitializable} from '../../protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; +import {L2PoolInstance, PoolInstance} from '../../instances/L2PoolInstance.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; contract MockL2Pool is L2PoolInstance { function getRevision() diff --git a/src/core/contracts/mocks/helpers/MockPeripheryContract.sol b/src/contracts/mocks/helpers/MockPeripheryContract.sol similarity index 100% rename from src/core/contracts/mocks/helpers/MockPeripheryContract.sol rename to src/contracts/mocks/helpers/MockPeripheryContract.sol diff --git a/src/core/contracts/mocks/helpers/MockPool.sol b/src/contracts/mocks/helpers/MockPool.sol similarity index 92% rename from src/core/contracts/mocks/helpers/MockPool.sol rename to src/contracts/mocks/helpers/MockPool.sol index c66b83a6..7a27bf14 100644 --- a/src/core/contracts/mocks/helpers/MockPool.sol +++ b/src/contracts/mocks/helpers/MockPool.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {PoolInstance} from '../../../instances/PoolInstance.sol'; +import {PoolInstance} from '../../instances/PoolInstance.sol'; contract MockPoolInherited is PoolInstance { uint16 internal _maxNumberOfReserves = 128; diff --git a/src/core/contracts/mocks/helpers/MockReserveConfiguration.sol b/src/contracts/mocks/helpers/MockReserveConfiguration.sol similarity index 100% rename from src/core/contracts/mocks/helpers/MockReserveConfiguration.sol rename to src/contracts/mocks/helpers/MockReserveConfiguration.sol diff --git a/src/core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol b/src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol similarity index 100% rename from src/core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol rename to src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol diff --git a/src/core/contracts/mocks/oracle/PriceOracle.sol b/src/contracts/mocks/oracle/PriceOracle.sol similarity index 100% rename from src/core/contracts/mocks/oracle/PriceOracle.sol rename to src/contracts/mocks/oracle/PriceOracle.sol diff --git a/src/core/contracts/mocks/oracle/SequencerOracle.sol b/src/contracts/mocks/oracle/SequencerOracle.sol similarity index 100% rename from src/core/contracts/mocks/oracle/SequencerOracle.sol rename to src/contracts/mocks/oracle/SequencerOracle.sol diff --git a/src/periphery/contracts/mocks/swap/MockParaSwapAugustus.sol b/src/contracts/mocks/swap/MockParaSwapAugustus.sol similarity index 91% rename from src/periphery/contracts/mocks/swap/MockParaSwapAugustus.sol rename to src/contracts/mocks/swap/MockParaSwapAugustus.sol index cf41670b..5970c3b7 100644 --- a/src/periphery/contracts/mocks/swap/MockParaSwapAugustus.sol +++ b/src/contracts/mocks/swap/MockParaSwapAugustus.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IParaSwapAugustus} from '../../adapters/paraswap/interfaces/IParaSwapAugustus.sol'; +import {IParaSwapAugustus} from '../../extensions/paraswap-adapters/interfaces/IParaSwapAugustus.sol'; import {MockParaSwapTokenTransferProxy} from './MockParaSwapTokenTransferProxy.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {MintableERC20} from 'aave-v3-core/contracts/mocks/tokens/MintableERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {MintableERC20} from '../tokens/MintableERC20.sol'; contract MockParaSwapAugustus is IParaSwapAugustus { MockParaSwapTokenTransferProxy immutable TOKEN_TRANSFER_PROXY; diff --git a/src/periphery/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol b/src/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol similarity index 74% rename from src/periphery/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol rename to src/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol index 5e34d659..82fa93f8 100644 --- a/src/periphery/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol +++ b/src/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IParaSwapAugustusRegistry} from '../../adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol'; +import {IParaSwapAugustusRegistry} from '../../extensions/paraswap-adapters/interfaces/IParaSwapAugustusRegistry.sol'; contract MockParaSwapAugustusRegistry is IParaSwapAugustusRegistry { address immutable AUGUSTUS; diff --git a/src/periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol b/src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol similarity index 88% rename from src/periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol rename to src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol index efec5e9d..80f41d19 100644 --- a/src/periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol +++ b/src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IFeeClaimer} from '../../adapters/paraswap/interfaces/IFeeClaimer.sol'; +import {IFeeClaimer} from '../../extensions/paraswap-adapters/interfaces/IFeeClaimer.sol'; import {MockParaSwapTokenTransferProxy} from './MockParaSwapTokenTransferProxy.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {MintableERC20} from 'aave-v3-core/contracts/mocks/tokens/MintableERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {MintableERC20} from '../tokens/MintableERC20.sol'; contract MockParaSwapFeeClaimer is IFeeClaimer { MockParaSwapTokenTransferProxy immutable TOKEN_TRANSFER_PROXY; diff --git a/src/periphery/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol b/src/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol similarity index 60% rename from src/periphery/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol rename to src/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol index 711012e8..b36e6a44 100644 --- a/src/periphery/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol +++ b/src/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; contract MockParaSwapTokenTransferProxy is Ownable { function transferFrom( diff --git a/src/periphery/contracts/mocks/testnet-helpers/Faucet.sol b/src/contracts/mocks/testnet-helpers/Faucet.sol similarity index 95% rename from src/periphery/contracts/mocks/testnet-helpers/Faucet.sol rename to src/contracts/mocks/testnet-helpers/Faucet.sol index 539aee46..47a2a3f6 100644 --- a/src/periphery/contracts/mocks/testnet-helpers/Faucet.sol +++ b/src/contracts/mocks/testnet-helpers/Faucet.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; +import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; import {TestnetERC20} from './TestnetERC20.sol'; import {IFaucet} from './IFaucet.sol'; diff --git a/src/periphery/contracts/mocks/testnet-helpers/IFaucet.sol b/src/contracts/mocks/testnet-helpers/IFaucet.sol similarity index 100% rename from src/periphery/contracts/mocks/testnet-helpers/IFaucet.sol rename to src/contracts/mocks/testnet-helpers/IFaucet.sol diff --git a/src/periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol similarity index 90% rename from src/periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol rename to src/contracts/mocks/testnet-helpers/TestnetERC20.sol index 58e4ddf2..efe94186 100644 --- a/src/periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol +++ b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; -import {ERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/ERC20.sol'; -import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; +import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; +import {ERC20} from '../../dependencies/openzeppelin/contracts/ERC20.sol'; +import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; /** * @title TestnetERC20 diff --git a/src/core/contracts/mocks/tests/FlashloanAttacker.sol b/src/contracts/mocks/tests/FlashloanAttacker.sol similarity index 95% rename from src/core/contracts/mocks/tests/FlashloanAttacker.sol rename to src/contracts/mocks/tests/FlashloanAttacker.sol index 63d09b1b..9f32fbd9 100644 --- a/src/core/contracts/mocks/tests/FlashloanAttacker.sol +++ b/src/contracts/mocks/tests/FlashloanAttacker.sol @@ -6,7 +6,7 @@ import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {FlashLoanSimpleReceiverBase} from '../../flashloan/base/FlashLoanSimpleReceiverBase.sol'; +import {FlashLoanSimpleReceiverBase} from '../../misc/flashloan/base/FlashLoanSimpleReceiverBase.sol'; import {MintableERC20} from '../tokens/MintableERC20.sol'; import {IPool} from '../../interfaces/IPool.sol'; import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; diff --git a/src/core/contracts/mocks/tests/MathUtilsWrapper.sol b/src/contracts/mocks/tests/MathUtilsWrapper.sol similarity index 100% rename from src/core/contracts/mocks/tests/MathUtilsWrapper.sol rename to src/contracts/mocks/tests/MathUtilsWrapper.sol diff --git a/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol b/src/contracts/mocks/tests/MockReserveInterestRateStrategy.sol similarity index 88% rename from src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol rename to src/contracts/mocks/tests/MockReserveInterestRateStrategy.sol index 082d7651..fd7b1f25 100644 --- a/src/core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol +++ b/src/contracts/mocks/tests/MockReserveInterestRateStrategy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {DefaultReserveInterestRateStrategyV2} from '../../protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; +import {DefaultReserveInterestRateStrategyV2} from '../../misc/DefaultReserveInterestRateStrategyV2.sol'; import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; contract MockReserveInterestRateStrategy is DefaultReserveInterestRateStrategyV2 { diff --git a/src/core/contracts/mocks/tests/PercentageMathWrapper.sol b/src/contracts/mocks/tests/PercentageMathWrapper.sol similarity index 100% rename from src/core/contracts/mocks/tests/PercentageMathWrapper.sol rename to src/contracts/mocks/tests/PercentageMathWrapper.sol diff --git a/src/core/contracts/mocks/tests/WadRayMathWrapper.sol b/src/contracts/mocks/tests/WadRayMathWrapper.sol similarity index 100% rename from src/core/contracts/mocks/tests/WadRayMathWrapper.sol rename to src/contracts/mocks/tests/WadRayMathWrapper.sol diff --git a/src/core/contracts/mocks/tokens/MintableDelegationERC20.sol b/src/contracts/mocks/tokens/MintableDelegationERC20.sol similarity index 100% rename from src/core/contracts/mocks/tokens/MintableDelegationERC20.sol rename to src/contracts/mocks/tokens/MintableDelegationERC20.sol diff --git a/src/core/contracts/mocks/tokens/MintableERC20.sol b/src/contracts/mocks/tokens/MintableERC20.sol similarity index 100% rename from src/core/contracts/mocks/tokens/MintableERC20.sol rename to src/contracts/mocks/tokens/MintableERC20.sol diff --git a/src/core/contracts/mocks/tokens/MockATokenRepayment.sol b/src/contracts/mocks/tokens/MockATokenRepayment.sol similarity index 88% rename from src/core/contracts/mocks/tokens/MockATokenRepayment.sol rename to src/contracts/mocks/tokens/MockATokenRepayment.sol index 4e2c0dd2..c0f77de5 100644 --- a/src/core/contracts/mocks/tokens/MockATokenRepayment.sol +++ b/src/contracts/mocks/tokens/MockATokenRepayment.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {ATokenInstance} from '../../../instances/ATokenInstance.sol'; +import {ATokenInstance} from '../../instances/ATokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockATokenRepayment is ATokenInstance { diff --git a/src/core/contracts/mocks/tokens/MockDebtTokens.sol b/src/contracts/mocks/tokens/MockDebtTokens.sol similarity index 74% rename from src/core/contracts/mocks/tokens/MockDebtTokens.sol rename to src/contracts/mocks/tokens/MockDebtTokens.sol index 8c186b82..7418dab3 100644 --- a/src/core/contracts/mocks/tokens/MockDebtTokens.sol +++ b/src/contracts/mocks/tokens/MockDebtTokens.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {VariableDebtTokenInstance} from '../../../instances/VariableDebtTokenInstance.sol'; -import {StableDebtTokenInstance} from '../../../instances/StableDebtTokenInstance.sol'; +import {VariableDebtTokenInstance} from '../../instances/VariableDebtTokenInstance.sol'; +import {StableDebtTokenInstance} from '../../instances/StableDebtTokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockVariableDebtToken is VariableDebtTokenInstance { diff --git a/src/core/contracts/mocks/tokens/MockScaledToken.sol b/src/contracts/mocks/tokens/MockScaledToken.sol similarity index 85% rename from src/core/contracts/mocks/tokens/MockScaledToken.sol rename to src/contracts/mocks/tokens/MockScaledToken.sol index 854f4356..f3a26e2e 100644 --- a/src/core/contracts/mocks/tokens/MockScaledToken.sol +++ b/src/contracts/mocks/tokens/MockScaledToken.sol @@ -1,7 +1,8 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import 'aave-v3-core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol'; -import 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; +import '../../protocol/tokenization/base/ScaledBalanceTokenBase.sol'; +import '../../protocol/libraries/math/WadRayMath.sol'; contract MockScaledToken is ScaledBalanceTokenBase { using WadRayMath for uint256; diff --git a/src/core/contracts/mocks/tokens/WETH9Mocked.sol b/src/contracts/mocks/tokens/WETH9Mocked.sol similarity index 100% rename from src/core/contracts/mocks/tokens/WETH9Mocked.sol rename to src/contracts/mocks/tokens/WETH9Mocked.sol diff --git a/src/core/contracts/mocks/upgradeability/MockAToken.sol b/src/contracts/mocks/upgradeability/MockAToken.sol similarity index 80% rename from src/core/contracts/mocks/upgradeability/MockAToken.sol rename to src/contracts/mocks/upgradeability/MockAToken.sol index bcdc8c1c..14bbf1a8 100644 --- a/src/core/contracts/mocks/upgradeability/MockAToken.sol +++ b/src/contracts/mocks/upgradeability/MockAToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {ATokenInstance} from '../../../instances/ATokenInstance.sol'; +import {ATokenInstance} from '../../instances/ATokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockAToken is ATokenInstance { diff --git a/src/core/contracts/mocks/upgradeability/MockInitializableImplementation.sol b/src/contracts/mocks/upgradeability/MockInitializableImplementation.sol similarity index 96% rename from src/core/contracts/mocks/upgradeability/MockInitializableImplementation.sol rename to src/contracts/mocks/upgradeability/MockInitializableImplementation.sol index 9f63a598..ed48f44b 100644 --- a/src/core/contracts/mocks/upgradeability/MockInitializableImplementation.sol +++ b/src/contracts/mocks/upgradeability/MockInitializableImplementation.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {VersionedInitializable} from '../../protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; contract MockInitializableImple is VersionedInitializable { diff --git a/src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol b/src/contracts/mocks/upgradeability/MockStableDebtToken.sol similarity index 78% rename from src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol rename to src/contracts/mocks/upgradeability/MockStableDebtToken.sol index ea9d5cca..ecbd73c9 100644 --- a/src/core/contracts/mocks/upgradeability/MockStableDebtToken.sol +++ b/src/contracts/mocks/upgradeability/MockStableDebtToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {StableDebtTokenInstance} from '../../../instances/StableDebtTokenInstance.sol'; +import {StableDebtTokenInstance} from '../../instances/StableDebtTokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockStableDebtToken is StableDebtTokenInstance { diff --git a/src/core/contracts/mocks/upgradeability/MockVariableDebtToken.sol b/src/contracts/mocks/upgradeability/MockVariableDebtToken.sol similarity index 77% rename from src/core/contracts/mocks/upgradeability/MockVariableDebtToken.sol rename to src/contracts/mocks/upgradeability/MockVariableDebtToken.sol index 211821f5..a75db430 100644 --- a/src/core/contracts/mocks/upgradeability/MockVariableDebtToken.sol +++ b/src/contracts/mocks/upgradeability/MockVariableDebtToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {VariableDebtTokenInstance} from '../../../instances/VariableDebtTokenInstance.sol'; +import {VariableDebtTokenInstance} from '../../instances/VariableDebtTokenInstance.sol'; import {IPool} from '../../interfaces/IPool.sol'; contract MockVariableDebtToken is VariableDebtTokenInstance { diff --git a/src/core/contracts/protocol/configuration/ACLManager.sol b/src/contracts/protocol/configuration/ACLManager.sol similarity index 100% rename from src/core/contracts/protocol/configuration/ACLManager.sol rename to src/contracts/protocol/configuration/ACLManager.sol diff --git a/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol b/src/contracts/protocol/configuration/PoolAddressesProvider.sol similarity index 98% rename from src/core/contracts/protocol/configuration/PoolAddressesProvider.sol rename to src/contracts/protocol/configuration/PoolAddressesProvider.sol index 06fa9333..009f4e5c 100644 --- a/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol +++ b/src/contracts/protocol/configuration/PoolAddressesProvider.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {InitializableImmutableAdminUpgradeabilityProxy} from '../libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; +import {InitializableImmutableAdminUpgradeabilityProxy} from '../../misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; /** * @title PoolAddressesProvider diff --git a/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol b/src/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol similarity index 100% rename from src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol rename to src/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol diff --git a/src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol similarity index 100% rename from src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol rename to src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol diff --git a/src/core/contracts/protocol/libraries/configuration/UserConfiguration.sol b/src/contracts/protocol/libraries/configuration/UserConfiguration.sol similarity index 100% rename from src/core/contracts/protocol/libraries/configuration/UserConfiguration.sol rename to src/contracts/protocol/libraries/configuration/UserConfiguration.sol diff --git a/src/core/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol similarity index 100% rename from src/core/contracts/protocol/libraries/helpers/Errors.sol rename to src/contracts/protocol/libraries/helpers/Errors.sol diff --git a/src/core/contracts/protocol/libraries/helpers/Helpers.sol b/src/contracts/protocol/libraries/helpers/Helpers.sol similarity index 100% rename from src/core/contracts/protocol/libraries/helpers/Helpers.sol rename to src/contracts/protocol/libraries/helpers/Helpers.sol diff --git a/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol b/src/contracts/protocol/libraries/logic/BorrowLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/BorrowLogic.sol rename to src/contracts/protocol/libraries/logic/BorrowLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol b/src/contracts/protocol/libraries/logic/BridgeLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/BridgeLogic.sol rename to src/contracts/protocol/libraries/logic/BridgeLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol b/src/contracts/protocol/libraries/logic/CalldataLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/CalldataLogic.sol rename to src/contracts/protocol/libraries/logic/CalldataLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol similarity index 99% rename from src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol rename to src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol index e0b14e7b..244a2a55 100644 --- a/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol +++ b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.10; import {IPool} from '../../../interfaces/IPool.sol'; import {IInitializableAToken} from '../../../interfaces/IInitializableAToken.sol'; import {IInitializableDebtToken} from '../../../interfaces/IInitializableDebtToken.sol'; -import {InitializableImmutableAdminUpgradeabilityProxy} from '../aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; +import {InitializableImmutableAdminUpgradeabilityProxy} from '../../../misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; import {DataTypes} from '../types/DataTypes.sol'; diff --git a/src/core/contracts/protocol/libraries/logic/EModeLogic.sol b/src/contracts/protocol/libraries/logic/EModeLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/EModeLogic.sol rename to src/contracts/protocol/libraries/logic/EModeLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol b/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol similarity index 98% rename from src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol rename to src/contracts/protocol/libraries/logic/FlashLoanLogic.sol index 615b2fdd..efb4feae 100644 --- a/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol +++ b/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol @@ -6,8 +6,8 @@ import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.so import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; import {IPool} from '../../../interfaces/IPool.sol'; -import {IFlashLoanReceiver} from '../../../flashloan/interfaces/IFlashLoanReceiver.sol'; -import {IFlashLoanSimpleReceiver} from '../../../flashloan/interfaces/IFlashLoanSimpleReceiver.sol'; +import {IFlashLoanReceiver} from '../../../misc/flashloan/interfaces/IFlashLoanReceiver.sol'; +import {IFlashLoanSimpleReceiver} from '../../../misc/flashloan/interfaces/IFlashLoanSimpleReceiver.sol'; import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; diff --git a/src/core/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/GenericLogic.sol rename to src/contracts/protocol/libraries/logic/GenericLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol b/src/contracts/protocol/libraries/logic/IsolationModeLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol rename to src/contracts/protocol/libraries/logic/IsolationModeLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol rename to src/contracts/protocol/libraries/logic/LiquidationLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/PoolLogic.sol b/src/contracts/protocol/libraries/logic/PoolLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/PoolLogic.sol rename to src/contracts/protocol/libraries/logic/PoolLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/ReserveLogic.sol b/src/contracts/protocol/libraries/logic/ReserveLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/ReserveLogic.sol rename to src/contracts/protocol/libraries/logic/ReserveLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol b/src/contracts/protocol/libraries/logic/SupplyLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/SupplyLogic.sol rename to src/contracts/protocol/libraries/logic/SupplyLogic.sol diff --git a/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol similarity index 100% rename from src/core/contracts/protocol/libraries/logic/ValidationLogic.sol rename to src/contracts/protocol/libraries/logic/ValidationLogic.sol diff --git a/src/core/contracts/protocol/libraries/math/MathUtils.sol b/src/contracts/protocol/libraries/math/MathUtils.sol similarity index 100% rename from src/core/contracts/protocol/libraries/math/MathUtils.sol rename to src/contracts/protocol/libraries/math/MathUtils.sol diff --git a/src/core/contracts/protocol/libraries/math/PercentageMath.sol b/src/contracts/protocol/libraries/math/PercentageMath.sol similarity index 100% rename from src/core/contracts/protocol/libraries/math/PercentageMath.sol rename to src/contracts/protocol/libraries/math/PercentageMath.sol diff --git a/src/core/contracts/protocol/libraries/math/WadRayMath.sol b/src/contracts/protocol/libraries/math/WadRayMath.sol similarity index 100% rename from src/core/contracts/protocol/libraries/math/WadRayMath.sol rename to src/contracts/protocol/libraries/math/WadRayMath.sol diff --git a/src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol b/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol similarity index 100% rename from src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol rename to src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol diff --git a/src/core/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol similarity index 100% rename from src/core/contracts/protocol/libraries/types/DataTypes.sol rename to src/contracts/protocol/libraries/types/DataTypes.sol diff --git a/src/core/contracts/protocol/pool/L2Pool.sol b/src/contracts/protocol/pool/L2Pool.sol similarity index 100% rename from src/core/contracts/protocol/pool/L2Pool.sol rename to src/contracts/protocol/pool/L2Pool.sol diff --git a/src/core/contracts/protocol/pool/Pool.sol b/src/contracts/protocol/pool/Pool.sol similarity index 99% rename from src/core/contracts/protocol/pool/Pool.sol rename to src/contracts/protocol/pool/Pool.sol index 4397323d..c58a78d5 100644 --- a/src/core/contracts/protocol/pool/Pool.sol +++ b/src/contracts/protocol/pool/Pool.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; import {PoolLogic} from '../libraries/logic/PoolLogic.sol'; diff --git a/src/core/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol similarity index 99% rename from src/core/contracts/protocol/pool/PoolConfigurator.sol rename to src/contracts/protocol/pool/PoolConfigurator.sol index 041943e1..b22581b0 100644 --- a/src/core/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; diff --git a/src/core/contracts/protocol/pool/PoolStorage.sol b/src/contracts/protocol/pool/PoolStorage.sol similarity index 100% rename from src/core/contracts/protocol/pool/PoolStorage.sol rename to src/contracts/protocol/pool/PoolStorage.sol diff --git a/src/core/contracts/protocol/tokenization/AToken.sol b/src/contracts/protocol/tokenization/AToken.sol similarity index 98% rename from src/core/contracts/protocol/tokenization/AToken.sol rename to src/contracts/protocol/tokenization/AToken.sol index 126801bf..47ba03d9 100644 --- a/src/core/contracts/protocol/tokenization/AToken.sol +++ b/src/contracts/protocol/tokenization/AToken.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.10; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {SafeCast} from '../../dependencies/openzeppelin/contracts/SafeCast.sol'; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {IPool} from '../../interfaces/IPool.sol'; diff --git a/src/core/contracts/protocol/tokenization/StableDebtToken.sol b/src/contracts/protocol/tokenization/StableDebtToken.sol similarity index 97% rename from src/core/contracts/protocol/tokenization/StableDebtToken.sol rename to src/contracts/protocol/tokenization/StableDebtToken.sol index e7c785e6..74995247 100644 --- a/src/core/contracts/protocol/tokenization/StableDebtToken.sol +++ b/src/contracts/protocol/tokenization/StableDebtToken.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.10; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; import {IInitializableDebtToken} from '../../interfaces/IInitializableDebtToken.sol'; diff --git a/src/core/contracts/protocol/tokenization/VariableDebtToken.sol b/src/contracts/protocol/tokenization/VariableDebtToken.sol similarity index 97% rename from src/core/contracts/protocol/tokenization/VariableDebtToken.sol rename to src/contracts/protocol/tokenization/VariableDebtToken.sol index 0987494b..37494c85 100644 --- a/src/core/contracts/protocol/tokenization/VariableDebtToken.sol +++ b/src/contracts/protocol/tokenization/VariableDebtToken.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {SafeCast} from '../../dependencies/openzeppelin/contracts/SafeCast.sol'; -import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {IPool} from '../../interfaces/IPool.sol'; diff --git a/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol b/src/contracts/protocol/tokenization/base/DebtTokenBase.sol similarity index 97% rename from src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol rename to src/contracts/protocol/tokenization/base/DebtTokenBase.sol index 8dc79203..3280add0 100644 --- a/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol +++ b/src/contracts/protocol/tokenization/base/DebtTokenBase.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import {Context} from '../../../dependencies/openzeppelin/contracts/Context.sol'; import {Errors} from '../../libraries/helpers/Errors.sol'; -import {VersionedInitializable} from '../../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {VersionedInitializable} from '../../../misc/aave-upgradeability/VersionedInitializable.sol'; import {ICreditDelegationToken} from '../../../interfaces/ICreditDelegationToken.sol'; import {EIP712Base} from './EIP712Base.sol'; diff --git a/src/core/contracts/protocol/tokenization/base/EIP712Base.sol b/src/contracts/protocol/tokenization/base/EIP712Base.sol similarity index 100% rename from src/core/contracts/protocol/tokenization/base/EIP712Base.sol rename to src/contracts/protocol/tokenization/base/EIP712Base.sol diff --git a/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol b/src/contracts/protocol/tokenization/base/IncentivizedERC20.sol similarity index 100% rename from src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol rename to src/contracts/protocol/tokenization/base/IncentivizedERC20.sol diff --git a/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol b/src/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol similarity index 100% rename from src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol rename to src/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol diff --git a/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol b/src/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol similarity index 100% rename from src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol rename to src/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol diff --git a/src/periphery/contracts/rewards/EmissionManager.sol b/src/contracts/rewards/EmissionManager.sol similarity index 95% rename from src/periphery/contracts/rewards/EmissionManager.sol rename to src/contracts/rewards/EmissionManager.sol index 19138df8..b18473ff 100644 --- a/src/periphery/contracts/rewards/EmissionManager.sol +++ b/src/contracts/rewards/EmissionManager.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; -import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; +import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; +import {IEACAggregatorProxy} from '../helpers/interfaces/IEACAggregatorProxy.sol'; import {IEmissionManager} from './interfaces/IEmissionManager.sol'; import {ITransferStrategyBase} from './interfaces/ITransferStrategyBase.sol'; import {IRewardsController} from './interfaces/IRewardsController.sol'; diff --git a/src/periphery/contracts/rewards/RewardsController.sol b/src/contracts/rewards/RewardsController.sol similarity index 96% rename from src/periphery/contracts/rewards/RewardsController.sol rename to src/contracts/rewards/RewardsController.sol index 0c369a60..3a817f60 100644 --- a/src/periphery/contracts/rewards/RewardsController.sol +++ b/src/contracts/rewards/RewardsController.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {VersionedInitializable} from 'aave-v3-core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; -import {SafeCast} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; -import {IScaledBalanceToken} from 'aave-v3-core/contracts/interfaces/IScaledBalanceToken.sol'; +import {VersionedInitializable} from '../misc/aave-upgradeability/VersionedInitializable.sol'; +import {SafeCast} from '../dependencies/openzeppelin/contracts/SafeCast.sol'; +import {IScaledBalanceToken} from '../interfaces/IScaledBalanceToken.sol'; import {RewardsDistributor} from './RewardsDistributor.sol'; import {IRewardsController} from './interfaces/IRewardsController.sol'; import {ITransferStrategyBase} from './interfaces/ITransferStrategyBase.sol'; import {RewardsDataTypes} from './libraries/RewardsDataTypes.sol'; -import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; +import {IEACAggregatorProxy} from '../helpers/interfaces/IEACAggregatorProxy.sol'; /** * @title RewardsController diff --git a/src/periphery/contracts/rewards/RewardsDistributor.sol b/src/contracts/rewards/RewardsDistributor.sol similarity index 98% rename from src/periphery/contracts/rewards/RewardsDistributor.sol rename to src/contracts/rewards/RewardsDistributor.sol index ffc03d05..c8aa7a23 100644 --- a/src/periphery/contracts/rewards/RewardsDistributor.sol +++ b/src/contracts/rewards/RewardsDistributor.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IScaledBalanceToken} from 'aave-v3-core/contracts/interfaces/IScaledBalanceToken.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {SafeCast} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; +import {IScaledBalanceToken} from '../interfaces/IScaledBalanceToken.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {SafeCast} from '../dependencies/openzeppelin/contracts/SafeCast.sol'; import {IRewardsDistributor} from './interfaces/IRewardsDistributor.sol'; import {RewardsDataTypes} from './libraries/RewardsDataTypes.sol'; diff --git a/src/periphery/contracts/rewards/interfaces/IEmissionManager.sol b/src/contracts/rewards/interfaces/IEmissionManager.sol similarity index 98% rename from src/periphery/contracts/rewards/interfaces/IEmissionManager.sol rename to src/contracts/rewards/interfaces/IEmissionManager.sol index 2f1f7eac..4853af21 100644 --- a/src/periphery/contracts/rewards/interfaces/IEmissionManager.sol +++ b/src/contracts/rewards/interfaces/IEmissionManager.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import {IEACAggregatorProxy} from '../../misc/interfaces/IEACAggregatorProxy.sol'; +import {IEACAggregatorProxy} from '../../helpers/interfaces/IEACAggregatorProxy.sol'; import {RewardsDataTypes} from '../libraries/RewardsDataTypes.sol'; import {ITransferStrategyBase} from './ITransferStrategyBase.sol'; import {IRewardsController} from './IRewardsController.sol'; diff --git a/src/periphery/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol b/src/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol similarity index 100% rename from src/periphery/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol rename to src/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol diff --git a/src/periphery/contracts/rewards/interfaces/IRewardsController.sol b/src/contracts/rewards/interfaces/IRewardsController.sol similarity index 99% rename from src/periphery/contracts/rewards/interfaces/IRewardsController.sol rename to src/contracts/rewards/interfaces/IRewardsController.sol index 952da7cb..cdb2ac29 100644 --- a/src/periphery/contracts/rewards/interfaces/IRewardsController.sol +++ b/src/contracts/rewards/interfaces/IRewardsController.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import {IRewardsDistributor} from './IRewardsDistributor.sol'; import {ITransferStrategyBase} from './ITransferStrategyBase.sol'; -import {IEACAggregatorProxy} from '../../misc/interfaces/IEACAggregatorProxy.sol'; +import {IEACAggregatorProxy} from '../../helpers/interfaces/IEACAggregatorProxy.sol'; import {RewardsDataTypes} from '../libraries/RewardsDataTypes.sol'; /** diff --git a/src/periphery/contracts/rewards/interfaces/IRewardsDistributor.sol b/src/contracts/rewards/interfaces/IRewardsDistributor.sol similarity index 100% rename from src/periphery/contracts/rewards/interfaces/IRewardsDistributor.sol rename to src/contracts/rewards/interfaces/IRewardsDistributor.sol diff --git a/src/periphery/contracts/rewards/interfaces/IStakedToken.sol b/src/contracts/rewards/interfaces/IStakedToken.sol similarity index 100% rename from src/periphery/contracts/rewards/interfaces/IStakedToken.sol rename to src/contracts/rewards/interfaces/IStakedToken.sol diff --git a/src/periphery/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol b/src/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol similarity index 100% rename from src/periphery/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol rename to src/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol diff --git a/src/periphery/contracts/rewards/interfaces/ITransferStrategyBase.sol b/src/contracts/rewards/interfaces/ITransferStrategyBase.sol similarity index 100% rename from src/periphery/contracts/rewards/interfaces/ITransferStrategyBase.sol rename to src/contracts/rewards/interfaces/ITransferStrategyBase.sol diff --git a/src/periphery/contracts/rewards/libraries/RewardsDataTypes.sol b/src/contracts/rewards/libraries/RewardsDataTypes.sol similarity index 94% rename from src/periphery/contracts/rewards/libraries/RewardsDataTypes.sol rename to src/contracts/rewards/libraries/RewardsDataTypes.sol index 4cafda32..38fe87c5 100644 --- a/src/periphery/contracts/rewards/libraries/RewardsDataTypes.sol +++ b/src/contracts/rewards/libraries/RewardsDataTypes.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; -import {IEACAggregatorProxy} from '../../misc/interfaces/IEACAggregatorProxy.sol'; +import {IEACAggregatorProxy} from '../../helpers/interfaces/IEACAggregatorProxy.sol'; library RewardsDataTypes { struct RewardsConfigInput { diff --git a/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol b/src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol similarity index 88% rename from src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol rename to src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol index 46620b3e..dc4b5a9b 100644 --- a/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol +++ b/src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.10; import {IPullRewardsTransferStrategy} from '../interfaces/IPullRewardsTransferStrategy.sol'; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; import {TransferStrategyBase} from './TransferStrategyBase.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title PullRewardsTransferStrategy diff --git a/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol b/src/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol similarity index 92% rename from src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol rename to src/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol index bb3901c3..9ca6f8c3 100644 --- a/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol +++ b/src/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol @@ -5,8 +5,8 @@ import {IStakedToken} from '../interfaces/IStakedToken.sol'; import {IStakedTokenTransferStrategy} from '../interfaces/IStakedTokenTransferStrategy.sol'; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; import {TransferStrategyBase} from './TransferStrategyBase.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title StakedTokenTransferStrategy diff --git a/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol b/src/contracts/rewards/transfer-strategies/TransferStrategyBase.sol similarity index 89% rename from src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol rename to src/contracts/rewards/transfer-strategies/TransferStrategyBase.sol index 2f26b958..5064606d 100644 --- a/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol +++ b/src/contracts/rewards/transfer-strategies/TransferStrategyBase.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; -import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title TransferStrategyStorage diff --git a/src/periphery/contracts/treasury/Collector.sol b/src/contracts/treasury/Collector.sol similarity index 96% rename from src/periphery/contracts/treasury/Collector.sol rename to src/contracts/treasury/Collector.sol index 22cf3e2f..daf6b7a3 100644 --- a/src/periphery/contracts/treasury/Collector.sol +++ b/src/contracts/treasury/Collector.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import {ICollector} from './ICollector.sol'; import {ReentrancyGuard} from '../dependencies/openzeppelin/ReentrancyGuard.sol'; -import {VersionedInitializable} from '../../../core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; -import {IERC20} from '../../../core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {SafeERC20} from '../../../core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; -import {Address} from '../../../core/contracts/dependencies/openzeppelin/contracts/Address.sol'; +import {VersionedInitializable} from '../misc/aave-upgradeability/VersionedInitializable.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {Address} from '../dependencies/openzeppelin/contracts/Address.sol'; /** * @title Collector diff --git a/src/periphery/contracts/treasury/ICollector.sol b/src/contracts/treasury/ICollector.sol similarity index 98% rename from src/periphery/contracts/treasury/ICollector.sol rename to src/contracts/treasury/ICollector.sol index ae92353d..94103d48 100644 --- a/src/periphery/contracts/treasury/ICollector.sol +++ b/src/contracts/treasury/ICollector.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IERC20} from '../../../core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; interface ICollector { struct Stream { diff --git a/src/core/contracts/flashloan/base/LICENSE.md b/src/core/contracts/flashloan/base/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/core/contracts/flashloan/base/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/core/contracts/flashloan/interfaces/LICENSE.md b/src/core/contracts/flashloan/interfaces/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/core/contracts/flashloan/interfaces/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/core/contracts/interfaces/LICENSE.md b/src/core/contracts/interfaces/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/core/contracts/interfaces/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/core/contracts/misc/interfaces/LICENSE.md b/src/core/contracts/misc/interfaces/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/core/contracts/misc/interfaces/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/deployments/contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol b/src/deployments/contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol index db3e2bc8..d26419e7 100644 --- a/src/deployments/contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import '../../interfaces/IMarketReportTypes.sol'; -import {DefaultReserveInterestRateStrategyV2} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; +import {DefaultReserveInterestRateStrategyV2} from '../../../contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; contract AaveV3DefaultRateStrategyProcedure { function _deployDefaultRateStrategyV2(address poolAddressesProvider) internal returns (address) { diff --git a/src/deployments/contracts/procedures/AaveV3GettersProcedureOne.sol b/src/deployments/contracts/procedures/AaveV3GettersProcedureOne.sol index ffa52d4d..8aa66732 100644 --- a/src/deployments/contracts/procedures/AaveV3GettersProcedureOne.sol +++ b/src/deployments/contracts/procedures/AaveV3GettersProcedureOne.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {WalletBalanceProvider} from 'aave-v3-periphery/contracts/misc/WalletBalanceProvider.sol'; -import {UiPoolDataProviderV3} from 'aave-v3-periphery/contracts/misc/UiPoolDataProviderV3.sol'; -import {UiIncentiveDataProviderV3} from 'aave-v3-periphery/contracts/misc/UiIncentiveDataProviderV3.sol'; -import {IEACAggregatorProxy} from 'aave-v3-periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol'; -import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {WalletBalanceProvider} from '../../../contracts/helpers/WalletBalanceProvider.sol'; +import {UiPoolDataProviderV3} from '../../../contracts/helpers/UiPoolDataProviderV3.sol'; +import {UiIncentiveDataProviderV3} from '../../../contracts/helpers/UiIncentiveDataProviderV3.sol'; +import {IEACAggregatorProxy} from '../../../contracts/helpers/interfaces/IEACAggregatorProxy.sol'; +import {AaveProtocolDataProvider} from '../../../contracts/helpers/AaveProtocolDataProvider.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; contract AaveV3GettersProcedureOne { struct GettersReportBatchOne { diff --git a/src/deployments/contracts/procedures/AaveV3GettersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3GettersProcedureTwo.sol index eaaddb17..947cc7a9 100644 --- a/src/deployments/contracts/procedures/AaveV3GettersProcedureTwo.sol +++ b/src/deployments/contracts/procedures/AaveV3GettersProcedureTwo.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {WrappedTokenGatewayV3} from 'aave-v3-periphery/contracts/misc/WrappedTokenGatewayV3.sol'; -import {L2Encoder} from 'aave-v3-core/contracts/misc/L2Encoder.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; +import {WrappedTokenGatewayV3} from '../../../contracts/helpers/WrappedTokenGatewayV3.sol'; +import {L2Encoder} from '../../../contracts/helpers/L2Encoder.sol'; contract AaveV3GettersProcedureTwo { struct GettersReportBatchTwo { diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol new file mode 100644 index 00000000..952b02af --- /dev/null +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {Create2Utils} from '../utilities/Create2Utils.sol'; +import {ConfigEngineReport} from '../../interfaces/IMarketReportTypes.sol'; +import {AaveV3ConfigEngine, IAaveV3ConfigEngine, CapsEngine, BorrowEngine, CollateralEngine, RateEngine, PriceFeedEngine, EModeEngine, ListingEngine} from '../../../contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; +import {IPoolConfigurator} from '../../../contracts/interfaces/IPoolConfigurator.sol'; +import {IAaveOracle} from '../../../contracts/interfaces/IAaveOracle.sol'; + +contract AaveV3HelpersProcedureOne { + function _deployConfigEngine( + address pool, + address poolConfigurator, + address defaultInterestRateStrategy, + address aaveOracle, + address rewardsController, + address collector, + address aTokenImpl, + address vTokenImpl, + address sTokenImpl + ) internal returns (ConfigEngineReport memory configEngineReport) { + IAaveV3ConfigEngine.EngineLibraries memory engineLibraries = IAaveV3ConfigEngine + .EngineLibraries({ + listingEngine: Create2Utils._create2Deploy('v1', type(ListingEngine).creationCode), + eModeEngine: Create2Utils._create2Deploy('v1', type(EModeEngine).creationCode), + borrowEngine: Create2Utils._create2Deploy('v1', type(BorrowEngine).creationCode), + collateralEngine: Create2Utils._create2Deploy('v1', type(CollateralEngine).creationCode), + priceFeedEngine: Create2Utils._create2Deploy('v1', type(PriceFeedEngine).creationCode), + rateEngine: Create2Utils._create2Deploy('v1', type(RateEngine).creationCode), + capsEngine: Create2Utils._create2Deploy('v1', type(CapsEngine).creationCode) + }); + + IAaveV3ConfigEngine.EngineConstants memory engineConstants = IAaveV3ConfigEngine + .EngineConstants({ + pool: IPool(pool), + poolConfigurator: IPoolConfigurator(poolConfigurator), + defaultInterestRateStrategy: defaultInterestRateStrategy, + oracle: IAaveOracle(aaveOracle), + rewardsController: rewardsController, + collector: collector + }); + + configEngineReport.listingEngine = engineLibraries.listingEngine; + configEngineReport.eModeEngine = engineLibraries.eModeEngine; + configEngineReport.borrowEngine = engineLibraries.borrowEngine; + configEngineReport.collateralEngine = engineLibraries.collateralEngine; + configEngineReport.priceFeedEngine = engineLibraries.priceFeedEngine; + configEngineReport.rateEngine = engineLibraries.rateEngine; + configEngineReport.capsEngine = engineLibraries.capsEngine; + + configEngineReport.configEngine = address( + new AaveV3ConfigEngine( + aTokenImpl, + vTokenImpl, + sTokenImpl, + engineConstants, + engineLibraries + ) + ); + return configEngineReport; + } +} diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol new file mode 100644 index 00000000..f455b2e9 --- /dev/null +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../interfaces/IMarketReportTypes.sol'; +import {TransparentProxyFactory, ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; +import {StaticATokenLM} from '../../../contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {StaticATokenFactory} from '../../../contracts/extensions/static-a-token/StaticATokenFactory.sol'; +import {IErrors} from '../../interfaces/IErrors.sol'; + +contract AaveV3HelpersProcedureTwo is IErrors { + function _deployStaticAToken( + address pool, + address rewardsController, + address proxyAdmin + ) internal returns (StaticATokenReport memory staticATokenReport) { + if (proxyAdmin == address(0)) revert ProxyAdminNotFound(); + + staticATokenReport.transparentProxyFactory = address(new TransparentProxyFactory()); + staticATokenReport.staticATokenImplementation = address( + new StaticATokenLM( + IPool(pool), + IRewardsController(rewardsController) + ) + ); + staticATokenReport.staticATokenFactoryImplementation = address( + new StaticATokenFactory( + IPool(pool), + proxyAdmin, + ITransparentProxyFactory(staticATokenReport.transparentProxyFactory), + staticATokenReport.staticATokenImplementation + ) + ); + + staticATokenReport.staticATokenFactoryProxy = ITransparentProxyFactory(staticATokenReport.transparentProxyFactory).create( + staticATokenReport.staticATokenFactoryImplementation, + proxyAdmin, + abi.encodeWithSelector(StaticATokenFactory.initialize.selector) + ); + + return staticATokenReport; + } +} diff --git a/src/deployments/contracts/procedures/AaveV3IncentiveProcedure.sol b/src/deployments/contracts/procedures/AaveV3IncentiveProcedure.sol index 1801a748..b940f795 100644 --- a/src/deployments/contracts/procedures/AaveV3IncentiveProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3IncentiveProcedure.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {EmissionManager} from 'aave-v3-periphery/contracts/rewards/EmissionManager.sol'; -import {RewardsController} from 'aave-v3-periphery/contracts/rewards/RewardsController.sol'; +import {EmissionManager} from '../../../contracts/rewards/EmissionManager.sol'; +import {RewardsController} from '../../../contracts/rewards/RewardsController.sol'; contract AaveV3IncentiveProcedure { function _deployIncentives(address tempOwner) internal returns (address, address) { diff --git a/src/deployments/contracts/procedures/AaveV3L2PoolProcedure.sol b/src/deployments/contracts/procedures/AaveV3L2PoolProcedure.sol index 20c7965d..f6fcba67 100644 --- a/src/deployments/contracts/procedures/AaveV3L2PoolProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3L2PoolProcedure.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {L2PoolInstance} from 'aave-v3-core/instances/L2PoolInstance.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {L2PoolInstance} from '../../../contracts/instances/L2PoolInstance.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; import {AaveV3PoolConfigProcedure} from './AaveV3PoolConfigProcedure.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; import {IErrors} from '../../interfaces/IErrors.sol'; import '../../interfaces/IMarketReportTypes.sol'; diff --git a/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol b/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol new file mode 100644 index 00000000..bd6bac8b --- /dev/null +++ b/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../interfaces/IMarketReportTypes.sol'; +import {PriceOracleSentinel, ISequencerOracle} from '../../../contracts/misc/PriceOracleSentinel.sol'; +import {DefaultReserveInterestRateStrategyV2} from '../../../contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; +import {IErrors} from '../../interfaces/IErrors.sol'; + +contract AaveV3MiscProcedure is IErrors { + function _deploySentinelAndDefaultIR( + bool l2Flag, + address poolAddressesProvider, + address sequencerUptimeOracle, + uint256 gracePeriod + ) internal returns (MiscReport memory miscReport) { + if (poolAddressesProvider == address(0)) revert ProviderNotFound(); + + if (l2Flag && sequencerUptimeOracle != address(0) && gracePeriod != 0) { + miscReport.priceOracleSentinel = address( + new PriceOracleSentinel( + IPoolAddressesProvider(poolAddressesProvider), + ISequencerOracle(sequencerUptimeOracle), + gracePeriod + ) + ); + } + + miscReport.defaultInterestRateStrategy = address( + new DefaultReserveInterestRateStrategyV2(poolAddressesProvider) + ); + + return miscReport; + } +} diff --git a/src/deployments/contracts/procedures/AaveV3OracleProcedure.sol b/src/deployments/contracts/procedures/AaveV3OracleProcedure.sol index 7acc6c91..77e97a40 100644 --- a/src/deployments/contracts/procedures/AaveV3OracleProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3OracleProcedure.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import '../../interfaces/IMarketReportTypes.sol'; -import {AaveOracle} from 'aave-v3-core/contracts/misc/AaveOracle.sol'; +import {AaveOracle} from '../../../contracts/misc/AaveOracle.sol'; contract AaveV3OracleProcedure { function _deployAaveOracle( diff --git a/src/deployments/contracts/procedures/AaveV3ParaswapProcedure.sol b/src/deployments/contracts/procedures/AaveV3ParaswapProcedure.sol index 8e6e8b17..b89457b6 100644 --- a/src/deployments/contracts/procedures/AaveV3ParaswapProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3ParaswapProcedure.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {ParaSwapLiquiditySwapAdapter, IParaSwapAugustusRegistry} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol'; -import {ParaSwapRepayAdapter} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol'; -import {ParaSwapWithdrawSwapAdapter} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol'; -import {AaveParaSwapFeeClaimer} from 'aave-v3-periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol'; -import {IFeeClaimer} from 'aave-v3-periphery/contracts/adapters/paraswap/interfaces/IFeeClaimer.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {ParaSwapLiquiditySwapAdapter, IParaSwapAugustusRegistry} from '../../../contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol'; +import {ParaSwapRepayAdapter} from '../../../contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol'; +import {ParaSwapWithdrawSwapAdapter} from '../../../contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol'; +import {AaveParaSwapFeeClaimer} from '../../../contracts/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol'; +import {IFeeClaimer} from '../../../contracts/extensions/paraswap-adapters/interfaces/IFeeClaimer.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; contract AaveV3ParaswapProcedure { struct ParaswapAdapters { diff --git a/src/deployments/contracts/procedures/AaveV3PoolConfigProcedure.sol b/src/deployments/contracts/procedures/AaveV3PoolConfigProcedure.sol index fb968ec7..6f508ab8 100644 --- a/src/deployments/contracts/procedures/AaveV3PoolConfigProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3PoolConfigProcedure.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {PoolConfiguratorInstance} from 'aave-v3-core/instances/PoolConfiguratorInstance.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {AaveOracle} from 'aave-v3-core/contracts/misc/AaveOracle.sol'; +import {PoolConfiguratorInstance} from '../../../contracts/instances/PoolConfiguratorInstance.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; +import {AaveOracle} from '../../../contracts/misc/AaveOracle.sol'; contract AaveV3PoolConfigProcedure { function _deployPoolConfigurator(address poolAddressesProvider) internal returns (address) { diff --git a/src/deployments/contracts/procedures/AaveV3PoolProcedure.sol b/src/deployments/contracts/procedures/AaveV3PoolProcedure.sol index 0bf84a5d..cc3cc694 100644 --- a/src/deployments/contracts/procedures/AaveV3PoolProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3PoolProcedure.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {PoolInstance} from 'aave-v3-core/instances/PoolInstance.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; +import {PoolInstance} from '../../../contracts/instances/PoolInstance.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; import {AaveV3PoolConfigProcedure} from './AaveV3PoolConfigProcedure.sol'; import {IErrors} from '../../interfaces/IErrors.sol'; import '../../interfaces/IMarketReportTypes.sol'; diff --git a/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol b/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol index ce411cc5..9d85884b 100644 --- a/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.0; import '../../interfaces/IMarketReportTypes.sol'; import {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {IPoolConfigurator} from 'aave-v3-core/contracts/interfaces/IPoolConfigurator.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {PoolAddressesProvider} from 'aave-v3-core/contracts/protocol/configuration/PoolAddressesProvider.sol'; -import {PoolAddressesProviderRegistry} from 'aave-v3-core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol'; -import {IEmissionManager} from 'aave-v3-periphery/contracts/rewards/interfaces/IEmissionManager.sol'; -import {IRewardsController} from 'aave-v3-periphery/contracts/rewards/interfaces/IRewardsController.sol'; +import {ACLManager} from '../../../contracts/protocol/configuration/ACLManager.sol'; +import {IPoolConfigurator} from '../../../contracts/interfaces/IPoolConfigurator.sol'; +import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; +import {PoolAddressesProvider} from '../../../contracts/protocol/configuration/PoolAddressesProvider.sol'; +import {PoolAddressesProviderRegistry} from '../../../contracts/protocol/configuration/PoolAddressesProviderRegistry.sol'; +import {IEmissionManager} from '../../../contracts/rewards/interfaces/IEmissionManager.sol'; +import {IRewardsController} from '../../../contracts/rewards/interfaces/IRewardsController.sol'; contract AaveV3SetupProcedure { function _initialDeployment( @@ -38,7 +38,8 @@ contract AaveV3SetupProcedure { address poolConfiguratorImplementation, address protocolDataProvider, address aaveOracle, - address rewardsControllerImplementation + address rewardsControllerImplementation, + address priceOracleSentinel ) internal returns (SetupReport memory) { _validateMarketSetup(roles); @@ -49,7 +50,8 @@ contract AaveV3SetupProcedure { protocolDataProvider, roles.poolAdmin, aaveOracle, - rewardsControllerImplementation + rewardsControllerImplementation, + priceOracleSentinel ); report.aclManager = _setupACL( @@ -94,7 +96,8 @@ contract AaveV3SetupProcedure { address protocolDataProvider, address poolAdmin, address aaveOracle, - address rewardsControllerImplementation + address rewardsControllerImplementation, + address priceOracleSentinel ) internal returns (SetupReport memory) { SetupReport memory report; @@ -107,6 +110,10 @@ contract AaveV3SetupProcedure { report.poolProxy = address(provider.getPool()); report.poolConfiguratorProxy = address(provider.getPoolConfigurator()); + if (priceOracleSentinel != address(0)) { + provider.setPriceOracleSentinel(priceOracleSentinel); + } + bytes32 controllerId = keccak256('INCENTIVES_CONTROLLER'); provider.setAddressAsProxy(controllerId, rewardsControllerImplementation); report.rewardsControllerProxy = provider.getAddress(controllerId); diff --git a/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol b/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol index 51668cf8..342a6926 100644 --- a/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3TokensProcedure.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {ATokenInstance} from 'aave-v3-core/instances/ATokenInstance.sol'; -import {VariableDebtTokenInstance} from 'aave-v3-core/instances/VariableDebtTokenInstance.sol'; -import {StableDebtTokenInstance} from 'aave-v3-core/instances/StableDebtTokenInstance.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; +import {ATokenInstance} from '../../../contracts/instances/ATokenInstance.sol'; +import {VariableDebtTokenInstance} from '../../../contracts/instances/VariableDebtTokenInstance.sol'; +import {StableDebtTokenInstance} from '../../../contracts/instances/StableDebtTokenInstance.sol'; +import {IPool} from '../../../contracts/interfaces/IPool.sol'; +import {IAaveIncentivesController} from '../../../contracts/interfaces/IAaveIncentivesController.sol'; contract AaveV3TokensProcedure { struct TokensReport { diff --git a/src/deployments/contracts/procedures/AaveV3TreasuryProcedure.sol b/src/deployments/contracts/procedures/AaveV3TreasuryProcedure.sol index 8fddece8..d0169fc5 100644 --- a/src/deployments/contracts/procedures/AaveV3TreasuryProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3TreasuryProcedure.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; import {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol'; -import {Collector} from '../../../periphery/contracts/treasury/Collector.sol'; +import {Collector} from '../../../contracts/treasury/Collector.sol'; import '../../interfaces/IMarketReportTypes.sol'; contract AaveV3TreasuryProcedure { diff --git a/src/deployments/contracts/utilities/MarketReportUtils.sol b/src/deployments/contracts/utilities/MarketReportUtils.sol index 34e10e87..341a64c2 100644 --- a/src/deployments/contracts/utilities/MarketReportUtils.sol +++ b/src/deployments/contracts/utilities/MarketReportUtils.sol @@ -21,8 +21,8 @@ library MarketReportUtils { aaveOracle: IAaveOracle(report.aaveOracle), aclManager: IACLManager(report.aclManager), treasury: ICollector(report.treasury), - defaultInterestRateStrategyV2: IDefaultInterestRateStrategyV2( - report.defaultInterestRateStrategyV2 + defaultInterestRateStrategy: IDefaultInterestRateStrategyV2( + report.defaultInterestRateStrategy ), proxyAdmin: ProxyAdmin(report.proxyAdmin), treasuryImplementation: ICollector(report.treasuryImplementation), diff --git a/src/deployments/contracts/utilities/MetadataReporter.sol b/src/deployments/contracts/utilities/MetadataReporter.sol index a3a9b8ab..7fc3a262 100644 --- a/src/deployments/contracts/utilities/MetadataReporter.sol +++ b/src/deployments/contracts/utilities/MetadataReporter.sol @@ -69,6 +69,14 @@ contract MetadataReporter is IMetadataReporter { report.paraSwapWithdrawSwapAdapter ); vm.serializeAddress(jsonReport, 'aaveParaSwapFeeClaimer', report.aaveParaSwapFeeClaimer); + vm.serializeAddress(jsonReport, 'defaultInterestRateStrategy', report.defaultInterestRateStrategy); + vm.serializeAddress(jsonReport, 'priceOracleSentinel', report.priceOracleSentinel); + vm.serializeAddress(jsonReport, 'configEngine', report.configEngine); + vm.serializeAddress(jsonReport, 'staticATokenFactoryImplementation', report.staticATokenFactoryImplementation); + vm.serializeAddress(jsonReport, 'staticATokenFactoryProxy', report.staticATokenFactoryProxy); + vm.serializeAddress(jsonReport, 'staticATokenImplementation', report.staticATokenImplementation); + vm.serializeAddress(jsonReport, 'transparentProxyFactory', report.transparentProxyFactory); + string memory output = vm.serializeAddress( jsonReport, 'paraSwapRepayAdapter', diff --git a/src/deployments/interfaces/IErrors.sol b/src/deployments/interfaces/IErrors.sol index 5faefcc5..7d0df80a 100644 --- a/src/deployments/interfaces/IErrors.sol +++ b/src/deployments/interfaces/IErrors.sol @@ -5,4 +5,5 @@ interface IErrors { error L2MustBeEnabled(); error L2MustBeDisabled(); error ProviderNotFound(); + error ProxyAdminNotFound(); } diff --git a/src/deployments/interfaces/IMarketReportTypes.sol b/src/deployments/interfaces/IMarketReportTypes.sol index 2eb742f9..b838a0db 100644 --- a/src/deployments/interfaces/IMarketReportTypes.sol +++ b/src/deployments/interfaces/IMarketReportTypes.sol @@ -1,27 +1,28 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import 'aave-v3-core/contracts/interfaces/IPoolAddressesProviderRegistry.sol'; -import 'aave-v3-core/contracts/interfaces/IPool.sol'; -import 'aave-v3-core/contracts/interfaces/IPoolConfigurator.sol'; -import 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; -import 'aave-v3-core/contracts/interfaces/IACLManager.sol'; -import 'aave-v3-core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; -import 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; -import 'aave-v3-periphery/contracts/misc/UiPoolDataProviderV3.sol'; -import 'aave-v3-periphery/contracts/misc/UiIncentiveDataProviderV3.sol'; -import 'aave-v3-periphery/contracts/rewards/interfaces/IEmissionManager.sol'; -import 'aave-v3-periphery/contracts/rewards/interfaces/IRewardsController.sol'; -import 'aave-v3-periphery/contracts/misc/WalletBalanceProvider.sol'; -import 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol'; -import 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol'; -import 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol'; -import 'aave-v3-periphery/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol'; -import 'aave-v3-core/contracts/misc/L2Encoder.sol'; -import {ICollector} from 'aave-v3-periphery/contracts/treasury/ICollector.sol'; + +import '../../contracts/interfaces/IPoolAddressesProvider.sol'; +import '../../contracts/interfaces/IPoolAddressesProviderRegistry.sol'; +import '../../contracts/interfaces/IPool.sol'; +import '../../contracts/interfaces/IPoolConfigurator.sol'; +import '../../contracts/interfaces/IAaveOracle.sol'; +import '../../contracts/interfaces/IAToken.sol'; +import '../../contracts/interfaces/IVariableDebtToken.sol'; +import '../../contracts/interfaces/IStableDebtToken.sol'; +import '../../contracts/interfaces/IACLManager.sol'; +import '../../contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; +import '../../contracts/helpers/AaveProtocolDataProvider.sol'; +import '../../contracts/helpers/UiPoolDataProviderV3.sol'; +import '../../contracts/helpers/UiIncentiveDataProviderV3.sol'; +import '../../contracts/rewards/interfaces/IEmissionManager.sol'; +import '../../contracts/rewards/interfaces/IRewardsController.sol'; +import '../../contracts/helpers/WalletBalanceProvider.sol'; +import '../../contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol'; +import '../../contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol'; +import '../../contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol'; +import '../../contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol'; +import '../../contracts/helpers/L2Encoder.sol'; +import {ICollector} from '../../contracts/treasury/ICollector.sol'; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; struct ContractsReport { @@ -35,7 +36,7 @@ struct ContractsReport { IAaveOracle aaveOracle; IACLManager aclManager; ICollector treasury; - IDefaultInterestRateStrategyV2 defaultInterestRateStrategyV2; + IDefaultInterestRateStrategyV2 defaultInterestRateStrategy; ProxyAdmin proxyAdmin; ICollector treasuryImplementation; IWrappedTokenGatewayV3 wrappedTokenGateway; @@ -63,7 +64,8 @@ struct MarketReport { address poolConfiguratorImplementation; address protocolDataProvider; address aaveOracle; - address defaultInterestRateStrategyV2; + address defaultInterestRateStrategy; + address priceOracleSentinel; address aclManager; address treasury; address proxyAdmin; @@ -83,6 +85,11 @@ struct MarketReport { address emissionManager; address rewardsControllerImplementation; address rewardsControllerProxy; + address configEngine; + address transparentProxyFactory; + address staticATokenFactoryImplementation; + address staticATokenFactoryProxy; + address staticATokenImplementation; } struct LibrariesReport { @@ -109,6 +116,8 @@ struct MarketConfig { uint8 oracleDecimals; address paraswapAugustusRegistry; address paraswapFeeClaimer; + address l2SequencerUptimeFeed; + uint256 l2PriceOracleSentinelGracePeriod; uint256 providerId; bytes32 salt; address wrappedNativeToken; @@ -126,6 +135,29 @@ struct PoolReport { address poolConfiguratorImplementation; } +struct MiscReport { + address priceOracleSentinel; + address defaultInterestRateStrategy; +} + +struct ConfigEngineReport { + address configEngine; + address listingEngine; + address eModeEngine; + address borrowEngine; + address collateralEngine; + address priceFeedEngine; + address rateEngine; + address capsEngine; +} + +struct StaticATokenReport { + address transparentProxyFactory; + address staticATokenImplementation; + address staticATokenFactoryImplementation; + address staticATokenFactoryProxy; +} + struct InitialReport { address poolAddressesProvider; address poolAddressesProviderRegistry; @@ -145,7 +177,6 @@ struct PeripheryReport { address treasuryImplementation; address emissionManager; address rewardsControllerImplementation; - address defaultInterestRateStrategyV2; } struct ParaswapReport { diff --git a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol index 1512596b..ec93fc80 100644 --- a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol +++ b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol @@ -10,6 +10,9 @@ import {AaveV3GettersProcedureTwo} from '../../contracts/procedures/AaveV3Getter import {AaveV3PeripheryBatch} from './batches/AaveV3PeripheryBatch.sol'; import {AaveV3ParaswapBatch} from './batches/AaveV3ParaswapBatch.sol'; import {AaveV3SetupBatch} from './batches/AaveV3SetupBatch.sol'; +import {AaveV3HelpersBatchOne} from './batches/AaveV3HelpersBatchOne.sol'; +import {AaveV3HelpersBatchTwo} from './batches/AaveV3HelpersBatchTwo.sol'; +import {AaveV3MiscBatch} from './batches/AaveV3MiscBatch.sol'; import '../../interfaces/IMarketReportTypes.sol'; import {IMarketReportStorage} from '../../interfaces/IMarketReportStorage.sol'; import {IPoolReport} from '../../interfaces/IPoolReport.sol'; @@ -52,6 +55,13 @@ library AaveV3BatchOrchestration { address(setupBatch) ); + MiscReport memory miscReport = _deployMisc( + flags.l2, + initialReport.poolAddressesProvider, + config.l2SequencerUptimeFeed, + config.l2PriceOracleSentinelGracePeriod + ); + SetupReport memory setupReport = setupBatch.setupAaveV3Market( roles, config, @@ -59,7 +69,8 @@ library AaveV3BatchOrchestration { poolReport.poolConfiguratorImplementation, gettersReport1.protocolDataProvider, peripheryReport.aaveOracle, - peripheryReport.rewardsControllerImplementation + peripheryReport.rewardsControllerImplementation, + miscReport.priceOracleSentinel ); ParaswapReport memory paraswapReport = _deployParaswapAdapters( @@ -78,6 +89,19 @@ library AaveV3BatchOrchestration { AaveV3TokensBatch.TokensReport memory tokensReport = _deployTokens(setupReport.poolProxy); + ConfigEngineReport memory configEngineReport = _deployHelpersBatch1( + setupReport, + miscReport, + peripheryReport, + tokensReport + ); + + StaticATokenReport memory staticATokenReport = _deployHelpersBatch2( + setupReport.poolProxy, + setupReport.rewardsControllerProxy, + peripheryReport.proxyAdmin + ); + // Save final report at AaveV3SetupBatch contract MarketReport memory report = _generateMarketReport( initialReport, @@ -85,9 +109,12 @@ library AaveV3BatchOrchestration { gettersReport2, poolReport, peripheryReport, + miscReport, paraswapReport, setupReport, - tokensReport + tokensReport, + configEngineReport, + staticATokenReport ); setupBatch.setMarketReport(report); @@ -137,6 +164,57 @@ library AaveV3BatchOrchestration { }); } + function _deployHelpersBatch1( + SetupReport memory setupReport, + MiscReport memory miscReport, + PeripheryReport memory peripheryReport, + AaveV3TokensBatch.TokensReport memory tokensReport + ) internal returns (ConfigEngineReport memory) { + AaveV3HelpersBatchOne helpersBatchOne = new AaveV3HelpersBatchOne( + setupReport.poolProxy, + setupReport.poolConfiguratorProxy, + miscReport.defaultInterestRateStrategy, + peripheryReport.aaveOracle, + setupReport.rewardsControllerProxy, + peripheryReport.treasury, + tokensReport.aToken, + tokensReport.variableDebtToken, + tokensReport.stableDebtToken + ); + + return helpersBatchOne.getConfigEngineReport(); + } + + function _deployHelpersBatch2( + address pool, + address rewardsController, + address proxyAdmin + ) internal returns (StaticATokenReport memory) { + AaveV3HelpersBatchTwo helpersBatchTwo = new AaveV3HelpersBatchTwo( + pool, + rewardsController, + proxyAdmin + ); + + return helpersBatchTwo.staticATokenReport(); + } + + function _deployMisc( + bool l2Flag, + address poolAddressesProvider, + address sequencerUptimeOracle, + uint256 gracePeriod + ) internal returns (MiscReport memory) { + AaveV3MiscBatch miscBatch = new AaveV3MiscBatch( + l2Flag, + poolAddressesProvider, + sequencerUptimeOracle, + gracePeriod + ); + + return miscBatch.getMiscReport(); + } + function _deployPoolImplementations( address poolAddressesProvider, DeployFlags memory flags @@ -207,9 +285,12 @@ library AaveV3BatchOrchestration { AaveV3GettersBatchTwo.GettersReportBatchTwo memory gettersReportTwo, PoolReport memory poolReport, PeripheryReport memory peripheryReport, + MiscReport memory miscReport, ParaswapReport memory paraswapReport, SetupReport memory setupReport, - AaveV3TokensBatch.TokensReport memory tokensReport + AaveV3TokensBatch.TokensReport memory tokensReport, + ConfigEngineReport memory configEngineReport, + StaticATokenReport memory staticATokenReport ) internal pure returns (MarketReport memory) { MarketReport memory report; @@ -240,7 +321,13 @@ library AaveV3BatchOrchestration { report.aToken = tokensReport.aToken; report.variableDebtToken = tokensReport.variableDebtToken; report.stableDebtToken = tokensReport.stableDebtToken; - report.defaultInterestRateStrategyV2 = peripheryReport.defaultInterestRateStrategyV2; + report.priceOracleSentinel = miscReport.priceOracleSentinel; + report.defaultInterestRateStrategy = miscReport.defaultInterestRateStrategy; + report.configEngine = configEngineReport.configEngine; + report.staticATokenFactoryImplementation = staticATokenReport.staticATokenFactoryImplementation; + report.staticATokenFactoryProxy = staticATokenReport.staticATokenFactoryProxy; + report.staticATokenImplementation = staticATokenReport.staticATokenImplementation; + report.transparentProxyFactory = staticATokenReport.transparentProxyFactory; return report; } diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol new file mode 100644 index 00000000..f841b657 --- /dev/null +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {AaveV3HelpersProcedureOne} from '../../../contracts/procedures/AaveV3HelpersProcedureOne.sol'; +import '../../../interfaces/IMarketReportTypes.sol'; + +contract AaveV3HelpersBatchOne is AaveV3HelpersProcedureOne { + ConfigEngineReport internal _report; + + constructor( + address poolProxy, + address poolConfiguratorProxy, + address defaultInterestRateStrategy, + address aaveOracle, + address rewardsController, + address collector, + address aTokenImpl, + address vTokenImpl, + address sTokenImpl + ) { + _report = _deployConfigEngine( + poolProxy, + poolConfiguratorProxy, + defaultInterestRateStrategy, + aaveOracle, + rewardsController, + collector, + aTokenImpl, + vTokenImpl, + sTokenImpl + ); + } + + function getConfigEngineReport() external view returns (ConfigEngineReport memory) { + return _report; + } +} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol new file mode 100644 index 00000000..b145b257 --- /dev/null +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {AaveV3HelpersProcedureTwo} from '../../../contracts/procedures/AaveV3HelpersProcedureTwo.sol'; +import '../../../interfaces/IMarketReportTypes.sol'; + +contract AaveV3HelpersBatchTwo is AaveV3HelpersProcedureTwo { + StaticATokenReport internal _report; + + constructor( + address pool, + address rewardsController, + address proxyAdmin + ) { + _report = _deployStaticAToken( + pool, + rewardsController, + proxyAdmin + ); + } + + function staticATokenReport() external view returns (StaticATokenReport memory) { + return _report; + } +} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol new file mode 100644 index 00000000..a841d76a --- /dev/null +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {AaveV3MiscProcedure} from '../../../contracts/procedures/AaveV3MiscProcedure.sol'; +import '../../../interfaces/IMarketReportTypes.sol'; + +contract AaveV3MiscBatch is AaveV3MiscProcedure { + MiscReport internal _report; + + constructor( + bool l2Flag, + address poolAddressesProvider, + address sequencerUptimeOracle, + uint256 gracePeriod + ) { + MiscReport memory miscReport = _deploySentinelAndDefaultIR( + l2Flag, + poolAddressesProvider, + sequencerUptimeOracle, + gracePeriod + ); + _report.priceOracleSentinel = miscReport.priceOracleSentinel; + _report.defaultInterestRateStrategy = miscReport.defaultInterestRateStrategy; + } + + function getMiscReport() external view returns (MiscReport memory) { + return _report; + } +} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol index 43a25d9b..f2a3ec54 100644 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol @@ -4,14 +4,12 @@ pragma solidity ^0.8.0; import {AaveV3TreasuryProcedure} from '../../../contracts/procedures/AaveV3TreasuryProcedure.sol'; import {AaveV3OracleProcedure} from '../../../contracts/procedures/AaveV3OracleProcedure.sol'; import {AaveV3IncentiveProcedure} from '../../../contracts/procedures/AaveV3IncentiveProcedure.sol'; -import {AaveV3DefaultRateStrategyProcedure} from '../../../contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol'; import '../../../interfaces/IMarketReportTypes.sol'; contract AaveV3PeripheryBatch is AaveV3TreasuryProcedure, AaveV3OracleProcedure, - AaveV3IncentiveProcedure, - AaveV3DefaultRateStrategyProcedure + AaveV3IncentiveProcedure { PeripheryReport internal _report; @@ -34,8 +32,6 @@ contract AaveV3PeripheryBatch is (_report.emissionManager, _report.rewardsControllerImplementation) = _deployIncentives( setupBatch ); - - _report.defaultInterestRateStrategyV2 = _deployDefaultRateStrategyV2(poolAddressesProvider); } function getPeripheryReport() external view returns (PeripheryReport memory) { diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol index 78db0c47..abed9a61 100644 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; +import {Ownable} from '../../../../contracts/dependencies/openzeppelin/contracts/Ownable.sol'; import {AaveV3SetupProcedure} from '../../../contracts/procedures/AaveV3SetupProcedure.sol'; import '../../../contracts/MarketReportStorage.sol'; @@ -32,7 +32,8 @@ contract AaveV3SetupBatch is MarketReportStorage, AaveV3SetupProcedure, Ownable address poolConfiguratorImplementation, address protocolDataProvider, address aaveOracle, - address rewardsControllerImplementation + address rewardsControllerImplementation, + address priceOracleSentinel ) external onlyOwner returns (SetupReport memory) { _setupReport = _setupAaveV3Market( roles, @@ -42,7 +43,8 @@ contract AaveV3SetupBatch is MarketReportStorage, AaveV3SetupProcedure, Ownable poolConfiguratorImplementation, protocolDataProvider, aaveOracle, - rewardsControllerImplementation + rewardsControllerImplementation, + priceOracleSentinel ); return _setupReport; diff --git a/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch1.sol b/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch1.sol index 1eb97e86..5c292cee 100644 --- a/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch1.sol +++ b/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch1.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import '../../contracts/LibraryReportStorage.sol'; import {Create2Utils} from '../../contracts/utilities/Create2Utils.sol'; -import {BorrowLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/BorrowLogic.sol'; -import {BridgeLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/BridgeLogic.sol'; -import {ConfiguratorLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol'; -import {EModeLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/EModeLogic.sol'; +import {BorrowLogic} from '../../../contracts/protocol/libraries/logic/BorrowLogic.sol'; +import {BridgeLogic} from '../../../contracts/protocol/libraries/logic/BridgeLogic.sol'; +import {ConfiguratorLogic} from '../../../contracts/protocol/libraries/logic/ConfiguratorLogic.sol'; +import {EModeLogic} from '../../../contracts/protocol/libraries/logic/EModeLogic.sol'; contract AaveV3LibrariesBatch1 is LibraryReportStorage { constructor() { diff --git a/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch2.sol b/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch2.sol index ac1b3ce6..d65db0ac 100644 --- a/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch2.sol +++ b/src/deployments/projects/aave-v3-libraries/AaveV3LibrariesBatch2.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.0; import '../../contracts/LibraryReportStorage.sol'; import {Create2Utils} from '../../contracts/utilities/Create2Utils.sol'; -import {FlashLoanLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/FlashLoanLogic.sol'; -import {LiquidationLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/LiquidationLogic.sol'; -import {PoolLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/PoolLogic.sol'; -import {SupplyLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/SupplyLogic.sol'; +import {FlashLoanLogic} from '../../../contracts/protocol/libraries/logic/FlashLoanLogic.sol'; +import {LiquidationLogic} from '../../../contracts/protocol/libraries/logic/LiquidationLogic.sol'; +import {PoolLogic} from '../../../contracts/protocol/libraries/logic/PoolLogic.sol'; +import {SupplyLogic} from '../../../contracts/protocol/libraries/logic/SupplyLogic.sol'; contract AaveV3LibrariesBatch2 is LibraryReportStorage { constructor() { diff --git a/src/periphery/contracts/libraries/LICENSE.md b/src/periphery/contracts/libraries/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/libraries/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/misc/LICENSE.md b/src/periphery/contracts/misc/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/misc/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/misc/interfaces/IWETH.sol b/src/periphery/contracts/misc/interfaces/IWETH.sol deleted file mode 100644 index a46ede7f..00000000 --- a/src/periphery/contracts/misc/interfaces/IWETH.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -interface IWETH { - function deposit() external payable; - - function withdraw(uint256) external; - - function approve(address guy, uint256 wad) external returns (bool); - - function transferFrom(address src, address dst, uint256 wad) external returns (bool); -} diff --git a/src/periphery/contracts/misc/interfaces/LICENSE.md b/src/periphery/contracts/misc/interfaces/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/misc/interfaces/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/mocks/LICENSE.md b/src/periphery/contracts/mocks/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/mocks/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/rewards/interfaces/LICENSE.md b/src/periphery/contracts/rewards/interfaces/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/rewards/interfaces/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/rewards/libraries/LICENSE.md b/src/periphery/contracts/rewards/libraries/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/rewards/libraries/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/src/periphery/contracts/rewards/transfer-strategies/LICENSE.md b/src/periphery/contracts/rewards/transfer-strategies/LICENSE.md deleted file mode 100644 index 506d18ec..00000000 --- a/src/periphery/contracts/rewards/transfer-strategies/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2022 Aave - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) -for more details diff --git a/tests/AaveV3BatchTests.t.sol b/tests/AaveV3BatchTests.t.sol deleted file mode 100644 index f90652f8..00000000 --- a/tests/AaveV3BatchTests.t.sol +++ /dev/null @@ -1,158 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import 'forge-std/Test.sol'; -import '../src/deployments/interfaces/IMarketReportTypes.sol'; -import {AaveV3TokensBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol'; -import {AaveV3PoolBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3PoolBatch.sol'; -import {AaveV3L2PoolBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol'; -import {AaveV3GettersBatchOne} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol'; -import {AaveV3GettersBatchTwo} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol'; -import {AaveV3PeripheryBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; -import {AaveV3ParaswapBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; -import {AaveV3SetupBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {AugustusRegistryMock} from './mocks/AugustusRegistryMock.sol'; -import {MockParaSwapFeeClaimer} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; -import {BatchTestProcedures} from './utils/BatchTestProcedures.sol'; -import {AaveV3BatchOrchestration} from '../src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol'; - -contract AaveV3BatchTests is BatchTestProcedures { - address deployer; - address marketOwner; - address emergencyAdmin; - - Roles roles; - MarketConfig config; - DeployFlags flags; - MarketReport deployedContracts; - - InitialReport marketReportOne; - PoolReport poolReportOne; - - AaveV3GettersBatchOne.GettersReportBatchOne gettersReportOne; - AaveV3GettersBatchTwo.GettersReportBatchTwo gettersReportTwo; - - PeripheryReport peripheryReportOne; - ParaswapReport paraswapReportOne; - - SetupReport setupReportTwo; - - AaveV3SetupBatch aaveV3SetupOne; - - event ReportLog(MarketReport report); - - function setUp() public { - deployer = makeAddr('deployer'); - marketOwner = makeAddr('marketOwner'); - poolAdmin = makeAddr('poolAdmin'); - emergencyAdmin = makeAddr('emergencyAdmin'); - bytes32 emptySalt; - roles = Roles(marketOwner, poolAdmin, emergencyAdmin); - config = MarketConfig( - makeAddr('ethUsdOracle'), - makeAddr('ethUsdOracle'), - 'Testnet Market', - 8, - address(new AugustusRegistryMock()), - address(new MockParaSwapFeeClaimer()), - 8080, - emptySalt, - address(new WETH9()), - address(0), - 0.0005e4, - 0.0004e4 - ); - flags = DeployFlags(false); - - ( - marketReportOne, - gettersReportOne, - poolReportOne, - peripheryReportOne, - paraswapReportOne, - aaveV3SetupOne - ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); - (, , gettersReportTwo, , setupReportTwo, , , ) = deployAndSetup( - roles, - config, - flags, - deployedContracts - ); - } - - function testAaveV3FullBatchOrchestration() public { - vm.startPrank(deployer); - MarketReport memory market = AaveV3BatchOrchestration.deployAaveV3( - deployer, - roles, - config, - flags, - deployedContracts - ); - vm.stopPrank(); - checkFullReport(flags, market); - } - - function test0AaveV3SetupDeployment() public { - new AaveV3SetupBatch(msg.sender, roles, config, deployedContracts); - } - - function test1AaveV3GettersDeployment() public { - new AaveV3GettersBatchOne( - marketReportOne.poolAddressesProvider, - config.networkBaseTokenPriceInUsdProxyAggregator, - config.marketReferenceCurrencyPriceInUsdProxyAggregator - ); - - new AaveV3GettersBatchTwo( - setupReportTwo.poolProxy, - roles.poolAdmin, - config.wrappedNativeToken, - flags.l2 - ); - } - - function test2AaveV3PoolDeployment() public { - new AaveV3PoolBatch(marketReportOne.poolAddressesProvider); - } - - function test2AaveV3L2PoolDeployment() public { - new AaveV3L2PoolBatch(marketReportOne.poolAddressesProvider); - } - - function test4PeripheralsRelease() public { - new AaveV3PeripheryBatch( - roles.poolAdmin, - config, - marketReportOne.poolAddressesProvider, - address(aaveV3SetupOne) - ); - } - - function test5PeripheralsRelease() public { - new AaveV3ParaswapBatch( - roles.poolAdmin, - config, - marketReportOne.poolAddressesProvider, - peripheryReportOne.treasury - ); - } - - function test6SetupMarket() public { - vm.prank(roles.marketOwner); - aaveV3SetupOne.setupAaveV3Market( - roles, - config, - poolReportOne.poolImplementation, - poolReportOne.poolConfiguratorImplementation, - gettersReportOne.protocolDataProvider, - peripheryReportOne.aaveOracle, - peripheryReportOne.rewardsControllerImplementation - ); - } - - function test7TokensMarket() public { - new AaveV3TokensBatch(setupReportTwo.poolProxy); - } -} diff --git a/tests/AaveV3BatchDeployment.t.sol b/tests/deployments/AaveV3BatchDeployment.t.sol similarity index 62% rename from tests/AaveV3BatchDeployment.t.sol rename to tests/deployments/AaveV3BatchDeployment.t.sol index 1e7dca5f..aa0cf2d2 100644 --- a/tests/AaveV3BatchDeployment.t.sol +++ b/tests/deployments/AaveV3BatchDeployment.t.sol @@ -2,33 +2,30 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import '../src/deployments/interfaces/IMarketReportTypes.sol'; -import {ConfigEngineDeployer} from './utils/ConfigEngineDeployer.sol'; - -import {AugustusRegistryMock} from './mocks/AugustusRegistryMock.sol'; -import {MockParaSwapFeeClaimer} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; -import {BatchTestProcedures} from './utils/BatchTestProcedures.sol'; -import {AaveV3TestListing} from './mocks/AaveV3TestListing.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {AaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol'; +import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; +import {MockParaSwapFeeClaimer} from '../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; +import {BatchTestProcedures} from '../utils/BatchTestProcedures.sol'; +import {AaveV3TestListing} from '../mocks/AaveV3TestListing.sol'; +import {ACLManager} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IAaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol'; +import {IPool} from '../../src/contracts/interfaces/IPool.sol'; +import {AaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; +import {SequencerOracle} from '../../src/contracts/mocks/oracle/SequencerOracle.sol'; contract AaveV3BatchDeployment is BatchTestProcedures { address public marketOwner; address public emergencyAdmin; Roles public roles; - MarketConfig public config; DeployFlags public flags; + MarketConfig config; MarketReport deployedContracts; address public weth9; - event ReportLog(MarketReport report); - function setUp() public { bytes32 emptySalt; weth9 = address(new WETH9()); @@ -44,6 +41,8 @@ contract AaveV3BatchDeployment is BatchTestProcedures { 8, address(new AugustusRegistryMock()), address(new MockParaSwapFeeClaimer()), + address(0), // l2SequencerUptimeFeed + 0, // l2PriceOracleSentinelGracePeriod 8080, emptySalt, weth9, @@ -63,9 +62,8 @@ contract AaveV3BatchDeployment is BatchTestProcedures { ); checkFullReport(flags, fullReport); - address engine = ConfigEngineDeployer.deployEngine(vm, fullReport); AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(engine), + IAaveV3ConfigEngine(fullReport.configEngine), marketOwner, weth9, fullReport @@ -81,6 +79,8 @@ contract AaveV3BatchDeployment is BatchTestProcedures { function testAaveV3L2BatchDeploymentCheck() public { flags.l2 = true; + config.l2SequencerUptimeFeed = address(new SequencerOracle(poolAdmin)); + config.l2PriceOracleSentinelGracePeriod = 2 hours; MarketReport memory fullReport = deployAaveV3Testnet( marketOwner, @@ -92,9 +92,8 @@ contract AaveV3BatchDeployment is BatchTestProcedures { checkFullReport(flags, fullReport); - address engine = ConfigEngineDeployer.deployEngine(vm, fullReport); AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(engine), + IAaveV3ConfigEngine(fullReport.configEngine), marketOwner, weth9, fullReport diff --git a/tests/deployments/AaveV3BatchTests.t.sol b/tests/deployments/AaveV3BatchTests.t.sol new file mode 100644 index 00000000..0727aac6 --- /dev/null +++ b/tests/deployments/AaveV3BatchTests.t.sol @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {AaveV3TokensBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol'; +import {AaveV3PoolBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PoolBatch.sol'; +import {AaveV3L2PoolBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol'; +import {AaveV3GettersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol'; +import {AaveV3GettersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol'; +import {AaveV3PeripheryBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; +import {AaveV3ParaswapBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; +import {AaveV3SetupBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; +import {AaveV3MiscBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol'; +import {AaveV3HelpersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol'; +import {AaveV3HelpersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; +import {MockParaSwapFeeClaimer} from 'src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; +import {BatchTestProcedures} from '../utils/BatchTestProcedures.sol'; +import {AaveV3BatchOrchestration} from '../../src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol'; + +contract AaveV3BatchTests is BatchTestProcedures { + address deployer; + address marketOwner; + address emergencyAdmin; + + Roles roles; + MarketConfig config; + DeployFlags flags; + MarketReport deployedContracts; + + InitialReport marketReportOne; + PoolReport poolReportOne; + + AaveV3GettersBatchOne.GettersReportBatchOne gettersReportOne; + AaveV3GettersBatchTwo.GettersReportBatchTwo gettersReportTwo; + + PeripheryReport peripheryReportOne; + ParaswapReport paraswapReportOne; + MiscReport miscReport; + ConfigEngineReport configEngineReport; + StaticATokenReport staticATokenReport; + AaveV3TokensBatch.TokensReport tokensReport; + + SetupReport setupReportTwo; + + AaveV3SetupBatch aaveV3SetupOne; + + function setUp() public { + deployer = makeAddr('deployer'); + marketOwner = makeAddr('marketOwner'); + poolAdmin = makeAddr('poolAdmin'); + emergencyAdmin = makeAddr('emergencyAdmin'); + bytes32 emptySalt; + roles = Roles(marketOwner, poolAdmin, emergencyAdmin); + config = MarketConfig( + makeAddr('ethUsdOracle'), + makeAddr('ethUsdOracle'), + 'Testnet Market', + 8, + address(new AugustusRegistryMock()), + address(new MockParaSwapFeeClaimer()), + address(0), // l2SequencerUptimeFeed + 0, // l2PriceOracleSentinelGracePeriod + 8080, + emptySalt, + address(new WETH9()), + address(0), + 0.0005e4, + 0.0004e4 + ); + flags = DeployFlags(false); + + // Etch the create2 factory + vm.etch( + 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, + hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' + ); + + ( + marketReportOne, + gettersReportOne, + poolReportOne, + peripheryReportOne, + miscReport, + aaveV3SetupOne + ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); + + ( + , + , + gettersReportTwo, + , + setupReportTwo, + , + miscReport, + tokensReport, + paraswapReportOne, + ) = deployAndSetup( + roles, + config, + flags, + deployedContracts + ); + } + + function testAaveV3FullBatchOrchestration() public { + vm.startPrank(deployer); + MarketReport memory market = AaveV3BatchOrchestration.deployAaveV3( + deployer, + roles, + config, + flags, + deployedContracts + ); + vm.stopPrank(); + checkFullReport(flags, market); + } + + function test0AaveV3SetupDeployment() public { + new AaveV3SetupBatch(msg.sender, roles, config, deployedContracts); + } + + function test1AaveV3GettersDeployment() public { + new AaveV3GettersBatchOne( + marketReportOne.poolAddressesProvider, + config.networkBaseTokenPriceInUsdProxyAggregator, + config.marketReferenceCurrencyPriceInUsdProxyAggregator + ); + + new AaveV3GettersBatchTwo( + setupReportTwo.poolProxy, + roles.poolAdmin, + config.wrappedNativeToken, + flags.l2 + ); + } + + function test2AaveV3PoolDeployment() public { + new AaveV3PoolBatch(marketReportOne.poolAddressesProvider); + } + + function test3AaveV3L2PoolDeployment() public { + new AaveV3L2PoolBatch(marketReportOne.poolAddressesProvider); + } + + function test4PeripheralsRelease() public { + new AaveV3PeripheryBatch( + roles.poolAdmin, + config, + marketReportOne.poolAddressesProvider, + address(aaveV3SetupOne) + ); + } + + function test5MiscDeployment() public { + new AaveV3MiscBatch( + flags.l2, + marketReportOne.poolAddressesProvider, + config.l2SequencerUptimeFeed, + config.l2PriceOracleSentinelGracePeriod + ); + } + + function test6ParaswapRelease() public { + new AaveV3ParaswapBatch( + roles.poolAdmin, + config, + marketReportOne.poolAddressesProvider, + peripheryReportOne.treasury + ); + } + + function test7SetupMarket() public { + vm.prank(roles.marketOwner); + aaveV3SetupOne.setupAaveV3Market( + roles, + config, + poolReportOne.poolImplementation, + poolReportOne.poolConfiguratorImplementation, + gettersReportOne.protocolDataProvider, + peripheryReportOne.aaveOracle, + peripheryReportOne.rewardsControllerImplementation, + miscReport.priceOracleSentinel + ); + } + + function test8TokensMarket() public { + new AaveV3TokensBatch(setupReportTwo.poolProxy); + } + + function test9ConfigEngineDeployment() public { + new AaveV3HelpersBatchOne( + setupReportTwo.poolProxy, + setupReportTwo.poolConfiguratorProxy, + miscReport.defaultInterestRateStrategy, + peripheryReportOne.aaveOracle, + setupReportTwo.rewardsControllerProxy, + peripheryReportOne.treasury, + tokensReport.aToken, + tokensReport.variableDebtToken, + tokensReport.stableDebtToken + ); + } + + function test10StaticATokenDeployment() public { + new AaveV3HelpersBatchTwo( + setupReportTwo.poolProxy, + setupReportTwo.rewardsControllerProxy, + peripheryReportOne.proxyAdmin + ); + } +} diff --git a/tests/AaveV3PermissionsTest.t.sol b/tests/deployments/AaveV3PermissionsTest.t.sol similarity index 86% rename from tests/AaveV3PermissionsTest.t.sol rename to tests/deployments/AaveV3PermissionsTest.t.sol index 4224adb2..77b40647 100644 --- a/tests/AaveV3PermissionsTest.t.sol +++ b/tests/deployments/AaveV3PermissionsTest.t.sol @@ -2,16 +2,16 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import '../src/deployments/interfaces/IMarketReportTypes.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {RewardsController} from 'aave-v3-periphery/contracts/rewards/RewardsController.sol'; -import {EmissionManager} from 'aave-v3-periphery/contracts/rewards/EmissionManager.sol'; -import {AugustusRegistryMock} from './mocks/AugustusRegistryMock.sol'; -import {MockParaSwapFeeClaimer} from '../src/periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {BatchTestProcedures} from './utils/BatchTestProcedures.sol'; +import {Ownable} from '../../src/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {ACLManager} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {RewardsController} from '../../src/contracts/rewards/RewardsController.sol'; +import {EmissionManager} from '../../src/contracts/rewards/EmissionManager.sol'; +import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; +import {MockParaSwapFeeClaimer} from '../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import {BatchTestProcedures} from '../utils/BatchTestProcedures.sol'; contract AaveV3PermissionsTest is BatchTestProcedures { /** diff --git a/tests/DeploymentsGasLimits.t.sol b/tests/deployments/DeploymentsGasLimits.t.sol similarity index 54% rename from tests/DeploymentsGasLimits.t.sol rename to tests/deployments/DeploymentsGasLimits.t.sol index ba1082f5..6f33f88d 100644 --- a/tests/DeploymentsGasLimits.t.sol +++ b/tests/deployments/DeploymentsGasLimits.t.sol @@ -2,19 +2,23 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import '../src/deployments/interfaces/IMarketReportTypes.sol'; -import {AaveV3TokensBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol'; -import {AaveV3PoolBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3PoolBatch.sol'; -import {AaveV3L2PoolBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol'; -import {AaveV3GettersBatchOne} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol'; -import {AaveV3GettersBatchTwo} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol'; -import {AaveV3PeripheryBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; -import {AaveV3ParaswapBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; -import {AaveV3SetupBatch} from '../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {AugustusRegistryMock} from './mocks/AugustusRegistryMock.sol'; -import {MockParaSwapFeeClaimer} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; -import {BatchTestProcedures} from './utils/BatchTestProcedures.sol'; +import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {AaveV3TokensBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol'; +import {AaveV3PoolBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PoolBatch.sol'; +import {AaveV3L2PoolBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol'; +import {AaveV3GettersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol'; +import {AaveV3GettersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol'; +import {AaveV3PeripheryBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; +import {AaveV3ParaswapBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; +import {AaveV3SetupBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; +import {AaveV3MiscBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol'; +import {AaveV3HelpersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol'; +import {AaveV3HelpersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; +import {MockParaSwapFeeClaimer} from '../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; +import {SequencerOracle} from '../../src/contracts/mocks/oracle/SequencerOracle.sol'; +import {BatchTestProcedures} from '../utils/BatchTestProcedures.sol'; contract DeploymentsGasLimits is BatchTestProcedures { Roles roles; @@ -30,6 +34,8 @@ contract DeploymentsGasLimits is BatchTestProcedures { PeripheryReport peripheryReportOne; ParaswapReport paraswapReportOne; + MiscReport miscReport; + AaveV3TokensBatch.TokensReport tokensReport; SetupReport setupReportTwo; @@ -51,6 +57,8 @@ contract DeploymentsGasLimits is BatchTestProcedures { 8, address(new AugustusRegistryMock()), // replace with mock of augustus registry address(new MockParaSwapFeeClaimer()), + address(new SequencerOracle(poolAdmin)), + 2 hours, // l2PriceOracleSentinelGracePeriod 8080, empty, address(new WETH9()), @@ -58,17 +66,34 @@ contract DeploymentsGasLimits is BatchTestProcedures { 0.0005e4, 0.0004e4 ); - flags = DeployFlags(false); + flags = DeployFlags(true); + + // Etch the create2 factory + vm.etch( + 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, + hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' + ); ( marketReportOne, gettersReportOne, poolReportOne, peripheryReportOne, - paraswapReportOne, + miscReport, aaveV3SetupOne ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); - (, , gettersReportTwo, , setupReportTwo, , , ) = deployAndSetup( + + ( + , + , + gettersReportTwo, + , + setupReportTwo, + , + miscReport, + tokensReport, + paraswapReportOne, + ) = deployAndSetup( roles, config, flags, @@ -114,7 +139,16 @@ contract DeploymentsGasLimits is BatchTestProcedures { ); } - function test6ParaswapDeployment() public { + function test6MiscDeployment() public { + new AaveV3MiscBatch( + flags.l2, + marketReportOne.poolAddressesProvider, + config.l2SequencerUptimeFeed, + config.l2PriceOracleSentinelGracePeriod + ); + } + + function test7ParaswapDeployment() public { new AaveV3ParaswapBatch( roles.poolAdmin, config, @@ -123,7 +157,7 @@ contract DeploymentsGasLimits is BatchTestProcedures { ); } - function test7SetupMarket() public { + function test8SetupMarket() public { vm.prank(roles.marketOwner); aaveV3SetupOne.setupAaveV3Market( roles, @@ -132,14 +166,37 @@ contract DeploymentsGasLimits is BatchTestProcedures { poolReportOne.poolConfiguratorImplementation, gettersReportOne.protocolDataProvider, peripheryReportOne.aaveOracle, - peripheryReportOne.rewardsControllerImplementation + peripheryReportOne.rewardsControllerImplementation, + miscReport.priceOracleSentinel ); } - function test8TokensMarket() public { + function test9TokensMarket() public { new AaveV3TokensBatch(setupReportTwo.poolProxy); } + function test10ConfigEngineDeployment() public { + new AaveV3HelpersBatchOne( + setupReportTwo.poolProxy, + setupReportTwo.poolConfiguratorProxy, + miscReport.defaultInterestRateStrategy, + peripheryReportOne.aaveOracle, + setupReportTwo.rewardsControllerProxy, + peripheryReportOne.treasury, + tokensReport.aToken, + tokensReport.variableDebtToken, + tokensReport.stableDebtToken + ); + } + + function test11StaticATokenDeployment() public { + new AaveV3HelpersBatchTwo( + setupReportTwo.poolProxy, + setupReportTwo.rewardsControllerProxy, + peripheryReportOne.proxyAdmin + ); + } + function testCheckInitCodeSizeBatchs() public view { uint16 maxInitCodeSize = 49152; @@ -147,10 +204,13 @@ contract DeploymentsGasLimits is BatchTestProcedures { console.log('AaveV3L2PoolBatch', type(AaveV3L2PoolBatch).creationCode.length); console.log('AaveV3PoolBatch', type(AaveV3PoolBatch).creationCode.length); console.log('AaveV3PeripheryBatch', type(AaveV3PeripheryBatch).creationCode.length); + console.log('AaveV3MiscBatch', type(AaveV3MiscBatch).creationCode.length); console.log('AaveV3ParaswapBatch', type(AaveV3ParaswapBatch).creationCode.length); console.log('AaveV3GettersBatchOne', type(AaveV3GettersBatchOne).creationCode.length); console.log('AaveV3GettersBatchTwo', type(AaveV3GettersBatchTwo).creationCode.length); console.log('AaveV3TokensBatch', type(AaveV3TokensBatch).creationCode.length); + console.log('AaveV3HelpersBatchOne', type(AaveV3HelpersBatchOne).creationCode.length); + console.log('AaveV3HelpersBatchTwo', type(AaveV3HelpersBatchTwo).creationCode.length); assertLe( type(AaveV3SetupBatch).creationCode.length, @@ -172,6 +232,11 @@ contract DeploymentsGasLimits is BatchTestProcedures { maxInitCodeSize, 'AaveV3PeripheryBatch max init code size' ); + assertLe( + type(AaveV3MiscBatch).creationCode.length, + maxInitCodeSize, + 'AaveV3MiscBatch max init code size' + ); assertLe( type(AaveV3ParaswapBatch).creationCode.length, maxInitCodeSize, @@ -192,5 +257,15 @@ contract DeploymentsGasLimits is BatchTestProcedures { maxInitCodeSize, 'AaveV3TokensBatch max init code size' ); + assertLe( + type(AaveV3HelpersBatchOne).creationCode.length, + maxInitCodeSize, + 'AaveV3HelpersBatchOne max init code size' + ); + assertLe( + type(AaveV3HelpersBatchTwo).creationCode.length, + maxInitCodeSize, + 'AaveV3HelpersBatchTwo max init code size' + ); } } diff --git a/tests/periphery/ParaswapAdapters.t.sol b/tests/extensions/paraswap-adapters/ParaswapAdapters.t.sol similarity index 95% rename from tests/periphery/ParaswapAdapters.t.sol rename to tests/extensions/paraswap-adapters/ParaswapAdapters.t.sol index 56017b0e..42674e83 100644 --- a/tests/periphery/ParaswapAdapters.t.sol +++ b/tests/extensions/paraswap-adapters/ParaswapAdapters.t.sol @@ -1,22 +1,20 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import 'forge-std/Test.sol'; - -import {ParaSwapLiquiditySwapAdapter, IParaSwapAugustus} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol'; -import {ParaSwapRepayAdapter, IParaSwapAugustusRegistry} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol'; -import {ParaSwapWithdrawSwapAdapter} from 'aave-v3-periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol'; -import {AaveParaSwapFeeClaimer, IERC20} from 'aave-v3-periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol'; -import {BaseParaSwapAdapter} from 'aave-v3-periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol'; -import {IPool, DataTypes} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {MockParaSwapAugustus} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapAugustus.sol'; -import {MockParaSwapFeeClaimer} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; -import {MockParaSwapAugustusRegistry} from 'aave-v3-periphery/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {ParaSwapLiquiditySwapAdapter, IParaSwapAugustus} from '../../../src/contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol'; +import {ParaSwapRepayAdapter, IParaSwapAugustusRegistry} from '../../../src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol'; +import {ParaSwapWithdrawSwapAdapter} from '../../../src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol'; +import {AaveParaSwapFeeClaimer, IERC20} from '../../../src/contracts/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol'; +import {BaseParaSwapAdapter} from '../../../src/contracts/extensions/paraswap-adapters/BaseParaSwapAdapter.sol'; +import {IPool, DataTypes} from '../../../src/contracts/interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {MockParaSwapAugustus} from '../../../src/contracts/mocks/swap/MockParaSwapAugustus.sol'; +import {MockParaSwapFeeClaimer} from '../../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; +import {MockParaSwapAugustusRegistry} from '../../../src/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol'; +import {IERC20Detailed} from '../../../src/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract ParaswapAdaptersTest is TestnetProcedures { MockParaSwapAugustus internal mockParaSwapAugustus; diff --git a/tests/extensions/static-a-token/StataOracle.t.sol b/tests/extensions/static-a-token/StataOracle.t.sol new file mode 100644 index 00000000..bef3620f --- /dev/null +++ b/tests/extensions/static-a-token/StataOracle.t.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {StataOracle} from '../../../src/contracts/extensions/static-a-token/StataOracle.sol'; +import {StaticATokenLM} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {BaseTest} from './TestBase.sol'; + +contract StataOracleTest is BaseTest { + StataOracle public oracle; + + function setUp() public override { + super.setUp(); + oracle = new StataOracle(contracts.poolAddressesProvider); + + vm.prank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 1_000_000); + } + + function test_assetPrice() public view { + uint256 stataPrice = oracle.getAssetPrice(address(staticATokenLM)); + uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(UNDERLYING); + assertGe(stataPrice, underlyingPrice); + assertEq(stataPrice, (underlyingPrice * staticATokenLM.convertToAssets(1e18)) / 1e18); + } + + function test_assetsPrices() public view { + address[] memory staticATokens = factory.getStaticATokens(); + uint256[] memory stataPrices = oracle.getAssetsPrices(staticATokens); + + for (uint256 i = 0; i < staticATokens.length; i++) { + address staticAToken = staticATokens[i]; + uint256 stataPrice = stataPrices[i]; + + address underlying = StaticATokenLM(staticAToken).asset(); + uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(underlying); + + assertGe(stataPrice, underlyingPrice); + assertEq(stataPrice, (underlyingPrice * StaticATokenLM(staticAToken).convertToAssets(1e18)) / 1e18); + } + } + + function test_error(uint256 shares) public view { + vm.assume(shares <= staticATokenLM.maxMint(address(0))); + uint256 pricePerShare = oracle.getAssetPrice(address(staticATokenLM)); + uint256 pricePerAsset = contracts.aaveOracle.getAssetPrice(UNDERLYING); + uint256 assets = staticATokenLM.convertToAssets(shares); + + assertApproxEqAbs( + (pricePerShare * shares) / 1e18, + (pricePerAsset * assets) / 1e18, + (assets / 1e18) + 1 // there can be imprecision of 1 wei, which will accumulate for each asset + ); + } +} diff --git a/tests/extensions/static-a-token/StaticATokenLM.t.sol b/tests/extensions/static-a-token/StaticATokenLM.t.sol new file mode 100644 index 00000000..6fcdd428 --- /dev/null +++ b/tests/extensions/static-a-token/StaticATokenLM.t.sol @@ -0,0 +1,613 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {AToken} from '../../../src/contracts/protocol/tokenization/AToken.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IERC20, IERC20Metadata} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {RayMathExplicitRounding} from '../../../src/contracts/misc/libraries/RayMathExplicitRounding.sol'; +import {PullRewardsTransferStrategy} from '../../../src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; +import {RewardsDataTypes} from '../../../src/contracts/rewards/libraries/RewardsDataTypes.sol'; +import {ITransferStrategyBase} from '../../../src/contracts/rewards/interfaces/ITransferStrategyBase.sol'; +import {IEACAggregatorProxy} from '../../../src/contracts/helpers/interfaces/IEACAggregatorProxy.sol'; +import {IStaticATokenLM} from '../../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; +import {SigUtils} from '../../utils/SigUtils.sol'; +import {BaseTest, TestnetERC20} from './TestBase.sol'; + +contract StaticATokenLMTest is BaseTest { + using RayMathExplicitRounding for uint256; + + address public constant EMISSION_ADMIN = address(25); + + function setUp() public override { + super.setUp(); + + _configureLM(); + _openSupplyAndBorrowPositions(); + + vm.startPrank(user); + } + + function test_initializeShouldRevert() public { + address impl = factory.STATIC_A_TOKEN_IMPL(); + vm.expectRevert(); + IStaticATokenLM(impl).initialize(0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8, 'hey', 'ho'); + } + + function test_getters() public view { + assertEq(staticATokenLM.name(), 'Static Aave Local WETH'); + assertEq(staticATokenLM.symbol(), 'stataLocWETH'); + + IERC20 aToken = staticATokenLM.aToken(); + assertEq(address(aToken), A_TOKEN); + + address underlyingAddress = address(staticATokenLM.asset()); + assertEq(underlyingAddress, UNDERLYING); + + IERC20Metadata underlying = IERC20Metadata(underlyingAddress); + assertEq(staticATokenLM.decimals(), underlying.decimals()); + + assertEq( + address(staticATokenLM.INCENTIVES_CONTROLLER()), + address(AToken(A_TOKEN).getIncentivesController()) + ); + } + + function test_convertersAndPreviews() public view { + uint128 amount = 5 ether; + uint256 shares = staticATokenLM.convertToShares(amount); + assertLe(shares, amount, 'SHARES LOWER'); + assertEq(shares, staticATokenLM.previewDeposit(amount), 'PREVIEW_DEPOSIT'); + assertLe(shares, staticATokenLM.previewWithdraw(amount), 'PREVIEW_WITHDRAW'); + uint256 assets = staticATokenLM.convertToAssets(amount); + assertGe(assets, shares, 'ASSETS GREATER'); + assertLe(assets, staticATokenLM.previewMint(amount), 'PREVIEW_MINT'); + assertEq(assets, staticATokenLM.previewRedeem(amount), 'PREVIEW_REDEEM'); + } + + // Redeem tests + function test_redeem() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + assertEq(staticATokenLM.maxRedeem(user), staticATokenLM.balanceOf(user)); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); + assertEq(staticATokenLM.balanceOf(user), 0); + assertLe(IERC20(UNDERLYING).balanceOf(user), amountToDeposit); + assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user), amountToDeposit, 1); + } + + function test_redeemAToken() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + assertEq(staticATokenLM.maxRedeem(user), staticATokenLM.balanceOf(user)); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user, false); + assertEq(staticATokenLM.balanceOf(user), 0); + assertLe(IERC20(A_TOKEN).balanceOf(user), amountToDeposit); + assertApproxEqAbs(IERC20(A_TOKEN).balanceOf(user), amountToDeposit, 1); + } + + function test_redeemAllowance() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + staticATokenLM.approve(user1, staticATokenLM.maxRedeem(user)); + vm.stopPrank(); + vm.startPrank(user1); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user1, user); + assertEq(staticATokenLM.balanceOf(user), 0); + assertLe(IERC20(UNDERLYING).balanceOf(user1), amountToDeposit); + assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user1), amountToDeposit, 1); + } + + function testFail_redeemOverflowAllowance() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + staticATokenLM.approve(user1, staticATokenLM.maxRedeem(user) / 2); + vm.stopPrank(); + vm.startPrank(user1); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user1, user); + assertEq(staticATokenLM.balanceOf(user), 0); + assertEq(IERC20(A_TOKEN).balanceOf(user1), amountToDeposit); + } + + function testFail_redeemAboveBalance() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user) + 1, user, user); + } + + // Withdraw tests + function test_withdraw() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + assertLe(staticATokenLM.maxWithdraw(user), amountToDeposit); + staticATokenLM.withdraw(staticATokenLM.maxWithdraw(user), user, user); + assertEq(staticATokenLM.balanceOf(user), 0); + assertLe(IERC20(UNDERLYING).balanceOf(user), amountToDeposit); + assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user), amountToDeposit, 1); + } + + function testFail_withdrawAboveBalance() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + _fundUser(amountToDeposit, user1); + + _depositAToken(amountToDeposit, user); + _depositAToken(amountToDeposit, user1); + + assertEq(staticATokenLM.maxWithdraw(user), amountToDeposit); + staticATokenLM.withdraw(staticATokenLM.maxWithdraw(user) + 1, user, user); + } + + // mint + function test_mint() public { + vm.stopPrank(); + + // set supply cap to non-zero + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 15_000); + vm.stopPrank(); + + vm.startPrank(user); + + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + IERC20(UNDERLYING).approve(address(staticATokenLM), amountToDeposit); + uint256 shares = 1 ether; + staticATokenLM.mint(shares, user); + assertEq(shares, staticATokenLM.balanceOf(user)); + } + + function testFail_mintAboveBalance() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _underlyingToAToken(amountToDeposit, user); + IERC20(A_TOKEN).approve(address(staticATokenLM), amountToDeposit); + staticATokenLM.mint(amountToDeposit, user); + } + + // test rewards + function test_collectAndUpdateRewards() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); + uint256 claimable = staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN); + staticATokenLM.collectAndUpdateRewards(REWARD_TOKEN); + assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), claimable); + } + + function test_claimRewardsToSelf() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + + uint256 claimable = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable); + assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); + } + + function test_claimRewards() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + + uint256 claimable = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + staticATokenLM.claimRewards(user, rewardTokens); + assertEq(claimable, IERC20(REWARD_TOKEN).balanceOf(user)); + assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); + assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); + } + + // should fail as user1 is not a valid claimer + function testFail_claimRewardsOnBehalfOf() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + + vm.stopPrank(); + vm.startPrank(user1); + + staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + staticATokenLM.claimRewardsOnBehalf(user, user1, rewardTokens); + } + + function test_depositATokenClaimWithdrawClaim() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + // deposit aweth + _depositAToken(amountToDeposit, user); + + // forward time + _skipBlocks(60); + + // claim + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); + uint256 claimable0 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable0); + assertGt(claimable0, 0); + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable0); + + // forward time + _skipBlocks(60); + + // redeem + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); + uint256 claimable1 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable1); + assertGt(claimable1, 0); + + // claim on behalf of other user + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable1 + claimable0); + assertEq(staticATokenLM.balanceOf(user), 0); + assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); + assertGt(AToken(UNDERLYING).balanceOf(user), 5 ether); + } + + function test_depositWETHClaimWithdrawClaim() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + // forward time + _skipBlocks(60); + + // claim + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); + uint256 claimable0 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable0); + assertGt(claimable0, 0); + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable0); + + // forward time + _skipBlocks(60); + + // redeem + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); + uint256 claimable1 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable1); + assertGt(claimable1, 0); + + // claim on behalf of other user + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable1 + claimable0); + assertEq(staticATokenLM.balanceOf(user), 0); + assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); + assertGt(AToken(UNDERLYING).balanceOf(user), 5 ether); + } + + function test_transfer() public { + uint128 amountToDeposit = 10 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + // transfer to 2nd user + staticATokenLM.transfer(user1, amountToDeposit / 2); + assertEq(staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN), 0); + + // forward time + _skipBlocks(60); + + // redeem for both + uint256 claimableUser = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimableUser); + vm.stopPrank(); + vm.startPrank(user1); + uint256 claimableUser1 = staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN); + staticATokenLM.redeem(staticATokenLM.maxRedeem(user1), user1, user1); + staticATokenLM.claimRewardsToSelf(rewardTokens); + assertEq(IERC20(REWARD_TOKEN).balanceOf(user1), claimableUser1); + assertGt(claimableUser1, 0); + + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); + assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); + assertEq(staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN), 0); + } + + // getUnclaimedRewards + function test_getUnclaimedRewards() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + uint256 shares = _depositAToken(amountToDeposit, user); + assertEq(staticATokenLM.getUnclaimedRewards(user, REWARD_TOKEN), 0); + _skipBlocks(1000); + staticATokenLM.redeem(shares, user, user); + assertGt(staticATokenLM.getUnclaimedRewards(user, REWARD_TOKEN), 0); + } + + /** + * maxDeposit test + */ + function test_maxDeposit_freeze() public { + vm.stopPrank(); + vm.startPrank(roleList.marketOwner); + contracts.poolConfiguratorProxy.setReserveFreeze(UNDERLYING, true); + + uint256 max = staticATokenLM.maxDeposit(address(0)); + + assertEq(max, 0); + } + + function test_maxDeposit_paused() public { + vm.stopPrank(); + vm.startPrank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setReservePause(UNDERLYING, true); + + uint256 max = staticATokenLM.maxDeposit(address(0)); + + assertEq(max, 0); + } + + function test_maxDeposit_noCap() public { + vm.stopPrank(); + vm.startPrank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 0); + + uint256 maxDeposit = staticATokenLM.maxDeposit(address(0)); + uint256 maxMint = staticATokenLM.maxMint(address(0)); + + assertEq(maxDeposit, type(uint256).max); + assertEq(maxMint, type(uint256).max); + } + + // should be 0 as supply is ~5k + function test_maxDeposit_5kCap() public { + vm.stopPrank(); + vm.startPrank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 5_000); + + uint256 max = staticATokenLM.maxDeposit(address(0)); + assertEq(max, 0); + } + + function test_maxDeposit_50kCap() public { + vm.stopPrank(); + vm.startPrank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 50_000); + + uint256 max = staticATokenLM.maxDeposit(address(0)); + DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(UNDERLYING); + assertEq( + max, + 50_000 * + (10 ** IERC20Metadata(UNDERLYING).decimals()) - + (IERC20Metadata(A_TOKEN).totalSupply() + + uint256(reserveData.accruedToTreasury).rayMulRoundUp(staticATokenLM.rate())) + ); + } + + /** + * maxRedeem test + */ + function test_maxRedeem_paused() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + vm.stopPrank(); + vm.startPrank(address(roleList.marketOwner)); + contracts.poolConfiguratorProxy.setReservePause(UNDERLYING, true); + + uint256 max = staticATokenLM.maxRedeem(address(user)); + + assertEq(max, 0); + } + + function test_maxRedeem_allAvailable() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + uint256 max = staticATokenLM.maxRedeem(address(user)); + + assertEq(max, staticATokenLM.balanceOf(user)); + } + + function test_maxRedeem_partAvailable() public { + uint128 amountToDeposit = 50 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + vm.stopPrank(); + + uint256 maxRedeemBefore = staticATokenLM.previewRedeem(staticATokenLM.maxRedeem(address(user))); + uint256 underlyingBalanceBefore = IERC20Metadata(UNDERLYING).balanceOf(A_TOKEN); + + // create rich user + address borrowUser = address(99); + vm.startPrank(borrowUser); + deal(address(wbtc), borrowUser, 2_000e8); + wbtc.approve(address(POOL), 2_000e8); + POOL.deposit(address(wbtc), 2_000e8, borrowUser, 0); + + // borrow all available + POOL.borrow( + UNDERLYING, + underlyingBalanceBefore - (maxRedeemBefore / 2), + 2, + 0, + borrowUser + ); + + uint256 maxRedeemAfter = staticATokenLM.previewRedeem(staticATokenLM.maxRedeem(address(user))); + assertApproxEqAbs(maxRedeemAfter, (maxRedeemBefore / 2), 1); + } + + function test_maxRedeem_nonAvailable() public { + uint128 amountToDeposit = 50 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + vm.stopPrank(); + + uint256 underlyingBalanceBefore = IERC20Metadata(UNDERLYING).balanceOf(A_TOKEN); + // create rich user + address borrowUser = address(99); + vm.startPrank(borrowUser); + deal(address(wbtc), borrowUser, 2_000e8); + wbtc.approve(address(POOL), 2_000e8); + POOL.deposit(address(wbtc), 2_000e8, borrowUser, 0); + + // borrow all available + contracts.poolProxy.borrow(UNDERLYING, underlyingBalanceBefore, 2, 0, borrowUser); + + uint256 maxRedeemAfter = staticATokenLM.maxRedeem(address(user)); + assertEq(maxRedeemAfter, 0); + } + + function test_permit() public { + SigUtils.Permit memory permit = SigUtils.Permit({ + owner: user, + spender: spender, + value: 1 ether, + nonce: staticATokenLM.nonces(user), + deadline: block.timestamp + 1 days + }); + + bytes32 permitDigest = SigUtils.getTypedDataHash( + permit, + staticATokenLM.PERMIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); + + staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); + + assertEq(staticATokenLM.allowance(permit.owner, spender), permit.value); + } + + function test_permit_expired() public { + // as the default timestamp is 0, we move ahead in time a bit + vm.warp(10 days); + + SigUtils.Permit memory permit = SigUtils.Permit({ + owner: user, + spender: spender, + value: 1 ether, + nonce: staticATokenLM.nonces(user), + deadline: block.timestamp - 1 days + }); + + bytes32 permitDigest = SigUtils.getTypedDataHash( + permit, + staticATokenLM.PERMIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); + + vm.expectRevert('PERMIT_DEADLINE_EXPIRED'); + staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); + } + + function test_permit_invalidSigner() public { + SigUtils.Permit memory permit = SigUtils.Permit({ + owner: address(424242), + spender: spender, + value: 1 ether, + nonce: staticATokenLM.nonces(user), + deadline: block.timestamp + 1 days + }); + + bytes32 permitDigest = SigUtils.getTypedDataHash( + permit, + staticATokenLM.PERMIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); + + vm.expectRevert('INVALID_SIGNER'); + staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); + } + + function _configureLM() internal { + PullRewardsTransferStrategy strat = new PullRewardsTransferStrategy( + report.rewardsControllerProxy, + EMISSION_ADMIN, + EMISSION_ADMIN + ); + + vm.startPrank(poolAdmin); + contracts.emissionManager.setEmissionAdmin(REWARD_TOKEN, EMISSION_ADMIN); + vm.stopPrank(); + + vm.startPrank(EMISSION_ADMIN); + IERC20(REWARD_TOKEN).approve(address(strat), 10_000 ether); + vm.stopPrank(); + + vm.startPrank(OWNER); + TestnetERC20(REWARD_TOKEN).mint(EMISSION_ADMIN, 10_000 ether); + vm.stopPrank(); + + RewardsDataTypes.RewardsConfigInput[] memory config = new RewardsDataTypes.RewardsConfigInput[](1); + config[0] = RewardsDataTypes.RewardsConfigInput( + 0.00385 ether, + 10_000 ether, + uint32(block.timestamp + 30 days), + A_TOKEN, + REWARD_TOKEN, + ITransferStrategyBase(strat), + IEACAggregatorProxy(address(2)) + ); + + vm.prank(EMISSION_ADMIN); + contracts.emissionManager.configureAssets(config); + + staticATokenLM.refreshRewardTokens(); + } + + function _openSupplyAndBorrowPositions() internal { + // this is to open borrow positions so that the aToken balance increases + address whale = address(79); + vm.startPrank(whale); + _fundUser(5_000 ether, whale); + + weth.approve(address(POOL), 5_000 ether); + POOL.deposit(address(weth), 5_000 ether, whale, 0); + + POOL.borrow(address(weth), 1_000 ether, 2, 0, whale); + vm.stopPrank(); + } +} diff --git a/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol new file mode 100644 index 00000000..748986bb --- /dev/null +++ b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IERC20WithPermit.sol'; +import {StaticATokenLM, IStaticATokenLM, IERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {SigUtils} from '../../utils/SigUtils.sol'; +import {BaseTest, IAToken, IRewardsController, DataTypes} from './TestBase.sol'; + +contract StaticATokenMetaTransactions is BaseTest { + + function setUp() public override { + super.setUp(); + + // Testing meta transactions with USDX as WETH does not support permit + DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData(address(usdx)); + UNDERLYING = address(usdx); + A_TOKEN = reserveDataUSDX.aTokenAddress; + + staticATokenLM = StaticATokenLM(factory.getStaticAToken(UNDERLYING)); + + vm.startPrank(user); + } + + function test_validateDomainSeparator() public view { + address[] memory staticATokens = factory.getStaticATokens(); + + for (uint256 i = 0; i < staticATokens.length; i++) { + bytes32 separator1 = StaticATokenLM(staticATokens[i]).DOMAIN_SEPARATOR(); + for (uint256 j = 0; j < staticATokens.length; j++) { + if (i != j) { + bytes32 separator2 = StaticATokenLM(staticATokens[j]).DOMAIN_SEPARATOR(); + assertNotEq(separator1, separator2, 'DOMAIN_SEPARATOR_MUST_BE_UNIQUE'); + } + } + } + } + + function test_metaDepositATokenUnderlyingNoPermit() public { + uint128 amountToDeposit = 5e6; + deal(UNDERLYING, user, amountToDeposit); + IERC20(UNDERLYING).approve(address(staticATokenLM), 1e6); + IStaticATokenLM.PermitParams memory permitParams; + + // generate combined permit + SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ + owner: user, + spender: spender, + value: 1e6, + referralCode: 0, + fromUnderlying: true, + nonce: staticATokenLM.nonces(user), + deadline: block.timestamp + 1 days, + permit: permitParams + }); + bytes32 digest = SigUtils.getTypedDepositHash( + depositPermit, + staticATokenLM.METADEPOSIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); + + IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); + + uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); + staticATokenLM.metaDeposit( + depositPermit.owner, + depositPermit.spender, + depositPermit.value, + depositPermit.referralCode, + depositPermit.fromUnderlying, + depositPermit.deadline, + permitParams, + sigParams + ); + + assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); + } + + function test_metaDepositATokenUnderlying() public { + uint128 amountToDeposit = 5e6; + deal(UNDERLYING, user, amountToDeposit); + + // permit for aToken deposit + SigUtils.Permit memory permit = SigUtils.Permit({ + owner: user, + spender: address(staticATokenLM), + value: 1e6, + nonce: IERC20WithPermit(UNDERLYING).nonces(user), + deadline: block.timestamp + 1 days + }); + + bytes32 permitDigest = SigUtils.getTypedDataHash( + permit, + staticATokenLM.PERMIT_TYPEHASH(), + IERC20WithPermit(UNDERLYING).DOMAIN_SEPARATOR() + ); + + (uint8 pV, bytes32 pR, bytes32 pS) = vm.sign(userPrivateKey, permitDigest); + + IStaticATokenLM.PermitParams memory permitParams = IStaticATokenLM.PermitParams( + permit.owner, + permit.spender, + permit.value, + permit.deadline, + pV, + pR, + pS + ); + + // generate combined permit + SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ + owner: user, + spender: spender, + value: permit.value, + referralCode: 0, + fromUnderlying: true, + nonce: staticATokenLM.nonces(user), + deadline: permit.deadline, + permit: permitParams + }); + (uint8 v, bytes32 r, bytes32 s) = vm.sign( + userPrivateKey, + SigUtils.getTypedDepositHash( + depositPermit, + staticATokenLM.METADEPOSIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ) + ); + + IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); + + uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); + uint256 shares = staticATokenLM.metaDeposit( + depositPermit.owner, + depositPermit.spender, + depositPermit.value, + depositPermit.referralCode, + depositPermit.fromUnderlying, + depositPermit.deadline, + permitParams, + sigParams + ); + assertEq(shares, previewDeposit); + assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); + } + + function test_metaDepositAToken() public { + uint128 amountToDeposit = 5e6; + _fundUser(amountToDeposit, user); + _underlyingToAToken(amountToDeposit, user); + + // permit for aToken deposit + SigUtils.Permit memory permit = SigUtils.Permit({ + owner: user, + spender: address(staticATokenLM), + value: 1e6, + nonce: IERC20WithPermit(A_TOKEN).nonces(user), + deadline: block.timestamp + 1 days + }); + + bytes32 permitDigest = SigUtils.getTypedDataHash( + permit, + staticATokenLM.PERMIT_TYPEHASH(), + IERC20WithPermit(A_TOKEN).DOMAIN_SEPARATOR() + ); + + (uint8 pV, bytes32 pR, bytes32 pS) = vm.sign(userPrivateKey, permitDigest); + + IStaticATokenLM.PermitParams memory permitParams = IStaticATokenLM.PermitParams( + permit.owner, + permit.spender, + permit.value, + permit.deadline, + pV, + pR, + pS + ); + + // generate combined permit + SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ + owner: user, + spender: spender, + value: permit.value, + referralCode: 0, + fromUnderlying: false, + nonce: staticATokenLM.nonces(user), + deadline: permit.deadline, + permit: permitParams + }); + bytes32 digest = SigUtils.getTypedDepositHash( + depositPermit, + staticATokenLM.METADEPOSIT_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); + + IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); + + uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); + + staticATokenLM.metaDeposit( + depositPermit.owner, + depositPermit.spender, + depositPermit.value, + depositPermit.referralCode, + depositPermit.fromUnderlying, + depositPermit.deadline, + permitParams, + sigParams + ); + + assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); + } + + function test_metaWithdraw() public { + uint128 amountToDeposit = 5e6; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + SigUtils.WithdrawPermit memory permit = SigUtils.WithdrawPermit({ + owner: user, + spender: spender, + staticAmount: 0, + dynamicAmount: 1e6, + toUnderlying: false, + nonce: staticATokenLM.nonces(user), + deadline: block.timestamp + 1 days + }); + bytes32 digest = SigUtils.getTypedWithdrawHash( + permit, + staticATokenLM.METAWITHDRAWAL_TYPEHASH(), + staticATokenLM.DOMAIN_SEPARATOR() + ); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); + + IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); + + staticATokenLM.metaWithdraw( + permit.owner, + permit.spender, + permit.staticAmount, + permit.dynamicAmount, + permit.toUnderlying, + permit.deadline, + sigParams + ); + + assertEq(IERC20(A_TOKEN).balanceOf(permit.spender), permit.dynamicAmount); + } +} diff --git a/tests/extensions/static-a-token/StaticATokenNoLM.t.sol b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol new file mode 100644 index 00000000..f45d197b --- /dev/null +++ b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {BaseTest, IERC20} from './TestBase.sol'; + +/** + * Testing the static token wrapper on a pool that never had LM enabled + * This is a slightly different assumption than a pool that doesn't have LM enabled any more as incentivesController.rewardTokens() will have length=0 + */ +contract StaticATokenNoLMTest is BaseTest { + + function setUp() public override { + super.setUp(); + + vm.startPrank(user); + } + + // test rewards + function test_collectAndUpdateRewardsWithLMDisabled() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); + assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); + assertEq(staticATokenLM.collectAndUpdateRewards(REWARD_TOKEN), 0); + assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); + } + + function test_claimRewardsToSelfWithLMDisabled() public { + uint128 amountToDeposit = 5 ether; + _fundUser(amountToDeposit, user); + + _depositAToken(amountToDeposit, user); + + _skipBlocks(60); + + try staticATokenLM.getClaimableRewards(user, REWARD_TOKEN) {} catch Error( + string memory reason + ) { + require(keccak256(bytes(reason)) == keccak256(bytes('9'))); + } + + try staticATokenLM.claimRewardsToSelf(rewardTokens) {} catch Error(string memory reason) { + require(keccak256(bytes(reason)) == keccak256(bytes('9'))); + } + assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); + } +} diff --git a/tests/extensions/static-a-token/TestBase.sol b/tests/extensions/static-a-token/TestBase.sol new file mode 100644 index 00000000..7fb215b7 --- /dev/null +++ b/tests/extensions/static-a-token/TestBase.sol @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.10; + +import {IRewardsController} from 'src/contracts/rewards/interfaces/IRewardsController.sol'; +import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; +import {IPool} from '../../../src/contracts/interfaces/IPool.sol'; +import {StaticATokenFactory} from '../../../src/contracts/extensions/static-a-token/StaticATokenFactory.sol'; +import {StaticATokenLM, IStaticATokenLM, IERC20, IERC20Metadata, ERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {IAToken} from '../../../src/contracts/extensions/static-a-token/interfaces/IAToken.sol'; +import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; + +abstract contract BaseTest is TestnetProcedures { + address constant OWNER = address(1234); + + address public user; + address public user1; + address internal spender; + + uint256 internal userPrivateKey; + uint256 internal spenderPrivateKey; + + StaticATokenLM public staticATokenLM; + address public proxyAdmin; + ITransparentProxyFactory public proxyFactory; + StaticATokenFactory public factory; + + address[] rewardTokens; + + address public UNDERLYING; + address public A_TOKEN; + address public REWARD_TOKEN; + IPool public POOL; + + function setUp() public virtual { + userPrivateKey = 0xA11CE; + spenderPrivateKey = 0xB0B0; + user = address(vm.addr(userPrivateKey)); + user1 = address(vm.addr(2)); + spender = vm.addr(spenderPrivateKey); + + initTestEnvironment(); + DataTypes.ReserveDataLegacy memory reserveDataWETH = contracts.poolProxy.getReserveData(tokenList.weth); + + UNDERLYING = address(weth); + REWARD_TOKEN = address(new TestnetERC20( + 'LM Reward ERC20', + 'RWD', + 18, + OWNER + )); + A_TOKEN = reserveDataWETH.aTokenAddress; + POOL = contracts.poolProxy; + + rewardTokens.push(REWARD_TOKEN); + + proxyFactory = ITransparentProxyFactory(report.transparentProxyFactory); + proxyAdmin = report.proxyAdmin; + + factory = StaticATokenFactory(report.staticATokenFactoryProxy); + factory.createStaticATokens(POOL.getReservesList()); + + staticATokenLM = StaticATokenLM(factory.getStaticAToken(UNDERLYING)); + } + + function _fundUser(uint128 amountToDeposit, address targetUser) internal { + deal(UNDERLYING, targetUser, amountToDeposit); + } + + function _skipBlocks(uint128 blocks) internal { + vm.roll(block.number + blocks); + vm.warp(block.timestamp + blocks * 12); // assuming a block is around 12seconds + } + + function _underlyingToAToken(uint256 amountToDeposit, address targetUser) internal { + IERC20(UNDERLYING).approve(address(POOL), amountToDeposit); + POOL.deposit(UNDERLYING, amountToDeposit, targetUser, 0); + } + + function _depositAToken(uint256 amountToDeposit, address targetUser) internal returns (uint256) { + _underlyingToAToken(amountToDeposit, targetUser); + IERC20(A_TOKEN).approve(address(staticATokenLM), amountToDeposit); + return staticATokenLM.deposit(amountToDeposit, targetUser, 10, false); + } + + function testAdmin() public { + vm.stopPrank(); + vm.startPrank(proxyAdmin); + assertEq(TransparentUpgradeableProxy(payable(address(staticATokenLM))).admin(), proxyAdmin); + assertEq(TransparentUpgradeableProxy(payable(address(factory))).admin(), proxyAdmin); + vm.stopPrank(); + } +} diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol new file mode 100644 index 00000000..b9e60567 --- /dev/null +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -0,0 +1,644 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; +import {IAaveV3ConfigEngine} from '../../../src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol'; +import {AaveV3MockListing} from './mocks/AaveV3MockListing.sol'; +import {AaveV3MockListingCustom} from './mocks/AaveV3MockListingCustom.sol'; +import {AaveV3MockCapUpdate} from './mocks/AaveV3MockCapUpdate.sol'; +import {AaveV3MockCollateralUpdate} from './mocks/AaveV3MockCollateralUpdate.sol'; +import {AaveV3MockCollateralUpdateNoChange} from './mocks/AaveV3MockCollateralUpdateNoChange.sol'; +import {AaveV3MockCollateralUpdateWrongBonus, AaveV3MockCollateralUpdateCorrectBonus} from './mocks/AaveV3MockCollateralUpdateWrongBonus.sol'; +import {AaveV3MockBorrowUpdate} from './mocks/AaveV3MockBorrowUpdate.sol'; +import {AaveV3MockBorrowUpdateNoChange} from './mocks/AaveV3MockBorrowUpdateNoChange.sol'; +import {AaveV3MockRatesUpdate} from './mocks/AaveV3MockRatesUpdate.sol'; +import {AaveV3MockPriceFeedUpdate} from './mocks/AaveV3MockPriceFeedUpdate.sol'; +import {AaveV3MockEModeCategoryUpdate, AaveV3MockEModeCategoryUpdateEdgeBonus} from './mocks/AaveV3MockEModeCategoryUpdate.sol'; +import {AaveV3MockEModeCategoryUpdateNoChange} from './mocks/AaveV3MockEModeCategoryUpdateNoChange.sol'; +import {AaveV3MockAssetEModeUpdate} from './mocks/AaveV3MockAssetEModeUpdate.sol'; + +import {ATokenInstance} from '../../../src/contracts/instances/ATokenInstance.sol'; +import {StableDebtTokenInstance} from '../../../src/contracts/instances/StableDebtTokenInstance.sol'; +import {VariableDebtTokenInstance} from '../../../src/contracts/instances/VariableDebtTokenInstance.sol'; +import {TestnetProcedures, AaveV3ConfigEngine} from '../../utils/TestnetProcedures.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {MockAggregator} from '../../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {IPool, IPoolAddressesProvider} from '../../utils/ProtocolV3TestBase.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {ProtocolV3TestBase, IDefaultInterestRateStrategyV2, ReserveConfig, ReserveTokens, DataTypes as DataTypeOld} from '../../utils/ProtocolV3TestBase.sol'; + +contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { + using stdStorage for StdStorage; + address configEngine; + + function setUp() public { + initTestEnvironment(); + configEngine = report.configEngine; + } + + event CollateralConfigurationChanged( + address indexed asset, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus + ); + + event EModeCategoryAdded( + uint8 indexed categoryId, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus, + address oracle, + string label + ); + + function testListings() public { + address asset = address(new TestnetERC20( + '1INCH', + '1INCH', + 18, + address(this) + )); + + address feed = address(new MockAggregator(int256(25e8))); + AaveV3MockListing payload = new AaveV3MockListing(asset, feed, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineListing', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineListing', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineListing', 'postTestEngineListing'); + + ReserveConfig memory expectedAssetConfig = ReserveConfig({ + symbol: '1INCH', + underlying: asset, + aToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + variableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + stableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + decimals: 18, + ltv: 82_50, + liquidationThreshold: 86_00, + liquidationBonus: 105_00, + liquidationProtocolFee: 10_00, + reserveFactor: 10_00, + usageAsCollateralEnabled: true, + borrowingEnabled: true, + interestRateStrategy: AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), + stableBorrowRateEnabled: false, + isPaused: false, + isActive: true, + isFrozen: false, + isSiloed: false, + isBorrowableInIsolation: false, + isFlashloanable: false, + supplyCap: 85_000, + borrowCap: 60_000, + debtCeiling: 0, + eModeCategory: 0 + }); + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + + _noReservesConfigsChangesApartNewListings(allConfigsBefore, allConfigsAfter); + + _validateReserveTokensImpls( + _findReserveConfigBySymbol(allConfigsAfter, '1INCH'), + ReserveTokens({ + aToken: address(contracts.aToken), + stableDebtToken: address(contracts.stableDebtToken), + variableDebtToken: address(contracts.variableDebtToken) + }) + ); + + _validateAssetSourceOnOracle( + IPoolAddressesProvider(address(contracts.poolAddressesProvider)), + asset, + feed + ); + + _validateInterestRateStrategy( + asset, + contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), + AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), + IDefaultInterestRateStrategyV2.InterestRateDataRay({ + optimalUsageRatio: _bpsToRay(payload.newListings()[0].rateStrategyParams.optimalUsageRatio), + baseVariableBorrowRate: _bpsToRay(payload.newListings()[0].rateStrategyParams.baseVariableBorrowRate), + variableRateSlope1: _bpsToRay(payload.newListings()[0].rateStrategyParams.variableRateSlope1), + variableRateSlope2: _bpsToRay(payload.newListings()[0].rateStrategyParams.variableRateSlope2) + }) + ); + } + + function testListingsCustom() public { + address asset = address(new TestnetERC20( + 'PSP', + 'PSP', + 18, + address(this) + )); + + address feed = address(new MockAggregator(int256(15e8))); + address aTokenImpl = address(new ATokenInstance(contracts.poolProxy)); + address vTokenImpl = address(new VariableDebtTokenInstance(contracts.poolProxy)); + address sTokenImpl = address(new StableDebtTokenInstance(contracts.poolProxy)); + + AaveV3MockListingCustom payload = new AaveV3MockListingCustom(asset, feed, configEngine, aTokenImpl, vTokenImpl, sTokenImpl); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineListingCustom', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineListingCustom', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineListingCustom', 'postTestEngineListingCustom'); + + ReserveConfig memory expectedAssetConfig = ReserveConfig({ + symbol: 'PSP', + underlying: asset, + aToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + variableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + stableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution + decimals: 18, + ltv: 82_50, + liquidationThreshold: 86_00, + liquidationBonus: 105_00, + liquidationProtocolFee: 10_00, + reserveFactor: 10_00, + usageAsCollateralEnabled: true, + borrowingEnabled: true, + interestRateStrategy: AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), + stableBorrowRateEnabled: false, + isPaused: false, + isActive: true, + isFrozen: false, + isSiloed: false, + isBorrowableInIsolation: false, + isFlashloanable: false, + supplyCap: 85_000, + borrowCap: 60_000, + debtCeiling: 0, + eModeCategory: 0 + }); + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + + _noReservesConfigsChangesApartNewListings(allConfigsBefore, allConfigsAfter); + + _validateReserveTokensImpls( + _findReserveConfigBySymbol(allConfigsAfter, 'PSP'), + ReserveTokens({ + aToken: aTokenImpl, + stableDebtToken: sTokenImpl, + variableDebtToken: vTokenImpl + }) + ); + + _validateAssetSourceOnOracle( + IPoolAddressesProvider(address(contracts.poolAddressesProvider)), + asset, + feed + ); + + _validateInterestRateStrategy( + asset, + contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), + AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), + IDefaultInterestRateStrategyV2.InterestRateDataRay({ + optimalUsageRatio: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.optimalUsageRatio), + baseVariableBorrowRate: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.baseVariableBorrowRate), + variableRateSlope1: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope1), + variableRateSlope2: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope2) + }) + ); + } + + function testCapsUpdate() public { + // this asset has been listed before + address asset = tokenList.usdx; + AaveV3MockCapUpdate payload = new AaveV3MockCapUpdate(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineCaps', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineCaps', + IPool(address(contracts.poolProxy)) + ); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + + diffReports('preTestEngineCaps', 'postTestEngineCaps'); + + expectedAssetConfig.supplyCap = 1_000_000; + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + function testCollateralsUpdates() public { + // this asset has been listed before + address asset = tokenList.usdx; + AaveV3MockCollateralUpdate payload = new AaveV3MockCollateralUpdate(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineCollateral', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineCollateral', + IPool(address(contracts.poolProxy)) + ); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + + diffReports('preTestEngineCollateral', 'postTestEngineCollateral'); + + expectedAssetConfig.ltv = 62_00; + expectedAssetConfig.liquidationThreshold = 72_00; + expectedAssetConfig.liquidationBonus = 106_00; // 100_00 + 6_00 + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + + // TODO manage this after testFail* deprecation. + // This should not be necessary, but there seems there is no other way + // of validating that when all collateral params are KEEP_CURRENT, the config + // engine doesn't call the POOL_CONFIGURATOR. + // So the solution is expecting the event emitted on the POOL_CONFIGURATOR, + // and as this doesn't happen, expect the failure of the test + function testFailCollateralsUpdatesNoChange() public { + // this asset has been listed before + address asset = tokenList.usdx; + AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineCollateralNoChange', + IPool(address(contracts.poolProxy)) + ); + + vm.expectEmit(); + emit CollateralConfigurationChanged( + allConfigsBefore[0].underlying, + allConfigsBefore[0].ltv, + allConfigsBefore[0].liquidationThreshold, + allConfigsBefore[0].liquidationBonus + ); + payload.execute(); + } + + // Same as testFailCollateralsUpdatesNoChange, but this time should work, as we are not expecting any event emitted + function testCollateralsUpdatesNoChange() public { + // this asset has been listed before + address asset = tokenList.usdx; + AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineCollateralNoChange', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineCollateralNoChange', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineCollateralNoChange', 'postTestEngineCollateralNoChange'); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + + function testCollateralUpdateWrongBonus() public { + address asset = tokenList.usdx; + AaveV3MockCollateralUpdateWrongBonus payload = new AaveV3MockCollateralUpdateWrongBonus(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + vm.expectRevert(bytes('INVALID_LT_LB_RATIO')); + payload.execute(); + } + + function testCollateralUpdateCorrectBonus() public { + address asset = tokenList.usdx; + AaveV3MockCollateralUpdateCorrectBonus payload = new AaveV3MockCollateralUpdateCorrectBonus(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineCollateralEdgeBonus', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineCollateralEdgeBonus', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineCollateralEdgeBonus', 'postTestEngineCollateralEdgeBonus'); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + expectedAssetConfig.ltv = 62_00; + expectedAssetConfig.liquidationThreshold = 90_00; + expectedAssetConfig.liquidationBonus = 111_00; // 100_00 + 11_00 + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + + function testBorrowsUpdates() public { + address asset = tokenList.usdx; + AaveV3MockBorrowUpdate payload = new AaveV3MockBorrowUpdate(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineBorrow', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineBorrow', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineBorrow', 'postTestEngineBorrow'); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + expectedAssetConfig.reserveFactor = 15_00; + expectedAssetConfig.borrowingEnabled = true; + expectedAssetConfig.isFlashloanable = false; + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + + function testBorrowUpdatesNoChange() public { + address asset = tokenList.usdx; + AaveV3MockBorrowUpdateNoChange payload = new AaveV3MockBorrowUpdateNoChange(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( + 'preTestEngineBorrowNoChange', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( + 'postTestEngineBorrowNoChange', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineBorrowNoChange', 'postTestEngineBorrowNoChange'); + + ReserveConfig memory expectedAssetConfig = _findReserveConfig( + allConfigsBefore, + asset + ); + + _validateReserveConfig(expectedAssetConfig, allConfigsAfter); + } + + function testRateStrategiesUpdates() public { + address asset = tokenList.usdx; + AaveV3MockRatesUpdate payload = new AaveV3MockRatesUpdate(asset, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + createConfigurationSnapshot( + 'preTestEngineRates', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + createConfigurationSnapshot( + 'postTestEngineRates', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineRates', 'postTestEngineRates'); + + _validateInterestRateStrategy( + asset, + contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), + AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), + IDefaultInterestRateStrategyV2.InterestRateDataRay({ + optimalUsageRatio: _bpsToRay(payload.rateStrategiesUpdates()[0].params.optimalUsageRatio), + baseVariableBorrowRate: _bpsToRay(payload.rateStrategiesUpdates()[0].params.baseVariableBorrowRate), + variableRateSlope1: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope1), + variableRateSlope2: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope2) + }) + ); + } + + function testPriceFeedsUpdates() public { + address asset = tokenList.usdx; + address newFeed = address(new MockAggregator(int256(1.05e8))); + AaveV3MockPriceFeedUpdate payload = new AaveV3MockPriceFeedUpdate(asset, newFeed, configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + createConfigurationSnapshot( + 'preTestEnginePriceFeed', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + createConfigurationSnapshot( + 'postTestEnginePriceFeed', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEnginePriceFeed', 'postTestEnginePriceFeed'); + + _validateAssetSourceOnOracle( + IPoolAddressesProvider(address(contracts.poolAddressesProvider)), + asset, + newFeed + ); + } + + function testEModeCategoryUpdates() public { + AaveV3MockEModeCategoryUpdate payload = new AaveV3MockEModeCategoryUpdate(configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + contracts.poolProxy.getEModeCategoryData(1); + + createConfigurationSnapshot( + 'preTestEngineEModeCategoryUpdate', + IPool(address(contracts.poolProxy)) + ); + + payload.execute(); + + createConfigurationSnapshot( + 'postTestEngineEModeCategoryUpdate', + IPool(address(contracts.poolProxy)) + ); + + diffReports('preTestEngineEModeCategoryUpdate', 'postTestEngineEModeCategoryUpdate'); + + DataTypeOld.EModeCategory memory prevEmodeCategoryData; + prevEmodeCategoryData.ltv = 97_40; + prevEmodeCategoryData.liquidationThreshold = 97_60; + prevEmodeCategoryData.liquidationBonus = 101_50; // 100_00 + 1_50 + prevEmodeCategoryData.priceSource = address(0); + prevEmodeCategoryData.label = 'ETH Correlated'; + + _validateEmodeCategory(IPoolAddressesProvider(address(contracts.poolAddressesProvider)), 1, prevEmodeCategoryData); + } + + function testEModeCategoryUpdatesWrongBonus() public { + AaveV3MockEModeCategoryUpdateEdgeBonus payload = new AaveV3MockEModeCategoryUpdateEdgeBonus(configEngine); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + vm.expectRevert(bytes('INVALID_LT_LB_RATIO')); + payload.execute(); + } + + // TODO manage this after testFail* deprecation. + function testFailEModeCategoryUpdatesNoChange() public { + AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange(configEngine); + + DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts.poolProxy.getEModeCategoryData(1); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + vm.expectEmit(true, true, true, true); + emit EModeCategoryAdded( + 1, + eModeCategoryDataBefore.ltv, + eModeCategoryDataBefore.liquidationThreshold, + eModeCategoryDataBefore.liquidationBonus, + eModeCategoryDataBefore.priceSource, + eModeCategoryDataBefore.label + ); + payload.execute(); + } + + // Same as testFailEModeCategoryUpdatesNoChange, but this time should work, as we are not expecting any event emitted + function testEModeCategoryUpdatesNoChange() public { + AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange(configEngine); + + DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts.poolProxy.getEModeCategoryData(1); + + vm.prank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + + createConfigurationSnapshot('preTestEngineEModeCategoryNoChange', IPool(address(contracts.poolProxy))); + + payload.execute(); + + createConfigurationSnapshot('postTestEngineEModeCategoryNoChange', IPool(address(contracts.poolProxy))); + + diffReports('preTestEngineEModeCategoryNoChange', 'postTestEngineEModeCategoryNoChange'); + + DataTypeOld.EModeCategory memory prevEmodeCategoryData; + prevEmodeCategoryData.ltv = eModeCategoryDataBefore.ltv; + prevEmodeCategoryData.liquidationThreshold = eModeCategoryDataBefore.liquidationThreshold; + prevEmodeCategoryData.liquidationBonus = eModeCategoryDataBefore.liquidationBonus; + prevEmodeCategoryData.priceSource = eModeCategoryDataBefore.priceSource; + prevEmodeCategoryData.label = eModeCategoryDataBefore.label; + + _validateEmodeCategory(IPoolAddressesProvider(address(contracts.poolAddressesProvider)), 1, prevEmodeCategoryData); + } + + function testAssetEModeUpdates() public { + address asset = tokenList.usdx; + + AaveV3MockEModeCategoryUpdate payloadToAddEMode = new AaveV3MockEModeCategoryUpdate(configEngine); + AaveV3MockAssetEModeUpdate payload = new AaveV3MockAssetEModeUpdate(asset, configEngine); + + vm.startPrank(roleList.marketOwner); + contracts.aclManager.addPoolAdmin(address(payload)); + contracts.aclManager.addPoolAdmin(address(payloadToAddEMode)); + vm.stopPrank(); + + payloadToAddEMode.execute(); + + createConfigurationSnapshot('preTestEngineAssetEModeUpdate', IPool(address(contracts.poolProxy))); + + payload.execute(); + + createConfigurationSnapshot('postTestEngineAssetEModeUpdate', IPool(address(contracts.poolProxy))); + + diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); + + assertEq( + contracts.protocolDataProvider.getReserveEModeCategory( + asset + ), + 1 + ); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol new file mode 100644 index 00000000..31d67eb0 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock asset e-mode update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockAssetEModeUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function assetsEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { + IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](1); + + eModeUpdate[0] = IEngine.AssetEModeUpdate({ + asset: ASSET_ADDRESS, + eModeCategory: 1 + }); + + return eModeUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol new file mode 100644 index 00000000..d397e9f1 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock borrow update, to be able to test + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine + * @author BGD Labs + */ +contract AaveV3MockBorrowUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function borrowsUpdates() public view override returns (IEngine.BorrowUpdate[] memory) { + IEngine.BorrowUpdate[] memory borrowsUpdate = new IEngine.BorrowUpdate[](1); + + borrowsUpdate[0] = IEngine.BorrowUpdate({ + asset: ASSET_ADDRESS, + enabledToBorrow: EngineFlags.ENABLED, + flashloanable: EngineFlags.DISABLED, + stableRateModeEnabled: EngineFlags.KEEP_CURRENT, + borrowableInIsolation: EngineFlags.KEEP_CURRENT, + withSiloedBorrowing: EngineFlags.KEEP_CURRENT, + reserveFactor: 15_00 + }); + + return borrowsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol new file mode 100644 index 00000000..b7176035 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock borrow update with no change, to be able to test + * @author BGD Labs + */ +contract AaveV3MockBorrowUpdateNoChange is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function borrowsUpdates() public view override returns (IEngine.BorrowUpdate[] memory) { + IEngine.BorrowUpdate[] memory borrowsUpdate = new IEngine.BorrowUpdate[](1); + + borrowsUpdate[0] = IEngine.BorrowUpdate({ + asset: ASSET_ADDRESS, + enabledToBorrow: EngineFlags.KEEP_CURRENT, + flashloanable: EngineFlags.KEEP_CURRENT, + stableRateModeEnabled: EngineFlags.KEEP_CURRENT, + borrowableInIsolation: EngineFlags.KEEP_CURRENT, + withSiloedBorrowing: EngineFlags.KEEP_CURRENT, + reserveFactor: EngineFlags.KEEP_CURRENT + }); + + return borrowsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol new file mode 100644 index 00000000..7575fa20 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock caps update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockCapUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function capsUpdates() public view override returns (IEngine.CapsUpdate[] memory) { + IEngine.CapsUpdate[] memory capsUpdate = new IEngine.CapsUpdate[](1); + + capsUpdate[0] = IEngine.CapsUpdate({ + asset: ASSET_ADDRESS, + supplyCap: 1_000_000, + borrowCap: EngineFlags.KEEP_CURRENT + }); + + return capsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol new file mode 100644 index 00000000..70e38f1e --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock collateral update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockCollateralUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { + IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); + + collateralsUpdate[0] = IEngine.CollateralUpdate({ + asset: ASSET_ADDRESS, + ltv: 62_00, + liqThreshold: 72_00, + liqBonus: 6_00, + debtCeiling: EngineFlags.KEEP_CURRENT, + liqProtocolFee: EngineFlags.KEEP_CURRENT + }); + + return collateralsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol new file mode 100644 index 00000000..12c9221f --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock collateral update with no changes, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockCollateralUpdateNoChange is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { + IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); + + collateralsUpdate[0] = IEngine.CollateralUpdate({ + asset: ASSET_ADDRESS, + ltv: EngineFlags.KEEP_CURRENT, + liqThreshold: EngineFlags.KEEP_CURRENT, + liqBonus: EngineFlags.KEEP_CURRENT, + debtCeiling: EngineFlags.KEEP_CURRENT, + liqProtocolFee: EngineFlags.KEEP_CURRENT + }); + + return collateralsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol new file mode 100644 index 00000000..b41f26d5 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contracts for a mock collateral update, with wrong LT/LB ratio + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockCollateralUpdateWrongBonus is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { + IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); + + collateralsUpdate[0] = IEngine.CollateralUpdate({ + asset: ASSET_ADDRESS, + ltv: 62_00, + liqThreshold: 90_00, + liqBonus: 12_00, + debtCeiling: EngineFlags.KEEP_CURRENT, + liqProtocolFee: EngineFlags.KEEP_CURRENT + }); + + return collateralsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Avalanche', networkAbbreviation: 'Ava'}); + } +} + +/** + * @dev Smart contracts for a mock collateral update, with correct (but edge) LT/LB ratio + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockCollateralUpdateCorrectBonus is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { + IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); + + collateralsUpdate[0] = IEngine.CollateralUpdate({ + asset: ASSET_ADDRESS, + ltv: 62_00, + liqThreshold: 90_00, + liqBonus: 11_00, + debtCeiling: EngineFlags.KEEP_CURRENT, + liqProtocolFee: EngineFlags.KEEP_CURRENT + }); + + return collateralsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol new file mode 100644 index 00000000..796b4009 --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock emode category update, to be able to test + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine + * @author BGD Labs + */ +contract AaveV3MockEModeCategoryUpdate is AaveV3Payload { + constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} + + function eModeCategoriesUpdates() + public + pure + override + returns (IEngine.EModeCategoryUpdate[] memory) + { + IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); + + eModeUpdates[0] = IEngine.EModeCategoryUpdate({ + eModeCategory: 1, + ltv: 97_40, + liqThreshold: 97_60, + liqBonus: 1_50, + priceSource: address(0), + label: 'ETH Correlated' + }); + + return eModeUpdates; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Polygon', networkAbbreviation: 'Pol'}); + } +} + +/** + * @dev Smart contract for a mock emode category update, to be able to test + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine + * @author BGD Labs + */ +contract AaveV3MockEModeCategoryUpdateEdgeBonus is AaveV3Payload { + constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} + + function eModeCategoriesUpdates() + public + pure + override + returns (IEngine.EModeCategoryUpdate[] memory) + { + IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); + + eModeUpdates[0] = IEngine.EModeCategoryUpdate({ + eModeCategory: 1, + ltv: 97_40, + liqThreshold: 97_60, + liqBonus: 2_50, + priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, + label: EngineFlags.KEEP_CURRENT_STRING + }); + + return eModeUpdates; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol new file mode 100644 index 00000000..b36ce80c --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock e-mode category update with no changes, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockEModeCategoryUpdateNoChange is AaveV3Payload { + constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} + + function eModeCategoriesUpdates() + public + pure + override + returns (IEngine.EModeCategoryUpdate[] memory) + { + IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); + + eModeUpdates[0] = IEngine.EModeCategoryUpdate({ + eModeCategory: 1, + ltv: EngineFlags.KEEP_CURRENT, + liqThreshold: EngineFlags.KEEP_CURRENT, + liqBonus: EngineFlags.KEEP_CURRENT, + priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, + label: EngineFlags.KEEP_CURRENT_STRING + }); + + return eModeUpdates; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol new file mode 100644 index 00000000..7944629d --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock listing, to be able to test without having a v3 instance on Local + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine + * @author BGD Labs + */ +contract AaveV3MockListing is AaveV3Payload { + address public immutable ASSET_ADDRESS; + address public immutable ASSET_FEED; + + constructor(address assetAddress, address assetFeed, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + ASSET_FEED = assetFeed; + } + + function newListings() public view override returns (IEngine.Listing[] memory) { + IEngine.Listing[] memory listings = new IEngine.Listing[](1); + + listings[0] = IEngine.Listing({ + asset: ASSET_ADDRESS, + assetSymbol: '1INCH', + priceFeed: ASSET_FEED, + rateStrategyParams: IEngine.InterestRateInputData({ + optimalUsageRatio: 80_00, + baseVariableBorrowRate: 25, // 0.25% + variableRateSlope1: 3_00, + variableRateSlope2: 75_00 + }), + enabledToBorrow: EngineFlags.ENABLED, + stableRateModeEnabled: EngineFlags.DISABLED, + borrowableInIsolation: EngineFlags.DISABLED, + withSiloedBorrowing: EngineFlags.DISABLED, + flashloanable: EngineFlags.DISABLED, + ltv: 82_50, + liqThreshold: 86_00, + liqBonus: 5_00, + reserveFactor: 10_00, + supplyCap: 85_000, + borrowCap: 60_000, + debtCeiling: 0, + liqProtocolFee: 10_00, + eModeCategory: 0 + }); + + return listings; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol new file mode 100644 index 00000000..f9a342fd --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock custom listing update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockListingCustom is AaveV3Payload { + address public immutable ASSET_ADDRESS; + address public immutable ASSET_FEED; + + address public immutable A_TOKEN_IMPL; + address public immutable V_TOKEN_IMPL; + address public immutable S_TOKEN_IMPL; + + constructor(address assetAddress, address assetFeed, address customEngine, address aTokenImpl, address vTokenImpl, address sTokenImpl) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + ASSET_FEED = assetFeed; + A_TOKEN_IMPL = aTokenImpl; + V_TOKEN_IMPL = vTokenImpl; + S_TOKEN_IMPL = sTokenImpl; + } + + function newListingsCustom() + public + view + override + returns (IEngine.ListingWithCustomImpl[] memory) + { + IEngine.ListingWithCustomImpl[] memory listingsCustom = new IEngine.ListingWithCustomImpl[](1); + + listingsCustom[0] = IEngine.ListingWithCustomImpl( + IEngine.Listing({ + asset: ASSET_ADDRESS, + assetSymbol: 'PSP', + priceFeed: ASSET_FEED, + rateStrategyParams: IEngine.InterestRateInputData({ + optimalUsageRatio: 80_00, + baseVariableBorrowRate: 25, // 0.25% + variableRateSlope1: 3_00, + variableRateSlope2: 75_00 + }), + enabledToBorrow: EngineFlags.ENABLED, + stableRateModeEnabled: EngineFlags.DISABLED, + borrowableInIsolation: EngineFlags.DISABLED, + withSiloedBorrowing: EngineFlags.DISABLED, + flashloanable: EngineFlags.DISABLED, + ltv: 82_50, + liqThreshold: 86_00, + liqBonus: 5_00, + reserveFactor: 10_00, + supplyCap: 85_000, + borrowCap: 60_000, + debtCeiling: 0, + liqProtocolFee: 10_00, + eModeCategory: 0 + }), + IEngine.TokenImplementations({ + aToken: A_TOKEN_IMPL, + vToken: V_TOKEN_IMPL, + sToken: S_TOKEN_IMPL + }) + ); + + return listingsCustom; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol new file mode 100644 index 00000000..048c5b9d --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock price feed update, to be able to test + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine + * @author BGD Labs + */ +contract AaveV3MockPriceFeedUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + address public immutable ASSET_FEED; + + constructor(address assetAddress, address feed, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + ASSET_FEED = feed; + } + + function priceFeedsUpdates() public view override returns (IEngine.PriceFeedUpdate[] memory) { + IEngine.PriceFeedUpdate[] memory priceFeedsUpdate = new IEngine.PriceFeedUpdate[](1); + + priceFeedsUpdate[0] = IEngine.PriceFeedUpdate({ + asset: ASSET_ADDRESS, + priceFeed: ASSET_FEED + }); + + return priceFeedsUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol new file mode 100644 index 00000000..42214ccc --- /dev/null +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Smart contract for a mock rate strategy params update, for testing purposes + * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION + * @author BGD Labs + */ +contract AaveV3MockRatesUpdate is AaveV3Payload { + address public immutable ASSET_ADDRESS; + + constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + ASSET_ADDRESS = assetAddress; + } + + function rateStrategiesUpdates() + public + view + override + returns (IEngine.RateStrategyUpdate[] memory) + { + IEngine.RateStrategyUpdate[] memory ratesUpdate = new IEngine.RateStrategyUpdate[](1); + + ratesUpdate[0] = IEngine.RateStrategyUpdate({ + asset: ASSET_ADDRESS, + params: IEngine.InterestRateInputData({ + optimalUsageRatio: 50_00, + baseVariableBorrowRate: 30, // 0.30% + variableRateSlope1: 4_00, + variableRateSlope2: 76_00 + }) + }); + + return ratesUpdate; + } + + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); + } +} diff --git a/tests/harness/StableDebtToken.sol b/tests/harness/StableDebtToken.sol index c841b9ef..72e42146 100644 --- a/tests/harness/StableDebtToken.sol +++ b/tests/harness/StableDebtToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {StableDebtTokenInstance, IPool} from 'aave-v3-core/instances/StableDebtTokenInstance.sol'; +import {StableDebtTokenInstance, IPool} from '../../src/contracts/instances/StableDebtTokenInstance.sol'; contract StableDebtTokenHarness is StableDebtTokenInstance { constructor(IPool pool) StableDebtTokenInstance(pool) {} diff --git a/tests/harness/VariableDebtToken.sol b/tests/harness/VariableDebtToken.sol index 2ca73a61..73815d97 100644 --- a/tests/harness/VariableDebtToken.sol +++ b/tests/harness/VariableDebtToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {VariableDebtTokenInstance, IPool} from 'aave-v3-core/instances/VariableDebtTokenInstance.sol'; +import {VariableDebtTokenInstance, IPool} from '../../src/contracts/instances/VariableDebtTokenInstance.sol'; contract VariableDebtTokenHarness is VariableDebtTokenInstance { constructor(IPool pool) VariableDebtTokenInstance(pool) {} diff --git a/tests/periphery/WrappedTokenGateway.t.sol b/tests/helpers/WrappedTokenGateway.t.sol similarity index 95% rename from tests/periphery/WrappedTokenGateway.t.sol rename to tests/helpers/WrappedTokenGateway.t.sol index 4b97b910..9a09ac4c 100644 --- a/tests/periphery/WrappedTokenGateway.t.sol +++ b/tests/helpers/WrappedTokenGateway.t.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {AaveOracle} from 'aave-v3-core/contracts/misc/AaveOracle.sol'; -import {WrappedTokenGatewayV3} from 'aave-v3-periphery/contracts/misc/WrappedTokenGatewayV3.sol'; -import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; -import {AToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {StableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/StableDebtToken.sol'; -import {VariableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/VariableDebtToken.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {AaveOracle} from '../../src/contracts/misc/AaveOracle.sol'; +import {WrappedTokenGatewayV3} from '../../src/contracts/helpers/WrappedTokenGatewayV3.sol'; +import {AaveProtocolDataProvider} from '../../src/contracts/helpers/AaveProtocolDataProvider.sol'; +import {AToken} from '../../src/contracts/protocol/tokenization/AToken.sol'; +import {StableDebtToken} from '../../src/contracts/protocol/tokenization/StableDebtToken.sol'; +import {VariableDebtToken} from '../../src/contracts/protocol/tokenization/VariableDebtToken.sol'; +import {DataTypes} from '../../src/contracts/protocol/libraries/types/DataTypes.sol'; import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; diff --git a/tests/core/AaveOracle.t.sol b/tests/misc/AaveOracle.t.sol similarity index 95% rename from tests/core/AaveOracle.t.sol rename to tests/misc/AaveOracle.t.sol index 2bbd361f..3ec7335a 100644 --- a/tests/core/AaveOracle.t.sol +++ b/tests/misc/AaveOracle.t.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {MintableERC20} from 'aave-v3-core/contracts/mocks/tokens/MintableERC20.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {MintableERC20} from '../../src/contracts/mocks/tokens/MintableERC20.sol'; +import {MockAggregator} from '../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {PriceOracle} from 'aave-v3-core/contracts/mocks/oracle/PriceOracle.sol'; +import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {PriceOracle} from '../../src/contracts/mocks/oracle/PriceOracle.sol'; contract AaveOracleTest is TestnetProcedures { function setUp() public { diff --git a/tests/core/PriceOracleSentinel.t.sol b/tests/misc/PriceOracleSentinel.t.sol similarity index 89% rename from tests/core/PriceOracleSentinel.t.sol rename to tests/misc/PriceOracleSentinel.t.sol index ae4c0418..2ca5313b 100644 --- a/tests/core/PriceOracleSentinel.t.sol +++ b/tests/misc/PriceOracleSentinel.t.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {PriceOracleSentinel} from 'aave-v3-core/contracts/protocol/configuration/PriceOracleSentinel.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {SequencerOracle, ISequencerOracle} from 'aave-v3-core/contracts/mocks/oracle/SequencerOracle.sol'; +import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {PriceOracleSentinel} from '../../src/contracts/misc/PriceOracleSentinel.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {ACLManager} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {SequencerOracle, ISequencerOracle} from '../../src/contracts/mocks/oracle/SequencerOracle.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; contract PriceOracleSentinelTest is TestnetProcedures { diff --git a/tests/core/InitializableImmutableAdminUpgradeabilityProxy.t.sol b/tests/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.t.sol similarity index 96% rename from tests/core/InitializableImmutableAdminUpgradeabilityProxy.t.sol rename to tests/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.t.sol index 4740633c..e308ab05 100644 --- a/tests/core/InitializableImmutableAdminUpgradeabilityProxy.t.sol +++ b/tests/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {SlotParser} from '../utils/SlotParser.sol'; -import {MockInitializableImple, MockInitializableImpleV2} from 'aave-v3-core/contracts/mocks/upgradeability/MockInitializableImplementation.sol'; -import 'aave-v3-core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; +import {SlotParser} from '../../utils/SlotParser.sol'; +import {MockInitializableImple, MockInitializableImpleV2} from '../../../src/contracts/mocks/upgradeability/MockInitializableImplementation.sol'; +import '../../../src/contracts/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; contract InitializableImmutableAdminUpgradeabilityProxyTests is Test { using stdStorage for StdStorage; diff --git a/tests/core/RateStrategy.t.sol b/tests/misc/rates/RateStrategy.t.sol similarity index 99% rename from tests/core/RateStrategy.t.sol rename to tests/misc/rates/RateStrategy.t.sol index 9cc3e6bb..844c15ec 100644 --- a/tests/core/RateStrategy.t.sol +++ b/tests/misc/rates/RateStrategy.t.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {DefaultReserveInterestRateStrategyV2, IDefaultInterestRateStrategyV2, PercentageMath, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {DefaultReserveInterestRateStrategyV2, IDefaultInterestRateStrategyV2, PercentageMath, IPoolAddressesProvider} from '../../../src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract RateStrategyTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/core/RatesOverflow.t.sol b/tests/misc/rates/RatesOverflow.t.sol similarity index 83% rename from tests/core/RatesOverflow.t.sol rename to tests/misc/rates/RatesOverflow.t.sol index bb99d58f..af12d732 100644 --- a/tests/core/RatesOverflow.t.sol +++ b/tests/misc/rates/RatesOverflow.t.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {MockReserveInterestRateStrategy} from 'aave-v3-core/contracts/mocks/tests/MockReserveInterestRateStrategy.sol'; -import {IPoolConfigurator} from 'aave-v3-core/contracts/interfaces/IPoolConfigurator.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {MockReserveInterestRateStrategy} from '../../../src/contracts/mocks/tests/MockReserveInterestRateStrategy.sol'; +import {IPoolConfigurator} from '../../../src/contracts/interfaces/IPoolConfigurator.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; // @dev Ignored from coverage report, due Foundry Coverage can not detect functions if they return 0. contract RatesOverflowCheckTests is TestnetProcedures { diff --git a/tests/core/ZeroInteresRateStrategy.t.sol b/tests/misc/rates/ZeroInteresRateStrategy.t.sol similarity index 86% rename from tests/core/ZeroInteresRateStrategy.t.sol rename to tests/misc/rates/ZeroInteresRateStrategy.t.sol index 0ce57a59..e037f453 100644 --- a/tests/core/ZeroInteresRateStrategy.t.sol +++ b/tests/misc/rates/ZeroInteresRateStrategy.t.sol @@ -3,10 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {DefaultReserveInterestRateStrategyV2, DataTypes, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {IDefaultInterestRateStrategyV2} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken} from '../../../src/contracts/protocol/tokenization/AToken.sol'; +import {DefaultReserveInterestRateStrategyV2, DataTypes, IPoolAddressesProvider, IDefaultInterestRateStrategyV2} from '../../../src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; // @dev Ignored from coverage report, due Foundry Coverage can not detect functions if they return 0. contract ZeroReserveInterestRateStrategyTests is TestnetProcedures { diff --git a/tests/mocks/AaveV3TestListing.sol b/tests/mocks/AaveV3TestListing.sol index 95714b0f..97cc9cce 100644 --- a/tests/mocks/AaveV3TestListing.sol +++ b/tests/mocks/AaveV3TestListing.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import 'aave-v3-periphery/contracts/v3-config-engine/AaveV3Payload.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {MarketReport} from 'src/deployments/interfaces/IMarketReportTypes.sol'; +import '../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; +import {TestnetERC20} from '../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {MockAggregator} from '../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {ACLManager} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {MarketReport} from '../../src/deployments/interfaces/IMarketReportTypes.sol'; /** * @dev Smart contract for token listing, for testing purposes @@ -156,7 +156,7 @@ contract AaveV3TestListing is AaveV3Payload { } function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Ethereum Sepolia', networkAbbreviation: 'EthSep'}); + return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); } function _postExecute() internal override { diff --git a/tests/mocks/MockFlashLoanATokenReceiver.sol b/tests/mocks/MockFlashLoanATokenReceiver.sol index e9711df5..ae8947ec 100644 --- a/tests/mocks/MockFlashLoanATokenReceiver.sol +++ b/tests/mocks/MockFlashLoanATokenReceiver.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {FlashLoanSimpleReceiverBase} from 'aave-v3-core/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol'; +import {IERC20} from '../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../src/contracts/interfaces/IPool.sol'; +import {FlashLoanSimpleReceiverBase} from '../../src/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol'; /// @dev Helper contract to test donation attacks not possible in the context of a flash loan contract MockFlashLoanATokenReceiver is FlashLoanSimpleReceiverBase { diff --git a/tests/periphery/mocks/StakeMock.sol b/tests/mocks/StakeMock.sol similarity index 100% rename from tests/periphery/mocks/StakeMock.sol rename to tests/mocks/StakeMock.sol diff --git a/tests/core/ACLManager.t.sol b/tests/protocol/configuration/ACLManager.t.sol similarity index 96% rename from tests/core/ACLManager.t.sol rename to tests/protocol/configuration/ACLManager.t.sol index 373c4ee0..717395d7 100644 --- a/tests/core/ACLManager.t.sol +++ b/tests/protocol/configuration/ACLManager.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {PoolAddressesProvider} from 'aave-v3-core/contracts/protocol/configuration/PoolAddressesProvider.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ACLManager} from '../../../src/contracts/protocol/configuration/ACLManager.sol'; +import {PoolAddressesProvider} from '../../../src/contracts/protocol/configuration/PoolAddressesProvider.sol'; contract ACLManagerTest is TestnetProcedures { address internal immutable deployer; diff --git a/tests/core/AddressesProviderRegistry.t.sol b/tests/protocol/configuration/AddressesProviderRegistry.t.sol similarity index 97% rename from tests/core/AddressesProviderRegistry.t.sol rename to tests/protocol/configuration/AddressesProviderRegistry.t.sol index d1e5bb35..d549d752 100644 --- a/tests/core/AddressesProviderRegistry.t.sol +++ b/tests/protocol/configuration/AddressesProviderRegistry.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; contract PoolAddressesProviderRegistryTest is TestnetProcedures { event AddressesProviderRegistered(address indexed addressesProvider, uint256 indexed id); diff --git a/tests/core/PoolAddressesProvider.t.sol b/tests/protocol/configuration/PoolAddressesProvider.t.sol similarity index 95% rename from tests/core/PoolAddressesProvider.t.sol rename to tests/protocol/configuration/PoolAddressesProvider.t.sol index 115219b8..e4003f7c 100644 --- a/tests/core/PoolAddressesProvider.t.sol +++ b/tests/protocol/configuration/PoolAddressesProvider.t.sol @@ -3,14 +3,14 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {PoolAddressesProvider, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/configuration/PoolAddressesProvider.sol'; -import {PoolInstance} from 'aave-v3-core/instances/PoolInstance.sol'; -import {MockInitializableV1, MockInitializableV2} from 'aave-v3-core/contracts/mocks/upgradeability/MockInitializableImplementation.sol'; -import {PoolConfiguratorInstance} from 'aave-v3-core/instances/PoolConfiguratorInstance.sol'; -import {MockPoolInherited} from 'aave-v3-core/contracts/mocks/helpers/MockPool.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {SlotParser} from '../utils/SlotParser.sol'; +import {PoolAddressesProvider, IPoolAddressesProvider} from '../../../src/contracts/protocol/configuration/PoolAddressesProvider.sol'; +import {PoolInstance} from '../../../src/contracts/instances/PoolInstance.sol'; +import {MockInitializableV1, MockInitializableV2} from '../../../src/contracts/mocks/upgradeability/MockInitializableImplementation.sol'; +import {PoolConfiguratorInstance} from '../../../src/contracts/instances/PoolConfiguratorInstance.sol'; +import {MockPoolInherited} from '../../../src/contracts/mocks/helpers/MockPool.sol'; +import {ACLManager} from '../../../src/contracts/protocol/configuration/ACLManager.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {SlotParser} from '../../utils/SlotParser.sol'; contract PoolAddressesProviderTests is TestnetProcedures { using stdStorage for StdStorage; diff --git a/tests/core/BridgeLogic.t.sol b/tests/protocol/libraries/logic/BridgeLogic.t.sol similarity index 92% rename from tests/core/BridgeLogic.t.sol rename to tests/protocol/libraries/logic/BridgeLogic.t.sol index db9ddbe5..18660436 100644 --- a/tests/core/BridgeLogic.t.sol +++ b/tests/protocol/libraries/logic/BridgeLogic.t.sol @@ -3,15 +3,15 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {MathUtils} from 'aave-v3-core/contracts/protocol/libraries/math/MathUtils.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {SafeCast} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {MathUtils} from '../../../../src/contracts/protocol/libraries/math/MathUtils.sol'; +import {WadRayMath} from '../../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ReserveLogic} from '../../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import {PercentageMath} from '../../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {SafeCast} from '../../../../src/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; +import {IAToken} from '../../../../src/contracts/interfaces/IAToken.sol'; +import {DataTypes} from '../../../../src/contracts/protocol/libraries/types/DataTypes.sol'; contract BridgeLogicTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/core/PoolLogic.initReserves.edge.t.sol b/tests/protocol/libraries/logic/PoolLogic.initReserves.edge.t.sol similarity index 94% rename from tests/core/PoolLogic.initReserves.edge.t.sol rename to tests/protocol/libraries/logic/PoolLogic.initReserves.edge.t.sol index d7b6053c..695d96ee 100644 --- a/tests/core/PoolLogic.initReserves.edge.t.sol +++ b/tests/protocol/libraries/logic/PoolLogic.initReserves.edge.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {PoolLogic, ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/PoolLogic.sol'; -import '../utils/TestnetProcedures.sol'; +import {PoolLogic, ReserveLogic} from '../../../../src/contracts/protocol/libraries/logic/PoolLogic.sol'; +import '../../../utils/TestnetProcedures.sol'; contract Mock { string public constant value = 'MOCK'; diff --git a/tests/core/MathUtils.t.sol b/tests/protocol/libraries/math/MathUtils.t.sol similarity index 88% rename from tests/core/MathUtils.t.sol rename to tests/protocol/libraries/math/MathUtils.t.sol index 8f532c8e..ce27b819 100644 --- a/tests/core/MathUtils.t.sol +++ b/tests/protocol/libraries/math/MathUtils.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {MathUtils} from 'aave-v3-core/contracts/protocol/libraries/math/MathUtils.sol'; -import {MathUtilsWrapper} from 'aave-v3-core/contracts/mocks/tests/MathUtilsWrapper.sol'; +import {MathUtils} from '../../../../src/contracts/protocol/libraries/math/MathUtils.sol'; +import {MathUtilsWrapper} from '../../../../src/contracts/mocks/tests/MathUtilsWrapper.sol'; contract MathUtilsTests is Test { MathUtilsWrapper internal w; diff --git a/tests/core/PercentageMath.t.sol b/tests/protocol/libraries/math/PercentageMath.t.sol similarity index 89% rename from tests/core/PercentageMath.t.sol rename to tests/protocol/libraries/math/PercentageMath.t.sol index 1d6abb8c..47f949d2 100644 --- a/tests/core/PercentageMath.t.sol +++ b/tests/protocol/libraries/math/PercentageMath.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {PercentageMathWrapper} from 'aave-v3-core/contracts/mocks/tests/PercentageMathWrapper.sol'; +import {PercentageMath} from '../../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {PercentageMathWrapper} from '../../../../src/contracts/mocks/tests/PercentageMathWrapper.sol'; contract PercentageMathTests is Test { PercentageMathWrapper internal w; diff --git a/tests/core/WadRayMath.t.sol b/tests/protocol/libraries/math/WadRayMath.t.sol similarity index 97% rename from tests/core/WadRayMath.t.sol rename to tests/protocol/libraries/math/WadRayMath.t.sol index 7a582e34..baefd867 100644 --- a/tests/core/WadRayMath.t.sol +++ b/tests/protocol/libraries/math/WadRayMath.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {WadRayMathWrapper} from 'aave-v3-core/contracts/mocks/tests/WadRayMathWrapper.sol'; +import {WadRayMathWrapper} from '../../../../src/contracts/mocks/tests/WadRayMathWrapper.sol'; contract WadRayMathTests is Test { WadRayMathWrapper internal w; diff --git a/tests/core/L2Pool.t.sol b/tests/protocol/pool/L2Pool.t.sol similarity index 92% rename from tests/core/L2Pool.t.sol rename to tests/protocol/pool/L2Pool.t.sol index 18f73fd3..88b2e261 100644 --- a/tests/core/L2Pool.t.sol +++ b/tests/protocol/pool/L2Pool.t.sol @@ -3,17 +3,17 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {L2Encoder} from 'aave-v3-core/contracts/misc/L2Encoder.sol'; -import {IL2Pool} from 'aave-v3-core/contracts/interfaces/IL2Pool.sol'; -import {IReserveInterestRateStrategy} from 'aave-v3-core/contracts/interfaces/IReserveInterestRateStrategy.sol'; -import {BorrowLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/BorrowLogic.sol'; -import {SupplyLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/SupplyLogic.sol'; -import {LiquidationLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/LiquidationLogic.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; +import {L2Encoder} from '../../../src/contracts/helpers/L2Encoder.sol'; +import {IL2Pool} from '../../../src/contracts/interfaces/IL2Pool.sol'; +import {IReserveInterestRateStrategy} from '../../../src/contracts/interfaces/IReserveInterestRateStrategy.sol'; +import {BorrowLogic} from '../../../src/contracts/protocol/libraries/logic/BorrowLogic.sol'; +import {SupplyLogic} from '../../../src/contracts/protocol/libraries/logic/SupplyLogic.sol'; +import {LiquidationLogic} from '../../../src/contracts/protocol/libraries/logic/LiquidationLogic.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; import {PoolTests, DataTypes, Errors, IERC20, IPool} from './Pool.t.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; /// @dev All Pool.t.sol tests are run as L2Pool via inheriting PoolTests contract L2PoolTests is PoolTests { diff --git a/tests/core/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol similarity index 95% rename from tests/core/Pool.Borrow.t.sol rename to tests/protocol/pool/Pool.Borrow.t.sol index c73a30e8..bddd02e1 100644 --- a/tests/core/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -3,21 +3,21 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IReserveInterestRateStrategy} from 'aave-v3-core/contracts/interfaces/IReserveInterestRateStrategy.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {ISequencerOracle} from 'aave-v3-core/contracts/interfaces/ISequencerOracle.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {PriceOracleSentinel} from 'aave-v3-core/contracts/protocol/configuration/PriceOracleSentinel.sol'; -import {SequencerOracle} from 'aave-v3-core/contracts/mocks/oracle/SequencerOracle.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IStableDebtToken} from '../../../src/contracts/interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../../../src/contracts/interfaces/IVariableDebtToken.sol'; +import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {IReserveInterestRateStrategy} from '../../../src/contracts/interfaces/IReserveInterestRateStrategy.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {ISequencerOracle} from '../../../src/contracts/interfaces/ISequencerOracle.sol'; +import {UserConfiguration} from '../../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol'; +import {PriceOracleSentinel} from '../../../src/contracts/misc/PriceOracleSentinel.sol'; +import {SequencerOracle} from '../../../src/contracts/mocks/oracle/SequencerOracle.sol'; +import {MockAggregator} from '../../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {ReserveConfiguration} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IERC20} from '../../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract PoolBorrowTests is TestnetProcedures { using UserConfiguration for DataTypes.UserConfigurationMap; diff --git a/tests/core/Pool.FlashLoans.t.sol b/tests/protocol/pool/Pool.FlashLoans.t.sol similarity index 92% rename from tests/core/Pool.FlashLoans.t.sol rename to tests/protocol/pool/Pool.FlashLoans.t.sol index ea9c2e84..a98392c0 100644 --- a/tests/core/Pool.FlashLoans.t.sol +++ b/tests/protocol/pool/Pool.FlashLoans.t.sol @@ -3,20 +3,20 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {FlashLoanLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/FlashLoanLogic.sol'; -import {BorrowLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/BorrowLogic.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {MockFlashLoanReceiver} from 'aave-v3-core/contracts/mocks/flashloan/MockFlashLoanReceiver.sol'; -import {MockFlashLoanSimpleReceiver} from 'aave-v3-core/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {MockFlashLoanATokenReceiver} from '../mocks/MockFlashLoanATokenReceiver.sol'; -import {TestnetProcedures, TestReserveConfig} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {ReserveConfiguration} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {FlashLoanLogic} from '../../../src/contracts/protocol/libraries/logic/FlashLoanLogic.sol'; +import {BorrowLogic} from '../../../src/contracts/protocol/libraries/logic/BorrowLogic.sol'; +import {PercentageMath} from '../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {MockFlashLoanReceiver} from '../../../src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol'; +import {MockFlashLoanSimpleReceiver} from '../../../src/contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {IERC20} from '../../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {MockFlashLoanATokenReceiver} from '../../mocks/MockFlashLoanATokenReceiver.sol'; +import {TestnetProcedures, TestReserveConfig} from '../../utils/TestnetProcedures.sol'; contract PoolFlashLoansTests is TestnetProcedures { using ReserveConfiguration for DataTypes.ReserveConfigurationMap; diff --git a/tests/core/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol similarity index 96% rename from tests/core/Pool.Liquidations.t.sol rename to tests/protocol/pool/Pool.Liquidations.t.sol index 12c332da..f8466f23 100644 --- a/tests/core/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -3,23 +3,23 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {ReserveLogic, IERC20} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {PriceOracleSentinel} from 'aave-v3-core/contracts/protocol/configuration/PriceOracleSentinel.sol'; -import {SequencerOracle, ISequencerOracle} from 'aave-v3-core/contracts/mocks/oracle/SequencerOracle.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {LiquidationLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/LiquidationLogic.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IStableDebtToken} from '../../../src/contracts/interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../../../src/contracts/interfaces/IVariableDebtToken.sol'; +import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {UserConfiguration} from '../../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol'; +import {ReserveLogic, IERC20} from '../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import {ReserveConfiguration} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {PriceOracleSentinel} from '../../../src/contracts/misc/PriceOracleSentinel.sol'; +import {SequencerOracle, ISequencerOracle} from '../../../src/contracts/mocks/oracle/SequencerOracle.sol'; +import {MockAggregator} from '../../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {LiquidationLogic} from '../../../src/contracts/protocol/libraries/logic/LiquidationLogic.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {PercentageMath} from '../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract PoolLiquidationTests is TestnetProcedures { using stdStorage for StdStorage; diff --git a/tests/core/Pool.Repay.t.sol b/tests/protocol/pool/Pool.Repay.t.sol similarity index 95% rename from tests/core/Pool.Repay.t.sol rename to tests/protocol/pool/Pool.Repay.t.sol index 25530d81..79eb415a 100644 --- a/tests/core/Pool.Repay.t.sol +++ b/tests/protocol/pool/Pool.Repay.t.sol @@ -3,19 +3,19 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IStableDebtToken} from 'aave-v3-core/contracts/interfaces/IStableDebtToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {ISequencerOracle} from 'aave-v3-core/contracts/interfaces/ISequencerOracle.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {PriceOracleSentinel} from 'aave-v3-core/contracts/protocol/configuration/PriceOracleSentinel.sol'; -import {SequencerOracle} from 'aave-v3-core/contracts/mocks/oracle/SequencerOracle.sol'; -import {BorrowLogic, IERC20} from 'aave-v3-core/contracts/protocol/libraries/logic/BorrowLogic.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; +import {IStableDebtToken} from '../../../src/contracts/interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../../../src/contracts/interfaces/IVariableDebtToken.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {ISequencerOracle} from '../../../src/contracts/interfaces/ISequencerOracle.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {UserConfiguration} from '../../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol'; +import {PriceOracleSentinel} from '../../../src/contracts/misc/PriceOracleSentinel.sol'; +import {SequencerOracle} from '../../../src/contracts/mocks/oracle/SequencerOracle.sol'; +import {BorrowLogic, IERC20} from '../../../src/contracts/protocol/libraries/logic/BorrowLogic.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; contract PoolRepayTests is TestnetProcedures { using UserConfiguration for DataTypes.UserConfigurationMap; diff --git a/tests/core/Pool.Supply.t.sol b/tests/protocol/pool/Pool.Supply.t.sol similarity index 95% rename from tests/core/Pool.Supply.t.sol rename to tests/protocol/pool/Pool.Supply.t.sol index 507c4da9..12cc4135 100644 --- a/tests/core/Pool.Supply.t.sol +++ b/tests/protocol/pool/Pool.Supply.t.sol @@ -3,12 +3,12 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IAToken, IERC20} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetERC20, IERC20WithPermit} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; +import {IPool} from '../../../src/contracts/interfaces/IPool.sol'; +import {IAToken, IERC20} from '../../../src/contracts/interfaces/IAToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetERC20, IERC20WithPermit} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; contract PoolSupplyTests is TestnetProcedures { IPool internal pool; diff --git a/tests/core/Pool.Withdraw.t.sol b/tests/protocol/pool/Pool.Withdraw.t.sol similarity index 97% rename from tests/core/Pool.Withdraw.t.sol rename to tests/protocol/pool/Pool.Withdraw.t.sol index bb5fc57f..05598338 100644 --- a/tests/core/Pool.Withdraw.t.sol +++ b/tests/protocol/pool/Pool.Withdraw.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken, IERC20} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken, IERC20} from '../../../src/contracts/interfaces/IAToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract PoolWithdrawTests is TestnetProcedures { address internal aUSDX; diff --git a/tests/core/Pool.t.sol b/tests/protocol/pool/Pool.t.sol similarity index 97% rename from tests/core/Pool.t.sol rename to tests/protocol/pool/Pool.t.sol index 7ae63020..65aae648 100644 --- a/tests/core/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -4,15 +4,15 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import 'forge-std/StdStorage.sol'; -import {IAToken, IERC20} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {IPool, DataTypes} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {PoolInstance} from 'aave-v3-core/instances/PoolInstance.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken, IERC20} from '../../../src/contracts/interfaces/IAToken.sol'; +import {IPool, DataTypes} from '../../../src/contracts/interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {PoolInstance} from '../../../src/contracts/instances/PoolInstance.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ReserveConfiguration} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract PoolTests is TestnetProcedures { using stdStorage for StdStorage; diff --git a/tests/core/PoolConfigurator.ACLModifiers.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol similarity index 97% rename from tests/core/PoolConfigurator.ACLModifiers.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol index aad612d2..a6c86453 100644 --- a/tests/core/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ConfiguratorInputTypes} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ConfiguratorInputTypes} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorACLModifiersTest is TestnetProcedures { function setUp() public { @@ -244,7 +244,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { !contracts.aclManager.isRiskAdmin(caller) && caller != address(contracts.poolAddressesProvider) ); - vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); vm.prank(caller); @@ -290,7 +289,6 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { ); vm.prank(caller); - vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_OR_EMERGENCY_ADMIN)); contracts.poolConfiguratorProxy.setReservePause(asset, paused, gracePeriod); } diff --git a/tests/core/PoolConfigurator.borrowCaps.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.borrowCaps.t.sol similarity index 93% rename from tests/core/PoolConfigurator.borrowCaps.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.borrowCaps.t.sol index 6f347905..07728b7a 100644 --- a/tests/core/PoolConfigurator.borrowCaps.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.borrowCaps.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {IERC20} from '../../../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {DataTypes} from '../../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorBorrowCapTests is TestnetProcedures { address internal aUSDX; diff --git a/tests/core/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol similarity index 96% rename from tests/core/PoolConfigurator.eMode.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index 25351978..4a156738 100644 --- a/tests/core/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {ReserveConfiguration, DataTypes} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {PercentageMath} from '../../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {ReserveConfiguration, DataTypes} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorEModeConfigTests is TestnetProcedures { using PercentageMath for uint256; diff --git a/tests/core/PoolConfigurator.initReserves.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol similarity index 94% rename from tests/core/PoolConfigurator.initReserves.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol index a6159b64..c760a736 100644 --- a/tests/core/PoolConfigurator.initReserves.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol @@ -3,12 +3,12 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {AToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {ConfiguratorInputTypes} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {IDefaultInterestRateStrategyV2} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {TestnetProcedures, TestVars, TestReserveConfig} from '../utils/TestnetProcedures.sol'; +import {AToken} from '../../../../src/contracts/protocol/tokenization/AToken.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetERC20} from '../../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {ConfiguratorInputTypes} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {IDefaultInterestRateStrategyV2} from '../../../../src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; +import {TestnetProcedures, TestVars, TestReserveConfig} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorInitReservesTest is TestnetProcedures { event ReserveInitialized( @@ -33,7 +33,7 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.variableDebtSymbol = 'varDebtMISC'; t.stableDebtName = 'Stable Debt Misc'; t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategyV2; + t.rateStrategy = report.defaultInterestRateStrategy; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ optimalUsageRatio: 80_00, @@ -257,7 +257,7 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { t.variableDebtSymbol = 'varDebtMISC'; t.stableDebtName = 'Stable Debt Misc'; t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategyV2; + t.rateStrategy = report.defaultInterestRateStrategy; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ optimalUsageRatio: 80_00, diff --git a/tests/core/PoolConfigurator.liquidationFee.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.liquidationFee.t.sol similarity index 94% rename from tests/core/PoolConfigurator.liquidationFee.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.liquidationFee.t.sol index d509d49d..628485bb 100644 --- a/tests/core/PoolConfigurator.liquidationFee.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.liquidationFee.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorLiquidationFeeTests is TestnetProcedures { address internal aUSDX; diff --git a/tests/core/PoolConfigurator.pendingLTV.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.pendingLTV.t.sol similarity index 92% rename from tests/core/PoolConfigurator.pendingLTV.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.pendingLTV.t.sol index 5c3582cf..b15d5d01 100644 --- a/tests/core/PoolConfigurator.pendingLTV.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.pendingLTV.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {IERC20} from '../../../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {DataTypes} from '../../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorPendingLtvTests is TestnetProcedures { function setUp() public { diff --git a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol similarity index 98% rename from tests/core/PoolConfigurator.reserveRiskConfig.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol index cd6a28b7..97298c12 100644 --- a/tests/core/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ReserveLogic} from '../../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { using ReserveConfiguration for DataTypes.ReserveConfigurationMap; @@ -575,7 +575,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], true); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(true, 0); + contracts.poolConfiguratorProxy.setPoolPause(true); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -591,7 +591,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], false); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(false, 0); + contracts.poolConfiguratorProxy.setPoolPause(false); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -735,7 +735,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { function test_setLiquidationGracePeriodReserve(uint40 gracePeriod) public { vm.assume( - gracePeriod <= contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0 + gracePeriod < contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0 ); address asset = tokenList.usdx; diff --git a/tests/core/PoolConfigurator.supplyCaps.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.supplyCaps.t.sol similarity index 94% rename from tests/core/PoolConfigurator.supplyCaps.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.supplyCaps.t.sol index a1f7c01f..151d29fe 100644 --- a/tests/core/PoolConfigurator.supplyCaps.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.supplyCaps.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {IERC20} from '../../../../src/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorSupplyCapTests is TestnetProcedures { address internal aUSDX; diff --git a/tests/core/PoolConfigurator.upgradeabilty.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol similarity index 81% rename from tests/core/PoolConfigurator.upgradeabilty.t.sol rename to tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol index 2c84f556..a85fd89a 100644 --- a/tests/core/PoolConfigurator.upgradeabilty.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol @@ -3,18 +3,18 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {AToken} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {VariableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/VariableDebtToken.sol'; -import {StableDebtToken} from 'aave-v3-core/contracts/protocol/tokenization/StableDebtToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {ConfiguratorInputTypes, IPool, IPoolAddressesProvider} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {MockATokenRepayment} from 'aave-v3-core/contracts/mocks/tokens/MockATokenRepayment.sol'; -import {MockVariableDebtToken, MockStableDebtToken} from 'aave-v3-core/contracts/mocks/tokens/MockDebtTokens.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; - -import {SlotParser} from '../utils/SlotParser.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {AToken} from '../../../../src/contracts/protocol/tokenization/AToken.sol'; +import {VariableDebtToken} from '../../../../src/contracts/protocol/tokenization/VariableDebtToken.sol'; +import {StableDebtToken} from '../../../../src/contracts/protocol/tokenization/StableDebtToken.sol'; +import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ConfiguratorInputTypes, IPool, IPoolAddressesProvider} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {MockATokenRepayment} from '../../../../src/contracts/mocks/tokens/MockATokenRepayment.sol'; +import {MockVariableDebtToken, MockStableDebtToken} from '../../../../src/contracts/mocks/tokens/MockDebtTokens.sol'; +import {DataTypes} from '../../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {ReserveLogic} from '../../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; + +import {SlotParser} from '../../../utils/SlotParser.sol'; +import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { using stdStorage for StdStorage; @@ -31,6 +31,12 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { address newStrategy ); + event ReserveInterestRateDataChanged( + address indexed asset, + address indexed strategy, + bytes data + ); + event ATokenUpgraded( address indexed asset, address indexed proxy, @@ -85,6 +91,28 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { assertEq(newInterestRateStrategy, updatedInterestsRateStrategy); } + function test_setReserveInterestRateData() public { + address currentInterestRateStrategy = contracts + .protocolDataProvider + .getInterestRateStrategyAddress(tokenList.usdx); + + bytes memory newInterestRateData = _getDefaultInterestRatesStrategyData(); + + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit ReserveInterestRateDataChanged(tokenList.usdx, currentInterestRateStrategy, newInterestRateData); + + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setReserveInterestRateData( + tokenList.usdx, + _getDefaultInterestRatesStrategyData() + ); + + address newInterestRateStrategy = contracts.protocolDataProvider.getInterestRateStrategyAddress( + tokenList.usdx + ); + assertEq(currentInterestRateStrategy, newInterestRateStrategy); + } + function test_interestRateStrategy_update() public { vm.prank(carol); contracts.poolProxy.supply(tokenList.usdx, 100_000e6, carol, 0); diff --git a/tests/core/ATokenEdgeCases.t.sol b/tests/protocol/tokenization/ATokenEdgeCases.t.sol similarity index 95% rename from tests/core/ATokenEdgeCases.t.sol rename to tests/protocol/tokenization/ATokenEdgeCases.t.sol index ddce0cac..247ed6fd 100644 --- a/tests/core/ATokenEdgeCases.t.sol +++ b/tests/protocol/tokenization/ATokenEdgeCases.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {ATokenInstance} from 'aave-v3-core/instances/ATokenInstance.sol'; -import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; +import {ATokenInstance} from '../../../src/contracts/instances/ATokenInstance.sol'; +import {IAaveIncentivesController} from '../../../src/contracts/interfaces/IAaveIncentivesController.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; contract ATokenEdgeCasesTests is TestnetProcedures { ATokenInstance public aToken; diff --git a/tests/core/ATokenEvents.t.sol b/tests/protocol/tokenization/ATokenEvents.t.sol similarity index 96% rename from tests/core/ATokenEvents.t.sol rename to tests/protocol/tokenization/ATokenEvents.t.sol index 6911d439..9ba61ceb 100644 --- a/tests/core/ATokenEvents.t.sol +++ b/tests/protocol/tokenization/ATokenEvents.t.sol @@ -3,12 +3,12 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {ReserveLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import {MathUtils} from 'aave-v3-core/contracts/protocol/libraries/math/MathUtils.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {ReserveLogic} from '../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import {MathUtils} from '../../../src/contracts/protocol/libraries/math/MathUtils.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; contract ATokenEventsTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/core/ATokenModifiers.t.sol b/tests/protocol/tokenization/ATokenModifiers.t.sol similarity index 85% rename from tests/core/ATokenModifiers.t.sol rename to tests/protocol/tokenization/ATokenModifiers.t.sol index e29cb4dc..b29988bb 100644 --- a/tests/core/ATokenModifiers.t.sol +++ b/tests/protocol/tokenization/ATokenModifiers.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; contract ATokenModifiersTests is TestnetProcedures { IAToken public aToken; diff --git a/tests/core/ATokenPermit.t.sol b/tests/protocol/tokenization/ATokenPermit.t.sol similarity index 96% rename from tests/core/ATokenPermit.t.sol rename to tests/protocol/tokenization/ATokenPermit.t.sol index e7d90084..a1f708e4 100644 --- a/tests/core/ATokenPermit.t.sol +++ b/tests/protocol/tokenization/ATokenPermit.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; interface IATokenWithMetadata is IAToken { function name() external view returns (string memory); diff --git a/tests/core/ATokenRepay.t.sol b/tests/protocol/tokenization/ATokenRepay.t.sol similarity index 91% rename from tests/core/ATokenRepay.t.sol rename to tests/protocol/tokenization/ATokenRepay.t.sol index eb650f78..1aee8136 100644 --- a/tests/core/ATokenRepay.t.sol +++ b/tests/protocol/tokenization/ATokenRepay.t.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {IVariableDebtToken} from '../../../src/contracts/interfaces/IVariableDebtToken.sol'; +import {IERC20Detailed} from '../../../src/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; interface IVariableDebtTokenWithERC20 is IVariableDebtToken, IERC20Detailed {} diff --git a/tests/core/ATokenRescueTokens.sol b/tests/protocol/tokenization/ATokenRescueTokens.sol similarity index 90% rename from tests/core/ATokenRescueTokens.sol rename to tests/protocol/tokenization/ATokenRescueTokens.sol index 19592b12..870b3f9f 100644 --- a/tests/core/ATokenRescueTokens.sol +++ b/tests/protocol/tokenization/ATokenRescueTokens.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract ATokenRescueTokensTests is TestnetProcedures { IAToken public aTokenUSDX; diff --git a/tests/core/ATokenTransfers.t.sol b/tests/protocol/tokenization/ATokenTransfers.t.sol similarity index 95% rename from tests/core/ATokenTransfers.t.sol rename to tests/protocol/tokenization/ATokenTransfers.t.sol index dbf49542..1304da8b 100644 --- a/tests/core/ATokenTransfers.t.sol +++ b/tests/protocol/tokenization/ATokenTransfers.t.sol @@ -3,14 +3,14 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {IAToken, IERC20} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; -import {IVariableDebtToken} from 'aave-v3-core/contracts/interfaces/IVariableDebtToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {SupplyLogic} from 'aave-v3-core/contracts/protocol/libraries/logic/SupplyLogic.sol'; -import {MathUtils} from 'aave-v3-core/contracts/protocol/libraries/math/MathUtils.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {IAToken, IERC20} from '../../../src/contracts/interfaces/IAToken.sol'; +import {IVariableDebtToken} from '../../../src/contracts/interfaces/IVariableDebtToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {SupplyLogic} from '../../../src/contracts/protocol/libraries/logic/SupplyLogic.sol'; +import {MathUtils} from '../../../src/contracts/protocol/libraries/math/MathUtils.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract ATokenTransferTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/core/ScaledBalanceTokenBase.t.sol b/tests/protocol/tokenization/ScaledBalanceTokenBase.t.sol similarity index 94% rename from tests/core/ScaledBalanceTokenBase.t.sol rename to tests/protocol/tokenization/ScaledBalanceTokenBase.t.sol index aab5cfc5..cff2dd15 100644 --- a/tests/core/ScaledBalanceTokenBase.t.sol +++ b/tests/protocol/tokenization/ScaledBalanceTokenBase.t.sol @@ -1,10 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {MockScaledToken} from 'aave-v3-core/contracts/mocks/tokens/MockScaledToken.sol'; - -import '../utils/TestnetProcedures.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {MockScaledToken} from '../../../src/contracts/mocks/tokens/MockScaledToken.sol'; +import '../../utils/TestnetProcedures.sol'; contract ScaledBalanceTokenBaseEdgeTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/core/StableDebtToken.t.sol b/tests/protocol/tokenization/StableDebtToken.t.sol similarity index 96% rename from tests/core/StableDebtToken.t.sol rename to tests/protocol/tokenization/StableDebtToken.t.sol index 2394d4b6..06aa317c 100644 --- a/tests/core/StableDebtToken.t.sol +++ b/tests/protocol/tokenization/StableDebtToken.t.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {StableDebtTokenHarness as StableDebtTokenInstance} from '../harness/StableDebtToken.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {PoolConfigurator, ConfiguratorInputTypes, IPool} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {StableDebtTokenHarness as StableDebtTokenInstance} from '../../harness/StableDebtToken.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {IAaveIncentivesController} from '../../../src/contracts/interfaces/IAaveIncentivesController.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {PoolConfigurator, ConfiguratorInputTypes, IPool} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract StableDebtTokenEventsTests is TestnetProcedures { StableDebtTokenInstance public stableDebtToken; diff --git a/tests/core/VariableDebtToken.t.sol b/tests/protocol/tokenization/VariableDebtToken.t.sol similarity index 96% rename from tests/core/VariableDebtToken.t.sol rename to tests/protocol/tokenization/VariableDebtToken.t.sol index 9435b543..0c13902e 100644 --- a/tests/core/VariableDebtToken.t.sol +++ b/tests/protocol/tokenization/VariableDebtToken.t.sol @@ -3,15 +3,15 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {VariableDebtTokenHarness as VariableDebtTokenInstance} from '../harness/VariableDebtToken.sol'; -import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol'; -import {Errors} from 'aave-v3-core/contracts/protocol/libraries/helpers/Errors.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {ReserveLogic, DataTypes} from 'aave-v3-core/contracts/protocol/libraries/logic/ReserveLogic.sol'; -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; -import {ConfiguratorInputTypes, IPool} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {EIP712SigUtils} from '../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; +import {VariableDebtTokenHarness as VariableDebtTokenInstance} from '../../harness/VariableDebtToken.sol'; +import {IAaveIncentivesController} from '../../../src/contracts/interfaces/IAaveIncentivesController.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {ReserveLogic, DataTypes} from '../../../src/contracts/protocol/libraries/logic/ReserveLogic.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {ConfiguratorInputTypes, IPool} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; contract VariableDebtTokenEventsTests is TestnetProcedures { using WadRayMath for uint256; diff --git a/tests/periphery/EmissionsManager.t.sol b/tests/rewards/EmissionsManager.t.sol similarity index 76% rename from tests/periphery/EmissionsManager.t.sol rename to tests/rewards/EmissionsManager.t.sol index 2ebc7afd..9c157af1 100644 --- a/tests/periphery/EmissionsManager.t.sol +++ b/tests/rewards/EmissionsManager.t.sol @@ -1,16 +1,15 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import 'forge-std/Test.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {RewardsController} from 'aave-v3-periphery/contracts/rewards/RewardsController.sol'; -import {EmissionManager} from 'aave-v3-periphery/contracts/rewards/EmissionManager.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {ITransferStrategyBase} from 'aave-v3-periphery/contracts/rewards/interfaces/ITransferStrategyBase.sol'; -import {IEACAggregatorProxy} from 'aave-v3-periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol'; -import {RewardsDataTypes} from 'aave-v3-periphery/contracts/rewards/libraries/RewardsDataTypes.sol'; -import {PullRewardsTransferStrategy} from 'aave-v3-periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; +import {MockAggregator} from '../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {RewardsController} from '../../src/contracts/rewards/RewardsController.sol'; +import {EmissionManager} from '../../src/contracts/rewards/EmissionManager.sol'; +import {DataTypes} from '../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {IPool} from '../../src/contracts/interfaces/IPool.sol'; +import {ITransferStrategyBase} from '../../src/contracts/rewards/interfaces/ITransferStrategyBase.sol'; +import {IEACAggregatorProxy} from '../../src/contracts/helpers/interfaces/IEACAggregatorProxy.sol'; +import {RewardsDataTypes} from '../../src/contracts/rewards/libraries/RewardsDataTypes.sol'; +import {PullRewardsTransferStrategy} from '../../src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; contract EmissionManagerTest is TestnetProcedures { diff --git a/tests/periphery/RewardsController.t.sol b/tests/rewards/RewardsController.t.sol similarity index 94% rename from tests/periphery/RewardsController.t.sol rename to tests/rewards/RewardsController.t.sol index 38dae8cd..26d206ef 100644 --- a/tests/periphery/RewardsController.t.sol +++ b/tests/rewards/RewardsController.t.sol @@ -1,16 +1,15 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import 'forge-std/Test.sol'; -import {MockAggregator} from 'aave-v3-core/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {RewardsController, RewardsDistributor} from 'aave-v3-periphery/contracts/rewards/RewardsController.sol'; -import {EmissionManager} from 'aave-v3-periphery/contracts/rewards/EmissionManager.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {IAToken, IERC20} from 'aave-v3-core/contracts/protocol/tokenization/AToken.sol'; -import {ITransferStrategyBase} from 'aave-v3-periphery/contracts/rewards/interfaces/ITransferStrategyBase.sol'; -import {IEACAggregatorProxy} from 'aave-v3-periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol'; -import {RewardsDataTypes} from 'aave-v3-periphery/contracts/rewards/libraries/RewardsDataTypes.sol'; -import {PullRewardsTransferStrategy} from 'aave-v3-periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; +import {MockAggregator} from '../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; +import {RewardsController, RewardsDistributor} from '../../src/contracts/rewards/RewardsController.sol'; +import {EmissionManager} from '../../src/contracts/rewards/EmissionManager.sol'; +import {DataTypes} from '../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {IAToken, IERC20} from '../../src/contracts/protocol/tokenization/AToken.sol'; +import {ITransferStrategyBase} from '../../src/contracts/rewards/interfaces/ITransferStrategyBase.sol'; +import {IEACAggregatorProxy} from '../../src/contracts/helpers/interfaces/IEACAggregatorProxy.sol'; +import {RewardsDataTypes} from '../../src/contracts/rewards/libraries/RewardsDataTypes.sol'; +import {PullRewardsTransferStrategy} from '../../src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; contract RewardsControllerTest is TestnetProcedures { diff --git a/tests/periphery/StakedTokenTransferStrategy.t.sol b/tests/rewards/StakedTokenTransferStrategy.t.sol similarity index 94% rename from tests/periphery/StakedTokenTransferStrategy.t.sol rename to tests/rewards/StakedTokenTransferStrategy.t.sol index cbb78767..1c3b2775 100644 --- a/tests/periphery/StakedTokenTransferStrategy.t.sol +++ b/tests/rewards/StakedTokenTransferStrategy.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {StakedTokenTransferStrategy, IERC20, IStakedToken} from 'aave-v3-periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol'; -import {StakeMock} from './mocks/StakeMock.sol'; +import {StakedTokenTransferStrategy, IERC20, IStakedToken} from '../../src/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol'; +import {StakeMock} from '../mocks/StakeMock.sol'; import {TestnetProcedures} from '../utils/TestnetProcedures.sol'; contract StakedTokenTransferStrategyTest is TestnetProcedures { diff --git a/tests/utils/BatchTestProcedures.sol b/tests/utils/BatchTestProcedures.sol index 00b9efa3..d0418972 100644 --- a/tests/utils/BatchTestProcedures.sol +++ b/tests/utils/BatchTestProcedures.sol @@ -6,17 +6,18 @@ import '../../src/deployments/interfaces/IMarketReportTypes.sol'; import {DeployUtils} from '../../src/deployments/contracts/utilities/DeployUtils.sol'; import {AaveV3GettersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol'; import {AaveV3GettersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol'; +import {AaveV3TokensBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol'; import {AaveV3SetupBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; import {FfiUtils} from '../../src/deployments/contracts/utilities/FfiUtils.sol'; import {DefaultMarketInput} from '../../src/deployments/inputs/DefaultMarketInput.sol'; import {AaveV3BatchOrchestration} from '../../src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {ACLManager} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {ACLManager} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import '../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import '../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import '../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import '../../src/contracts/helpers/AaveProtocolDataProvider.sol'; import {MarketReportUtils} from '../../src/deployments/contracts/utilities/MarketReportUtils.sol'; struct TestVars { @@ -62,7 +63,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput AaveV3GettersBatchOne.GettersReportBatchOne memory gettersReport1, PoolReport memory poolReport, PeripheryReport memory peripheryReport, - ParaswapReport memory paraswapReport, + MiscReport memory miscReport, AaveV3SetupBatch setupContract ) { @@ -91,11 +92,11 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput address(setupContract) ); - paraswapReport = AaveV3BatchOrchestration._deployParaswapAdapters( - roles, - config, + miscReport = AaveV3BatchOrchestration._deployMisc( + flags.l2, initialReport.poolAddressesProvider, - peripheryReport.treasury + config.l2SequencerUptimeFeed, + config.l2PriceOracleSentinelGracePeriod ); return ( @@ -103,7 +104,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput gettersReport1, poolReport, peripheryReport, - paraswapReport, + miscReport, setupContract ); } @@ -122,6 +123,8 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput PoolReport memory poolReport, SetupReport memory setupReport, PeripheryReport memory peripheryReport, + MiscReport memory miscReport, + AaveV3TokensBatch.TokensReport memory tokensReport, ParaswapReport memory paraswapReport, AaveV3SetupBatch setupContract ) @@ -131,7 +134,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput gettersReport1, poolReport, peripheryReport, - paraswapReport, + miscReport, setupContract ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); @@ -143,7 +146,15 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput poolReport.poolConfiguratorImplementation, gettersReport1.protocolDataProvider, peripheryReport.aaveOracle, - peripheryReport.rewardsControllerImplementation + peripheryReport.rewardsControllerImplementation, + miscReport.priceOracleSentinel + ); + + paraswapReport = AaveV3BatchOrchestration._deployParaswapAdapters( + roles, + config, + initialReport.poolAddressesProvider, + peripheryReport.treasury ); gettersReport2 = AaveV3BatchOrchestration._deployGettersBatch2( @@ -153,6 +164,8 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput flags.l2 ); + tokensReport = AaveV3BatchOrchestration._deployTokens(setupReport.poolProxy); + return ( initialReport, gettersReport1, @@ -160,6 +173,8 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput poolReport, setupReport, peripheryReport, + miscReport, + tokensReport, paraswapReport, setupContract ); @@ -175,8 +190,8 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput assertTrue(r.protocolDataProvider != address(0), 'report.protocolDataProvider'); assertTrue(r.aaveOracle != address(0), 'report.aaveOracle'); assertTrue( - r.defaultInterestRateStrategyV2 != address(0), - 'report.defaultInterestRateStrategyV2' + r.defaultInterestRateStrategy != address(0), + 'report.defaultInterestRateStrategy' ); assertTrue(r.aclManager != address(0), 'report.aclManager'); assertTrue(r.treasury != address(0), 'report.treasury'); @@ -193,6 +208,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput if (flags.l2) { assertTrue(r.l2Encoder != address(0), 'report.l2Encoder'); + assertTrue(r.priceOracleSentinel != address(0), 'report.priceOracleSentinel'); } assertTrue(r.aToken != address(0), 'report.aToken'); @@ -204,6 +220,11 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput 'r.rewardsControllerImplementation' ); assertTrue(r.rewardsControllerProxy != address(0), 'report.rewardsControllerProxy'); + assertTrue(r.configEngine != address(0), 'report.configEngine'); + assertTrue(r.staticATokenFactoryImplementation != address(0), 'report.staticATokenFactoryImplementation'); + assertTrue(r.staticATokenFactoryProxy != address(0), 'report.staticATokenFactoryProxy'); + assertTrue(r.staticATokenImplementation != address(0), 'report.staticATokenImplementation'); + assertTrue(r.transparentProxyFactory != address(0), 'report.transparentProxyFactory'); } function deployAaveV3Testnet( @@ -215,6 +236,12 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput ) internal returns (MarketReport memory testReport) { detectFoundryLibrariesAndDelete(); + // Etch the create2 factory + vm.etch( + 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, + hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' + ); + vm.startPrank(deployer); MarketReport memory deployReport = AaveV3BatchOrchestration.deployAaveV3( deployer, @@ -266,7 +293,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput t.variableDebtSymbol = _concatStr('varDebtMISC ', x); t.stableDebtName = _concatStr('Stable Debt Misc ', x); t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); - t.rateStrategy = r.defaultInterestRateStrategyV2; + t.rateStrategy = r.defaultInterestRateStrategy; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ optimalUsageRatio: 80_00, diff --git a/tests/utils/ConfigEngineDeployer.sol b/tests/utils/ConfigEngineDeployer.sol deleted file mode 100644 index 1c25da03..00000000 --- a/tests/utils/ConfigEngineDeployer.sol +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../src/deployments/interfaces/IMarketReportTypes.sol'; -import {Vm} from 'forge-std/Vm.sol'; -import {Create2Utils} from '../../src/deployments/contracts/utilities/Create2Utils.sol'; -import {AaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol'; -import {IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol'; -import {IPoolAddressesProvider} from '../../src/core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPool} from '../../src/core/contracts/interfaces/IPool.sol'; -import {IPoolConfigurator} from '../../src/core/contracts/interfaces/IPoolConfigurator.sol'; -import {IAaveOracle} from '../../src/core/contracts/interfaces/IAaveOracle.sol'; -import {CapsEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/CapsEngine.sol'; -import {BorrowEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/BorrowEngine.sol'; -import {CollateralEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/CollateralEngine.sol'; -import {RateEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/RateEngine.sol'; -import {PriceFeedEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/PriceFeedEngine.sol'; -import {EModeEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/EModeEngine.sol'; -import {ListingEngine} from 'aave-v3-periphery/contracts/v3-config-engine/libraries/ListingEngine.sol'; - -library ConfigEngineDeployer { - function deployEngine(Vm vm, MarketReport memory report) internal returns (address) { - // Etch the create2 factory in the local env - vm.etch( - 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, - hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' - ); - IAaveV3ConfigEngine.EngineLibraries memory engineLibraries = IAaveV3ConfigEngine - .EngineLibraries({ - listingEngine: Create2Utils._create2Deploy('v1', type(ListingEngine).creationCode), - eModeEngine: Create2Utils._create2Deploy('v1', type(EModeEngine).creationCode), - borrowEngine: Create2Utils._create2Deploy('v1', type(BorrowEngine).creationCode), - collateralEngine: Create2Utils._create2Deploy('v1', type(CollateralEngine).creationCode), - priceFeedEngine: Create2Utils._create2Deploy('v1', type(PriceFeedEngine).creationCode), - rateEngine: Create2Utils._create2Deploy('v1', type(RateEngine).creationCode), - capsEngine: Create2Utils._create2Deploy('v1', type(CapsEngine).creationCode) - }); - - IAaveV3ConfigEngine.EngineConstants memory engineConstants = IAaveV3ConfigEngine - .EngineConstants({ - pool: IPool(report.poolProxy), - poolConfigurator: IPoolConfigurator(report.poolConfiguratorProxy), - defaultInterestRateStrategy: report.defaultInterestRateStrategyV2, - oracle: IAaveOracle(report.aaveOracle), - rewardsController: report.rewardsControllerProxy, - collector: report.treasury - }); - - return - address( - new AaveV3ConfigEngine( - report.aToken, - report.variableDebtToken, - report.stableDebtToken, - engineConstants, - engineLibraries - ) - ); - } -} diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 8f4aabad..616442ab 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.7.5 <0.9.0; -import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; -import {IDefaultInterestRateStrategyV2} from 'aave-v3-core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; -import {IPoolDataProvider} from 'aave-v3-core/contracts/interfaces/IPoolDataProvider.sol'; -import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; -import {IAaveOracle} from 'aave-v3-core/contracts/interfaces/IAaveOracle.sol'; -import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; -import {IPoolConfigurator} from 'aave-v3-core/contracts/interfaces/IPoolConfigurator.sol'; +import {IERC20Detailed} from '../../src/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {IDefaultInterestRateStrategyV2} from '../../src/contracts/interfaces/IDefaultInterestRateStrategyV2.sol'; +import {ReserveConfiguration} from '../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPoolDataProvider} from '../../src/contracts/interfaces/IPoolDataProvider.sol'; +import {IPool} from '../../src/contracts/interfaces/IPool.sol'; +import {IAaveOracle} from '../../src/contracts/interfaces/IAaveOracle.sol'; +import {DataTypes} from '../../src/contracts/protocol/libraries/types/DataTypes.sol'; +import {IPoolConfigurator} from '../../src/contracts/interfaces/IPoolConfigurator.sol'; import {ProxyHelpers} from './ProxyHelpers.sol'; import {DiffUtils} from './DiffUtils.sol'; @@ -110,18 +110,6 @@ struct LocalVars { ReserveConfig[] configs; } -struct InterestStrategyValues { - address addressesProvider; - uint256 optimalUsageRatio; - uint256 optimalStableToTotalDebtRatio; - uint256 baseStableBorrowRate; - uint256 stableRateSlope1; - uint256 stableRateSlope2; - uint256 baseVariableBorrowRate; - uint256 variableRateSlope1; - uint256 variableRateSlope2; -} - /** * only applicable to harmony at this point */ @@ -615,7 +603,7 @@ contract ProtocolV3TestBase is DiffUtils { address reserve, address interestRateStrategyAddress, address expectedStrategy, - InterestStrategyValues memory expectedStrategyValues + IDefaultInterestRateStrategyV2.InterestRateDataRay memory expectedStrategyValues ) internal view { IDefaultInterestRateStrategyV2 strategy = IDefaultInterestRateStrategyV2( interestRateStrategyAddress @@ -630,10 +618,6 @@ contract ProtocolV3TestBase is DiffUtils { strategy.getOptimalUsageRatio(reserve) == expectedStrategyValues.optimalUsageRatio, '_validateInterestRateStrategy() : INVALID_OPTIMAL_RATIO' ); - require( - address(strategy.ADDRESSES_PROVIDER()) == expectedStrategyValues.addressesProvider, - '_validateInterestRateStrategy() : INVALID_ADDRESSES_PROVIDER' - ); require( strategy.getBaseVariableBorrowRate(reserve) == expectedStrategyValues.baseVariableBorrowRate, '_validateInterestRateStrategy() : INVALID_BASE_VARIABLE_BORROW' diff --git a/tests/utils/SigUtils.sol b/tests/utils/SigUtils.sol new file mode 100644 index 00000000..72aed63c --- /dev/null +++ b/tests/utils/SigUtils.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.10; + +import {IStaticATokenLM} from '../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; + +library SigUtils { + struct Permit { + address owner; + address spender; + uint256 value; + uint256 nonce; + uint256 deadline; + } + + struct WithdrawPermit { + address owner; + address spender; + uint256 staticAmount; + uint256 dynamicAmount; + bool toUnderlying; + uint256 nonce; + uint256 deadline; + } + + struct DepositPermit { + address owner; + address spender; + uint256 value; + uint16 referralCode; + bool fromUnderlying; + uint256 nonce; + uint256 deadline; + IStaticATokenLM.PermitParams permit; + } + + // computes the hash of a permit + function getStructHash(Permit memory _permit, bytes32 typehash) internal pure returns (bytes32) { + return + keccak256( + abi.encode( + typehash, + _permit.owner, + _permit.spender, + _permit.value, + _permit.nonce, + _permit.deadline + ) + ); + } + + function getWithdrawHash( + WithdrawPermit memory permit, + bytes32 typehash + ) internal pure returns (bytes32) { + return + keccak256( + abi.encode( + typehash, + permit.owner, + permit.spender, + permit.staticAmount, + permit.dynamicAmount, + permit.toUnderlying, + permit.nonce, + permit.deadline + ) + ); + } + + function getDepositHash( + DepositPermit memory permit, + bytes32 typehash + ) internal pure returns (bytes32) { + return + keccak256( + abi.encode( + typehash, + permit.owner, + permit.spender, + permit.value, + permit.referralCode, + permit.fromUnderlying, + permit.nonce, + permit.deadline, + permit.permit + ) + ); + } + + // computes the hash of the fully encoded EIP-712 message for the domain, which can be used to recover the signer + function getTypedDataHash( + Permit memory permit, + bytes32 typehash, + bytes32 domainSeparator + ) public pure returns (bytes32) { + return + keccak256(abi.encodePacked('\x19\x01', domainSeparator, getStructHash(permit, typehash))); + } + + function getTypedWithdrawHash( + WithdrawPermit memory permit, + bytes32 typehash, + bytes32 domainSeparator + ) public pure returns (bytes32) { + return + keccak256(abi.encodePacked('\x19\x01', domainSeparator, getWithdrawHash(permit, typehash))); + } + + function getTypedDepositHash( + DepositPermit memory permit, + bytes32 typehash, + bytes32 domainSeparator + ) public pure returns (bytes32) { + return + keccak256(abi.encodePacked('\x19\x01', domainSeparator, getDepositHash(permit, typehash))); + } +} diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 5d6f39c2..35669294 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -4,23 +4,22 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import '../../src/deployments/interfaces/IMarketReportTypes.sol'; -import {ConfigEngineDeployer} from './ConfigEngineDeployer.sol'; import {DeployUtils} from '../../src/deployments/contracts/utilities/DeployUtils.sol'; import {FfiUtils} from '../../src/deployments/contracts/utilities/FfiUtils.sol'; import {DefaultMarketInput} from '../../src/deployments/inputs/DefaultMarketInput.sol'; import {AaveV3BatchOrchestration} from '../../src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol'; -import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; import {AaveV3TestListing} from '../mocks/AaveV3TestListing.sol'; -import {ACLManager, Errors} from 'aave-v3-core/contracts/protocol/configuration/ACLManager.sol'; -import {WETH9} from 'aave-v3-core/contracts/dependencies/weth/WETH9.sol'; -import {TestnetERC20} from 'aave-v3-periphery/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {PoolConfigurator} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; -import {DefaultReserveInterestRateStrategyV2} from 'aave-v3-core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol'; -import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; -import {AaveProtocolDataProvider} from 'aave-v3-core/contracts/misc/AaveProtocolDataProvider.sol'; +import {ACLManager, Errors} from '../../src/contracts/protocol/configuration/ACLManager.sol'; +import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; +import {TestnetERC20} from '../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; +import {PoolConfigurator} from '../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {DefaultReserveInterestRateStrategyV2} from '../../src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; +import {ReserveConfiguration} from '../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; +import {PercentageMath} from '../../src/contracts/protocol/libraries/math/PercentageMath.sol'; +import {AaveProtocolDataProvider} from '../../src/contracts/helpers/AaveProtocolDataProvider.sol'; import {MarketReportUtils} from '../../src/deployments/contracts/utilities/MarketReportUtils.sol'; -import {AaveV3ConfigEngine, IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/AaveV3ConfigEngine.sol'; +import {AaveV3ConfigEngine, IAaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; struct TestVars { string aTokenName; @@ -111,9 +110,14 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { MarketReport memory deployedContracts ) = _getMarketInput(poolAdmin); roleList = roles; - flags.l2 = l2; + // Etch the create2 factory + vm.etch( + 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, + hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' + ); + (report, tokenList) = deployAaveV3TestnetAssets( poolAdmin, roles, @@ -218,10 +222,8 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { MarketReport memory r = deployAaveV3Testnet(deployer, roles, config, flags, deployedContracts); - address engine = ConfigEngineDeployer.deployEngine(vm, r); - AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(engine), + IAaveV3ConfigEngine(r.configEngine), roles.poolAdmin, assetsList.weth, r @@ -298,7 +300,7 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { t.variableDebtSymbol = _concatStr('varDebtMISC ', x); t.stableDebtName = _concatStr('Stable Debt Misc ', x); t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); - t.rateStrategy = r.defaultInterestRateStrategyV2; + t.rateStrategy = r.defaultInterestRateStrategy; t.interestRateData = abi.encode( IDefaultInterestRateStrategyV2.InterestRateData({ optimalUsageRatio: 80_00, From b77eb7117c1cb9998aa35b037b1652f4aefbe84d Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 29 Apr 2024 14:01:50 +0530 Subject: [PATCH 14/88] fix: lint --- .../misc/DeployAaveV3MarketBatchedBase.sol | 3 +- .../extensions/v3-config-engine/README.md | 3 +- .../procedures/AaveV3HelpersProcedureOne.sol | 8 +- .../procedures/AaveV3HelpersProcedureTwo.sol | 17 +- .../contracts/utilities/MetadataReporter.sol | 18 +- .../batches/AaveV3HelpersBatchTwo.sol | 12 +- tests/deployments/AaveV3BatchTests.t.sol | 8 +- tests/deployments/DeploymentsGasLimits.t.sol | 8 +- .../static-a-token/StataOracle.t.sol | 5 +- .../static-a-token/StaticATokenLM.t.sol | 12 +- .../StaticATokenMetaTransactions.t.sol | 5 +- .../static-a-token/StaticATokenNoLM.t.sol | 1 - tests/extensions/static-a-token/TestBase.sol | 11 +- .../AaveV3ConfigEngineTest.t.sol | 194 ++++++++++-------- .../mocks/AaveV3MockAssetEModeUpdate.sol | 5 +- .../mocks/AaveV3MockListing.sol | 6 +- .../mocks/AaveV3MockListingCustom.sol | 9 +- .../mocks/AaveV3MockPriceFeedUpdate.sol | 11 +- .../PoolConfigurator.reserveRiskConfig.t.sol | 4 +- .../PoolConfigurator.upgradeabilty.t.sol | 12 +- tests/utils/BatchTestProcedures.sol | 19 +- 21 files changed, 192 insertions(+), 179 deletions(-) diff --git a/scripts/misc/DeployAaveV3MarketBatchedBase.sol b/scripts/misc/DeployAaveV3MarketBatchedBase.sol index 961b0f38..25af8793 100644 --- a/scripts/misc/DeployAaveV3MarketBatchedBase.sol +++ b/scripts/misc/DeployAaveV3MarketBatchedBase.sol @@ -46,7 +46,8 @@ abstract contract DeployAaveV3MarketBatchedBase is DeployUtils, MarketInput, Scr } if ( (flags.l2 && - (config.l2SequencerUptimeFeed == address(0) || config.l2PriceOracleSentinelGracePeriod == 0)) + (config.l2SequencerUptimeFeed == address(0) || + config.l2PriceOracleSentinelGracePeriod == 0)) ) { console.log( 'Warning: L2 Sequencer uptime feed wont be set at deployment due missing config.l2SequencerUptimeFeed config.l2PriceOracleSentinelGracePeriod' diff --git a/src/contracts/extensions/v3-config-engine/README.md b/src/contracts/extensions/v3-config-engine/README.md index 7308dde5..62480d8f 100644 --- a/src/contracts/extensions/v3-config-engine/README.md +++ b/src/contracts/extensions/v3-config-engine/README.md @@ -35,7 +35,7 @@ Change eMode category of a particular asset? Same as previous, just define the u ### Internal aspects to consider - Frequently, at the same time that you want to do an update of parameters or listing, you also want to do something extra before or after. -The `Base Aave v3 Payload` defines `_preExecute()` and `_postExecute()` hook functions, that you can redefine on your payload and will the execute before and after all configs changes/listings you define. + The `Base Aave v3 Payload` defines `_preExecute()` and `_postExecute()` hook functions, that you can redefine on your payload and will the execute before and after all configs changes/listings you define. - The payload also allow you to group changes of parameters and listings, just by defining at the same time the aforementioned `newListings()`, `capsUpdate()` and/or `collateralsUpdates()` and so on. For reference, the execution ordering is the following: 1. `_preExecute()` @@ -51,6 +51,7 @@ The `Base Aave v3 Payload` defines `_preExecute()` and `_postExecute()` hook fun 11. `_postExecute()` ## Links to examples + - [Simple mock listing on Aave v3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockListing.sol) - [Simple custom mock listing on Aave V3 with custom token impl](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockListingCustom.sol) - [Mock e-mode category update on Aave V3](../../../../tests/helpers/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol) diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol index 952b02af..7ff449f2 100644 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol @@ -50,13 +50,7 @@ contract AaveV3HelpersProcedureOne { configEngineReport.capsEngine = engineLibraries.capsEngine; configEngineReport.configEngine = address( - new AaveV3ConfigEngine( - aTokenImpl, - vTokenImpl, - sTokenImpl, - engineConstants, - engineLibraries - ) + new AaveV3ConfigEngine(aTokenImpl, vTokenImpl, sTokenImpl, engineConstants, engineLibraries) ); return configEngineReport; } diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol index f455b2e9..9a92839a 100644 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol @@ -17,10 +17,7 @@ contract AaveV3HelpersProcedureTwo is IErrors { staticATokenReport.transparentProxyFactory = address(new TransparentProxyFactory()); staticATokenReport.staticATokenImplementation = address( - new StaticATokenLM( - IPool(pool), - IRewardsController(rewardsController) - ) + new StaticATokenLM(IPool(pool), IRewardsController(rewardsController)) ); staticATokenReport.staticATokenFactoryImplementation = address( new StaticATokenFactory( @@ -31,11 +28,13 @@ contract AaveV3HelpersProcedureTwo is IErrors { ) ); - staticATokenReport.staticATokenFactoryProxy = ITransparentProxyFactory(staticATokenReport.transparentProxyFactory).create( - staticATokenReport.staticATokenFactoryImplementation, - proxyAdmin, - abi.encodeWithSelector(StaticATokenFactory.initialize.selector) - ); + staticATokenReport.staticATokenFactoryProxy = ITransparentProxyFactory( + staticATokenReport.transparentProxyFactory + ).create( + staticATokenReport.staticATokenFactoryImplementation, + proxyAdmin, + abi.encodeWithSelector(StaticATokenFactory.initialize.selector) + ); return staticATokenReport; } diff --git a/src/deployments/contracts/utilities/MetadataReporter.sol b/src/deployments/contracts/utilities/MetadataReporter.sol index 7fc3a262..27b5085c 100644 --- a/src/deployments/contracts/utilities/MetadataReporter.sol +++ b/src/deployments/contracts/utilities/MetadataReporter.sol @@ -69,12 +69,24 @@ contract MetadataReporter is IMetadataReporter { report.paraSwapWithdrawSwapAdapter ); vm.serializeAddress(jsonReport, 'aaveParaSwapFeeClaimer', report.aaveParaSwapFeeClaimer); - vm.serializeAddress(jsonReport, 'defaultInterestRateStrategy', report.defaultInterestRateStrategy); + vm.serializeAddress( + jsonReport, + 'defaultInterestRateStrategy', + report.defaultInterestRateStrategy + ); vm.serializeAddress(jsonReport, 'priceOracleSentinel', report.priceOracleSentinel); vm.serializeAddress(jsonReport, 'configEngine', report.configEngine); - vm.serializeAddress(jsonReport, 'staticATokenFactoryImplementation', report.staticATokenFactoryImplementation); + vm.serializeAddress( + jsonReport, + 'staticATokenFactoryImplementation', + report.staticATokenFactoryImplementation + ); vm.serializeAddress(jsonReport, 'staticATokenFactoryProxy', report.staticATokenFactoryProxy); - vm.serializeAddress(jsonReport, 'staticATokenImplementation', report.staticATokenImplementation); + vm.serializeAddress( + jsonReport, + 'staticATokenImplementation', + report.staticATokenImplementation + ); vm.serializeAddress(jsonReport, 'transparentProxyFactory', report.transparentProxyFactory); string memory output = vm.serializeAddress( diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol index b145b257..1db9f7b9 100644 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol @@ -7,16 +7,8 @@ import '../../../interfaces/IMarketReportTypes.sol'; contract AaveV3HelpersBatchTwo is AaveV3HelpersProcedureTwo { StaticATokenReport internal _report; - constructor( - address pool, - address rewardsController, - address proxyAdmin - ) { - _report = _deployStaticAToken( - pool, - rewardsController, - proxyAdmin - ); + constructor(address pool, address rewardsController, address proxyAdmin) { + _report = _deployStaticAToken(pool, rewardsController, proxyAdmin); } function staticATokenReport() external view returns (StaticATokenReport memory) { diff --git a/tests/deployments/AaveV3BatchTests.t.sol b/tests/deployments/AaveV3BatchTests.t.sol index 0727aac6..99a41eac 100644 --- a/tests/deployments/AaveV3BatchTests.t.sol +++ b/tests/deployments/AaveV3BatchTests.t.sol @@ -96,12 +96,8 @@ contract AaveV3BatchTests is BatchTestProcedures { miscReport, tokensReport, paraswapReportOne, - ) = deployAndSetup( - roles, - config, - flags, - deployedContracts - ); + + ) = deployAndSetup(roles, config, flags, deployedContracts); } function testAaveV3FullBatchOrchestration() public { diff --git a/tests/deployments/DeploymentsGasLimits.t.sol b/tests/deployments/DeploymentsGasLimits.t.sol index 6f33f88d..fd42791e 100644 --- a/tests/deployments/DeploymentsGasLimits.t.sol +++ b/tests/deployments/DeploymentsGasLimits.t.sol @@ -93,12 +93,8 @@ contract DeploymentsGasLimits is BatchTestProcedures { miscReport, tokensReport, paraswapReportOne, - ) = deployAndSetup( - roles, - config, - flags, - deployedContracts - ); + + ) = deployAndSetup(roles, config, flags, deployedContracts); } function test0AaveV3SetupDeployment() public { diff --git a/tests/extensions/static-a-token/StataOracle.t.sol b/tests/extensions/static-a-token/StataOracle.t.sol index bef3620f..5e6e4efd 100644 --- a/tests/extensions/static-a-token/StataOracle.t.sol +++ b/tests/extensions/static-a-token/StataOracle.t.sol @@ -35,7 +35,10 @@ contract StataOracleTest is BaseTest { uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(underlying); assertGe(stataPrice, underlyingPrice); - assertEq(stataPrice, (underlyingPrice * StaticATokenLM(staticAToken).convertToAssets(1e18)) / 1e18); + assertEq( + stataPrice, + (underlyingPrice * StaticATokenLM(staticAToken).convertToAssets(1e18)) / 1e18 + ); } } diff --git a/tests/extensions/static-a-token/StaticATokenLM.t.sol b/tests/extensions/static-a-token/StaticATokenLM.t.sol index 6fcdd428..5c84fe55 100644 --- a/tests/extensions/static-a-token/StaticATokenLM.t.sol +++ b/tests/extensions/static-a-token/StaticATokenLM.t.sol @@ -464,13 +464,7 @@ contract StaticATokenLMTest is BaseTest { POOL.deposit(address(wbtc), 2_000e8, borrowUser, 0); // borrow all available - POOL.borrow( - UNDERLYING, - underlyingBalanceBefore - (maxRedeemBefore / 2), - 2, - 0, - borrowUser - ); + POOL.borrow(UNDERLYING, underlyingBalanceBefore - (maxRedeemBefore / 2), 2, 0, borrowUser); uint256 maxRedeemAfter = staticATokenLM.previewRedeem(staticATokenLM.maxRedeem(address(user))); assertApproxEqAbs(maxRedeemAfter, (maxRedeemBefore / 2), 1); @@ -581,7 +575,9 @@ contract StaticATokenLMTest is BaseTest { TestnetERC20(REWARD_TOKEN).mint(EMISSION_ADMIN, 10_000 ether); vm.stopPrank(); - RewardsDataTypes.RewardsConfigInput[] memory config = new RewardsDataTypes.RewardsConfigInput[](1); + RewardsDataTypes.RewardsConfigInput[] memory config = new RewardsDataTypes.RewardsConfigInput[]( + 1 + ); config[0] = RewardsDataTypes.RewardsConfigInput( 0.00385 ether, 10_000 ether, diff --git a/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol index 748986bb..4cc133e7 100644 --- a/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol +++ b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol @@ -7,12 +7,13 @@ import {SigUtils} from '../../utils/SigUtils.sol'; import {BaseTest, IAToken, IRewardsController, DataTypes} from './TestBase.sol'; contract StaticATokenMetaTransactions is BaseTest { - function setUp() public override { super.setUp(); // Testing meta transactions with USDX as WETH does not support permit - DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData(address(usdx)); + DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( + address(usdx) + ); UNDERLYING = address(usdx); A_TOKEN = reserveDataUSDX.aTokenAddress; diff --git a/tests/extensions/static-a-token/StaticATokenNoLM.t.sol b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol index f45d197b..84ddbd33 100644 --- a/tests/extensions/static-a-token/StaticATokenNoLM.t.sol +++ b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol @@ -8,7 +8,6 @@ import {BaseTest, IERC20} from './TestBase.sol'; * This is a slightly different assumption than a pool that doesn't have LM enabled any more as incentivesController.rewardTokens() will have length=0 */ contract StaticATokenNoLMTest is BaseTest { - function setUp() public override { super.setUp(); diff --git a/tests/extensions/static-a-token/TestBase.sol b/tests/extensions/static-a-token/TestBase.sol index 7fb215b7..d4b488fa 100644 --- a/tests/extensions/static-a-token/TestBase.sol +++ b/tests/extensions/static-a-token/TestBase.sol @@ -41,15 +41,12 @@ abstract contract BaseTest is TestnetProcedures { spender = vm.addr(spenderPrivateKey); initTestEnvironment(); - DataTypes.ReserveDataLegacy memory reserveDataWETH = contracts.poolProxy.getReserveData(tokenList.weth); + DataTypes.ReserveDataLegacy memory reserveDataWETH = contracts.poolProxy.getReserveData( + tokenList.weth + ); UNDERLYING = address(weth); - REWARD_TOKEN = address(new TestnetERC20( - 'LM Reward ERC20', - 'RWD', - 18, - OWNER - )); + REWARD_TOKEN = address(new TestnetERC20('LM Reward ERC20', 'RWD', 18, OWNER)); A_TOKEN = reserveDataWETH.aTokenAddress; POOL = contracts.poolProxy; diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index b9e60567..cf909a86 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -53,12 +53,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { ); function testListings() public { - address asset = address(new TestnetERC20( - '1INCH', - '1INCH', - 18, - address(this) - )); + address asset = address(new TestnetERC20('1INCH', '1INCH', 18, address(this))); address feed = address(new MockAggregator(int256(25e8))); AaveV3MockListing payload = new AaveV3MockListing(asset, feed, configEngine); @@ -133,27 +128,35 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), IDefaultInterestRateStrategyV2.InterestRateDataRay({ optimalUsageRatio: _bpsToRay(payload.newListings()[0].rateStrategyParams.optimalUsageRatio), - baseVariableBorrowRate: _bpsToRay(payload.newListings()[0].rateStrategyParams.baseVariableBorrowRate), - variableRateSlope1: _bpsToRay(payload.newListings()[0].rateStrategyParams.variableRateSlope1), - variableRateSlope2: _bpsToRay(payload.newListings()[0].rateStrategyParams.variableRateSlope2) + baseVariableBorrowRate: _bpsToRay( + payload.newListings()[0].rateStrategyParams.baseVariableBorrowRate + ), + variableRateSlope1: _bpsToRay( + payload.newListings()[0].rateStrategyParams.variableRateSlope1 + ), + variableRateSlope2: _bpsToRay( + payload.newListings()[0].rateStrategyParams.variableRateSlope2 + ) }) ); } function testListingsCustom() public { - address asset = address(new TestnetERC20( - 'PSP', - 'PSP', - 18, - address(this) - )); + address asset = address(new TestnetERC20('PSP', 'PSP', 18, address(this))); address feed = address(new MockAggregator(int256(15e8))); address aTokenImpl = address(new ATokenInstance(contracts.poolProxy)); address vTokenImpl = address(new VariableDebtTokenInstance(contracts.poolProxy)); address sTokenImpl = address(new StableDebtTokenInstance(contracts.poolProxy)); - AaveV3MockListingCustom payload = new AaveV3MockListingCustom(asset, feed, configEngine, aTokenImpl, vTokenImpl, sTokenImpl); + AaveV3MockListingCustom payload = new AaveV3MockListingCustom( + asset, + feed, + configEngine, + aTokenImpl, + vTokenImpl, + sTokenImpl + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -224,10 +227,18 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), IDefaultInterestRateStrategyV2.InterestRateDataRay({ - optimalUsageRatio: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.optimalUsageRatio), - baseVariableBorrowRate: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.baseVariableBorrowRate), - variableRateSlope1: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope1), - variableRateSlope2: _bpsToRay(payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope2) + optimalUsageRatio: _bpsToRay( + payload.newListingsCustom()[0].base.rateStrategyParams.optimalUsageRatio + ), + baseVariableBorrowRate: _bpsToRay( + payload.newListingsCustom()[0].base.rateStrategyParams.baseVariableBorrowRate + ), + variableRateSlope1: _bpsToRay( + payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope1 + ), + variableRateSlope2: _bpsToRay( + payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope2 + ) }) ); } @@ -252,16 +263,14 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { IPool(address(contracts.poolProxy)) ); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); diffReports('preTestEngineCaps', 'postTestEngineCaps'); expectedAssetConfig.supplyCap = 1_000_000; _validateReserveConfig(expectedAssetConfig, allConfigsAfter); } + function testCollateralsUpdates() public { // this asset has been listed before address asset = tokenList.usdx; @@ -282,10 +291,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { IPool(address(contracts.poolProxy)) ); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); diffReports('preTestEngineCollateral', 'postTestEngineCollateral'); @@ -305,7 +311,10 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { function testFailCollateralsUpdatesNoChange() public { // this asset has been listed before address asset = tokenList.usdx; - AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange(asset, configEngine); + AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange( + asset, + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -329,7 +338,10 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { function testCollateralsUpdatesNoChange() public { // this asset has been listed before address asset = tokenList.usdx; - AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange(asset, configEngine); + AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange( + asset, + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -348,17 +360,17 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineCollateralNoChange', 'postTestEngineCollateralNoChange'); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); _validateReserveConfig(expectedAssetConfig, allConfigsAfter); } function testCollateralUpdateWrongBonus() public { address asset = tokenList.usdx; - AaveV3MockCollateralUpdateWrongBonus payload = new AaveV3MockCollateralUpdateWrongBonus(asset, configEngine); + AaveV3MockCollateralUpdateWrongBonus payload = new AaveV3MockCollateralUpdateWrongBonus( + asset, + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -369,7 +381,10 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { function testCollateralUpdateCorrectBonus() public { address asset = tokenList.usdx; - AaveV3MockCollateralUpdateCorrectBonus payload = new AaveV3MockCollateralUpdateCorrectBonus(asset, configEngine); + AaveV3MockCollateralUpdateCorrectBonus payload = new AaveV3MockCollateralUpdateCorrectBonus( + asset, + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -388,10 +403,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineCollateralEdgeBonus', 'postTestEngineCollateralEdgeBonus'); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); expectedAssetConfig.ltv = 62_00; expectedAssetConfig.liquidationThreshold = 90_00; expectedAssetConfig.liquidationBonus = 111_00; // 100_00 + 11_00 @@ -420,10 +432,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineBorrow', 'postTestEngineBorrow'); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); expectedAssetConfig.reserveFactor = 15_00; expectedAssetConfig.borrowingEnabled = true; expectedAssetConfig.isFlashloanable = false; @@ -433,7 +442,10 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { function testBorrowUpdatesNoChange() public { address asset = tokenList.usdx; - AaveV3MockBorrowUpdateNoChange payload = new AaveV3MockBorrowUpdateNoChange(asset, configEngine); + AaveV3MockBorrowUpdateNoChange payload = new AaveV3MockBorrowUpdateNoChange( + asset, + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -452,10 +464,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineBorrowNoChange', 'postTestEngineBorrowNoChange'); - ReserveConfig memory expectedAssetConfig = _findReserveConfig( - allConfigsBefore, - asset - ); + ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); _validateReserveConfig(expectedAssetConfig, allConfigsAfter); } @@ -467,17 +476,11 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); - createConfigurationSnapshot( - 'preTestEngineRates', - IPool(address(contracts.poolProxy)) - ); + createConfigurationSnapshot('preTestEngineRates', IPool(address(contracts.poolProxy))); payload.execute(); - createConfigurationSnapshot( - 'postTestEngineRates', - IPool(address(contracts.poolProxy)) - ); + createConfigurationSnapshot('postTestEngineRates', IPool(address(contracts.poolProxy))); diffReports('preTestEngineRates', 'postTestEngineRates'); @@ -487,7 +490,9 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), IDefaultInterestRateStrategyV2.InterestRateDataRay({ optimalUsageRatio: _bpsToRay(payload.rateStrategiesUpdates()[0].params.optimalUsageRatio), - baseVariableBorrowRate: _bpsToRay(payload.rateStrategiesUpdates()[0].params.baseVariableBorrowRate), + baseVariableBorrowRate: _bpsToRay( + payload.rateStrategiesUpdates()[0].params.baseVariableBorrowRate + ), variableRateSlope1: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope1), variableRateSlope2: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope2) }) @@ -502,17 +507,11 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); - createConfigurationSnapshot( - 'preTestEnginePriceFeed', - IPool(address(contracts.poolProxy)) - ); + createConfigurationSnapshot('preTestEnginePriceFeed', IPool(address(contracts.poolProxy))); payload.execute(); - createConfigurationSnapshot( - 'postTestEnginePriceFeed', - IPool(address(contracts.poolProxy)) - ); + createConfigurationSnapshot('postTestEnginePriceFeed', IPool(address(contracts.poolProxy))); diffReports('preTestEnginePriceFeed', 'postTestEnginePriceFeed'); @@ -552,11 +551,17 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { prevEmodeCategoryData.priceSource = address(0); prevEmodeCategoryData.label = 'ETH Correlated'; - _validateEmodeCategory(IPoolAddressesProvider(address(contracts.poolAddressesProvider)), 1, prevEmodeCategoryData); + _validateEmodeCategory( + IPoolAddressesProvider(address(contracts.poolAddressesProvider)), + 1, + prevEmodeCategoryData + ); } function testEModeCategoryUpdatesWrongBonus() public { - AaveV3MockEModeCategoryUpdateEdgeBonus payload = new AaveV3MockEModeCategoryUpdateEdgeBonus(configEngine); + AaveV3MockEModeCategoryUpdateEdgeBonus payload = new AaveV3MockEModeCategoryUpdateEdgeBonus( + configEngine + ); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -567,9 +572,13 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { // TODO manage this after testFail* deprecation. function testFailEModeCategoryUpdatesNoChange() public { - AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange(configEngine); + AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange( + configEngine + ); - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts.poolProxy.getEModeCategoryData(1); + DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts + .poolProxy + .getEModeCategoryData(1); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -588,18 +597,28 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { // Same as testFailEModeCategoryUpdatesNoChange, but this time should work, as we are not expecting any event emitted function testEModeCategoryUpdatesNoChange() public { - AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange(configEngine); + AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange( + configEngine + ); - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts.poolProxy.getEModeCategoryData(1); + DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts + .poolProxy + .getEModeCategoryData(1); vm.prank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); - createConfigurationSnapshot('preTestEngineEModeCategoryNoChange', IPool(address(contracts.poolProxy))); + createConfigurationSnapshot( + 'preTestEngineEModeCategoryNoChange', + IPool(address(contracts.poolProxy)) + ); payload.execute(); - createConfigurationSnapshot('postTestEngineEModeCategoryNoChange', IPool(address(contracts.poolProxy))); + createConfigurationSnapshot( + 'postTestEngineEModeCategoryNoChange', + IPool(address(contracts.poolProxy)) + ); diffReports('preTestEngineEModeCategoryNoChange', 'postTestEngineEModeCategoryNoChange'); @@ -610,13 +629,19 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { prevEmodeCategoryData.priceSource = eModeCategoryDataBefore.priceSource; prevEmodeCategoryData.label = eModeCategoryDataBefore.label; - _validateEmodeCategory(IPoolAddressesProvider(address(contracts.poolAddressesProvider)), 1, prevEmodeCategoryData); + _validateEmodeCategory( + IPoolAddressesProvider(address(contracts.poolAddressesProvider)), + 1, + prevEmodeCategoryData + ); } function testAssetEModeUpdates() public { address asset = tokenList.usdx; - AaveV3MockEModeCategoryUpdate payloadToAddEMode = new AaveV3MockEModeCategoryUpdate(configEngine); + AaveV3MockEModeCategoryUpdate payloadToAddEMode = new AaveV3MockEModeCategoryUpdate( + configEngine + ); AaveV3MockAssetEModeUpdate payload = new AaveV3MockAssetEModeUpdate(asset, configEngine); vm.startPrank(roleList.marketOwner); @@ -626,19 +651,20 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { payloadToAddEMode.execute(); - createConfigurationSnapshot('preTestEngineAssetEModeUpdate', IPool(address(contracts.poolProxy))); + createConfigurationSnapshot( + 'preTestEngineAssetEModeUpdate', + IPool(address(contracts.poolProxy)) + ); payload.execute(); - createConfigurationSnapshot('postTestEngineAssetEModeUpdate', IPool(address(contracts.poolProxy))); + createConfigurationSnapshot( + 'postTestEngineAssetEModeUpdate', + IPool(address(contracts.poolProxy)) + ); diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); - assertEq( - contracts.protocolDataProvider.getReserveEModeCategory( - asset - ), - 1 - ); + assertEq(contracts.protocolDataProvider.getReserveEModeCategory(asset), 1); } } diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol index 31d67eb0..5e2d45ac 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol @@ -18,10 +18,7 @@ contract AaveV3MockAssetEModeUpdate is AaveV3Payload { function assetsEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](1); - eModeUpdate[0] = IEngine.AssetEModeUpdate({ - asset: ASSET_ADDRESS, - eModeCategory: 1 - }); + eModeUpdate[0] = IEngine.AssetEModeUpdate({asset: ASSET_ADDRESS, eModeCategory: 1}); return eModeUpdate; } diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol index 7944629d..825e80ee 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol @@ -13,7 +13,11 @@ contract AaveV3MockListing is AaveV3Payload { address public immutable ASSET_ADDRESS; address public immutable ASSET_FEED; - constructor(address assetAddress, address assetFeed, address customEngine) AaveV3Payload(IEngine(customEngine)) { + constructor( + address assetAddress, + address assetFeed, + address customEngine + ) AaveV3Payload(IEngine(customEngine)) { ASSET_ADDRESS = assetAddress; ASSET_FEED = assetFeed; } diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol index f9a342fd..dc41c531 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol @@ -16,7 +16,14 @@ contract AaveV3MockListingCustom is AaveV3Payload { address public immutable V_TOKEN_IMPL; address public immutable S_TOKEN_IMPL; - constructor(address assetAddress, address assetFeed, address customEngine, address aTokenImpl, address vTokenImpl, address sTokenImpl) AaveV3Payload(IEngine(customEngine)) { + constructor( + address assetAddress, + address assetFeed, + address customEngine, + address aTokenImpl, + address vTokenImpl, + address sTokenImpl + ) AaveV3Payload(IEngine(customEngine)) { ASSET_ADDRESS = assetAddress; ASSET_FEED = assetFeed; A_TOKEN_IMPL = aTokenImpl; diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol index 048c5b9d..0b5bd8b1 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol @@ -13,7 +13,11 @@ contract AaveV3MockPriceFeedUpdate is AaveV3Payload { address public immutable ASSET_ADDRESS; address public immutable ASSET_FEED; - constructor(address assetAddress, address feed, address customEngine) AaveV3Payload(IEngine(customEngine)) { + constructor( + address assetAddress, + address feed, + address customEngine + ) AaveV3Payload(IEngine(customEngine)) { ASSET_ADDRESS = assetAddress; ASSET_FEED = feed; } @@ -21,10 +25,7 @@ contract AaveV3MockPriceFeedUpdate is AaveV3Payload { function priceFeedsUpdates() public view override returns (IEngine.PriceFeedUpdate[] memory) { IEngine.PriceFeedUpdate[] memory priceFeedsUpdate = new IEngine.PriceFeedUpdate[](1); - priceFeedsUpdate[0] = IEngine.PriceFeedUpdate({ - asset: ASSET_ADDRESS, - priceFeed: ASSET_FEED - }); + priceFeedsUpdate[0] = IEngine.PriceFeedUpdate({asset: ASSET_ADDRESS, priceFeed: ASSET_FEED}); return priceFeedsUpdate; } diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol index 97298c12..087ae883 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol @@ -734,9 +734,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { } function test_setLiquidationGracePeriodReserve(uint40 gracePeriod) public { - vm.assume( - gracePeriod < contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0 - ); + vm.assume(gracePeriod < contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0); address asset = tokenList.usdx; diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol index a85fd89a..586971d9 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.upgradeabilty.t.sol @@ -31,11 +31,7 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { address newStrategy ); - event ReserveInterestRateDataChanged( - address indexed asset, - address indexed strategy, - bytes data - ); + event ReserveInterestRateDataChanged(address indexed asset, address indexed strategy, bytes data); event ATokenUpgraded( address indexed asset, @@ -99,7 +95,11 @@ contract PoolConfiguratorUpgradeabilityTests is TestnetProcedures { bytes memory newInterestRateData = _getDefaultInterestRatesStrategyData(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit ReserveInterestRateDataChanged(tokenList.usdx, currentInterestRateStrategy, newInterestRateData); + emit ReserveInterestRateDataChanged( + tokenList.usdx, + currentInterestRateStrategy, + newInterestRateData + ); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setReserveInterestRateData( diff --git a/tests/utils/BatchTestProcedures.sol b/tests/utils/BatchTestProcedures.sol index d0418972..dfdcd416 100644 --- a/tests/utils/BatchTestProcedures.sol +++ b/tests/utils/BatchTestProcedures.sol @@ -99,14 +99,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput config.l2PriceOracleSentinelGracePeriod ); - return ( - initialReport, - gettersReport1, - poolReport, - peripheryReport, - miscReport, - setupContract - ); + return (initialReport, gettersReport1, poolReport, peripheryReport, miscReport, setupContract); } function deployAndSetup( @@ -189,10 +182,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput assertTrue(r.poolConfiguratorImplementation != address(0), 'r.poolConfiguratorImplementation'); assertTrue(r.protocolDataProvider != address(0), 'report.protocolDataProvider'); assertTrue(r.aaveOracle != address(0), 'report.aaveOracle'); - assertTrue( - r.defaultInterestRateStrategy != address(0), - 'report.defaultInterestRateStrategy' - ); + assertTrue(r.defaultInterestRateStrategy != address(0), 'report.defaultInterestRateStrategy'); assertTrue(r.aclManager != address(0), 'report.aclManager'); assertTrue(r.treasury != address(0), 'report.treasury'); assertTrue(r.proxyAdmin != address(0), 'report.proxyAdmin'); @@ -221,7 +211,10 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput ); assertTrue(r.rewardsControllerProxy != address(0), 'report.rewardsControllerProxy'); assertTrue(r.configEngine != address(0), 'report.configEngine'); - assertTrue(r.staticATokenFactoryImplementation != address(0), 'report.staticATokenFactoryImplementation'); + assertTrue( + r.staticATokenFactoryImplementation != address(0), + 'report.staticATokenFactoryImplementation' + ); assertTrue(r.staticATokenFactoryProxy != address(0), 'report.staticATokenFactoryProxy'); assertTrue(r.staticATokenImplementation != address(0), 'report.staticATokenImplementation'); assertTrue(r.transparentProxyFactory != address(0), 'report.transparentProxyFactory'); From cab9796c5f5bd79f2ee4c7e838ac7df5e5e8032f Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 29 Apr 2024 14:15:30 +0530 Subject: [PATCH 15/88] chore: add reports dir --- reports/.empty | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 reports/.empty diff --git a/reports/.empty b/reports/.empty new file mode 100644 index 00000000..e69de29b From d25f6d91f740a3889bc0653219085d6fbd006ee1 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 2 May 2024 16:11:05 +0200 Subject: [PATCH 16/88] Update src/core/contracts/protocol/pool/PoolConfigurator.sol Co-authored-by: sendra --- src/core/contracts/protocol/pool/PoolConfigurator.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/contracts/protocol/pool/PoolConfigurator.sol b/src/core/contracts/protocol/pool/PoolConfigurator.sol index 0bd9277a..f47f0db4 100644 --- a/src/core/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/core/contracts/protocol/pool/PoolConfigurator.sol @@ -237,7 +237,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator bool paused, uint40 gracePeriod ) public override onlyEmergencyOrPoolAdmin { - // Only setting grace period if the transition is to not paused + // Only setting grace period if the transition is not paused if (!paused && gracePeriod != 0) { require(gracePeriod <= MAX_GRACE_PERIOD, Errors.INVALID_GRACE_PERIOD); From 03a0f73a252e49f714d9841105b69ab5818d25e6 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 6 May 2024 13:52:48 +0530 Subject: [PATCH 17/88] chore: fix conflicts --- .../PoolConfigurator.ACLModifiers.t.sol | 11 +- .../PoolConfigurator.initReserves.t.sol | 239 ++++-------------- .../PoolConfigurator.reserveRiskConfig.t.sol | 84 +++--- .../tokenization/StableDebtToken.t.sol | 70 ++--- .../tokenization/VariableDebtToken.t.sol | 66 ++--- tests/utils/TestnetProcedures.sol | 114 +++++---- 6 files changed, 231 insertions(+), 353 deletions(-) diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol index a6c86453..dc351d2f 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol @@ -5,15 +5,20 @@ import 'forge-std/Test.sol'; import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; import {ConfiguratorInputTypes} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; -import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorACLModifiersTest is TestnetProcedures { function setUp() public { initTestEnvironment(); } - function test_reverts_notAdmin_initReserves(address caller) public { - ConfiguratorInputTypes.InitReserveInput[] memory input; + function test_reverts_notAdmin_initReserves(TestVars memory t, address caller) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, + report, + poolAdmin, + true + ); vm.assume( !contracts.aclManager.isPoolAdmin(caller) && !contracts.aclManager.isAssetListingAdmin(caller) && diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol index c760a736..24a16c0e 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.initReserves.t.sol @@ -23,189 +23,77 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { initTestEnvironment(); } - function test_initReserves_singleAsset(bool isVirtualAccActive) public { - TestnetERC20 newToken = new TestnetERC20('Misc Token', 'MISC', 18, poolAdmin); + function test_initReserves_validNumberOfAssets(TestVars[128] memory t, uint8 length) public { + vm.assume(length > 0 && length < 128); - TestVars memory t; - t.aTokenName = 'Misc AToken'; - t.aTokenSymbol = 'aMISC'; - t.variableDebtName = 'Variable Debt Misc'; - t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategy; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; + uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; + vm.assume(length < maxListings); ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](1); - - input[0] = ConfiguratorInputTypes.InitReserveInput( - report.aToken, - report.stableDebtToken, - report.variableDebtToken, - newToken.decimals(), - isVirtualAccActive, - t.rateStrategy, - address(newToken), - report.treasury, - report.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData - ); - vm.expectEmit(true, false, false, false, address(contracts.poolConfiguratorProxy)); - emit ReserveInitialized( - input[0].underlyingAsset, - address(0), - address(0), - address(0), - input[0].interestRateStrategyAddress - ); - - // Perform action - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.initReserves(input); - - // Perform assertions - { - (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts - .protocolDataProvider - .getReserveTokensAddresses(address(newToken)); + memory input = new ConfiguratorInputTypes.InitReserveInput[](length); + for (uint i = 0; i < length; i++) { + input[i] = _generateInitReserveInput(t[i], report, poolAdmin, true); - assertEq(AToken(aTokenProxy).name(), t.aTokenName); - assertEq(AToken(aTokenProxy).symbol(), t.aTokenSymbol); - assertEq(AToken(aTokenProxy).decimals(), newToken.decimals()); - assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), report.treasury); - assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(aTokenProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - - assertEq(AToken(stableDebtProxy).name(), t.stableDebtName); - assertEq(AToken(stableDebtProxy).symbol(), t.stableDebtSymbol); - assertEq(AToken(stableDebtProxy).decimals(), newToken.decimals()); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(stableDebtProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - - assertEq(AToken(variableDebtProxy).name(), t.variableDebtName); - assertEq(AToken(variableDebtProxy).symbol(), t.variableDebtSymbol); - assertEq(AToken(variableDebtProxy).decimals(), newToken.decimals()); - assertEq(AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), address(newToken)); - assertEq( - address(AToken(variableDebtProxy).getIncentivesController()), - report.rewardsControllerProxy - ); - } - // Perform default asset checks - TestReserveConfig memory c = _getReserveConfig(address(newToken), report.protocolDataProvider); - - assertEq(c.isActive, true); - assertEq(c.isFrozen, false); - assertEq(c.isPaused, false); - assertEq(c.decimals, newToken.decimals()); - - assertEq(c.ltv, 0); - assertEq(c.liquidationThreshold, 0); - assertEq(c.liquidationBonus, 0); - assertEq(c.reserveFactor, 0); - assertEq(c.usageAsCollateralEnabled, false); - assertEq(c.borrowingEnabled, false); - assertEq(c.stableBorrowRateEnabled, false); - assertEq(c.isVirtualAccActive, isVirtualAccActive); - - assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + 1); - } - - function test_initReserves_multipleAssets() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 4, - report, - poolAdmin - ); - uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; - - for (uint256 y; y < input.length; ++y) { vm.expectEmit(true, false, false, false, address(contracts.poolConfiguratorProxy)); emit ReserveInitialized( - input[y].underlyingAsset, + input[i].underlyingAsset, address(0), address(0), address(0), - input[y].interestRateStrategyAddress + input[i].interestRateStrategyAddress ); } - // Perform action vm.prank(poolAdmin); contracts.poolConfiguratorProxy.initReserves(input); - // Perform assertions - for (uint256 y; y < input.length; ++y) { - ConfiguratorInputTypes.InitReserveInput memory reserveInput = input[y]; - + for (uint i = 0; i < length; i++) { + ConfiguratorInputTypes.InitReserveInput memory initConfig = input[i]; + // Perform assertions { (address aTokenProxy, address stableDebtProxy, address variableDebtProxy) = contracts .protocolDataProvider - .getReserveTokensAddresses(reserveInput.underlyingAsset); + .getReserveTokensAddresses(initConfig.underlyingAsset); - assertEq(AToken(aTokenProxy).name(), reserveInput.aTokenName); - assertEq(AToken(aTokenProxy).symbol(), reserveInput.aTokenSymbol); - assertEq(AToken(aTokenProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), reserveInput.treasury); - assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), reserveInput.underlyingAsset); + assertEq(AToken(aTokenProxy).name(), initConfig.aTokenName); + assertEq(AToken(aTokenProxy).symbol(), initConfig.aTokenSymbol); + assertEq(AToken(aTokenProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(aTokenProxy).RESERVE_TREASURY_ADDRESS(), initConfig.treasury); + assertEq(AToken(aTokenProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(aTokenProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); - assertEq(AToken(stableDebtProxy).name(), reserveInput.stableDebtTokenName); - assertEq(AToken(stableDebtProxy).symbol(), reserveInput.stableDebtTokenSymbol); - assertEq(AToken(stableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), reserveInput.underlyingAsset); + assertEq(AToken(stableDebtProxy).name(), initConfig.stableDebtTokenName); + assertEq(AToken(stableDebtProxy).symbol(), initConfig.stableDebtTokenSymbol); + assertEq(AToken(stableDebtProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(stableDebtProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(stableDebtProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); - assertEq(AToken(variableDebtProxy).name(), reserveInput.variableDebtTokenName); - assertEq(AToken(variableDebtProxy).symbol(), reserveInput.variableDebtTokenSymbol); - assertEq(AToken(variableDebtProxy).decimals(), reserveInput.underlyingAssetDecimals); - assertEq( - AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), - reserveInput.underlyingAsset - ); + assertEq(AToken(variableDebtProxy).name(), initConfig.variableDebtTokenName); + assertEq(AToken(variableDebtProxy).symbol(), initConfig.variableDebtTokenSymbol); + assertEq(AToken(variableDebtProxy).decimals(), initConfig.underlyingAssetDecimals); + assertEq(AToken(variableDebtProxy).UNDERLYING_ASSET_ADDRESS(), initConfig.underlyingAsset); assertEq( address(AToken(variableDebtProxy).getIncentivesController()), - reserveInput.incentivesController + initConfig.incentivesController ); } // Perform default asset checks TestReserveConfig memory c = _getReserveConfig( - reserveInput.underlyingAsset, + initConfig.underlyingAsset, report.protocolDataProvider ); assertEq(c.isActive, true); assertEq(c.isFrozen, false); assertEq(c.isPaused, false); - assertEq(c.decimals, reserveInput.underlyingAssetDecimals); + assertEq(c.decimals, initConfig.underlyingAssetDecimals); assertEq(c.ltv, 0); assertEq(c.liquidationThreshold, 0); @@ -214,8 +102,9 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(c.usageAsCollateralEnabled, false); assertEq(c.borrowingEnabled, false); assertEq(c.stableBorrowRateEnabled, false); + assertEq(c.isVirtualAccActive, initConfig.useVirtualBalance); } - assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + input.length); + assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets + length); } function test_initReserves_zeroAssets() public { @@ -230,14 +119,16 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets); } - function test_reverts_initReserves_maxAssets() public { + function test_reverts_initReserves_maxAssets(TestVars memory t, uint8 lengthSeed) public { uint256 previousListedAssets = contracts.poolProxy.getReservesList().length; + uint256 maxListings = contracts.poolProxy.MAX_NUMBER_RESERVES() - previousListedAssets + 1; - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - maxListings, - report, - poolAdmin - ); + uint256 length = maxListings + lengthSeed; + + ConfiguratorInputTypes.InitReserveInput[] + memory input = new ConfiguratorInputTypes.InitReserveInput[](length); + for (uint256 i = 0; i < length; i++) + input[i] = _generateInitReserveInput(t, report, poolAdmin, true); vm.expectRevert(bytes(Errors.NO_MORE_RESERVES_ALLOWED)); vm.prank(poolAdmin); @@ -246,48 +137,14 @@ contract PoolConfiguratorInitReservesTest is TestnetProcedures { assertEq(contracts.poolProxy.getReservesList().length, previousListedAssets); } - function test_initReserves_notEnoughDecimal(uint8 decimals) public { - vm.assume(decimals < 6); - TestnetERC20 newToken = new TestnetERC20('Misc Token', 'MISC', decimals, poolAdmin); + function test_initReserves_notEnoughDecimal(TestVars memory t) public { + vm.assume(t.underlyingDecimals < 6); - TestVars memory t; - t.aTokenName = 'Misc AToken'; - t.aTokenSymbol = 'aMISC'; - t.variableDebtName = 'Variable Debt Misc'; - t.variableDebtSymbol = 'varDebtMISC'; - t.stableDebtName = 'Stable Debt Misc'; - t.stableDebtSymbol = 'stableDebtMISC'; - t.rateStrategy = report.defaultInterestRateStrategy; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); - - ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](1); - - input[0] = ConfiguratorInputTypes.InitReserveInput( - report.aToken, - report.stableDebtToken, - report.variableDebtToken, - newToken.decimals(), - true, - t.rateStrategy, - address(newToken), - report.treasury, - report.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, + report, + poolAdmin, + false ); vm.expectRevert(bytes(Errors.INVALID_DECIMALS)); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol index 087ae883..caa9dd1e 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol @@ -65,11 +65,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { contracts.poolProxy.supply(tokenList.wbtc, 100e8, bob, 0); } - function test_enableBorrowing() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableBorrowing(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -103,11 +104,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(borrowingConfigAfter, false); } - function test_enableFlashBorrow() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableFlashBorrow(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -130,15 +132,16 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(valueAfter, false); } - function test_setCollateralConfig() public { + function test_setCollateralConfig(TestVars memory t) public { uint256 ltv = 80_00; uint256 liquidationThreshold = 85_00; uint256 liquidationBonus = 105_00; - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -169,11 +172,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(liqBonus, liquidationBonus); } - function test_reverts_setCollateralConfig_invalidParams() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_reverts_setCollateralConfig_invalidParams(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -234,11 +238,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { contracts.poolConfiguratorProxy.configureReserveAsCollateral(tokenList.usdx, 0, 0, 0); } - function test_enableStableBorrowing() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_enableStableBorrowing(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -276,11 +281,12 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(borrowingConfigAfter, false); } - function test_reverts_enableStableBorrowing_borrowNotEnabled() public { - ConfiguratorInputTypes.InitReserveInput[] memory input = _generateListingInput( - 1, + function test_reverts_enableStableBorrowing_borrowNotEnabled(TestVars memory t) public { + ConfiguratorInputTypes.InitReserveInput[] memory input = _generateInitConfig( + t, report, - poolAdmin + poolAdmin, + true ); // Perform action @@ -740,30 +746,14 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { uint40 until = uint40(block.timestamp) + gracePeriod; - vm.startPrank(poolAdmin); - - // reserve unpause -> unpause, liquidationGracePeriod would be set - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit LiquidationGracePeriodChanged(asset, until); - contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - - // reserve unpause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - assertTrue(contracts.protocolDataProvider.getPaused(asset)); - - // reserve pause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); - - // reserve pause -> unpause, liquidationGracePeriod would be set - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit LiquidationGracePeriodChanged(asset, until + 1); - contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until + 1); + vm.prank(poolAdmin); - vm.stopPrank(); + if (gracePeriod != 0) { + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit LiquidationGracePeriodChanged(asset, until); + contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod); + assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); + } } function test_setLiquidationGracePeriodPool(uint40 gracePeriod) public { diff --git a/tests/protocol/tokenization/StableDebtToken.t.sol b/tests/protocol/tokenization/StableDebtToken.t.sol index 06aa317c..f2461065 100644 --- a/tests/protocol/tokenization/StableDebtToken.t.sol +++ b/tests/protocol/tokenization/StableDebtToken.t.sol @@ -9,7 +9,7 @@ import {IAaveIncentivesController} from '../../../src/contracts/interfaces/IAave import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; import {PoolConfigurator, ConfiguratorInputTypes, IPool} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../../utils/TestnetProcedures.sol'; contract StableDebtTokenEventsTests is TestnetProcedures { StableDebtTokenInstance public stableDebtToken; @@ -69,11 +69,14 @@ contract StableDebtTokenEventsTests is TestnetProcedures { return stDebtToken; } - function test_reverts_initialize_twice() public { - StableDebtTokenInstance staDebtToken = test_initialize_StableDebtToken(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + function test_reverts_initialize_twice(TestVars memory t) public { + StableDebtTokenInstance staDebtToken = test_initialize_StableDebtToken(t); + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -90,11 +93,16 @@ contract StableDebtTokenEventsTests is TestnetProcedures { ); } - function test_initialize_StableDebtToken() public returns (StableDebtTokenInstance) { + function test_initialize_StableDebtToken( + TestVars memory t + ) public returns (StableDebtTokenInstance) { StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); vm.expectEmit(address(stDebtToken)); emit Initialized( @@ -128,11 +136,14 @@ contract StableDebtTokenEventsTests is TestnetProcedures { return stDebtToken; } - function test_reverts_initialize_pool_do_not_match() public { + function test_reverts_initialize_pool_do_not_match(TestVars memory t) public { StableDebtTokenInstance stDebtToken = test_new_StableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -149,8 +160,8 @@ contract StableDebtTokenEventsTests is TestnetProcedures { ); } - function test_mint_stableDebt_caller_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); + function test_mint_stableDebt_caller_alice(TestVars memory t) public { + StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(t); vm.expectRevert(bytes(Errors.OPERATION_NOT_SUPPORTED)); @@ -158,8 +169,8 @@ contract StableDebtTokenEventsTests is TestnetProcedures { debtToken.mint(alice, alice, 0, 0); } - function test_mint_stableDebt_caller_bob_onBehalf_alice() public { - StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(); + function test_mint_stableDebt_caller_bob_onBehalf_alice(TestVars memory t) public { + StableDebtTokenInstance debtToken = test_initialize_StableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -208,53 +219,48 @@ contract StableDebtTokenEventsTests is TestnetProcedures { stDebtToken.burn(address(0), 0); } - function test_default_revision() public { - StableDebtTokenInstance stDebtToken = new StableDebtTokenInstance(IPool(report.poolProxy)); - assertEq(stDebtToken._getRevision(), stDebtToken.DEBT_TOKEN_REVISION()); - } - - function test_getAverageStableRate() public view { + function test_getAverageStableRate() public { uint256 avgStableRate = stableDebtToken.getAverageStableRate(); assertEq(avgStableRate, 0); } - function test_getUserLastUpdated() public view { + function test_getUserLastUpdated() public { uint256 lastUpdated = stableDebtToken.getUserLastUpdated(alice); assertEq(lastUpdated, 0); } - function test_getUserStableRate() public view { + function test_getUserStableRate() public { uint256 userStableRate = stableDebtToken.getUserStableRate(alice); assertEq(userStableRate, 0); } - function test_balanceOf() public view { + function test_balanceOf() public { uint256 balance = stableDebtToken.balanceOf(alice); assertEq(balance, 0); } - function test_totalSupply() public view { + function test_totalSupply() public { uint256 scaledTotalSupply = stableDebtToken.totalSupply(); assertEq(scaledTotalSupply, 0); } - function test_getTotalSupplyLastUpdated() public view { + function test_getTotalSupplyLastUpdated() public { uint256 totalSupplyLastUpdated = stableDebtToken.getTotalSupplyLastUpdated(); assertEq(totalSupplyLastUpdated, 0); } - function test_principalBalanceOf() public view { + function test_principalBalanceOf() public { uint256 principalBalanceOf = stableDebtToken.principalBalanceOf(alice); assertEq(principalBalanceOf, 0); } - function test_getTotalSupplyAndAvgRate() public view { + function test_getTotalSupplyAndAvgRate() public { (uint256 totalSupply, uint256 avgRate) = stableDebtToken.getTotalSupplyAndAvgRate(); assertEq(totalSupply, 0); assertEq(avgRate, 0); } - function test_getSupplyData() public view { + function test_getSupplyData() public { ( uint256 principal, uint256 totalSupply, diff --git a/tests/protocol/tokenization/VariableDebtToken.t.sol b/tests/protocol/tokenization/VariableDebtToken.t.sol index 0c13902e..5124f253 100644 --- a/tests/protocol/tokenization/VariableDebtToken.t.sol +++ b/tests/protocol/tokenization/VariableDebtToken.t.sol @@ -11,7 +11,7 @@ import {ReserveLogic, DataTypes} from '../../../src/contracts/protocol/libraries import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; import {ConfiguratorInputTypes, IPool} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; import {EIP712SigUtils} from '../../utils/EIP712SigUtils.sol'; -import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {TestnetProcedures, TestVars} from '../../utils/TestnetProcedures.sol'; contract VariableDebtTokenEventsTests is TestnetProcedures { using WadRayMath for uint256; @@ -82,18 +82,23 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { return varDebtToken; } - function test_initialize_VariableDebtToken() public returns (VariableDebtTokenInstance) { + function test_initialize_VariableDebtToken( + TestVars memory t + ) public returns (VariableDebtTokenInstance) { VariableDebtTokenInstance varDebtToken = test_new_VariableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); vm.expectEmit(address(varDebtToken)); emit Initialized( listing.underlyingAsset, report.poolProxy, - report.rewardsControllerProxy, - TestnetERC20(listing.underlyingAsset).decimals(), + listing.incentivesController, + listing.underlyingAssetDecimals, listing.variableDebtTokenName, listing.variableDebtTokenSymbol, listing.params @@ -103,7 +108,7 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { IPool(report.poolProxy), listing.underlyingAsset, IAaveIncentivesController(listing.incentivesController), - TestnetERC20(listing.underlyingAsset).decimals(), + listing.underlyingAssetDecimals, listing.variableDebtTokenName, listing.variableDebtTokenSymbol, listing.params @@ -120,11 +125,14 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { return varDebtToken; } - function test_reverts_initialize_twice() public { - VariableDebtTokenInstance varDebtToken = test_initialize_VariableDebtToken(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + function test_reverts_initialize_twice(TestVars memory t) public { + VariableDebtTokenInstance varDebtToken = test_initialize_VariableDebtToken(t); + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -141,11 +149,14 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { ); } - function test_reverts_initialize_pool_do_not_match() public { + function test_reverts_initialize_pool_do_not_match(TestVars memory t) public { VariableDebtTokenInstance varDebtToken = test_new_VariableDebtToken_implementation(); - ConfiguratorInputTypes.InitReserveInput memory listing = ( - _generateListingInput(1, report, poolAdmin) - )[0]; + ConfiguratorInputTypes.InitReserveInput memory listing = _generateInitReserveInput( + t, + report, + poolAdmin, + true + ); uint8 decimals = TestnetERC20(listing.underlyingAsset).decimals(); @@ -162,13 +173,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { ); } - function test_default_revision() public { - VariableDebtTokenInstance varDebtToken = new VariableDebtTokenInstance(IPool(report.poolProxy)); - assertEq(varDebtToken._getRevision(), varDebtToken.DEBT_TOKEN_REVISION()); - } - - function test_mint_variableDebt_caller_alice() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_mint_variableDebt_caller_alice(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -182,8 +188,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), amount); } - function test_mint_variableDebt_caller_bob_onBehalf_alice() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_mint_variableDebt_caller_bob_onBehalf_alice(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -203,8 +209,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), amount); } - function test_partial_burn_variableDebt() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_partial_burn_variableDebt(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; @@ -229,8 +235,8 @@ contract VariableDebtTokenEventsTests is TestnetProcedures { assertEq(debtToken.scaledBalanceOf(alice), balanceScaled - repaymentScaled); } - function test_total_burn_variableDebt() public { - VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(); + function test_total_burn_variableDebt(TestVars memory t) public { + VariableDebtTokenInstance debtToken = test_initialize_VariableDebtToken(t); TestnetERC20 asset = TestnetERC20(debtToken.UNDERLYING_ASSET_ADDRESS()); uint8 decimals = asset.decimals(); uint256 amount = 1200 * 10 ** decimals; diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 35669294..5d74854a 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -22,6 +22,7 @@ import {MarketReportUtils} from '../../src/deployments/contracts/utilities/Marke import {AaveV3ConfigEngine, IAaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; struct TestVars { + uint8 underlyingDecimals; string aTokenName; string aTokenSymbol; string variableDebtName; @@ -29,10 +30,11 @@ struct TestVars { string stableDebtName; string stableDebtSymbol; address rateStrategy; - bytes interestRateData; - bytes emptyParams; - uint256 previousReservesLength; + address incentivesController; + address treasury; + bool useVirtualBalance; } + struct TestReserveConfig { uint256 decimals; uint256 ltv; @@ -278,59 +280,71 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { return string(abi.encodePacked(a, vm.toString(b))); } - function _generateListingInput( - uint256 listings, + function _generateInitConfig( + TestVars memory t, + MarketReport memory r, + address poolAdminUser, + bool isValidDecimals + ) internal returns (ConfiguratorInputTypes.InitReserveInput[] memory) { + TestVars[] memory tArray = new TestVars[](1); + tArray[0] = t; + return _generateInitConfig(tArray, r, poolAdminUser, isValidDecimals); + } + + function _generateInitConfig( + TestVars[] memory t, MarketReport memory r, - address poolAdminUser + address poolAdminUser, + bool isValidDecimals ) internal returns (ConfiguratorInputTypes.InitReserveInput[] memory) { ConfiguratorInputTypes.InitReserveInput[] - memory input = new ConfiguratorInputTypes.InitReserveInput[](listings); - - for (uint256 x; x < listings; ++x) { - TestnetERC20 listingToken = new TestnetERC20( - _concatStr('Token', x), - _concatStr('T', x), - uint8(10 + x), - poolAdminUser - ); - TestVars memory t; - t.aTokenName = _concatStr('AToken ', x); - t.aTokenName = _concatStr('a ', x); - t.variableDebtName = _concatStr('Variable Debt Misc', x); - t.variableDebtSymbol = _concatStr('varDebtMISC ', x); - t.stableDebtName = _concatStr('Stable Debt Misc ', x); - t.stableDebtSymbol = _concatStr('stableDebtMISC ', x); - t.rateStrategy = r.defaultInterestRateStrategy; - t.interestRateData = abi.encode( - IDefaultInterestRateStrategyV2.InterestRateData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 1_00, - variableRateSlope1: 4_00, - variableRateSlope2: 60_00 - }) - ); + memory configurations = new ConfiguratorInputTypes.InitReserveInput[](t.length); + for (uint256 i = 0; i < t.length; i++) { + configurations[i] = _generateInitReserveInput(t[i], r, poolAdminUser, isValidDecimals); + } + return configurations; + } - input[x] = ConfiguratorInputTypes.InitReserveInput( - r.aToken, - r.stableDebtToken, - r.variableDebtToken, - listingToken.decimals(), - true, - t.rateStrategy, - address(listingToken), - r.treasury, - r.rewardsControllerProxy, - t.aTokenName, - t.aTokenSymbol, - t.variableDebtName, - t.variableDebtSymbol, - t.stableDebtName, - t.stableDebtSymbol, - t.emptyParams, - t.interestRateData - ); + function _generateInitReserveInput( + TestVars memory t, + MarketReport memory r, + address poolAdminUser, + bool isValidDecimals + ) internal returns (ConfiguratorInputTypes.InitReserveInput memory) { + if (isValidDecimals) { + t.underlyingDecimals = uint8(bound(t.underlyingDecimals, 6, 25)); + } else { + t.underlyingDecimals = uint8(bound(t.underlyingDecimals, 0, 5)); } + ConfiguratorInputTypes.InitReserveInput memory input; + input.aTokenImpl = r.aToken; + input.underlyingAsset = address( + new TestnetERC20('Misc Token', 'MISC', t.underlyingDecimals, poolAdminUser) + ); + input.stableDebtTokenImpl = r.stableDebtToken; + input.variableDebtTokenImpl = r.variableDebtToken; + input.underlyingAssetDecimals = t.underlyingDecimals; + input.useVirtualBalance = t.useVirtualBalance; + input.interestRateStrategyAddress = r.defaultInterestRateStrategy; + input.treasury = t.treasury; + input.incentivesController = r.rewardsControllerProxy; + input.aTokenName = t.aTokenName; + input.aTokenSymbol = t.aTokenSymbol; + input.variableDebtTokenName = t.variableDebtName; + input.variableDebtTokenSymbol = t.variableDebtSymbol; + input.stableDebtTokenName = t.stableDebtName; + input.stableDebtTokenSymbol = t.stableDebtSymbol; + input.params = bytes(''); + input.interestRateData = abi.encode( + IDefaultInterestRateStrategyV2.InterestRateData({ + optimalUsageRatio: 80_00, + baseVariableBorrowRate: 1_00, + variableRateSlope1: 4_00, + variableRateSlope2: 60_00 + }) + ); + return input; } From 9d80072d95a426e4c19584110411ddf25ea60e65 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 6 May 2024 17:05:03 +0530 Subject: [PATCH 18/88] fix: remove static-a-token, config engine tests and the deployments --- .../misc/DeployAaveV3MarketBatchedBase.sol | 13 +- .../openzeppelin/contracts/ECDSA.sol | 180 ----- src/contracts/dependencies/solmate/ERC20.sol | 207 ----- .../extensions/static-a-token/README.md | 38 - .../extensions/static-a-token/StataOracle.sol | 41 - .../static-a-token/StaticATokenErrors.sol | 14 - .../static-a-token/StaticATokenFactory.sol | 86 --- .../static-a-token/StaticATokenLM.sol | 712 ------------------ .../static-a-token/interfaces/IAToken.sol | 16 - .../static-a-token/interfaces/IERC4626.sol | 241 ------ .../IInitializableStaticATokenLM.sol | 32 - .../interfaces/IStataOracle.sol | 31 - .../interfaces/IStaticATokenFactory.sol | 24 - .../interfaces/IStaticATokenLM.sol | 214 ------ .../libraries/RayMathExplicitRounding.sol | 42 -- .../procedures/AaveV3HelpersProcedureOne.sol | 57 -- .../procedures/AaveV3HelpersProcedureTwo.sol | 41 - .../procedures/AaveV3MiscProcedure.sol | 34 - .../procedures/AaveV3SetupProcedure.sol | 13 +- .../contracts/utilities/MetadataReporter.sol | 24 +- .../interfaces/IMarketReportTypes.sol | 32 +- .../AaveV3BatchOrchestration.sol | 95 +-- .../batches/AaveV3HelpersBatchOne.sol | 37 - .../batches/AaveV3HelpersBatchTwo.sol | 17 - .../batches/AaveV3MiscBatch.sol | 29 - .../batches/AaveV3PeripheryBatch.sol | 6 +- .../batches/AaveV3SetupBatch.sol | 6 +- tests/deployments/AaveV3BatchDeployment.t.sol | 16 +- tests/deployments/AaveV3BatchTests.t.sol | 80 +- tests/deployments/DeploymentsGasLimits.t.sol | 94 +-- .../static-a-token/StataOracle.t.sol | 57 -- .../static-a-token/StaticATokenLM.t.sol | 609 --------------- .../StaticATokenMetaTransactions.t.sol | 252 ------- .../static-a-token/StaticATokenNoLM.t.sol | 50 -- tests/extensions/static-a-token/TestBase.sol | 91 --- .../AaveV3ConfigEngineTest.t.sol | 670 ---------------- .../mocks/AaveV3MockAssetEModeUpdate.sol | 29 - .../mocks/AaveV3MockBorrowUpdate.sol | 38 - .../mocks/AaveV3MockBorrowUpdateNoChange.sol | 36 - .../mocks/AaveV3MockCapUpdate.sol | 33 - .../mocks/AaveV3MockCollateralUpdate.sol | 36 - .../AaveV3MockCollateralUpdateNoChange.sol | 36 - .../AaveV3MockCollateralUpdateWrongBonus.sol | 68 -- .../mocks/AaveV3MockEModeCategoryUpdate.sol | 72 -- .../AaveV3MockEModeCategoryUpdateNoChange.sol | 37 - .../mocks/AaveV3MockListing.sol | 60 -- .../mocks/AaveV3MockListingCustom.sol | 81 -- .../mocks/AaveV3MockPriceFeedUpdate.sol | 36 - .../mocks/AaveV3MockRatesUpdate.sol | 42 -- tests/utils/BatchTestProcedures.sol | 57 +- tests/utils/ConfigEngineDeployer.sol | 60 ++ tests/utils/SigUtils.sol | 117 --- tests/utils/TestnetProcedures.sol | 12 +- 53 files changed, 141 insertions(+), 4910 deletions(-) delete mode 100644 src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol delete mode 100644 src/contracts/dependencies/solmate/ERC20.sol delete mode 100644 src/contracts/extensions/static-a-token/README.md delete mode 100644 src/contracts/extensions/static-a-token/StataOracle.sol delete mode 100644 src/contracts/extensions/static-a-token/StaticATokenErrors.sol delete mode 100644 src/contracts/extensions/static-a-token/StaticATokenFactory.sol delete mode 100644 src/contracts/extensions/static-a-token/StaticATokenLM.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IAToken.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IERC4626.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol delete mode 100644 src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol delete mode 100644 src/contracts/misc/libraries/RayMathExplicitRounding.sol delete mode 100644 src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol delete mode 100644 src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol delete mode 100644 src/deployments/contracts/procedures/AaveV3MiscProcedure.sol delete mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol delete mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol delete mode 100644 src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol delete mode 100644 tests/extensions/static-a-token/StataOracle.t.sol delete mode 100644 tests/extensions/static-a-token/StaticATokenLM.t.sol delete mode 100644 tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol delete mode 100644 tests/extensions/static-a-token/StaticATokenNoLM.t.sol delete mode 100644 tests/extensions/static-a-token/TestBase.sol delete mode 100644 tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol delete mode 100644 tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol create mode 100644 tests/utils/ConfigEngineDeployer.sol delete mode 100644 tests/utils/SigUtils.sol diff --git a/scripts/misc/DeployAaveV3MarketBatchedBase.sol b/scripts/misc/DeployAaveV3MarketBatchedBase.sol index 25af8793..e6fddd33 100644 --- a/scripts/misc/DeployAaveV3MarketBatchedBase.sol +++ b/scripts/misc/DeployAaveV3MarketBatchedBase.sol @@ -25,7 +25,7 @@ abstract contract DeployAaveV3MarketBatchedBase is DeployUtils, MarketInput, Scr (roles, config, flags, report) = _getMarketInput(msg.sender); - _loadWarnings(config, flags); + _loadWarnings(config); vm.startBroadcast(); report = AaveV3BatchOrchestration.deployAaveV3(msg.sender, roles, config, flags, report); @@ -38,21 +38,12 @@ abstract contract DeployAaveV3MarketBatchedBase is DeployUtils, MarketInput, Scr metadataReporter.writeJsonReportMarket(report); } - function _loadWarnings(MarketConfig memory config, DeployFlags memory flags) internal view { + function _loadWarnings(MarketConfig memory config) internal view { if (config.paraswapAugustusRegistry == address(0)) { console.log( 'Warning: Paraswap Adapters will be skipped at deployment due missing config.paraswapAugustusRegistry' ); } - if ( - (flags.l2 && - (config.l2SequencerUptimeFeed == address(0) || - config.l2PriceOracleSentinelGracePeriod == 0)) - ) { - console.log( - 'Warning: L2 Sequencer uptime feed wont be set at deployment due missing config.l2SequencerUptimeFeed config.l2PriceOracleSentinelGracePeriod' - ); - } if ( config.networkBaseTokenPriceInUsdProxyAggregator == address(0) || config.marketReferenceCurrencyPriceInUsdProxyAggregator == address(0) diff --git a/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol b/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol deleted file mode 100644 index e58805c6..00000000 --- a/src/contracts/dependencies/openzeppelin/contracts/ECDSA.sol +++ /dev/null @@ -1,180 +0,0 @@ -// SPDX-License-Identifier: MIT -// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) -pragma solidity ^0.8.0; - -/** - * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. - * - * These functions can be used to verify that a message was signed by the holder - * of the private keys of a given address. - */ -library ECDSA { - enum RecoverError { - NoError, - InvalidSignature, - InvalidSignatureLength, - InvalidSignatureS - } - - /** - * @dev The signature derives the `address(0)`. - */ - error ECDSAInvalidSignature(); - - /** - * @dev The signature has an invalid length. - */ - error ECDSAInvalidSignatureLength(uint256 length); - - /** - * @dev The signature has an S value that is in the upper half order. - */ - error ECDSAInvalidSignatureS(bytes32 s); - - /** - * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not - * return address(0) without also returning an error description. Errors are documented using an enum (error type) - * and a bytes32 providing additional information about the error. - * - * If no error is returned, then the address can be used for verification purposes. - * - * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: - * this function rejects them by requiring the `s` value to be in the lower - * half order, and the `v` value to be either 27 or 28. - * - * IMPORTANT: `hash` _must_ be the result of a hash operation for the - * verification to be secure: it is possible to craft signatures that - * recover to arbitrary addresses for non-hashed data. A safe way to ensure - * this is by receiving a hash of the original message (which may otherwise - * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. - * - * Documentation for signature generation: - * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] - * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] - */ - function tryRecover( - bytes32 hash, - bytes memory signature - ) internal pure returns (address, RecoverError, bytes32) { - if (signature.length == 65) { - bytes32 r; - bytes32 s; - uint8 v; - // ecrecover takes the signature parameters, and the only way to get them - // currently is to use assembly. - /// @solidity memory-safe-assembly - assembly { - r := mload(add(signature, 0x20)) - s := mload(add(signature, 0x40)) - v := byte(0, mload(add(signature, 0x60))) - } - return tryRecover(hash, v, r, s); - } else { - return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); - } - } - - /** - * @dev Returns the address that signed a hashed message (`hash`) with - * `signature`. This address can then be used for verification purposes. - * - * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: - * this function rejects them by requiring the `s` value to be in the lower - * half order, and the `v` value to be either 27 or 28. - * - * IMPORTANT: `hash` _must_ be the result of a hash operation for the - * verification to be secure: it is possible to craft signatures that - * recover to arbitrary addresses for non-hashed data. A safe way to ensure - * this is by receiving a hash of the original message (which may otherwise - * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. - */ - function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { - (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); - _throwError(error, errorArg); - return recovered; - } - - /** - * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. - * - * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] - */ - function tryRecover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address, RecoverError, bytes32) { - unchecked { - bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); - // We do not check for an overflow here since the shift operation results in 0 or 1. - uint8 v = uint8((uint256(vs) >> 255) + 27); - return tryRecover(hash, v, r, s); - } - } - - /** - * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. - */ - function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { - (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); - _throwError(error, errorArg); - return recovered; - } - - /** - * @dev Overload of {ECDSA-tryRecover} that receives the `v`, - * `r` and `s` signature fields separately. - */ - function tryRecover( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) internal pure returns (address, RecoverError, bytes32) { - // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature - // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines - // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most - // signatures from current libraries generate a unique signature with an s-value in the lower half order. - // - // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value - // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or - // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept - // these malleable signatures as well. - if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { - return (address(0), RecoverError.InvalidSignatureS, s); - } - - // If the signature is valid (and not malleable), return the signer address - address signer = ecrecover(hash, v, r, s); - if (signer == address(0)) { - return (address(0), RecoverError.InvalidSignature, bytes32(0)); - } - - return (signer, RecoverError.NoError, bytes32(0)); - } - - /** - * @dev Overload of {ECDSA-recover} that receives the `v`, - * `r` and `s` signature fields separately. - */ - function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { - (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); - _throwError(error, errorArg); - return recovered; - } - - /** - * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. - */ - function _throwError(RecoverError error, bytes32 errorArg) private pure { - if (error == RecoverError.NoError) { - return; // no error: do nothing - } else if (error == RecoverError.InvalidSignature) { - revert ECDSAInvalidSignature(); - } else if (error == RecoverError.InvalidSignatureLength) { - revert ECDSAInvalidSignatureLength(uint256(errorArg)); - } else if (error == RecoverError.InvalidSignatureS) { - revert ECDSAInvalidSignatureS(errorArg); - } - } -} diff --git a/src/contracts/dependencies/solmate/ERC20.sol b/src/contracts/dependencies/solmate/ERC20.sol deleted file mode 100644 index 47d7b549..00000000 --- a/src/contracts/dependencies/solmate/ERC20.sol +++ /dev/null @@ -1,207 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only -pragma solidity >=0.8.0; - -import {ECDSA} from '../openzeppelin/contracts/ECDSA.sol'; - -/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. -/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) -/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) -/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. -abstract contract ERC20 { - bytes32 public constant PERMIT_TYPEHASH = - keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); - - /* ////////////////////////////////////////////////////////////// - EVENTS - ////////////////////////////////////////////////////////////// */ - - event Transfer(address indexed from, address indexed to, uint256 amount); - - event Approval(address indexed owner, address indexed spender, uint256 amount); - - /* ////////////////////////////////////////////////////////////// - METADATA STORAGE - ////////////////////////////////////////////////////////////// */ - - string public name; - - string public symbol; - - uint8 public decimals; - - /* ////////////////////////////////////////////////////////////// - ERC20 STORAGE - ////////////////////////////////////////////////////////////// */ - - uint256 public totalSupply; - - mapping(address => uint256) public balanceOf; - - mapping(address => mapping(address => uint256)) public allowance; - - /* ////////////////////////////////////////////////////////////// - EIP-2612 STORAGE - ////////////////////////////////////////////////////////////// */ - - mapping(address => uint256) public nonces; - - /* ////////////////////////////////////////////////////////////// - CONSTRUCTOR - ////////////////////////////////////////////////////////////// */ - - constructor(string memory _name, string memory _symbol, uint8 _decimals) { - name = _name; - symbol = _symbol; - decimals = _decimals; - } - - /* ////////////////////////////////////////////////////////////// - ERC20 LOGIC - ////////////////////////////////////////////////////////////// */ - - function approve(address spender, uint256 amount) public virtual returns (bool) { - allowance[msg.sender][spender] = amount; - - emit Approval(msg.sender, spender, amount); - - return true; - } - - function transfer(address to, uint256 amount) public virtual returns (bool) { - _beforeTokenTransfer(msg.sender, to, amount); - balanceOf[msg.sender] -= amount; - - // Cannot overflow because the sum of all user - // balances can't exceed the max uint256 value. - unchecked { - balanceOf[to] += amount; - } - - emit Transfer(msg.sender, to, amount); - - return true; - } - - function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { - _beforeTokenTransfer(from, to, amount); - uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. - - if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; - - balanceOf[from] -= amount; - - // Cannot overflow because the sum of all user - // balances can't exceed the max uint256 value. - unchecked { - balanceOf[to] += amount; - } - - emit Transfer(from, to, amount); - - return true; - } - - /* ////////////////////////////////////////////////////////////// - EIP-2612 LOGIC - ////////////////////////////////////////////////////////////// */ - - function permit( - address owner, - address spender, - uint256 value, - uint256 deadline, - uint8 v, - bytes32 r, - bytes32 s - ) public virtual { - require(deadline >= block.timestamp, 'PERMIT_DEADLINE_EXPIRED'); - - // Unchecked because the only math done is incrementing - // the owner's nonce which cannot realistically overflow. - unchecked { - address signer = ECDSA.recover( - keccak256( - abi.encodePacked( - '\x19\x01', - DOMAIN_SEPARATOR(), - keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) - ) - ), - v, - r, - s - ); - - require(signer == owner, 'INVALID_SIGNER'); - - allowance[signer][spender] = value; - } - - emit Approval(owner, spender, value); - } - - function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { - return computeDomainSeparator(); - } - - function computeDomainSeparator() internal view virtual returns (bytes32) { - return - keccak256( - abi.encode( - keccak256( - 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)' - ), - keccak256(bytes(name)), - keccak256('1'), - block.chainid, - address(this) - ) - ); - } - - /* ////////////////////////////////////////////////////////////// - INTERNAL MINT/BURN LOGIC - ////////////////////////////////////////////////////////////// */ - - function _mint(address to, uint256 amount) internal virtual { - _beforeTokenTransfer(address(0), to, amount); - totalSupply += amount; - - // Cannot overflow because the sum of all user - // balances can't exceed the max uint256 value. - unchecked { - balanceOf[to] += amount; - } - - emit Transfer(address(0), to, amount); - } - - function _burn(address from, uint256 amount) internal virtual { - _beforeTokenTransfer(from, address(0), amount); - balanceOf[from] -= amount; - - // Cannot underflow because a user's balance - // will never be larger than the total supply. - unchecked { - totalSupply -= amount; - } - - emit Transfer(from, address(0), amount); - } - - /** - * @dev Hook that is called before any transfer of tokens. This includes - * minting and burning. - * - * Calling conditions: - * - * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens - * will be to transferred to `to`. - * - when `from` is zero, `amount` tokens will be minted for `to`. - * - when `to` is zero, `amount` of ``from``'s tokens will be burned. - * - `from` and `to` are never both zero. - * - * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. - */ - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} -} diff --git a/src/contracts/extensions/static-a-token/README.md b/src/contracts/extensions/static-a-token/README.md deleted file mode 100644 index 9ced57a6..00000000 --- a/src/contracts/extensions/static-a-token/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# stataToken - Static aToken vault/wrapper - -

- -

- -## About - -The static-a-token contains an [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626) generic token vault/wrapper for all Aave v3 pools. - -## Features - -- **Full [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626) compatibility.** -- **Accounting for any potential liquidity mining rewards.** Let’s say some team of the Aave ecosystem (or the Aave community itself) decides to incentivize deposits of USDC on Aave v3 Ethereum. By holding `stataUSDC`, the user will still be eligible for those incentives. - It is important to highlight that while currently the wrapper supports infinite reward tokens by design (e.g. AAVE incentivizing stETH & Lido incentivizing stETH as well), each reward needs to be permissionlessly registered which bears some [⁽¹⁾](#limitations). -- **Meta-transactions support.** To enable interfaces to offer gas-less transactions to deposit/withdraw on the wrapper/Aave protocol (also supported on Aave v3). Including permit() for transfers of the `stataAToken` itself. -- **Upgradable by the Aave governance.** Similar to other contracts of the Aave ecosystem, the Level 1 executor (short executor) will be able to add new features to the deployed instances of the `stataTokens`. -- **Powered by a stataToken Factory.** Whenever a token will be listed on Aave v3, anybody will be able to call the stataToken Factory to deploy an instance for the new asset, permissionless, but still assuring the code used and permissions are properly configured without any extra headache. - -See [IStaticATokenLM.sol](./interfaces/IStaticATokenLM.sol) for detailed method documentation. - -## Deployed Addresses - -The staticATokenFactory is deployed for all major Aave v3 pools. -An up to date address can be fetched from the respective [address-book pool library](https://github.com/bgd-labs/aave-address-book/blob/main/src/AaveV3Ethereum.sol). - -## Limitations - -The `stataToken` is not natively integrated into the aave protocol and therefore cannot hook into the emissionManager. -This means a `reward` added **after** `statToken` creation needs to be registered manually on the token via the permissionless `refreshRewardTokens()` method. -As this process is not currently automated users might be missing out on rewards until the method is called. - -## Security procedures - -For this project, the security procedures applied/being finished are: - -- The test suite of the codebase itself. -- Certora audit/property checking for all the dynamics of the `stataToken`, including respecting all the specs of [EIP-4626](https://eips.ethereum.org/EIPS/eip-4626). diff --git a/src/contracts/extensions/static-a-token/StataOracle.sol b/src/contracts/extensions/static-a-token/StataOracle.sol deleted file mode 100644 index 50715593..00000000 --- a/src/contracts/extensions/static-a-token/StataOracle.sol +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IPool} from '../../interfaces/IPool.sol'; -import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; -import {IAaveOracle} from '../../interfaces/IAaveOracle.sol'; -import {IStataOracle} from './interfaces/IStataOracle.sol'; -import {IERC4626} from './interfaces/IERC4626.sol'; - -/** - * @title StataOracle - * @author BGD Labs - * @notice Contract to get asset prices of stata tokens - */ -contract StataOracle is IStataOracle { - /// @inheritdoc IStataOracle - IPool public immutable POOL; - /// @inheritdoc IStataOracle - IAaveOracle public immutable AAVE_ORACLE; - - constructor(IPoolAddressesProvider provider) { - POOL = IPool(provider.getPool()); - AAVE_ORACLE = IAaveOracle(provider.getPriceOracle()); - } - - /// @inheritdoc IStataOracle - function getAssetPrice(address asset) public view returns (uint256) { - address underlying = IERC4626(asset).asset(); - return - (AAVE_ORACLE.getAssetPrice(underlying) * POOL.getReserveNormalizedIncome(underlying)) / 1e27; - } - - /// @inheritdoc IStataOracle - function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory) { - uint256[] memory prices = new uint256[](assets.length); - for (uint256 i = 0; i < assets.length; i++) { - prices[i] = getAssetPrice(assets[i]); - } - return prices; - } -} diff --git a/src/contracts/extensions/static-a-token/StaticATokenErrors.sol b/src/contracts/extensions/static-a-token/StaticATokenErrors.sol deleted file mode 100644 index bec417df..00000000 --- a/src/contracts/extensions/static-a-token/StaticATokenErrors.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -library StaticATokenErrors { - string public constant INVALID_OWNER = '1'; - string public constant INVALID_EXPIRATION = '2'; - string public constant INVALID_SIGNATURE = '3'; - string public constant INVALID_DEPOSITOR = '4'; - string public constant INVALID_RECIPIENT = '5'; - string public constant INVALID_CLAIMER = '6'; - string public constant ONLY_ONE_AMOUNT_FORMAT_ALLOWED = '7'; - string public constant INVALID_ZERO_AMOUNT = '8'; - string public constant REWARD_NOT_INITIALIZED = '9'; -} diff --git a/src/contracts/extensions/static-a-token/StaticATokenFactory.sol b/src/contracts/extensions/static-a-token/StaticATokenFactory.sol deleted file mode 100644 index bf307197..00000000 --- a/src/contracts/extensions/static-a-token/StaticATokenFactory.sol +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IPool, DataTypes} from '../../interfaces/IPool.sol'; -import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; -import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol'; -import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; -import {StaticATokenLM} from './StaticATokenLM.sol'; -import {IStaticATokenFactory} from './interfaces/IStaticATokenFactory.sol'; - -/** - * @title StaticATokenFactory - * @notice Factory contract that keeps track of all deployed static aToken wrappers for a specified pool. - * This registry also acts as a factory, allowing to deploy new static aTokens on demand. - * There can only be one static aToken per underlying on the registry at a time. - * @author BGD labs - */ -contract StaticATokenFactory is Initializable, IStaticATokenFactory { - IPool public immutable POOL; - address public immutable ADMIN; - ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY; - address public immutable STATIC_A_TOKEN_IMPL; - - mapping(address => address) internal _underlyingToStaticAToken; - address[] internal _staticATokens; - - event StaticTokenCreated(address indexed staticAToken, address indexed underlying); - - constructor( - IPool pool, - address proxyAdmin, - ITransparentProxyFactory transparentProxyFactory, - address staticATokenImpl - ) { - POOL = pool; - ADMIN = proxyAdmin; - TRANSPARENT_PROXY_FACTORY = transparentProxyFactory; - STATIC_A_TOKEN_IMPL = staticATokenImpl; - } - - function initialize() external initializer {} - - ///@inheritdoc IStaticATokenFactory - function createStaticATokens(address[] memory underlyings) external returns (address[] memory) { - address[] memory staticATokens = new address[](underlyings.length); - for (uint256 i = 0; i < underlyings.length; i++) { - address cachedStaticAToken = _underlyingToStaticAToken[underlyings[i]]; - if (cachedStaticAToken == address(0)) { - DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(underlyings[i]); - require(reserveData.aTokenAddress != address(0), 'UNDERLYING_NOT_LISTED'); - bytes memory symbol = abi.encodePacked( - 'stat', - IERC20Metadata(reserveData.aTokenAddress).symbol() - ); - address staticAToken = TRANSPARENT_PROXY_FACTORY.createDeterministic( - STATIC_A_TOKEN_IMPL, - ADMIN, - abi.encodeWithSelector( - StaticATokenLM.initialize.selector, - reserveData.aTokenAddress, - string(abi.encodePacked('Static ', IERC20Metadata(reserveData.aTokenAddress).name())), - string(symbol) - ), - bytes32(uint256(uint160(underlyings[i]))) - ); - _underlyingToStaticAToken[underlyings[i]] = staticAToken; - staticATokens[i] = staticAToken; - _staticATokens.push(staticAToken); - emit StaticTokenCreated(staticAToken, underlyings[i]); - } else { - staticATokens[i] = cachedStaticAToken; - } - } - return staticATokens; - } - - ///@inheritdoc IStaticATokenFactory - function getStaticATokens() external view returns (address[] memory) { - return _staticATokens; - } - - ///@inheritdoc IStaticATokenFactory - function getStaticAToken(address underlying) external view returns (address) { - return _underlyingToStaticAToken[underlying]; - } -} diff --git a/src/contracts/extensions/static-a-token/StaticATokenLM.sol b/src/contracts/extensions/static-a-token/StaticATokenLM.sol deleted file mode 100644 index cb74ee88..00000000 --- a/src/contracts/extensions/static-a-token/StaticATokenLM.sol +++ /dev/null @@ -1,712 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IPool} from '../../interfaces/IPool.sol'; -import {DataTypes, ReserveConfiguration} from '../../protocol/libraries/configuration/ReserveConfiguration.sol'; -import {IRewardsController} from '../../rewards/interfaces/IRewardsController.sol'; -import {WadRayMath} from '../../protocol/libraries/math/WadRayMath.sol'; -import {MathUtils} from '../../protocol/libraries/math/MathUtils.sol'; -import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol'; -import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; -import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; -import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; -import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; -import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IERC20WithPermit.sol'; - -import {IStaticATokenLM} from './interfaces/IStaticATokenLM.sol'; -import {IAToken} from './interfaces/IAToken.sol'; -import {ERC20} from '../../dependencies/solmate/ERC20.sol'; -import {IInitializableStaticATokenLM} from './interfaces/IInitializableStaticATokenLM.sol'; -import {StaticATokenErrors} from './StaticATokenErrors.sol'; -import {RayMathExplicitRounding, Rounding} from '../../misc/libraries/RayMathExplicitRounding.sol'; -import {IERC4626} from './interfaces/IERC4626.sol'; - -/** - * @title StaticATokenLM - * @notice Wrapper smart contract that allows to deposit tokens on the Aave protocol and receive - * a token which balance doesn't increase automatically, but uses an ever-increasing exchange rate. - * It supports claiming liquidity mining rewards from the Aave system. - * @author BGD labs - */ -contract StaticATokenLM is - Initializable, - ERC20('STATIC__aToken_IMPL', 'STATIC__aToken_IMPL', 18), - IStaticATokenLM, - IERC4626 -{ - using SafeERC20 for IERC20; - using SafeCast for uint256; - using WadRayMath for uint256; - using RayMathExplicitRounding for uint256; - - bytes32 public constant METADEPOSIT_TYPEHASH = - keccak256( - 'Deposit(address depositor,address receiver,uint256 assets,uint16 referralCode,bool depositToAave,uint256 nonce,uint256 deadline,PermitParams permit)' - ); - bytes32 public constant METAWITHDRAWAL_TYPEHASH = - keccak256( - 'Withdraw(address owner,address receiver,uint256 shares,uint256 assets,bool withdrawFromAave,uint256 nonce,uint256 deadline)' - ); - - uint256 public constant STATIC__ATOKEN_LM_REVISION = 2; - - IPool public immutable POOL; - IRewardsController public immutable INCENTIVES_CONTROLLER; - - IERC20 internal _aToken; - address internal _aTokenUnderlying; - address[] internal _rewardTokens; - mapping(address => RewardIndexCache) internal _startIndex; - mapping(address => mapping(address => UserRewardsData)) internal _userRewardsData; - - constructor(IPool pool, IRewardsController rewardsController) { - POOL = pool; - INCENTIVES_CONTROLLER = rewardsController; - } - - ///@inheritdoc IInitializableStaticATokenLM - function initialize( - address newAToken, - string calldata staticATokenName, - string calldata staticATokenSymbol - ) external initializer { - require(IAToken(newAToken).POOL() == address(POOL)); - _aToken = IERC20(newAToken); - - name = staticATokenName; - symbol = staticATokenSymbol; - decimals = IERC20Metadata(newAToken).decimals(); - - _aTokenUnderlying = IAToken(newAToken).UNDERLYING_ASSET_ADDRESS(); - IERC20(_aTokenUnderlying).forceApprove(address(POOL), type(uint256).max); - - if (INCENTIVES_CONTROLLER != IRewardsController(address(0))) { - refreshRewardTokens(); - } - - emit Initialized(newAToken, staticATokenName, staticATokenSymbol); - } - - ///@inheritdoc IStaticATokenLM - function refreshRewardTokens() public override { - address[] memory rewards = INCENTIVES_CONTROLLER.getRewardsByAsset(address(_aToken)); - for (uint256 i = 0; i < rewards.length; i++) { - _registerRewardToken(rewards[i]); - } - } - - ///@inheritdoc IStaticATokenLM - function isRegisteredRewardToken(address reward) public view override returns (bool) { - return _startIndex[reward].isRegistered; - } - - ///@inheritdoc IStaticATokenLM - function deposit( - uint256 assets, - address receiver, - uint16 referralCode, - bool depositToAave - ) external returns (uint256) { - (uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, referralCode, depositToAave); - return shares; - } - - ///@inheritdoc IStaticATokenLM - function metaDeposit( - address depositor, - address receiver, - uint256 assets, - uint16 referralCode, - bool depositToAave, - uint256 deadline, - PermitParams calldata permit, - SignatureParams calldata sigParams - ) external returns (uint256) { - require(depositor != address(0), StaticATokenErrors.INVALID_DEPOSITOR); - //solium-disable-next-line - require(deadline >= block.timestamp, StaticATokenErrors.INVALID_EXPIRATION); - uint256 nonce = nonces[depositor]; - - // Unchecked because the only math done is incrementing - // the owner's nonce which cannot realistically overflow. - unchecked { - bytes32 digest = keccak256( - abi.encodePacked( - '\x19\x01', - DOMAIN_SEPARATOR(), - keccak256( - abi.encode( - METADEPOSIT_TYPEHASH, - depositor, - receiver, - assets, - referralCode, - depositToAave, - nonce, - deadline, - permit - ) - ) - ) - ); - nonces[depositor] = nonce + 1; - require( - depositor == ecrecover(digest, sigParams.v, sigParams.r, sigParams.s), - StaticATokenErrors.INVALID_SIGNATURE - ); - } - // assume if deadline 0 no permit was supplied - if (permit.deadline != 0) { - try - IERC20WithPermit(depositToAave ? address(_aTokenUnderlying) : address(_aToken)).permit( - depositor, - address(this), - permit.value, - permit.deadline, - permit.v, - permit.r, - permit.s - ) - {} catch {} - } - (uint256 shares, ) = _deposit(depositor, receiver, 0, assets, referralCode, depositToAave); - return shares; - } - - ///@inheritdoc IStaticATokenLM - function metaWithdraw( - address owner, - address receiver, - uint256 shares, - uint256 assets, - bool withdrawFromAave, - uint256 deadline, - SignatureParams calldata sigParams - ) external returns (uint256, uint256) { - require(owner != address(0), StaticATokenErrors.INVALID_OWNER); - //solium-disable-next-line - require(deadline >= block.timestamp, StaticATokenErrors.INVALID_EXPIRATION); - uint256 nonce = nonces[owner]; - // Unchecked because the only math done is incrementing - // the owner's nonce which cannot realistically overflow. - unchecked { - bytes32 digest = keccak256( - abi.encodePacked( - '\x19\x01', - DOMAIN_SEPARATOR(), - keccak256( - abi.encode( - METAWITHDRAWAL_TYPEHASH, - owner, - receiver, - shares, - assets, - withdrawFromAave, - nonce, - deadline - ) - ) - ) - ); - nonces[owner] = nonce + 1; - require( - owner == ecrecover(digest, sigParams.v, sigParams.r, sigParams.s), - StaticATokenErrors.INVALID_SIGNATURE - ); - } - return _withdraw(owner, receiver, shares, assets, withdrawFromAave); - } - - ///@inheritdoc IERC4626 - function previewRedeem(uint256 shares) public view virtual returns (uint256) { - return _convertToAssets(shares, Rounding.DOWN); - } - - ///@inheritdoc IERC4626 - function previewMint(uint256 shares) public view virtual returns (uint256) { - return _convertToAssets(shares, Rounding.UP); - } - - ///@inheritdoc IERC4626 - function previewWithdraw(uint256 assets) public view virtual returns (uint256) { - return _convertToShares(assets, Rounding.UP); - } - - ///@inheritdoc IERC4626 - function previewDeposit(uint256 assets) public view virtual returns (uint256) { - return _convertToShares(assets, Rounding.DOWN); - } - - ///@inheritdoc IStaticATokenLM - function rate() public view returns (uint256) { - return POOL.getReserveNormalizedIncome(_aTokenUnderlying); - } - - ///@inheritdoc IStaticATokenLM - function collectAndUpdateRewards(address reward) public returns (uint256) { - if (reward == address(0)) { - return 0; - } - - address[] memory assets = new address[](1); - assets[0] = address(_aToken); - - return INCENTIVES_CONTROLLER.claimRewards(assets, type(uint256).max, address(this), reward); - } - - ///@inheritdoc IStaticATokenLM - function claimRewardsOnBehalf( - address onBehalfOf, - address receiver, - address[] memory rewards - ) external { - require( - msg.sender == onBehalfOf || msg.sender == INCENTIVES_CONTROLLER.getClaimer(onBehalfOf), - StaticATokenErrors.INVALID_CLAIMER - ); - _claimRewardsOnBehalf(onBehalfOf, receiver, rewards); - } - - ///@inheritdoc IStaticATokenLM - function claimRewards(address receiver, address[] memory rewards) external { - _claimRewardsOnBehalf(msg.sender, receiver, rewards); - } - - ///@inheritdoc IStaticATokenLM - function claimRewardsToSelf(address[] memory rewards) external { - _claimRewardsOnBehalf(msg.sender, msg.sender, rewards); - } - - ///@inheritdoc IStaticATokenLM - function getCurrentRewardsIndex(address reward) public view returns (uint256) { - if (address(reward) == address(0)) { - return 0; - } - (, uint256 nextIndex) = INCENTIVES_CONTROLLER.getAssetIndex(address(_aToken), reward); - return nextIndex; - } - - ///@inheritdoc IStaticATokenLM - function getTotalClaimableRewards(address reward) external view returns (uint256) { - if (reward == address(0)) { - return 0; - } - - address[] memory assets = new address[](1); - assets[0] = address(_aToken); - uint256 freshRewards = INCENTIVES_CONTROLLER.getUserRewards(assets, address(this), reward); - return IERC20(reward).balanceOf(address(this)) + freshRewards; - } - - ///@inheritdoc IStaticATokenLM - function getClaimableRewards(address user, address reward) external view returns (uint256) { - return _getClaimableRewards(user, reward, balanceOf[user], getCurrentRewardsIndex(reward)); - } - - ///@inheritdoc IStaticATokenLM - function getUnclaimedRewards(address user, address reward) external view returns (uint256) { - return _userRewardsData[user][reward].unclaimedRewards; - } - - ///@inheritdoc IERC4626 - function asset() external view returns (address) { - return address(_aTokenUnderlying); - } - - ///@inheritdoc IStaticATokenLM - function aToken() external view returns (IERC20) { - return _aToken; - } - - ///@inheritdoc IStaticATokenLM - function rewardTokens() external view returns (address[] memory) { - return _rewardTokens; - } - - ///@inheritdoc IERC4626 - function totalAssets() external view returns (uint256) { - return _aToken.balanceOf(address(this)); - } - - ///@inheritdoc IERC4626 - function convertToShares(uint256 assets) external view returns (uint256) { - return _convertToShares(assets, Rounding.DOWN); - } - - ///@inheritdoc IERC4626 - function convertToAssets(uint256 shares) external view returns (uint256) { - return _convertToAssets(shares, Rounding.DOWN); - } - - ///@inheritdoc IERC4626 - function maxMint(address) public view virtual returns (uint256) { - uint256 assets = maxDeposit(address(0)); - if (assets == type(uint256).max) return type(uint256).max; - return _convertToShares(assets, Rounding.DOWN); - } - - ///@inheritdoc IERC4626 - function maxWithdraw(address owner) public view virtual returns (uint256) { - uint256 shares = maxRedeem(owner); - return _convertToAssets(shares, Rounding.DOWN); - } - - ///@inheritdoc IERC4626 - function maxRedeem(address owner) public view virtual returns (uint256) { - address cachedATokenUnderlying = _aTokenUnderlying; - DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(cachedATokenUnderlying); - - // if paused or inactive users cannot withdraw underlying - if ( - !ReserveConfiguration.getActive(reserveData.configuration) || - ReserveConfiguration.getPaused(reserveData.configuration) - ) { - return 0; - } - - // otherwise users can withdraw up to the available amount - uint256 underlyingTokenBalanceInShares = _convertToShares( - IERC20(cachedATokenUnderlying).balanceOf(reserveData.aTokenAddress), - Rounding.DOWN - ); - uint256 cachedUserBalance = balanceOf[owner]; - return - underlyingTokenBalanceInShares >= cachedUserBalance - ? cachedUserBalance - : underlyingTokenBalanceInShares; - } - - ///@inheritdoc IERC4626 - function maxDeposit(address) public view virtual returns (uint256) { - DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(_aTokenUnderlying); - - // if inactive, paused or frozen users cannot deposit underlying - if ( - !ReserveConfiguration.getActive(reserveData.configuration) || - ReserveConfiguration.getPaused(reserveData.configuration) || - ReserveConfiguration.getFrozen(reserveData.configuration) - ) { - return 0; - } - - uint256 supplyCap = ReserveConfiguration.getSupplyCap(reserveData.configuration) * - (10 ** ReserveConfiguration.getDecimals(reserveData.configuration)); - // if no supply cap deposit is unlimited - if (supplyCap == 0) return type(uint256).max; - // return remaining supply cap margin - uint256 currentSupply = (IAToken(reserveData.aTokenAddress).scaledTotalSupply() + - reserveData.accruedToTreasury).rayMulRoundUp(_getNormalizedIncome(reserveData)); - return currentSupply > supplyCap ? 0 : supplyCap - currentSupply; - } - - ///@inheritdoc IERC4626 - function deposit(uint256 assets, address receiver) external virtual returns (uint256) { - (uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, 0, true); - return shares; - } - - ///@inheritdoc IERC4626 - function mint(uint256 shares, address receiver) external virtual returns (uint256) { - (, uint256 assets) = _deposit(msg.sender, receiver, shares, 0, 0, true); - - return assets; - } - - ///@inheritdoc IERC4626 - function withdraw( - uint256 assets, - address receiver, - address owner - ) external virtual returns (uint256) { - (uint256 shares, ) = _withdraw(owner, receiver, 0, assets, true); - - return shares; - } - - ///@inheritdoc IERC4626 - function redeem( - uint256 shares, - address receiver, - address owner - ) external virtual returns (uint256) { - (, uint256 assets) = _withdraw(owner, receiver, shares, 0, true); - - return assets; - } - - ///@inheritdoc IStaticATokenLM - function redeem( - uint256 shares, - address receiver, - address owner, - bool withdrawFromAave - ) external virtual returns (uint256, uint256) { - return _withdraw(owner, receiver, shares, 0, withdrawFromAave); - } - - function _deposit( - address depositor, - address receiver, - uint256 _shares, - uint256 _assets, - uint16 referralCode, - bool depositToAave - ) internal returns (uint256, uint256) { - require(receiver != address(0), StaticATokenErrors.INVALID_RECIPIENT); - require(_shares == 0 || _assets == 0, StaticATokenErrors.ONLY_ONE_AMOUNT_FORMAT_ALLOWED); - - uint256 assets = _assets; - uint256 shares = _shares; - if (shares > 0) { - if (depositToAave) { - require(shares <= maxMint(receiver), 'ERC4626: mint more than max'); - } - assets = previewMint(shares); - } else { - if (depositToAave) { - require(assets <= maxDeposit(receiver), 'ERC4626: deposit more than max'); - } - shares = previewDeposit(assets); - } - require(shares != 0, StaticATokenErrors.INVALID_ZERO_AMOUNT); - - if (depositToAave) { - address cachedATokenUnderlying = _aTokenUnderlying; - IERC20(cachedATokenUnderlying).safeTransferFrom(depositor, address(this), assets); - POOL.deposit(cachedATokenUnderlying, assets, address(this), referralCode); - } else { - _aToken.safeTransferFrom(depositor, address(this), assets); - } - - _mint(receiver, shares); - - emit Deposit(depositor, receiver, assets, shares); - - return (shares, assets); - } - - function _withdraw( - address owner, - address receiver, - uint256 _shares, - uint256 _assets, - bool withdrawFromAave - ) internal returns (uint256, uint256) { - require(receiver != address(0), StaticATokenErrors.INVALID_RECIPIENT); - require(_shares == 0 || _assets == 0, StaticATokenErrors.ONLY_ONE_AMOUNT_FORMAT_ALLOWED); - require(_shares != _assets, StaticATokenErrors.INVALID_ZERO_AMOUNT); - - uint256 assets = _assets; - uint256 shares = _shares; - - if (shares > 0) { - if (withdrawFromAave) { - require(shares <= maxRedeem(owner), 'ERC4626: redeem more than max'); - } - assets = previewRedeem(shares); - } else { - if (withdrawFromAave) { - require(assets <= maxWithdraw(owner), 'ERC4626: withdraw more than max'); - } - shares = previewWithdraw(assets); - } - - if (msg.sender != owner) { - uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. - - if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; - } - - _burn(owner, shares); - - emit Withdraw(msg.sender, receiver, owner, assets, shares); - - if (withdrawFromAave) { - POOL.withdraw(_aTokenUnderlying, assets, receiver); - } else { - _aToken.safeTransfer(receiver, assets); - } - - return (shares, assets); - } - - /** - * @notice Updates rewards for senders and receiver in a transfer (not updating rewards for address(0)) - * @param from The address of the sender of tokens - * @param to The address of the receiver of tokens - */ - function _beforeTokenTransfer(address from, address to, uint256) internal override { - for (uint256 i = 0; i < _rewardTokens.length; i++) { - address rewardToken = address(_rewardTokens[i]); - uint256 rewardsIndex = getCurrentRewardsIndex(rewardToken); - if (from != address(0)) { - _updateUser(from, rewardsIndex, rewardToken); - } - if (to != address(0) && from != to) { - _updateUser(to, rewardsIndex, rewardToken); - } - } - } - - /** - * @notice Adding the pending rewards to the unclaimed for specific user and updating user index - * @param user The address of the user to update - * @param currentRewardsIndex The current rewardIndex - * @param rewardToken The address of the reward token - */ - function _updateUser(address user, uint256 currentRewardsIndex, address rewardToken) internal { - uint256 balance = balanceOf[user]; - if (balance > 0) { - _userRewardsData[user][rewardToken].unclaimedRewards = _getClaimableRewards( - user, - rewardToken, - balance, - currentRewardsIndex - ).toUint128(); - } - _userRewardsData[user][rewardToken].rewardsIndexOnLastInteraction = currentRewardsIndex - .toUint128(); - } - - /** - * @notice Compute the pending in WAD. Pending is the amount to add (not yet unclaimed) rewards in WAD. - * @param balance The balance of the user - * @param rewardsIndexOnLastInteraction The index which was on the last interaction of the user - * @param currentRewardsIndex The current rewards index in the system - * @param assetUnit One unit of asset (10**decimals) - * @return The amount of pending rewards in WAD - */ - function _getPendingRewards( - uint256 balance, - uint256 rewardsIndexOnLastInteraction, - uint256 currentRewardsIndex, - uint256 assetUnit - ) internal pure returns (uint256) { - if (balance == 0) { - return 0; - } - return (balance * (currentRewardsIndex - rewardsIndexOnLastInteraction)) / assetUnit; - } - - /** - * @notice Compute the claimable rewards for a user - * @param user The address of the user - * @param reward The address of the reward - * @param balance The balance of the user in WAD - * @param currentRewardsIndex The current rewards index - * @return The total rewards that can be claimed by the user (if `fresh` flag true, after updating rewards) - */ - function _getClaimableRewards( - address user, - address reward, - uint256 balance, - uint256 currentRewardsIndex - ) internal view returns (uint256) { - RewardIndexCache memory rewardsIndexCache = _startIndex[reward]; - require(rewardsIndexCache.isRegistered == true, StaticATokenErrors.REWARD_NOT_INITIALIZED); - UserRewardsData memory currentUserRewardsData = _userRewardsData[user][reward]; - uint256 assetUnit = 10 ** decimals; - return - currentUserRewardsData.unclaimedRewards + - _getPendingRewards( - balance, - currentUserRewardsData.rewardsIndexOnLastInteraction == 0 - ? rewardsIndexCache.lastUpdatedIndex - : currentUserRewardsData.rewardsIndexOnLastInteraction, - currentRewardsIndex, - assetUnit - ); - } - - /** - * @notice Claim rewards on behalf of a user and send them to a receiver - * @param onBehalfOf The address to claim on behalf of - * @param rewards The addresses of the rewards - * @param receiver The address to receive the rewards - */ - function _claimRewardsOnBehalf( - address onBehalfOf, - address receiver, - address[] memory rewards - ) internal { - for (uint256 i = 0; i < rewards.length; i++) { - if (address(rewards[i]) == address(0)) { - continue; - } - uint256 currentRewardsIndex = getCurrentRewardsIndex(rewards[i]); - uint256 balance = balanceOf[onBehalfOf]; - uint256 userReward = _getClaimableRewards( - onBehalfOf, - rewards[i], - balance, - currentRewardsIndex - ); - uint256 totalRewardTokenBalance = IERC20(rewards[i]).balanceOf(address(this)); - uint256 unclaimedReward = 0; - - if (userReward > totalRewardTokenBalance) { - totalRewardTokenBalance += collectAndUpdateRewards(address(rewards[i])); - } - - if (userReward > totalRewardTokenBalance) { - unclaimedReward = userReward - totalRewardTokenBalance; - userReward = totalRewardTokenBalance; - } - if (userReward > 0) { - _userRewardsData[onBehalfOf][rewards[i]].unclaimedRewards = unclaimedReward.toUint128(); - _userRewardsData[onBehalfOf][rewards[i]].rewardsIndexOnLastInteraction = currentRewardsIndex - .toUint128(); - IERC20(rewards[i]).safeTransfer(receiver, userReward); - } - } - } - - function _convertToShares(uint256 assets, Rounding rounding) internal view returns (uint256) { - if (rounding == Rounding.UP) return assets.rayDivRoundUp(rate()); - return assets.rayDivRoundDown(rate()); - } - - function _convertToAssets(uint256 shares, Rounding rounding) internal view returns (uint256) { - if (rounding == Rounding.UP) return shares.rayMulRoundUp(rate()); - return shares.rayMulRoundDown(rate()); - } - - /** - * @notice Initializes a new rewardToken - * @param reward The reward token to be registered - */ - function _registerRewardToken(address reward) internal { - if (isRegisteredRewardToken(reward)) return; - uint256 startIndex = getCurrentRewardsIndex(reward); - - _rewardTokens.push(reward); - _startIndex[reward] = RewardIndexCache(true, startIndex.toUint240()); - - emit RewardTokenRegistered(reward, startIndex); - } - - /** - * Copy of https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ReserveLogic.sol#L47 with memory instead of calldata - * @notice Returns the ongoing normalized income for the reserve. - * @dev A value of 1e27 means there is no income. As time passes, the income is accrued - * @dev A value of 2*1e27 means for each unit of asset one unit of income has been accrued - * @param reserve The reserve object - * @return The normalized income, expressed in ray - */ - function _getNormalizedIncome( - DataTypes.ReserveDataLegacy memory reserve - ) internal view returns (uint256) { - uint40 timestamp = reserve.lastUpdateTimestamp; - - //solium-disable-next-line - if (timestamp == block.timestamp) { - //if the index was updated in the same block, no need to perform any calculation - return reserve.liquidityIndex; - } else { - return - MathUtils.calculateLinearInterest(reserve.currentLiquidityRate, timestamp).rayMul( - reserve.liquidityIndex - ); - } - } -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IAToken.sol b/src/contracts/extensions/static-a-token/interfaces/IAToken.sol deleted file mode 100644 index 31e9a805..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IAToken.sol +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -interface IAToken { - function POOL() external view returns (address); - - function getIncentivesController() external view returns (address); - - function UNDERLYING_ASSET_ADDRESS() external view returns (address); - - /** - * @notice Returns the scaled total supply of the scaled balance token. Represents sum(debt/index) - * @return The scaled total supply - */ - function scaledTotalSupply() external view returns (uint256); -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol b/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol deleted file mode 100644 index 08f14f90..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol +++ /dev/null @@ -1,241 +0,0 @@ -// SPDX-License-Identifier: MIT -// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol) - -pragma solidity ^0.8.10; - -/** - * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in - * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. - * - * _Available since v4.7._ - */ -interface IERC4626 { - event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); - - event Withdraw( - address indexed sender, - address indexed receiver, - address indexed owner, - uint256 assets, - uint256 shares - ); - - /** - * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. - * - * - MUST be an ERC-20 token contract. - * - MUST NOT revert. - */ - function asset() external view returns (address assetTokenAddress); - - /** - * @dev Returns the total amount of the underlying asset that is “managed” by Vault. - * - * - SHOULD include any compounding that occurs from yield. - * - MUST be inclusive of any fees that are charged against assets in the Vault. - * - MUST NOT revert. - */ - function totalAssets() external view returns (uint256 totalManagedAssets); - - /** - * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal - * scenario where all the conditions are met. - * - * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. - * - MUST NOT show any variations depending on the caller. - * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. - * - MUST NOT revert. - * - * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the - * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and - * from. - */ - function convertToShares(uint256 assets) external view returns (uint256 shares); - - /** - * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal - * scenario where all the conditions are met. - * - * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. - * - MUST NOT show any variations depending on the caller. - * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. - * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. - * - * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the - * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and - * from. - */ - function convertToAssets(uint256 shares) external view returns (uint256 assets); - - /** - * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, - * through a deposit call. - * While deposit of aToken is not affected by aave pool configrations, deposit of the aTokenUnderlying will need to deposit to aave - * so it is affected by current aave pool configuration. - * Reference: https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ValidationLogic.sol#L57 - * - MUST return a limited value if receiver is subject to some deposit limit. - * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. - * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. - */ - function maxDeposit(address receiver) external view returns (uint256 maxAssets); - - /** - * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given - * current on-chain conditions. - * - * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit - * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called - * in the same transaction. - * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the - * deposit would be accepted, regardless if the user has enough tokens approved, etc. - * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. - * - MUST NOT revert. - * - * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in - * share price or some other type of condition, meaning the depositor will lose assets by depositing. - */ - function previewDeposit(uint256 assets) external view returns (uint256 shares); - - /** - * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. - * - * - MUST emit the Deposit event. - * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the - * deposit execution, and are accounted for during deposit. - * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not - * approving enough underlying tokens to the Vault contract, etc). - * - * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - */ - function deposit(uint256 assets, address receiver) external returns (uint256 shares); - - /** - * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. - * - MUST return a limited value if receiver is subject to some mint limit. - * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. - * - MUST NOT revert. - */ - function maxMint(address receiver) external view returns (uint256 maxShares); - - /** - * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given - * current on-chain conditions. - * - * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call - * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the - * same transaction. - * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint - * would be accepted, regardless if the user has enough tokens approved, etc. - * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. - * - MUST NOT revert. - * - * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in - * share price or some other type of condition, meaning the depositor will lose assets by minting. - */ - function previewMint(uint256 shares) external view returns (uint256 assets); - - /** - * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. - * - * - MUST emit the Deposit event. - * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint - * execution, and are accounted for during mint. - * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not - * approving enough underlying tokens to the Vault contract, etc). - * - * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - */ - function mint(uint256 shares, address receiver) external returns (uint256 assets); - - /** - * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the - * Vault, through a withdraw call. - * - * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - * - MUST NOT revert. - */ - function maxWithdraw(address owner) external view returns (uint256 maxAssets); - - /** - * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, - * given current on-chain conditions. - * - * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw - * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if - * called - * in the same transaction. - * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though - * the withdrawal would be accepted, regardless if the user has enough shares, etc. - * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. - * - MUST NOT revert. - * - * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in - * share price or some other type of condition, meaning the depositor will lose assets by depositing. - */ - function previewWithdraw(uint256 assets) external view returns (uint256 shares); - - /** - * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. - * - * - MUST emit the Withdraw event. - * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the - * withdraw execution, and are accounted for during withdraw. - * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner - * not having enough shares, etc). - * - * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. - * Those methods should be performed separately. - */ - function withdraw( - uint256 assets, - address receiver, - address owner - ) external returns (uint256 shares); - - /** - * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, - * through a redeem call to the aToken underlying. - * While redeem of aToken is not affected by aave pool configrations, redeeming of the aTokenUnderlying will need to redeem from aave - * so it is affected by current aave pool configuration. - * Reference: https://github.com/aave/aave-v3-core/blob/29ff9b9f89af7cd8255231bc5faf26c3ce0fb7ce/contracts/protocol/libraries/logic/ValidationLogic.sol#L87 - * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. - * - MUST NOT revert. - */ - function maxRedeem(address owner) external view returns (uint256 maxShares); - - /** - * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, - * given current on-chain conditions. - * - * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call - * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the - * same transaction. - * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the - * redemption would be accepted, regardless if the user has enough shares, etc. - * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. - * - MUST NOT revert. - * - * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in - * share price or some other type of condition, meaning the depositor will lose assets by redeeming. - */ - function previewRedeem(uint256 shares) external view returns (uint256 assets); - - /** - * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. - * - * - MUST emit the Withdraw event. - * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the - * redeem execution, and are accounted for during redeem. - * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner - * not having enough shares, etc). - * - * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. - * Those methods should be performed separately. - */ - function redeem( - uint256 shares, - address receiver, - address owner - ) external returns (uint256 assets); -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol deleted file mode 100644 index 586a935a..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -import {IPool} from '../../../interfaces/IPool.sol'; -import {IAaveIncentivesController} from '../../../interfaces/IAaveIncentivesController.sol'; - -/** - * @title IInitializableStaticATokenLM - * @notice Interface for the initialize function on StaticATokenLM - * @author Aave - **/ -interface IInitializableStaticATokenLM { - /** - * @dev Emitted when a StaticATokenLM is initialized - * @param aToken The address of the underlying aToken (aWETH) - * @param staticATokenName The name of the Static aToken - * @param staticATokenSymbol The symbol of the Static aToken - **/ - event Initialized(address indexed aToken, string staticATokenName, string staticATokenSymbol); - - /** - * @dev Initializes the StaticATokenLM - * @param aToken The address of the underlying aToken (aWETH) - * @param staticATokenName The name of the Static aToken - * @param staticATokenSymbol The symbol of the Static aToken - */ - function initialize( - address aToken, - string calldata staticATokenName, - string calldata staticATokenSymbol - ) external; -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol b/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol deleted file mode 100644 index d08f2a29..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -import {IPool} from '../../../interfaces/IPool.sol'; -import {IAaveOracle} from '../../../interfaces/IAaveOracle.sol'; - -interface IStataOracle { - /** - * @return The pool used for fetching the rate on the aggregator oracle - */ - function POOL() external view returns (IPool); - - /** - * @return The aave oracle used for fetching the price of the underlying - */ - function AAVE_ORACLE() external view returns (IAaveOracle); - - /** - * @notice Returns the prices of an asset address - * @param asset The asset address - * @return The prices of the given asset - */ - function getAssetPrice(address asset) external view returns (uint256); - - /** - * @notice Returns a list of prices from a list of assets addresses - * @param assets The list of assets addresses - * @return The prices of the given assets - */ - function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory); -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol deleted file mode 100644 index 7532e92c..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -interface IStaticATokenFactory { - /** - * @notice Creates new staticATokens - * @param underlyings the addresses of the underlyings to create. - * @return address[] addresses of the new staticATokens. - */ - function createStaticATokens(address[] memory underlyings) external returns (address[] memory); - - /** - * @notice Returns all tokens deployed via this registry. - * @return address[] list of tokens - */ - function getStaticATokens() external view returns (address[] memory); - - /** - * @notice Returns the staticAToken for a given underlying. - * @param underlying the address of the underlying. - * @return address the staticAToken address. - */ - function getStaticAToken(address underlying) external view returns (address); -} diff --git a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol deleted file mode 100644 index eed469f3..00000000 --- a/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol +++ /dev/null @@ -1,214 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; -import {IInitializableStaticATokenLM} from './IInitializableStaticATokenLM.sol'; - -interface IStaticATokenLM is IInitializableStaticATokenLM { - struct SignatureParams { - uint8 v; - bytes32 r; - bytes32 s; - } - - struct PermitParams { - address owner; - address spender; - uint256 value; - uint256 deadline; - uint8 v; - bytes32 r; - bytes32 s; - } - - struct UserRewardsData { - uint128 rewardsIndexOnLastInteraction; // (in RAYs) - uint128 unclaimedRewards; // (in RAYs) - } - - struct RewardIndexCache { - bool isRegistered; - uint248 lastUpdatedIndex; - } - - event RewardTokenRegistered(address indexed reward, uint256 startIndex); - - /** - * @notice Burns `amount` of static aToken, with receiver receiving the corresponding amount of `ASSET` - * @param shares The amount to withdraw, in static balance of StaticAToken - * @param receiver The address that will receive the amount of `ASSET` withdrawn from the Aave protocol - * @param withdrawFromAave bool - * - `true` for the receiver to get underlying tokens (e.g. USDC) - * - `false` for the receiver to get aTokens (e.g. aUSDC) - * @return amountToBurn: StaticATokens burnt, static balance - * @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance - **/ - function redeem( - uint256 shares, - address receiver, - address owner, - bool withdrawFromAave - ) external returns (uint256, uint256); - - /** - * @notice Deposits `ASSET` in the Aave protocol and mints static aTokens to msg.sender - * @param assets The amount of underlying `ASSET` to deposit (e.g. deposit of 100 USDC) - * @param receiver The address that will receive the static aTokens - * @param referralCode Code used to register the integrator originating the operation, for potential rewards. - * 0 if the action is executed directly by the user, without any middle-man - * @param depositToAave bool - * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) - * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) - * @return uint256 The amount of StaticAToken minted, static balance - **/ - function deposit( - uint256 assets, - address receiver, - uint16 referralCode, - bool depositToAave - ) external returns (uint256); - - /** - * @notice Allows to deposit on Aave via meta-transaction - * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md - * @param depositor Address from which the funds to deposit are going to be pulled - * @param receiver Address that will receive the staticATokens, in the average case, same as the `depositor` - * @param assets The amount to deposit - * @param referralCode Code used to register the integrator originating the operation, for potential rewards. - * 0 if the action is executed directly by the user, without any middle-man - * @param depositToAave bool - * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) - * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) - * @param deadline The deadline timestamp, type(uint256).max for max deadline - * @param sigParams Signature params: v,r,s - * @return uint256 The amount of StaticAToken minted, static balance - */ - function metaDeposit( - address depositor, - address receiver, - uint256 assets, - uint16 referralCode, - bool depositToAave, - uint256 deadline, - PermitParams calldata permit, - SignatureParams calldata sigParams - ) external returns (uint256); - - /** - * @notice Allows to withdraw from Aave via meta-transaction - * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md - * @param owner Address owning the staticATokens - * @param receiver Address that will receive the underlying withdrawn from Aave - * @param shares The amount of staticAToken to withdraw. If > 0, `assets` needs to be 0 - * @param assets The amount of underlying/aToken to withdraw. If > 0, `shares` needs to be 0 - * @param withdrawFromAave bool - * - `true` for the receiver to get underlying tokens (e.g. USDC) - * - `false` for the receiver to get aTokens (e.g. aUSDC) - * @param deadline The deadline timestamp, type(uint256).max for max deadline - * @param sigParams Signature params: v,r,s - * @return amountToBurn: StaticATokens burnt, static balance - * @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance - */ - function metaWithdraw( - address owner, - address receiver, - uint256 shares, - uint256 assets, - bool withdrawFromAave, - uint256 deadline, - SignatureParams calldata sigParams - ) external returns (uint256, uint256); - - /** - * @notice Returns the Aave liquidity index of the underlying aToken, denominated rate here - * as it can be considered as an ever-increasing exchange rate - * @return The liquidity index - **/ - function rate() external view returns (uint256); - - /** - * @notice Claims rewards from `INCENTIVES_CONTROLLER` and updates internal accounting of rewards. - * @param reward The reward to claim - * @return uint256 Amount collected - */ - function collectAndUpdateRewards(address reward) external returns (uint256); - - /** - * @notice Claim rewards on behalf of a user and send them to a receiver - * @dev Only callable by if sender is onBehalfOf or sender is approved claimer - * @param onBehalfOf The address to claim on behalf of - * @param receiver The address to receive the rewards - * @param rewards The rewards to claim - */ - function claimRewardsOnBehalf( - address onBehalfOf, - address receiver, - address[] memory rewards - ) external; - - /** - * @notice Claim rewards and send them to a receiver - * @param receiver The address to receive the rewards - * @param rewards The rewards to claim - */ - function claimRewards(address receiver, address[] memory rewards) external; - - /** - * @notice Claim rewards - * @param rewards The rewards to claim - */ - function claimRewardsToSelf(address[] memory rewards) external; - - /** - * @notice Get the total claimable rewards of the contract. - * @param reward The reward to claim - * @return uint256 The current balance + pending rewards from the `_incentivesController` - */ - function getTotalClaimableRewards(address reward) external view returns (uint256); - - /** - * @notice Get the total claimable rewards for a user in WAD - * @param user The address of the user - * @param reward The reward to claim - * @return uint256 The claimable amount of rewards in WAD - */ - function getClaimableRewards(address user, address reward) external view returns (uint256); - - /** - * @notice The unclaimed rewards for a user in WAD - * @param user The address of the user - * @param reward The reward to claim - * @return uint256 The unclaimed amount of rewards in WAD - */ - function getUnclaimedRewards(address user, address reward) external view returns (uint256); - - /** - * @notice The underlying asset reward index in RAY - * @param reward The reward to claim - * @return uint256 The underlying asset reward index in RAY - */ - function getCurrentRewardsIndex(address reward) external view returns (uint256); - - /** - * @notice The aToken used inside the 4626 vault. - * @return IERC20 The aToken IERC20. - */ - function aToken() external view returns (IERC20); - - /** - * @notice The IERC20s that are currently rewarded to addresses of the vault via LM on incentivescontroller. - * @return IERC20 The IERC20s of the rewards. - */ - function rewardTokens() external view returns (address[] memory); - - /** - * @notice Fetches all rewardTokens from the incentivecontroller and registers the missing ones. - */ - function refreshRewardTokens() external; - - /** - * @notice Checks if the passed token is a registered reward. - * @return bool signaling if token is a registered reward. - */ - function isRegisteredRewardToken(address reward) external view returns (bool); -} diff --git a/src/contracts/misc/libraries/RayMathExplicitRounding.sol b/src/contracts/misc/libraries/RayMathExplicitRounding.sol deleted file mode 100644 index 8d3f3dcb..00000000 --- a/src/contracts/misc/libraries/RayMathExplicitRounding.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity ^0.8.10; - -enum Rounding { - UP, - DOWN -} - -/** - * Simplified version of RayMath that instead of half-up rounding does explicit rounding in a specified direction. - * This is needed to have a 4626 complient implementation, that always predictable rounds in favor of the vault / static a token. - */ -library RayMathExplicitRounding { - uint256 internal constant RAY = 1e27; - uint256 internal constant WAD_RAY_RATIO = 1e9; - - function rayMulRoundDown(uint256 a, uint256 b) internal pure returns (uint256) { - if (a == 0 || b == 0) { - return 0; - } - return (a * b) / RAY; - } - - function rayMulRoundUp(uint256 a, uint256 b) internal pure returns (uint256) { - if (a == 0 || b == 0) { - return 0; - } - return ((a * b) + RAY - 1) / RAY; - } - - function rayDivRoundDown(uint256 a, uint256 b) internal pure returns (uint256) { - return (a * RAY) / b; - } - - function rayDivRoundUp(uint256 a, uint256 b) internal pure returns (uint256) { - return ((a * RAY) + b - 1) / b; - } - - function rayToWadRoundDown(uint256 a) internal pure returns (uint256) { - return a / WAD_RAY_RATIO; - } -} diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol deleted file mode 100644 index 7ff449f2..00000000 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureOne.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {Create2Utils} from '../utilities/Create2Utils.sol'; -import {ConfigEngineReport} from '../../interfaces/IMarketReportTypes.sol'; -import {AaveV3ConfigEngine, IAaveV3ConfigEngine, CapsEngine, BorrowEngine, CollateralEngine, RateEngine, PriceFeedEngine, EModeEngine, ListingEngine} from '../../../contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; -import {IPool} from '../../../contracts/interfaces/IPool.sol'; -import {IPoolConfigurator} from '../../../contracts/interfaces/IPoolConfigurator.sol'; -import {IAaveOracle} from '../../../contracts/interfaces/IAaveOracle.sol'; - -contract AaveV3HelpersProcedureOne { - function _deployConfigEngine( - address pool, - address poolConfigurator, - address defaultInterestRateStrategy, - address aaveOracle, - address rewardsController, - address collector, - address aTokenImpl, - address vTokenImpl, - address sTokenImpl - ) internal returns (ConfigEngineReport memory configEngineReport) { - IAaveV3ConfigEngine.EngineLibraries memory engineLibraries = IAaveV3ConfigEngine - .EngineLibraries({ - listingEngine: Create2Utils._create2Deploy('v1', type(ListingEngine).creationCode), - eModeEngine: Create2Utils._create2Deploy('v1', type(EModeEngine).creationCode), - borrowEngine: Create2Utils._create2Deploy('v1', type(BorrowEngine).creationCode), - collateralEngine: Create2Utils._create2Deploy('v1', type(CollateralEngine).creationCode), - priceFeedEngine: Create2Utils._create2Deploy('v1', type(PriceFeedEngine).creationCode), - rateEngine: Create2Utils._create2Deploy('v1', type(RateEngine).creationCode), - capsEngine: Create2Utils._create2Deploy('v1', type(CapsEngine).creationCode) - }); - - IAaveV3ConfigEngine.EngineConstants memory engineConstants = IAaveV3ConfigEngine - .EngineConstants({ - pool: IPool(pool), - poolConfigurator: IPoolConfigurator(poolConfigurator), - defaultInterestRateStrategy: defaultInterestRateStrategy, - oracle: IAaveOracle(aaveOracle), - rewardsController: rewardsController, - collector: collector - }); - - configEngineReport.listingEngine = engineLibraries.listingEngine; - configEngineReport.eModeEngine = engineLibraries.eModeEngine; - configEngineReport.borrowEngine = engineLibraries.borrowEngine; - configEngineReport.collateralEngine = engineLibraries.collateralEngine; - configEngineReport.priceFeedEngine = engineLibraries.priceFeedEngine; - configEngineReport.rateEngine = engineLibraries.rateEngine; - configEngineReport.capsEngine = engineLibraries.capsEngine; - - configEngineReport.configEngine = address( - new AaveV3ConfigEngine(aTokenImpl, vTokenImpl, sTokenImpl, engineConstants, engineLibraries) - ); - return configEngineReport; - } -} diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol deleted file mode 100644 index 9a92839a..00000000 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../interfaces/IMarketReportTypes.sol'; -import {TransparentProxyFactory, ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; -import {StaticATokenLM} from '../../../contracts/extensions/static-a-token/StaticATokenLM.sol'; -import {StaticATokenFactory} from '../../../contracts/extensions/static-a-token/StaticATokenFactory.sol'; -import {IErrors} from '../../interfaces/IErrors.sol'; - -contract AaveV3HelpersProcedureTwo is IErrors { - function _deployStaticAToken( - address pool, - address rewardsController, - address proxyAdmin - ) internal returns (StaticATokenReport memory staticATokenReport) { - if (proxyAdmin == address(0)) revert ProxyAdminNotFound(); - - staticATokenReport.transparentProxyFactory = address(new TransparentProxyFactory()); - staticATokenReport.staticATokenImplementation = address( - new StaticATokenLM(IPool(pool), IRewardsController(rewardsController)) - ); - staticATokenReport.staticATokenFactoryImplementation = address( - new StaticATokenFactory( - IPool(pool), - proxyAdmin, - ITransparentProxyFactory(staticATokenReport.transparentProxyFactory), - staticATokenReport.staticATokenImplementation - ) - ); - - staticATokenReport.staticATokenFactoryProxy = ITransparentProxyFactory( - staticATokenReport.transparentProxyFactory - ).create( - staticATokenReport.staticATokenFactoryImplementation, - proxyAdmin, - abi.encodeWithSelector(StaticATokenFactory.initialize.selector) - ); - - return staticATokenReport; - } -} diff --git a/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol b/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol deleted file mode 100644 index bd6bac8b..00000000 --- a/src/deployments/contracts/procedures/AaveV3MiscProcedure.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../interfaces/IMarketReportTypes.sol'; -import {PriceOracleSentinel, ISequencerOracle} from '../../../contracts/misc/PriceOracleSentinel.sol'; -import {DefaultReserveInterestRateStrategyV2} from '../../../contracts/misc/DefaultReserveInterestRateStrategyV2.sol'; -import {IErrors} from '../../interfaces/IErrors.sol'; - -contract AaveV3MiscProcedure is IErrors { - function _deploySentinelAndDefaultIR( - bool l2Flag, - address poolAddressesProvider, - address sequencerUptimeOracle, - uint256 gracePeriod - ) internal returns (MiscReport memory miscReport) { - if (poolAddressesProvider == address(0)) revert ProviderNotFound(); - - if (l2Flag && sequencerUptimeOracle != address(0) && gracePeriod != 0) { - miscReport.priceOracleSentinel = address( - new PriceOracleSentinel( - IPoolAddressesProvider(poolAddressesProvider), - ISequencerOracle(sequencerUptimeOracle), - gracePeriod - ) - ); - } - - miscReport.defaultInterestRateStrategy = address( - new DefaultReserveInterestRateStrategyV2(poolAddressesProvider) - ); - - return miscReport; - } -} diff --git a/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol b/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol index 9d85884b..7f48b649 100644 --- a/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol +++ b/src/deployments/contracts/procedures/AaveV3SetupProcedure.sol @@ -38,8 +38,7 @@ contract AaveV3SetupProcedure { address poolConfiguratorImplementation, address protocolDataProvider, address aaveOracle, - address rewardsControllerImplementation, - address priceOracleSentinel + address rewardsControllerImplementation ) internal returns (SetupReport memory) { _validateMarketSetup(roles); @@ -50,8 +49,7 @@ contract AaveV3SetupProcedure { protocolDataProvider, roles.poolAdmin, aaveOracle, - rewardsControllerImplementation, - priceOracleSentinel + rewardsControllerImplementation ); report.aclManager = _setupACL( @@ -96,8 +94,7 @@ contract AaveV3SetupProcedure { address protocolDataProvider, address poolAdmin, address aaveOracle, - address rewardsControllerImplementation, - address priceOracleSentinel + address rewardsControllerImplementation ) internal returns (SetupReport memory) { SetupReport memory report; @@ -110,10 +107,6 @@ contract AaveV3SetupProcedure { report.poolProxy = address(provider.getPool()); report.poolConfiguratorProxy = address(provider.getPoolConfigurator()); - if (priceOracleSentinel != address(0)) { - provider.setPriceOracleSentinel(priceOracleSentinel); - } - bytes32 controllerId = keccak256('INCENTIVES_CONTROLLER'); provider.setAddressAsProxy(controllerId, rewardsControllerImplementation); report.rewardsControllerProxy = provider.getAddress(controllerId); diff --git a/src/deployments/contracts/utilities/MetadataReporter.sol b/src/deployments/contracts/utilities/MetadataReporter.sol index 27b5085c..a4dfb787 100644 --- a/src/deployments/contracts/utilities/MetadataReporter.sol +++ b/src/deployments/contracts/utilities/MetadataReporter.sol @@ -57,6 +57,11 @@ contract MetadataReporter is IMetadataReporter { vm.serializeAddress(jsonReport, 'rewardsControllerProxy', report.rewardsControllerProxy); vm.serializeAddress(jsonReport, 'aclManager', report.aclManager); vm.serializeAddress(jsonReport, 'protocolDataProvider', report.protocolDataProvider); + vm.serializeAddress( + jsonReport, + 'defaultInterestRateStrategy', + report.defaultInterestRateStrategy + ); vm.serializeAddress( jsonReport, @@ -69,25 +74,6 @@ contract MetadataReporter is IMetadataReporter { report.paraSwapWithdrawSwapAdapter ); vm.serializeAddress(jsonReport, 'aaveParaSwapFeeClaimer', report.aaveParaSwapFeeClaimer); - vm.serializeAddress( - jsonReport, - 'defaultInterestRateStrategy', - report.defaultInterestRateStrategy - ); - vm.serializeAddress(jsonReport, 'priceOracleSentinel', report.priceOracleSentinel); - vm.serializeAddress(jsonReport, 'configEngine', report.configEngine); - vm.serializeAddress( - jsonReport, - 'staticATokenFactoryImplementation', - report.staticATokenFactoryImplementation - ); - vm.serializeAddress(jsonReport, 'staticATokenFactoryProxy', report.staticATokenFactoryProxy); - vm.serializeAddress( - jsonReport, - 'staticATokenImplementation', - report.staticATokenImplementation - ); - vm.serializeAddress(jsonReport, 'transparentProxyFactory', report.transparentProxyFactory); string memory output = vm.serializeAddress( jsonReport, diff --git a/src/deployments/interfaces/IMarketReportTypes.sol b/src/deployments/interfaces/IMarketReportTypes.sol index b838a0db..4d0d3967 100644 --- a/src/deployments/interfaces/IMarketReportTypes.sol +++ b/src/deployments/interfaces/IMarketReportTypes.sol @@ -65,7 +65,6 @@ struct MarketReport { address protocolDataProvider; address aaveOracle; address defaultInterestRateStrategy; - address priceOracleSentinel; address aclManager; address treasury; address proxyAdmin; @@ -85,11 +84,6 @@ struct MarketReport { address emissionManager; address rewardsControllerImplementation; address rewardsControllerProxy; - address configEngine; - address transparentProxyFactory; - address staticATokenFactoryImplementation; - address staticATokenFactoryProxy; - address staticATokenImplementation; } struct LibrariesReport { @@ -116,8 +110,6 @@ struct MarketConfig { uint8 oracleDecimals; address paraswapAugustusRegistry; address paraswapFeeClaimer; - address l2SequencerUptimeFeed; - uint256 l2PriceOracleSentinelGracePeriod; uint256 providerId; bytes32 salt; address wrappedNativeToken; @@ -135,29 +127,6 @@ struct PoolReport { address poolConfiguratorImplementation; } -struct MiscReport { - address priceOracleSentinel; - address defaultInterestRateStrategy; -} - -struct ConfigEngineReport { - address configEngine; - address listingEngine; - address eModeEngine; - address borrowEngine; - address collateralEngine; - address priceFeedEngine; - address rateEngine; - address capsEngine; -} - -struct StaticATokenReport { - address transparentProxyFactory; - address staticATokenImplementation; - address staticATokenFactoryImplementation; - address staticATokenFactoryProxy; -} - struct InitialReport { address poolAddressesProvider; address poolAddressesProviderRegistry; @@ -177,6 +146,7 @@ struct PeripheryReport { address treasuryImplementation; address emissionManager; address rewardsControllerImplementation; + address defaultInterestRateStrategy; } struct ParaswapReport { diff --git a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol index ec93fc80..39b50d94 100644 --- a/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol +++ b/src/deployments/projects/aave-v3-batched/AaveV3BatchOrchestration.sol @@ -10,9 +10,6 @@ import {AaveV3GettersProcedureTwo} from '../../contracts/procedures/AaveV3Getter import {AaveV3PeripheryBatch} from './batches/AaveV3PeripheryBatch.sol'; import {AaveV3ParaswapBatch} from './batches/AaveV3ParaswapBatch.sol'; import {AaveV3SetupBatch} from './batches/AaveV3SetupBatch.sol'; -import {AaveV3HelpersBatchOne} from './batches/AaveV3HelpersBatchOne.sol'; -import {AaveV3HelpersBatchTwo} from './batches/AaveV3HelpersBatchTwo.sol'; -import {AaveV3MiscBatch} from './batches/AaveV3MiscBatch.sol'; import '../../interfaces/IMarketReportTypes.sol'; import {IMarketReportStorage} from '../../interfaces/IMarketReportStorage.sol'; import {IPoolReport} from '../../interfaces/IPoolReport.sol'; @@ -55,13 +52,6 @@ library AaveV3BatchOrchestration { address(setupBatch) ); - MiscReport memory miscReport = _deployMisc( - flags.l2, - initialReport.poolAddressesProvider, - config.l2SequencerUptimeFeed, - config.l2PriceOracleSentinelGracePeriod - ); - SetupReport memory setupReport = setupBatch.setupAaveV3Market( roles, config, @@ -69,8 +59,7 @@ library AaveV3BatchOrchestration { poolReport.poolConfiguratorImplementation, gettersReport1.protocolDataProvider, peripheryReport.aaveOracle, - peripheryReport.rewardsControllerImplementation, - miscReport.priceOracleSentinel + peripheryReport.rewardsControllerImplementation ); ParaswapReport memory paraswapReport = _deployParaswapAdapters( @@ -89,19 +78,6 @@ library AaveV3BatchOrchestration { AaveV3TokensBatch.TokensReport memory tokensReport = _deployTokens(setupReport.poolProxy); - ConfigEngineReport memory configEngineReport = _deployHelpersBatch1( - setupReport, - miscReport, - peripheryReport, - tokensReport - ); - - StaticATokenReport memory staticATokenReport = _deployHelpersBatch2( - setupReport.poolProxy, - setupReport.rewardsControllerProxy, - peripheryReport.proxyAdmin - ); - // Save final report at AaveV3SetupBatch contract MarketReport memory report = _generateMarketReport( initialReport, @@ -109,12 +85,9 @@ library AaveV3BatchOrchestration { gettersReport2, poolReport, peripheryReport, - miscReport, paraswapReport, setupReport, - tokensReport, - configEngineReport, - staticATokenReport + tokensReport ); setupBatch.setMarketReport(report); @@ -164,57 +137,6 @@ library AaveV3BatchOrchestration { }); } - function _deployHelpersBatch1( - SetupReport memory setupReport, - MiscReport memory miscReport, - PeripheryReport memory peripheryReport, - AaveV3TokensBatch.TokensReport memory tokensReport - ) internal returns (ConfigEngineReport memory) { - AaveV3HelpersBatchOne helpersBatchOne = new AaveV3HelpersBatchOne( - setupReport.poolProxy, - setupReport.poolConfiguratorProxy, - miscReport.defaultInterestRateStrategy, - peripheryReport.aaveOracle, - setupReport.rewardsControllerProxy, - peripheryReport.treasury, - tokensReport.aToken, - tokensReport.variableDebtToken, - tokensReport.stableDebtToken - ); - - return helpersBatchOne.getConfigEngineReport(); - } - - function _deployHelpersBatch2( - address pool, - address rewardsController, - address proxyAdmin - ) internal returns (StaticATokenReport memory) { - AaveV3HelpersBatchTwo helpersBatchTwo = new AaveV3HelpersBatchTwo( - pool, - rewardsController, - proxyAdmin - ); - - return helpersBatchTwo.staticATokenReport(); - } - - function _deployMisc( - bool l2Flag, - address poolAddressesProvider, - address sequencerUptimeOracle, - uint256 gracePeriod - ) internal returns (MiscReport memory) { - AaveV3MiscBatch miscBatch = new AaveV3MiscBatch( - l2Flag, - poolAddressesProvider, - sequencerUptimeOracle, - gracePeriod - ); - - return miscBatch.getMiscReport(); - } - function _deployPoolImplementations( address poolAddressesProvider, DeployFlags memory flags @@ -285,12 +207,9 @@ library AaveV3BatchOrchestration { AaveV3GettersBatchTwo.GettersReportBatchTwo memory gettersReportTwo, PoolReport memory poolReport, PeripheryReport memory peripheryReport, - MiscReport memory miscReport, ParaswapReport memory paraswapReport, SetupReport memory setupReport, - AaveV3TokensBatch.TokensReport memory tokensReport, - ConfigEngineReport memory configEngineReport, - StaticATokenReport memory staticATokenReport + AaveV3TokensBatch.TokensReport memory tokensReport ) internal pure returns (MarketReport memory) { MarketReport memory report; @@ -321,13 +240,7 @@ library AaveV3BatchOrchestration { report.aToken = tokensReport.aToken; report.variableDebtToken = tokensReport.variableDebtToken; report.stableDebtToken = tokensReport.stableDebtToken; - report.priceOracleSentinel = miscReport.priceOracleSentinel; - report.defaultInterestRateStrategy = miscReport.defaultInterestRateStrategy; - report.configEngine = configEngineReport.configEngine; - report.staticATokenFactoryImplementation = staticATokenReport.staticATokenFactoryImplementation; - report.staticATokenFactoryProxy = staticATokenReport.staticATokenFactoryProxy; - report.staticATokenImplementation = staticATokenReport.staticATokenImplementation; - report.transparentProxyFactory = staticATokenReport.transparentProxyFactory; + report.defaultInterestRateStrategy = peripheryReport.defaultInterestRateStrategy; return report; } diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol deleted file mode 100644 index f841b657..00000000 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {AaveV3HelpersProcedureOne} from '../../../contracts/procedures/AaveV3HelpersProcedureOne.sol'; -import '../../../interfaces/IMarketReportTypes.sol'; - -contract AaveV3HelpersBatchOne is AaveV3HelpersProcedureOne { - ConfigEngineReport internal _report; - - constructor( - address poolProxy, - address poolConfiguratorProxy, - address defaultInterestRateStrategy, - address aaveOracle, - address rewardsController, - address collector, - address aTokenImpl, - address vTokenImpl, - address sTokenImpl - ) { - _report = _deployConfigEngine( - poolProxy, - poolConfiguratorProxy, - defaultInterestRateStrategy, - aaveOracle, - rewardsController, - collector, - aTokenImpl, - vTokenImpl, - sTokenImpl - ); - } - - function getConfigEngineReport() external view returns (ConfigEngineReport memory) { - return _report; - } -} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol deleted file mode 100644 index 1db9f7b9..00000000 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {AaveV3HelpersProcedureTwo} from '../../../contracts/procedures/AaveV3HelpersProcedureTwo.sol'; -import '../../../interfaces/IMarketReportTypes.sol'; - -contract AaveV3HelpersBatchTwo is AaveV3HelpersProcedureTwo { - StaticATokenReport internal _report; - - constructor(address pool, address rewardsController, address proxyAdmin) { - _report = _deployStaticAToken(pool, rewardsController, proxyAdmin); - } - - function staticATokenReport() external view returns (StaticATokenReport memory) { - return _report; - } -} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol deleted file mode 100644 index a841d76a..00000000 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {AaveV3MiscProcedure} from '../../../contracts/procedures/AaveV3MiscProcedure.sol'; -import '../../../interfaces/IMarketReportTypes.sol'; - -contract AaveV3MiscBatch is AaveV3MiscProcedure { - MiscReport internal _report; - - constructor( - bool l2Flag, - address poolAddressesProvider, - address sequencerUptimeOracle, - uint256 gracePeriod - ) { - MiscReport memory miscReport = _deploySentinelAndDefaultIR( - l2Flag, - poolAddressesProvider, - sequencerUptimeOracle, - gracePeriod - ); - _report.priceOracleSentinel = miscReport.priceOracleSentinel; - _report.defaultInterestRateStrategy = miscReport.defaultInterestRateStrategy; - } - - function getMiscReport() external view returns (MiscReport memory) { - return _report; - } -} diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol index f2a3ec54..8ec0c136 100644 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol @@ -4,12 +4,14 @@ pragma solidity ^0.8.0; import {AaveV3TreasuryProcedure} from '../../../contracts/procedures/AaveV3TreasuryProcedure.sol'; import {AaveV3OracleProcedure} from '../../../contracts/procedures/AaveV3OracleProcedure.sol'; import {AaveV3IncentiveProcedure} from '../../../contracts/procedures/AaveV3IncentiveProcedure.sol'; +import {AaveV3DefaultRateStrategyProcedure} from '../../../contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol'; import '../../../interfaces/IMarketReportTypes.sol'; contract AaveV3PeripheryBatch is AaveV3TreasuryProcedure, AaveV3OracleProcedure, - AaveV3IncentiveProcedure + AaveV3IncentiveProcedure, + AaveV3DefaultRateStrategyProcedure { PeripheryReport internal _report; @@ -32,6 +34,8 @@ contract AaveV3PeripheryBatch is (_report.emissionManager, _report.rewardsControllerImplementation) = _deployIncentives( setupBatch ); + + _report.defaultInterestRateStrategy = _deployDefaultRateStrategyV2(poolAddressesProvider); } function getPeripheryReport() external view returns (PeripheryReport memory) { diff --git a/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol b/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol index abed9a61..f62bcd4f 100644 --- a/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol +++ b/src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol @@ -32,8 +32,7 @@ contract AaveV3SetupBatch is MarketReportStorage, AaveV3SetupProcedure, Ownable address poolConfiguratorImplementation, address protocolDataProvider, address aaveOracle, - address rewardsControllerImplementation, - address priceOracleSentinel + address rewardsControllerImplementation ) external onlyOwner returns (SetupReport memory) { _setupReport = _setupAaveV3Market( roles, @@ -43,8 +42,7 @@ contract AaveV3SetupBatch is MarketReportStorage, AaveV3SetupProcedure, Ownable poolConfiguratorImplementation, protocolDataProvider, aaveOracle, - rewardsControllerImplementation, - priceOracleSentinel + rewardsControllerImplementation ); return _setupReport; diff --git a/tests/deployments/AaveV3BatchDeployment.t.sol b/tests/deployments/AaveV3BatchDeployment.t.sol index aa0cf2d2..55c5a81d 100644 --- a/tests/deployments/AaveV3BatchDeployment.t.sol +++ b/tests/deployments/AaveV3BatchDeployment.t.sol @@ -3,6 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {ConfigEngineDeployer} from '../utils/ConfigEngineDeployer.sol'; + import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; import {MockParaSwapFeeClaimer} from '../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; import {BatchTestProcedures} from '../utils/BatchTestProcedures.sol'; @@ -20,12 +22,14 @@ contract AaveV3BatchDeployment is BatchTestProcedures { address public emergencyAdmin; Roles public roles; + MarketConfig public config; DeployFlags public flags; - MarketConfig config; MarketReport deployedContracts; address public weth9; + event ReportLog(MarketReport report); + function setUp() public { bytes32 emptySalt; weth9 = address(new WETH9()); @@ -41,8 +45,6 @@ contract AaveV3BatchDeployment is BatchTestProcedures { 8, address(new AugustusRegistryMock()), address(new MockParaSwapFeeClaimer()), - address(0), // l2SequencerUptimeFeed - 0, // l2PriceOracleSentinelGracePeriod 8080, emptySalt, weth9, @@ -62,8 +64,9 @@ contract AaveV3BatchDeployment is BatchTestProcedures { ); checkFullReport(flags, fullReport); + address engine = ConfigEngineDeployer.deployEngine(vm, fullReport); AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(fullReport.configEngine), + IAaveV3ConfigEngine(engine), marketOwner, weth9, fullReport @@ -79,8 +82,6 @@ contract AaveV3BatchDeployment is BatchTestProcedures { function testAaveV3L2BatchDeploymentCheck() public { flags.l2 = true; - config.l2SequencerUptimeFeed = address(new SequencerOracle(poolAdmin)); - config.l2PriceOracleSentinelGracePeriod = 2 hours; MarketReport memory fullReport = deployAaveV3Testnet( marketOwner, @@ -92,8 +93,9 @@ contract AaveV3BatchDeployment is BatchTestProcedures { checkFullReport(flags, fullReport); + address engine = ConfigEngineDeployer.deployEngine(vm, fullReport); AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(fullReport.configEngine), + IAaveV3ConfigEngine(engine), marketOwner, weth9, fullReport diff --git a/tests/deployments/AaveV3BatchTests.t.sol b/tests/deployments/AaveV3BatchTests.t.sol index 99a41eac..254db0d1 100644 --- a/tests/deployments/AaveV3BatchTests.t.sol +++ b/tests/deployments/AaveV3BatchTests.t.sol @@ -10,9 +10,6 @@ import {AaveV3GettersBatchTwo} from '../../src/deployments/projects/aave-v3-batc import {AaveV3PeripheryBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; import {AaveV3ParaswapBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; import {AaveV3SetupBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; -import {AaveV3MiscBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol'; -import {AaveV3HelpersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol'; -import {AaveV3HelpersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol'; import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; import {MockParaSwapFeeClaimer} from 'src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; @@ -37,15 +34,13 @@ contract AaveV3BatchTests is BatchTestProcedures { PeripheryReport peripheryReportOne; ParaswapReport paraswapReportOne; - MiscReport miscReport; - ConfigEngineReport configEngineReport; - StaticATokenReport staticATokenReport; - AaveV3TokensBatch.TokensReport tokensReport; SetupReport setupReportTwo; AaveV3SetupBatch aaveV3SetupOne; + event ReportLog(MarketReport report); + function setUp() public { deployer = makeAddr('deployer'); marketOwner = makeAddr('marketOwner'); @@ -60,8 +55,6 @@ contract AaveV3BatchTests is BatchTestProcedures { 8, address(new AugustusRegistryMock()), address(new MockParaSwapFeeClaimer()), - address(0), // l2SequencerUptimeFeed - 0, // l2PriceOracleSentinelGracePeriod 8080, emptySalt, address(new WETH9()), @@ -71,33 +64,20 @@ contract AaveV3BatchTests is BatchTestProcedures { ); flags = DeployFlags(false); - // Etch the create2 factory - vm.etch( - 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, - hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' - ); - ( marketReportOne, gettersReportOne, poolReportOne, peripheryReportOne, - miscReport, + paraswapReportOne, aaveV3SetupOne ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); - - ( - , - , - gettersReportTwo, - , - setupReportTwo, - , - miscReport, - tokensReport, - paraswapReportOne, - - ) = deployAndSetup(roles, config, flags, deployedContracts); + (, , gettersReportTwo, , setupReportTwo, , , ) = deployAndSetup( + roles, + config, + flags, + deployedContracts + ); } function testAaveV3FullBatchOrchestration() public { @@ -136,7 +116,7 @@ contract AaveV3BatchTests is BatchTestProcedures { new AaveV3PoolBatch(marketReportOne.poolAddressesProvider); } - function test3AaveV3L2PoolDeployment() public { + function test2AaveV3L2PoolDeployment() public { new AaveV3L2PoolBatch(marketReportOne.poolAddressesProvider); } @@ -149,16 +129,7 @@ contract AaveV3BatchTests is BatchTestProcedures { ); } - function test5MiscDeployment() public { - new AaveV3MiscBatch( - flags.l2, - marketReportOne.poolAddressesProvider, - config.l2SequencerUptimeFeed, - config.l2PriceOracleSentinelGracePeriod - ); - } - - function test6ParaswapRelease() public { + function test5PeripheralsRelease() public { new AaveV3ParaswapBatch( roles.poolAdmin, config, @@ -167,7 +138,7 @@ contract AaveV3BatchTests is BatchTestProcedures { ); } - function test7SetupMarket() public { + function test6SetupMarket() public { vm.prank(roles.marketOwner); aaveV3SetupOne.setupAaveV3Market( roles, @@ -176,34 +147,11 @@ contract AaveV3BatchTests is BatchTestProcedures { poolReportOne.poolConfiguratorImplementation, gettersReportOne.protocolDataProvider, peripheryReportOne.aaveOracle, - peripheryReportOne.rewardsControllerImplementation, - miscReport.priceOracleSentinel + peripheryReportOne.rewardsControllerImplementation ); } - function test8TokensMarket() public { + function test7TokensMarket() public { new AaveV3TokensBatch(setupReportTwo.poolProxy); } - - function test9ConfigEngineDeployment() public { - new AaveV3HelpersBatchOne( - setupReportTwo.poolProxy, - setupReportTwo.poolConfiguratorProxy, - miscReport.defaultInterestRateStrategy, - peripheryReportOne.aaveOracle, - setupReportTwo.rewardsControllerProxy, - peripheryReportOne.treasury, - tokensReport.aToken, - tokensReport.variableDebtToken, - tokensReport.stableDebtToken - ); - } - - function test10StaticATokenDeployment() public { - new AaveV3HelpersBatchTwo( - setupReportTwo.poolProxy, - setupReportTwo.rewardsControllerProxy, - peripheryReportOne.proxyAdmin - ); - } } diff --git a/tests/deployments/DeploymentsGasLimits.t.sol b/tests/deployments/DeploymentsGasLimits.t.sol index fd42791e..ae3865f0 100644 --- a/tests/deployments/DeploymentsGasLimits.t.sol +++ b/tests/deployments/DeploymentsGasLimits.t.sol @@ -11,9 +11,6 @@ import {AaveV3GettersBatchTwo} from '../../src/deployments/projects/aave-v3-batc import {AaveV3PeripheryBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3PeripheryBatch.sol'; import {AaveV3ParaswapBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol'; import {AaveV3SetupBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol'; -import {AaveV3MiscBatch} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol'; -import {AaveV3HelpersBatchOne} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol'; -import {AaveV3HelpersBatchTwo} from '../../src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol'; import {WETH9} from '../../src/contracts/dependencies/weth/WETH9.sol'; import {AugustusRegistryMock} from '../mocks/AugustusRegistryMock.sol'; import {MockParaSwapFeeClaimer} from '../../src/contracts/mocks/swap/MockParaSwapFeeClaimer.sol'; @@ -34,8 +31,6 @@ contract DeploymentsGasLimits is BatchTestProcedures { PeripheryReport peripheryReportOne; ParaswapReport paraswapReportOne; - MiscReport miscReport; - AaveV3TokensBatch.TokensReport tokensReport; SetupReport setupReportTwo; @@ -57,8 +52,6 @@ contract DeploymentsGasLimits is BatchTestProcedures { 8, address(new AugustusRegistryMock()), // replace with mock of augustus registry address(new MockParaSwapFeeClaimer()), - address(new SequencerOracle(poolAdmin)), - 2 hours, // l2PriceOracleSentinelGracePeriod 8080, empty, address(new WETH9()), @@ -66,35 +59,22 @@ contract DeploymentsGasLimits is BatchTestProcedures { 0.0005e4, 0.0004e4 ); - flags = DeployFlags(true); - - // Etch the create2 factory - vm.etch( - 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, - hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' - ); + flags = DeployFlags(false); ( marketReportOne, gettersReportOne, poolReportOne, peripheryReportOne, - miscReport, + paraswapReportOne, aaveV3SetupOne ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); - - ( - , - , - gettersReportTwo, - , - setupReportTwo, - , - miscReport, - tokensReport, - paraswapReportOne, - - ) = deployAndSetup(roles, config, flags, deployedContracts); + (, , gettersReportTwo, , setupReportTwo, , , ) = deployAndSetup( + roles, + config, + flags, + deployedContracts + ); } function test0AaveV3SetupDeployment() public { @@ -135,16 +115,7 @@ contract DeploymentsGasLimits is BatchTestProcedures { ); } - function test6MiscDeployment() public { - new AaveV3MiscBatch( - flags.l2, - marketReportOne.poolAddressesProvider, - config.l2SequencerUptimeFeed, - config.l2PriceOracleSentinelGracePeriod - ); - } - - function test7ParaswapDeployment() public { + function test6ParaswapDeployment() public { new AaveV3ParaswapBatch( roles.poolAdmin, config, @@ -153,7 +124,7 @@ contract DeploymentsGasLimits is BatchTestProcedures { ); } - function test8SetupMarket() public { + function test7SetupMarket() public { vm.prank(roles.marketOwner); aaveV3SetupOne.setupAaveV3Market( roles, @@ -162,37 +133,14 @@ contract DeploymentsGasLimits is BatchTestProcedures { poolReportOne.poolConfiguratorImplementation, gettersReportOne.protocolDataProvider, peripheryReportOne.aaveOracle, - peripheryReportOne.rewardsControllerImplementation, - miscReport.priceOracleSentinel + peripheryReportOne.rewardsControllerImplementation ); } - function test9TokensMarket() public { + function test8TokensMarket() public { new AaveV3TokensBatch(setupReportTwo.poolProxy); } - function test10ConfigEngineDeployment() public { - new AaveV3HelpersBatchOne( - setupReportTwo.poolProxy, - setupReportTwo.poolConfiguratorProxy, - miscReport.defaultInterestRateStrategy, - peripheryReportOne.aaveOracle, - setupReportTwo.rewardsControllerProxy, - peripheryReportOne.treasury, - tokensReport.aToken, - tokensReport.variableDebtToken, - tokensReport.stableDebtToken - ); - } - - function test11StaticATokenDeployment() public { - new AaveV3HelpersBatchTwo( - setupReportTwo.poolProxy, - setupReportTwo.rewardsControllerProxy, - peripheryReportOne.proxyAdmin - ); - } - function testCheckInitCodeSizeBatchs() public view { uint16 maxInitCodeSize = 49152; @@ -200,13 +148,10 @@ contract DeploymentsGasLimits is BatchTestProcedures { console.log('AaveV3L2PoolBatch', type(AaveV3L2PoolBatch).creationCode.length); console.log('AaveV3PoolBatch', type(AaveV3PoolBatch).creationCode.length); console.log('AaveV3PeripheryBatch', type(AaveV3PeripheryBatch).creationCode.length); - console.log('AaveV3MiscBatch', type(AaveV3MiscBatch).creationCode.length); console.log('AaveV3ParaswapBatch', type(AaveV3ParaswapBatch).creationCode.length); console.log('AaveV3GettersBatchOne', type(AaveV3GettersBatchOne).creationCode.length); console.log('AaveV3GettersBatchTwo', type(AaveV3GettersBatchTwo).creationCode.length); console.log('AaveV3TokensBatch', type(AaveV3TokensBatch).creationCode.length); - console.log('AaveV3HelpersBatchOne', type(AaveV3HelpersBatchOne).creationCode.length); - console.log('AaveV3HelpersBatchTwo', type(AaveV3HelpersBatchTwo).creationCode.length); assertLe( type(AaveV3SetupBatch).creationCode.length, @@ -228,11 +173,6 @@ contract DeploymentsGasLimits is BatchTestProcedures { maxInitCodeSize, 'AaveV3PeripheryBatch max init code size' ); - assertLe( - type(AaveV3MiscBatch).creationCode.length, - maxInitCodeSize, - 'AaveV3MiscBatch max init code size' - ); assertLe( type(AaveV3ParaswapBatch).creationCode.length, maxInitCodeSize, @@ -253,15 +193,5 @@ contract DeploymentsGasLimits is BatchTestProcedures { maxInitCodeSize, 'AaveV3TokensBatch max init code size' ); - assertLe( - type(AaveV3HelpersBatchOne).creationCode.length, - maxInitCodeSize, - 'AaveV3HelpersBatchOne max init code size' - ); - assertLe( - type(AaveV3HelpersBatchTwo).creationCode.length, - maxInitCodeSize, - 'AaveV3HelpersBatchTwo max init code size' - ); } } diff --git a/tests/extensions/static-a-token/StataOracle.t.sol b/tests/extensions/static-a-token/StataOracle.t.sol deleted file mode 100644 index 5e6e4efd..00000000 --- a/tests/extensions/static-a-token/StataOracle.t.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {StataOracle} from '../../../src/contracts/extensions/static-a-token/StataOracle.sol'; -import {StaticATokenLM} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; -import {BaseTest} from './TestBase.sol'; - -contract StataOracleTest is BaseTest { - StataOracle public oracle; - - function setUp() public override { - super.setUp(); - oracle = new StataOracle(contracts.poolAddressesProvider); - - vm.prank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 1_000_000); - } - - function test_assetPrice() public view { - uint256 stataPrice = oracle.getAssetPrice(address(staticATokenLM)); - uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(UNDERLYING); - assertGe(stataPrice, underlyingPrice); - assertEq(stataPrice, (underlyingPrice * staticATokenLM.convertToAssets(1e18)) / 1e18); - } - - function test_assetsPrices() public view { - address[] memory staticATokens = factory.getStaticATokens(); - uint256[] memory stataPrices = oracle.getAssetsPrices(staticATokens); - - for (uint256 i = 0; i < staticATokens.length; i++) { - address staticAToken = staticATokens[i]; - uint256 stataPrice = stataPrices[i]; - - address underlying = StaticATokenLM(staticAToken).asset(); - uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(underlying); - - assertGe(stataPrice, underlyingPrice); - assertEq( - stataPrice, - (underlyingPrice * StaticATokenLM(staticAToken).convertToAssets(1e18)) / 1e18 - ); - } - } - - function test_error(uint256 shares) public view { - vm.assume(shares <= staticATokenLM.maxMint(address(0))); - uint256 pricePerShare = oracle.getAssetPrice(address(staticATokenLM)); - uint256 pricePerAsset = contracts.aaveOracle.getAssetPrice(UNDERLYING); - uint256 assets = staticATokenLM.convertToAssets(shares); - - assertApproxEqAbs( - (pricePerShare * shares) / 1e18, - (pricePerAsset * assets) / 1e18, - (assets / 1e18) + 1 // there can be imprecision of 1 wei, which will accumulate for each asset - ); - } -} diff --git a/tests/extensions/static-a-token/StaticATokenLM.t.sol b/tests/extensions/static-a-token/StaticATokenLM.t.sol deleted file mode 100644 index 5c84fe55..00000000 --- a/tests/extensions/static-a-token/StaticATokenLM.t.sol +++ /dev/null @@ -1,609 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {AToken} from '../../../src/contracts/protocol/tokenization/AToken.sol'; -import {DataTypes} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {IERC20, IERC20Metadata} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; -import {RayMathExplicitRounding} from '../../../src/contracts/misc/libraries/RayMathExplicitRounding.sol'; -import {PullRewardsTransferStrategy} from '../../../src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; -import {RewardsDataTypes} from '../../../src/contracts/rewards/libraries/RewardsDataTypes.sol'; -import {ITransferStrategyBase} from '../../../src/contracts/rewards/interfaces/ITransferStrategyBase.sol'; -import {IEACAggregatorProxy} from '../../../src/contracts/helpers/interfaces/IEACAggregatorProxy.sol'; -import {IStaticATokenLM} from '../../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; -import {SigUtils} from '../../utils/SigUtils.sol'; -import {BaseTest, TestnetERC20} from './TestBase.sol'; - -contract StaticATokenLMTest is BaseTest { - using RayMathExplicitRounding for uint256; - - address public constant EMISSION_ADMIN = address(25); - - function setUp() public override { - super.setUp(); - - _configureLM(); - _openSupplyAndBorrowPositions(); - - vm.startPrank(user); - } - - function test_initializeShouldRevert() public { - address impl = factory.STATIC_A_TOKEN_IMPL(); - vm.expectRevert(); - IStaticATokenLM(impl).initialize(0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8, 'hey', 'ho'); - } - - function test_getters() public view { - assertEq(staticATokenLM.name(), 'Static Aave Local WETH'); - assertEq(staticATokenLM.symbol(), 'stataLocWETH'); - - IERC20 aToken = staticATokenLM.aToken(); - assertEq(address(aToken), A_TOKEN); - - address underlyingAddress = address(staticATokenLM.asset()); - assertEq(underlyingAddress, UNDERLYING); - - IERC20Metadata underlying = IERC20Metadata(underlyingAddress); - assertEq(staticATokenLM.decimals(), underlying.decimals()); - - assertEq( - address(staticATokenLM.INCENTIVES_CONTROLLER()), - address(AToken(A_TOKEN).getIncentivesController()) - ); - } - - function test_convertersAndPreviews() public view { - uint128 amount = 5 ether; - uint256 shares = staticATokenLM.convertToShares(amount); - assertLe(shares, amount, 'SHARES LOWER'); - assertEq(shares, staticATokenLM.previewDeposit(amount), 'PREVIEW_DEPOSIT'); - assertLe(shares, staticATokenLM.previewWithdraw(amount), 'PREVIEW_WITHDRAW'); - uint256 assets = staticATokenLM.convertToAssets(amount); - assertGe(assets, shares, 'ASSETS GREATER'); - assertLe(assets, staticATokenLM.previewMint(amount), 'PREVIEW_MINT'); - assertEq(assets, staticATokenLM.previewRedeem(amount), 'PREVIEW_REDEEM'); - } - - // Redeem tests - function test_redeem() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - assertEq(staticATokenLM.maxRedeem(user), staticATokenLM.balanceOf(user)); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); - assertEq(staticATokenLM.balanceOf(user), 0); - assertLe(IERC20(UNDERLYING).balanceOf(user), amountToDeposit); - assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user), amountToDeposit, 1); - } - - function test_redeemAToken() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - assertEq(staticATokenLM.maxRedeem(user), staticATokenLM.balanceOf(user)); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user, false); - assertEq(staticATokenLM.balanceOf(user), 0); - assertLe(IERC20(A_TOKEN).balanceOf(user), amountToDeposit); - assertApproxEqAbs(IERC20(A_TOKEN).balanceOf(user), amountToDeposit, 1); - } - - function test_redeemAllowance() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - staticATokenLM.approve(user1, staticATokenLM.maxRedeem(user)); - vm.stopPrank(); - vm.startPrank(user1); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user1, user); - assertEq(staticATokenLM.balanceOf(user), 0); - assertLe(IERC20(UNDERLYING).balanceOf(user1), amountToDeposit); - assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user1), amountToDeposit, 1); - } - - function testFail_redeemOverflowAllowance() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - staticATokenLM.approve(user1, staticATokenLM.maxRedeem(user) / 2); - vm.stopPrank(); - vm.startPrank(user1); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user1, user); - assertEq(staticATokenLM.balanceOf(user), 0); - assertEq(IERC20(A_TOKEN).balanceOf(user1), amountToDeposit); - } - - function testFail_redeemAboveBalance() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user) + 1, user, user); - } - - // Withdraw tests - function test_withdraw() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - assertLe(staticATokenLM.maxWithdraw(user), amountToDeposit); - staticATokenLM.withdraw(staticATokenLM.maxWithdraw(user), user, user); - assertEq(staticATokenLM.balanceOf(user), 0); - assertLe(IERC20(UNDERLYING).balanceOf(user), amountToDeposit); - assertApproxEqAbs(IERC20(UNDERLYING).balanceOf(user), amountToDeposit, 1); - } - - function testFail_withdrawAboveBalance() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - _fundUser(amountToDeposit, user1); - - _depositAToken(amountToDeposit, user); - _depositAToken(amountToDeposit, user1); - - assertEq(staticATokenLM.maxWithdraw(user), amountToDeposit); - staticATokenLM.withdraw(staticATokenLM.maxWithdraw(user) + 1, user, user); - } - - // mint - function test_mint() public { - vm.stopPrank(); - - // set supply cap to non-zero - vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 15_000); - vm.stopPrank(); - - vm.startPrank(user); - - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - IERC20(UNDERLYING).approve(address(staticATokenLM), amountToDeposit); - uint256 shares = 1 ether; - staticATokenLM.mint(shares, user); - assertEq(shares, staticATokenLM.balanceOf(user)); - } - - function testFail_mintAboveBalance() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _underlyingToAToken(amountToDeposit, user); - IERC20(A_TOKEN).approve(address(staticATokenLM), amountToDeposit); - staticATokenLM.mint(amountToDeposit, user); - } - - // test rewards - function test_collectAndUpdateRewards() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); - uint256 claimable = staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN); - staticATokenLM.collectAndUpdateRewards(REWARD_TOKEN); - assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), claimable); - } - - function test_claimRewardsToSelf() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - - uint256 claimable = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable); - assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); - } - - function test_claimRewards() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - - uint256 claimable = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - staticATokenLM.claimRewards(user, rewardTokens); - assertEq(claimable, IERC20(REWARD_TOKEN).balanceOf(user)); - assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); - assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); - } - - // should fail as user1 is not a valid claimer - function testFail_claimRewardsOnBehalfOf() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - - vm.stopPrank(); - vm.startPrank(user1); - - staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - staticATokenLM.claimRewardsOnBehalf(user, user1, rewardTokens); - } - - function test_depositATokenClaimWithdrawClaim() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - // deposit aweth - _depositAToken(amountToDeposit, user); - - // forward time - _skipBlocks(60); - - // claim - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); - uint256 claimable0 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable0); - assertGt(claimable0, 0); - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable0); - - // forward time - _skipBlocks(60); - - // redeem - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); - uint256 claimable1 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable1); - assertGt(claimable1, 0); - - // claim on behalf of other user - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable1 + claimable0); - assertEq(staticATokenLM.balanceOf(user), 0); - assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); - assertGt(AToken(UNDERLYING).balanceOf(user), 5 ether); - } - - function test_depositWETHClaimWithdrawClaim() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - // forward time - _skipBlocks(60); - - // claim - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); - uint256 claimable0 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable0); - assertGt(claimable0, 0); - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable0); - - // forward time - _skipBlocks(60); - - // redeem - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); - uint256 claimable1 = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), claimable1); - assertGt(claimable1, 0); - - // claim on behalf of other user - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimable1 + claimable0); - assertEq(staticATokenLM.balanceOf(user), 0); - assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); - assertGt(AToken(UNDERLYING).balanceOf(user), 5 ether); - } - - function test_transfer() public { - uint128 amountToDeposit = 10 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - // transfer to 2nd user - staticATokenLM.transfer(user1, amountToDeposit / 2); - assertEq(staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN), 0); - - // forward time - _skipBlocks(60); - - // redeem for both - uint256 claimableUser = staticATokenLM.getClaimableRewards(user, REWARD_TOKEN); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user), user, user); - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), claimableUser); - vm.stopPrank(); - vm.startPrank(user1); - uint256 claimableUser1 = staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN); - staticATokenLM.redeem(staticATokenLM.maxRedeem(user1), user1, user1); - staticATokenLM.claimRewardsToSelf(rewardTokens); - assertEq(IERC20(REWARD_TOKEN).balanceOf(user1), claimableUser1); - assertGt(claimableUser1, 0); - - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); - assertEq(staticATokenLM.getClaimableRewards(user, REWARD_TOKEN), 0); - assertEq(staticATokenLM.getClaimableRewards(user1, REWARD_TOKEN), 0); - } - - // getUnclaimedRewards - function test_getUnclaimedRewards() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - uint256 shares = _depositAToken(amountToDeposit, user); - assertEq(staticATokenLM.getUnclaimedRewards(user, REWARD_TOKEN), 0); - _skipBlocks(1000); - staticATokenLM.redeem(shares, user, user); - assertGt(staticATokenLM.getUnclaimedRewards(user, REWARD_TOKEN), 0); - } - - /** - * maxDeposit test - */ - function test_maxDeposit_freeze() public { - vm.stopPrank(); - vm.startPrank(roleList.marketOwner); - contracts.poolConfiguratorProxy.setReserveFreeze(UNDERLYING, true); - - uint256 max = staticATokenLM.maxDeposit(address(0)); - - assertEq(max, 0); - } - - function test_maxDeposit_paused() public { - vm.stopPrank(); - vm.startPrank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setReservePause(UNDERLYING, true); - - uint256 max = staticATokenLM.maxDeposit(address(0)); - - assertEq(max, 0); - } - - function test_maxDeposit_noCap() public { - vm.stopPrank(); - vm.startPrank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 0); - - uint256 maxDeposit = staticATokenLM.maxDeposit(address(0)); - uint256 maxMint = staticATokenLM.maxMint(address(0)); - - assertEq(maxDeposit, type(uint256).max); - assertEq(maxMint, type(uint256).max); - } - - // should be 0 as supply is ~5k - function test_maxDeposit_5kCap() public { - vm.stopPrank(); - vm.startPrank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 5_000); - - uint256 max = staticATokenLM.maxDeposit(address(0)); - assertEq(max, 0); - } - - function test_maxDeposit_50kCap() public { - vm.stopPrank(); - vm.startPrank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 50_000); - - uint256 max = staticATokenLM.maxDeposit(address(0)); - DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(UNDERLYING); - assertEq( - max, - 50_000 * - (10 ** IERC20Metadata(UNDERLYING).decimals()) - - (IERC20Metadata(A_TOKEN).totalSupply() + - uint256(reserveData.accruedToTreasury).rayMulRoundUp(staticATokenLM.rate())) - ); - } - - /** - * maxRedeem test - */ - function test_maxRedeem_paused() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - vm.stopPrank(); - vm.startPrank(address(roleList.marketOwner)); - contracts.poolConfiguratorProxy.setReservePause(UNDERLYING, true); - - uint256 max = staticATokenLM.maxRedeem(address(user)); - - assertEq(max, 0); - } - - function test_maxRedeem_allAvailable() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - uint256 max = staticATokenLM.maxRedeem(address(user)); - - assertEq(max, staticATokenLM.balanceOf(user)); - } - - function test_maxRedeem_partAvailable() public { - uint128 amountToDeposit = 50 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - vm.stopPrank(); - - uint256 maxRedeemBefore = staticATokenLM.previewRedeem(staticATokenLM.maxRedeem(address(user))); - uint256 underlyingBalanceBefore = IERC20Metadata(UNDERLYING).balanceOf(A_TOKEN); - - // create rich user - address borrowUser = address(99); - vm.startPrank(borrowUser); - deal(address(wbtc), borrowUser, 2_000e8); - wbtc.approve(address(POOL), 2_000e8); - POOL.deposit(address(wbtc), 2_000e8, borrowUser, 0); - - // borrow all available - POOL.borrow(UNDERLYING, underlyingBalanceBefore - (maxRedeemBefore / 2), 2, 0, borrowUser); - - uint256 maxRedeemAfter = staticATokenLM.previewRedeem(staticATokenLM.maxRedeem(address(user))); - assertApproxEqAbs(maxRedeemAfter, (maxRedeemBefore / 2), 1); - } - - function test_maxRedeem_nonAvailable() public { - uint128 amountToDeposit = 50 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - vm.stopPrank(); - - uint256 underlyingBalanceBefore = IERC20Metadata(UNDERLYING).balanceOf(A_TOKEN); - // create rich user - address borrowUser = address(99); - vm.startPrank(borrowUser); - deal(address(wbtc), borrowUser, 2_000e8); - wbtc.approve(address(POOL), 2_000e8); - POOL.deposit(address(wbtc), 2_000e8, borrowUser, 0); - - // borrow all available - contracts.poolProxy.borrow(UNDERLYING, underlyingBalanceBefore, 2, 0, borrowUser); - - uint256 maxRedeemAfter = staticATokenLM.maxRedeem(address(user)); - assertEq(maxRedeemAfter, 0); - } - - function test_permit() public { - SigUtils.Permit memory permit = SigUtils.Permit({ - owner: user, - spender: spender, - value: 1 ether, - nonce: staticATokenLM.nonces(user), - deadline: block.timestamp + 1 days - }); - - bytes32 permitDigest = SigUtils.getTypedDataHash( - permit, - staticATokenLM.PERMIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); - - staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); - - assertEq(staticATokenLM.allowance(permit.owner, spender), permit.value); - } - - function test_permit_expired() public { - // as the default timestamp is 0, we move ahead in time a bit - vm.warp(10 days); - - SigUtils.Permit memory permit = SigUtils.Permit({ - owner: user, - spender: spender, - value: 1 ether, - nonce: staticATokenLM.nonces(user), - deadline: block.timestamp - 1 days - }); - - bytes32 permitDigest = SigUtils.getTypedDataHash( - permit, - staticATokenLM.PERMIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); - - vm.expectRevert('PERMIT_DEADLINE_EXPIRED'); - staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); - } - - function test_permit_invalidSigner() public { - SigUtils.Permit memory permit = SigUtils.Permit({ - owner: address(424242), - spender: spender, - value: 1 ether, - nonce: staticATokenLM.nonces(user), - deadline: block.timestamp + 1 days - }); - - bytes32 permitDigest = SigUtils.getTypedDataHash( - permit, - staticATokenLM.PERMIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, permitDigest); - - vm.expectRevert('INVALID_SIGNER'); - staticATokenLM.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s); - } - - function _configureLM() internal { - PullRewardsTransferStrategy strat = new PullRewardsTransferStrategy( - report.rewardsControllerProxy, - EMISSION_ADMIN, - EMISSION_ADMIN - ); - - vm.startPrank(poolAdmin); - contracts.emissionManager.setEmissionAdmin(REWARD_TOKEN, EMISSION_ADMIN); - vm.stopPrank(); - - vm.startPrank(EMISSION_ADMIN); - IERC20(REWARD_TOKEN).approve(address(strat), 10_000 ether); - vm.stopPrank(); - - vm.startPrank(OWNER); - TestnetERC20(REWARD_TOKEN).mint(EMISSION_ADMIN, 10_000 ether); - vm.stopPrank(); - - RewardsDataTypes.RewardsConfigInput[] memory config = new RewardsDataTypes.RewardsConfigInput[]( - 1 - ); - config[0] = RewardsDataTypes.RewardsConfigInput( - 0.00385 ether, - 10_000 ether, - uint32(block.timestamp + 30 days), - A_TOKEN, - REWARD_TOKEN, - ITransferStrategyBase(strat), - IEACAggregatorProxy(address(2)) - ); - - vm.prank(EMISSION_ADMIN); - contracts.emissionManager.configureAssets(config); - - staticATokenLM.refreshRewardTokens(); - } - - function _openSupplyAndBorrowPositions() internal { - // this is to open borrow positions so that the aToken balance increases - address whale = address(79); - vm.startPrank(whale); - _fundUser(5_000 ether, whale); - - weth.approve(address(POOL), 5_000 ether); - POOL.deposit(address(weth), 5_000 ether, whale, 0); - - POOL.borrow(address(weth), 1_000 ether, 2, 0, whale); - vm.stopPrank(); - } -} diff --git a/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol deleted file mode 100644 index 4cc133e7..00000000 --- a/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol +++ /dev/null @@ -1,252 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IERC20WithPermit.sol'; -import {StaticATokenLM, IStaticATokenLM, IERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; -import {SigUtils} from '../../utils/SigUtils.sol'; -import {BaseTest, IAToken, IRewardsController, DataTypes} from './TestBase.sol'; - -contract StaticATokenMetaTransactions is BaseTest { - function setUp() public override { - super.setUp(); - - // Testing meta transactions with USDX as WETH does not support permit - DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( - address(usdx) - ); - UNDERLYING = address(usdx); - A_TOKEN = reserveDataUSDX.aTokenAddress; - - staticATokenLM = StaticATokenLM(factory.getStaticAToken(UNDERLYING)); - - vm.startPrank(user); - } - - function test_validateDomainSeparator() public view { - address[] memory staticATokens = factory.getStaticATokens(); - - for (uint256 i = 0; i < staticATokens.length; i++) { - bytes32 separator1 = StaticATokenLM(staticATokens[i]).DOMAIN_SEPARATOR(); - for (uint256 j = 0; j < staticATokens.length; j++) { - if (i != j) { - bytes32 separator2 = StaticATokenLM(staticATokens[j]).DOMAIN_SEPARATOR(); - assertNotEq(separator1, separator2, 'DOMAIN_SEPARATOR_MUST_BE_UNIQUE'); - } - } - } - } - - function test_metaDepositATokenUnderlyingNoPermit() public { - uint128 amountToDeposit = 5e6; - deal(UNDERLYING, user, amountToDeposit); - IERC20(UNDERLYING).approve(address(staticATokenLM), 1e6); - IStaticATokenLM.PermitParams memory permitParams; - - // generate combined permit - SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ - owner: user, - spender: spender, - value: 1e6, - referralCode: 0, - fromUnderlying: true, - nonce: staticATokenLM.nonces(user), - deadline: block.timestamp + 1 days, - permit: permitParams - }); - bytes32 digest = SigUtils.getTypedDepositHash( - depositPermit, - staticATokenLM.METADEPOSIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); - - IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); - - uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); - staticATokenLM.metaDeposit( - depositPermit.owner, - depositPermit.spender, - depositPermit.value, - depositPermit.referralCode, - depositPermit.fromUnderlying, - depositPermit.deadline, - permitParams, - sigParams - ); - - assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); - } - - function test_metaDepositATokenUnderlying() public { - uint128 amountToDeposit = 5e6; - deal(UNDERLYING, user, amountToDeposit); - - // permit for aToken deposit - SigUtils.Permit memory permit = SigUtils.Permit({ - owner: user, - spender: address(staticATokenLM), - value: 1e6, - nonce: IERC20WithPermit(UNDERLYING).nonces(user), - deadline: block.timestamp + 1 days - }); - - bytes32 permitDigest = SigUtils.getTypedDataHash( - permit, - staticATokenLM.PERMIT_TYPEHASH(), - IERC20WithPermit(UNDERLYING).DOMAIN_SEPARATOR() - ); - - (uint8 pV, bytes32 pR, bytes32 pS) = vm.sign(userPrivateKey, permitDigest); - - IStaticATokenLM.PermitParams memory permitParams = IStaticATokenLM.PermitParams( - permit.owner, - permit.spender, - permit.value, - permit.deadline, - pV, - pR, - pS - ); - - // generate combined permit - SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ - owner: user, - spender: spender, - value: permit.value, - referralCode: 0, - fromUnderlying: true, - nonce: staticATokenLM.nonces(user), - deadline: permit.deadline, - permit: permitParams - }); - (uint8 v, bytes32 r, bytes32 s) = vm.sign( - userPrivateKey, - SigUtils.getTypedDepositHash( - depositPermit, - staticATokenLM.METADEPOSIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ) - ); - - IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); - - uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); - uint256 shares = staticATokenLM.metaDeposit( - depositPermit.owner, - depositPermit.spender, - depositPermit.value, - depositPermit.referralCode, - depositPermit.fromUnderlying, - depositPermit.deadline, - permitParams, - sigParams - ); - assertEq(shares, previewDeposit); - assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); - } - - function test_metaDepositAToken() public { - uint128 amountToDeposit = 5e6; - _fundUser(amountToDeposit, user); - _underlyingToAToken(amountToDeposit, user); - - // permit for aToken deposit - SigUtils.Permit memory permit = SigUtils.Permit({ - owner: user, - spender: address(staticATokenLM), - value: 1e6, - nonce: IERC20WithPermit(A_TOKEN).nonces(user), - deadline: block.timestamp + 1 days - }); - - bytes32 permitDigest = SigUtils.getTypedDataHash( - permit, - staticATokenLM.PERMIT_TYPEHASH(), - IERC20WithPermit(A_TOKEN).DOMAIN_SEPARATOR() - ); - - (uint8 pV, bytes32 pR, bytes32 pS) = vm.sign(userPrivateKey, permitDigest); - - IStaticATokenLM.PermitParams memory permitParams = IStaticATokenLM.PermitParams( - permit.owner, - permit.spender, - permit.value, - permit.deadline, - pV, - pR, - pS - ); - - // generate combined permit - SigUtils.DepositPermit memory depositPermit = SigUtils.DepositPermit({ - owner: user, - spender: spender, - value: permit.value, - referralCode: 0, - fromUnderlying: false, - nonce: staticATokenLM.nonces(user), - deadline: permit.deadline, - permit: permitParams - }); - bytes32 digest = SigUtils.getTypedDepositHash( - depositPermit, - staticATokenLM.METADEPOSIT_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); - - IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); - - uint256 previewDeposit = staticATokenLM.previewDeposit(depositPermit.value); - - staticATokenLM.metaDeposit( - depositPermit.owner, - depositPermit.spender, - depositPermit.value, - depositPermit.referralCode, - depositPermit.fromUnderlying, - depositPermit.deadline, - permitParams, - sigParams - ); - - assertEq(staticATokenLM.balanceOf(depositPermit.spender), previewDeposit); - } - - function test_metaWithdraw() public { - uint128 amountToDeposit = 5e6; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - SigUtils.WithdrawPermit memory permit = SigUtils.WithdrawPermit({ - owner: user, - spender: spender, - staticAmount: 0, - dynamicAmount: 1e6, - toUnderlying: false, - nonce: staticATokenLM.nonces(user), - deadline: block.timestamp + 1 days - }); - bytes32 digest = SigUtils.getTypedWithdrawHash( - permit, - staticATokenLM.METAWITHDRAWAL_TYPEHASH(), - staticATokenLM.DOMAIN_SEPARATOR() - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(userPrivateKey, digest); - - IStaticATokenLM.SignatureParams memory sigParams = IStaticATokenLM.SignatureParams(v, r, s); - - staticATokenLM.metaWithdraw( - permit.owner, - permit.spender, - permit.staticAmount, - permit.dynamicAmount, - permit.toUnderlying, - permit.deadline, - sigParams - ); - - assertEq(IERC20(A_TOKEN).balanceOf(permit.spender), permit.dynamicAmount); - } -} diff --git a/tests/extensions/static-a-token/StaticATokenNoLM.t.sol b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol deleted file mode 100644 index 84ddbd33..00000000 --- a/tests/extensions/static-a-token/StaticATokenNoLM.t.sol +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {BaseTest, IERC20} from './TestBase.sol'; - -/** - * Testing the static token wrapper on a pool that never had LM enabled - * This is a slightly different assumption than a pool that doesn't have LM enabled any more as incentivesController.rewardTokens() will have length=0 - */ -contract StaticATokenNoLMTest is BaseTest { - function setUp() public override { - super.setUp(); - - vm.startPrank(user); - } - - // test rewards - function test_collectAndUpdateRewardsWithLMDisabled() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); - assertEq(staticATokenLM.getTotalClaimableRewards(REWARD_TOKEN), 0); - assertEq(staticATokenLM.collectAndUpdateRewards(REWARD_TOKEN), 0); - assertEq(IERC20(REWARD_TOKEN).balanceOf(address(staticATokenLM)), 0); - } - - function test_claimRewardsToSelfWithLMDisabled() public { - uint128 amountToDeposit = 5 ether; - _fundUser(amountToDeposit, user); - - _depositAToken(amountToDeposit, user); - - _skipBlocks(60); - - try staticATokenLM.getClaimableRewards(user, REWARD_TOKEN) {} catch Error( - string memory reason - ) { - require(keccak256(bytes(reason)) == keccak256(bytes('9'))); - } - - try staticATokenLM.claimRewardsToSelf(rewardTokens) {} catch Error(string memory reason) { - require(keccak256(bytes(reason)) == keccak256(bytes('9'))); - } - assertEq(IERC20(REWARD_TOKEN).balanceOf(user), 0); - } -} diff --git a/tests/extensions/static-a-token/TestBase.sol b/tests/extensions/static-a-token/TestBase.sol deleted file mode 100644 index d4b488fa..00000000 --- a/tests/extensions/static-a-token/TestBase.sol +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.10; - -import {IRewardsController} from 'src/contracts/rewards/interfaces/IRewardsController.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; -import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; -import {IPool} from '../../../src/contracts/interfaces/IPool.sol'; -import {StaticATokenFactory} from '../../../src/contracts/extensions/static-a-token/StaticATokenFactory.sol'; -import {StaticATokenLM, IStaticATokenLM, IERC20, IERC20Metadata, ERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; -import {IAToken} from '../../../src/contracts/extensions/static-a-token/interfaces/IAToken.sol'; -import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol'; -import {DataTypes} from '../../../src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; - -abstract contract BaseTest is TestnetProcedures { - address constant OWNER = address(1234); - - address public user; - address public user1; - address internal spender; - - uint256 internal userPrivateKey; - uint256 internal spenderPrivateKey; - - StaticATokenLM public staticATokenLM; - address public proxyAdmin; - ITransparentProxyFactory public proxyFactory; - StaticATokenFactory public factory; - - address[] rewardTokens; - - address public UNDERLYING; - address public A_TOKEN; - address public REWARD_TOKEN; - IPool public POOL; - - function setUp() public virtual { - userPrivateKey = 0xA11CE; - spenderPrivateKey = 0xB0B0; - user = address(vm.addr(userPrivateKey)); - user1 = address(vm.addr(2)); - spender = vm.addr(spenderPrivateKey); - - initTestEnvironment(); - DataTypes.ReserveDataLegacy memory reserveDataWETH = contracts.poolProxy.getReserveData( - tokenList.weth - ); - - UNDERLYING = address(weth); - REWARD_TOKEN = address(new TestnetERC20('LM Reward ERC20', 'RWD', 18, OWNER)); - A_TOKEN = reserveDataWETH.aTokenAddress; - POOL = contracts.poolProxy; - - rewardTokens.push(REWARD_TOKEN); - - proxyFactory = ITransparentProxyFactory(report.transparentProxyFactory); - proxyAdmin = report.proxyAdmin; - - factory = StaticATokenFactory(report.staticATokenFactoryProxy); - factory.createStaticATokens(POOL.getReservesList()); - - staticATokenLM = StaticATokenLM(factory.getStaticAToken(UNDERLYING)); - } - - function _fundUser(uint128 amountToDeposit, address targetUser) internal { - deal(UNDERLYING, targetUser, amountToDeposit); - } - - function _skipBlocks(uint128 blocks) internal { - vm.roll(block.number + blocks); - vm.warp(block.timestamp + blocks * 12); // assuming a block is around 12seconds - } - - function _underlyingToAToken(uint256 amountToDeposit, address targetUser) internal { - IERC20(UNDERLYING).approve(address(POOL), amountToDeposit); - POOL.deposit(UNDERLYING, amountToDeposit, targetUser, 0); - } - - function _depositAToken(uint256 amountToDeposit, address targetUser) internal returns (uint256) { - _underlyingToAToken(amountToDeposit, targetUser); - IERC20(A_TOKEN).approve(address(staticATokenLM), amountToDeposit); - return staticATokenLM.deposit(amountToDeposit, targetUser, 10, false); - } - - function testAdmin() public { - vm.stopPrank(); - vm.startPrank(proxyAdmin); - assertEq(TransparentUpgradeableProxy(payable(address(staticATokenLM))).admin(), proxyAdmin); - assertEq(TransparentUpgradeableProxy(payable(address(factory))).admin(), proxyAdmin); - vm.stopPrank(); - } -} diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol deleted file mode 100644 index cf909a86..00000000 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ /dev/null @@ -1,670 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import 'forge-std/Test.sol'; -import {IAaveV3ConfigEngine} from '../../../src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol'; -import {AaveV3MockListing} from './mocks/AaveV3MockListing.sol'; -import {AaveV3MockListingCustom} from './mocks/AaveV3MockListingCustom.sol'; -import {AaveV3MockCapUpdate} from './mocks/AaveV3MockCapUpdate.sol'; -import {AaveV3MockCollateralUpdate} from './mocks/AaveV3MockCollateralUpdate.sol'; -import {AaveV3MockCollateralUpdateNoChange} from './mocks/AaveV3MockCollateralUpdateNoChange.sol'; -import {AaveV3MockCollateralUpdateWrongBonus, AaveV3MockCollateralUpdateCorrectBonus} from './mocks/AaveV3MockCollateralUpdateWrongBonus.sol'; -import {AaveV3MockBorrowUpdate} from './mocks/AaveV3MockBorrowUpdate.sol'; -import {AaveV3MockBorrowUpdateNoChange} from './mocks/AaveV3MockBorrowUpdateNoChange.sol'; -import {AaveV3MockRatesUpdate} from './mocks/AaveV3MockRatesUpdate.sol'; -import {AaveV3MockPriceFeedUpdate} from './mocks/AaveV3MockPriceFeedUpdate.sol'; -import {AaveV3MockEModeCategoryUpdate, AaveV3MockEModeCategoryUpdateEdgeBonus} from './mocks/AaveV3MockEModeCategoryUpdate.sol'; -import {AaveV3MockEModeCategoryUpdateNoChange} from './mocks/AaveV3MockEModeCategoryUpdateNoChange.sol'; -import {AaveV3MockAssetEModeUpdate} from './mocks/AaveV3MockAssetEModeUpdate.sol'; - -import {ATokenInstance} from '../../../src/contracts/instances/ATokenInstance.sol'; -import {StableDebtTokenInstance} from '../../../src/contracts/instances/StableDebtTokenInstance.sol'; -import {VariableDebtTokenInstance} from '../../../src/contracts/instances/VariableDebtTokenInstance.sol'; -import {TestnetProcedures, AaveV3ConfigEngine} from '../../utils/TestnetProcedures.sol'; -import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; -import {MockAggregator} from '../../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; -import {IPool, IPoolAddressesProvider} from '../../utils/ProtocolV3TestBase.sol'; -import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; -import {ProtocolV3TestBase, IDefaultInterestRateStrategyV2, ReserveConfig, ReserveTokens, DataTypes as DataTypeOld} from '../../utils/ProtocolV3TestBase.sol'; - -contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { - using stdStorage for StdStorage; - address configEngine; - - function setUp() public { - initTestEnvironment(); - configEngine = report.configEngine; - } - - event CollateralConfigurationChanged( - address indexed asset, - uint256 ltv, - uint256 liquidationThreshold, - uint256 liquidationBonus - ); - - event EModeCategoryAdded( - uint8 indexed categoryId, - uint256 ltv, - uint256 liquidationThreshold, - uint256 liquidationBonus, - address oracle, - string label - ); - - function testListings() public { - address asset = address(new TestnetERC20('1INCH', '1INCH', 18, address(this))); - - address feed = address(new MockAggregator(int256(25e8))); - AaveV3MockListing payload = new AaveV3MockListing(asset, feed, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineListing', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineListing', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineListing', 'postTestEngineListing'); - - ReserveConfig memory expectedAssetConfig = ReserveConfig({ - symbol: '1INCH', - underlying: asset, - aToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - variableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - stableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - decimals: 18, - ltv: 82_50, - liquidationThreshold: 86_00, - liquidationBonus: 105_00, - liquidationProtocolFee: 10_00, - reserveFactor: 10_00, - usageAsCollateralEnabled: true, - borrowingEnabled: true, - interestRateStrategy: AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), - stableBorrowRateEnabled: false, - isPaused: false, - isActive: true, - isFrozen: false, - isSiloed: false, - isBorrowableInIsolation: false, - isFlashloanable: false, - supplyCap: 85_000, - borrowCap: 60_000, - debtCeiling: 0, - eModeCategory: 0 - }); - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - - _noReservesConfigsChangesApartNewListings(allConfigsBefore, allConfigsAfter); - - _validateReserveTokensImpls( - _findReserveConfigBySymbol(allConfigsAfter, '1INCH'), - ReserveTokens({ - aToken: address(contracts.aToken), - stableDebtToken: address(contracts.stableDebtToken), - variableDebtToken: address(contracts.variableDebtToken) - }) - ); - - _validateAssetSourceOnOracle( - IPoolAddressesProvider(address(contracts.poolAddressesProvider)), - asset, - feed - ); - - _validateInterestRateStrategy( - asset, - contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), - AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), - IDefaultInterestRateStrategyV2.InterestRateDataRay({ - optimalUsageRatio: _bpsToRay(payload.newListings()[0].rateStrategyParams.optimalUsageRatio), - baseVariableBorrowRate: _bpsToRay( - payload.newListings()[0].rateStrategyParams.baseVariableBorrowRate - ), - variableRateSlope1: _bpsToRay( - payload.newListings()[0].rateStrategyParams.variableRateSlope1 - ), - variableRateSlope2: _bpsToRay( - payload.newListings()[0].rateStrategyParams.variableRateSlope2 - ) - }) - ); - } - - function testListingsCustom() public { - address asset = address(new TestnetERC20('PSP', 'PSP', 18, address(this))); - - address feed = address(new MockAggregator(int256(15e8))); - address aTokenImpl = address(new ATokenInstance(contracts.poolProxy)); - address vTokenImpl = address(new VariableDebtTokenInstance(contracts.poolProxy)); - address sTokenImpl = address(new StableDebtTokenInstance(contracts.poolProxy)); - - AaveV3MockListingCustom payload = new AaveV3MockListingCustom( - asset, - feed, - configEngine, - aTokenImpl, - vTokenImpl, - sTokenImpl - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineListingCustom', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineListingCustom', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineListingCustom', 'postTestEngineListingCustom'); - - ReserveConfig memory expectedAssetConfig = ReserveConfig({ - symbol: 'PSP', - underlying: asset, - aToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - variableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - stableDebtToken: address(0), // Mock, as they don't get validated, because of the "dynamic" deployment on proposal execution - decimals: 18, - ltv: 82_50, - liquidationThreshold: 86_00, - liquidationBonus: 105_00, - liquidationProtocolFee: 10_00, - reserveFactor: 10_00, - usageAsCollateralEnabled: true, - borrowingEnabled: true, - interestRateStrategy: AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), - stableBorrowRateEnabled: false, - isPaused: false, - isActive: true, - isFrozen: false, - isSiloed: false, - isBorrowableInIsolation: false, - isFlashloanable: false, - supplyCap: 85_000, - borrowCap: 60_000, - debtCeiling: 0, - eModeCategory: 0 - }); - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - - _noReservesConfigsChangesApartNewListings(allConfigsBefore, allConfigsAfter); - - _validateReserveTokensImpls( - _findReserveConfigBySymbol(allConfigsAfter, 'PSP'), - ReserveTokens({ - aToken: aTokenImpl, - stableDebtToken: sTokenImpl, - variableDebtToken: vTokenImpl - }) - ); - - _validateAssetSourceOnOracle( - IPoolAddressesProvider(address(contracts.poolAddressesProvider)), - asset, - feed - ); - - _validateInterestRateStrategy( - asset, - contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), - AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), - IDefaultInterestRateStrategyV2.InterestRateDataRay({ - optimalUsageRatio: _bpsToRay( - payload.newListingsCustom()[0].base.rateStrategyParams.optimalUsageRatio - ), - baseVariableBorrowRate: _bpsToRay( - payload.newListingsCustom()[0].base.rateStrategyParams.baseVariableBorrowRate - ), - variableRateSlope1: _bpsToRay( - payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope1 - ), - variableRateSlope2: _bpsToRay( - payload.newListingsCustom()[0].base.rateStrategyParams.variableRateSlope2 - ) - }) - ); - } - - function testCapsUpdate() public { - // this asset has been listed before - address asset = tokenList.usdx; - AaveV3MockCapUpdate payload = new AaveV3MockCapUpdate(asset, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineCaps', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineCaps', - IPool(address(contracts.poolProxy)) - ); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - - diffReports('preTestEngineCaps', 'postTestEngineCaps'); - - expectedAssetConfig.supplyCap = 1_000_000; - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - function testCollateralsUpdates() public { - // this asset has been listed before - address asset = tokenList.usdx; - AaveV3MockCollateralUpdate payload = new AaveV3MockCollateralUpdate(asset, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineCollateral', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineCollateral', - IPool(address(contracts.poolProxy)) - ); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - - diffReports('preTestEngineCollateral', 'postTestEngineCollateral'); - - expectedAssetConfig.ltv = 62_00; - expectedAssetConfig.liquidationThreshold = 72_00; - expectedAssetConfig.liquidationBonus = 106_00; // 100_00 + 6_00 - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - // TODO manage this after testFail* deprecation. - // This should not be necessary, but there seems there is no other way - // of validating that when all collateral params are KEEP_CURRENT, the config - // engine doesn't call the POOL_CONFIGURATOR. - // So the solution is expecting the event emitted on the POOL_CONFIGURATOR, - // and as this doesn't happen, expect the failure of the test - function testFailCollateralsUpdatesNoChange() public { - // this asset has been listed before - address asset = tokenList.usdx; - AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange( - asset, - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineCollateralNoChange', - IPool(address(contracts.poolProxy)) - ); - - vm.expectEmit(); - emit CollateralConfigurationChanged( - allConfigsBefore[0].underlying, - allConfigsBefore[0].ltv, - allConfigsBefore[0].liquidationThreshold, - allConfigsBefore[0].liquidationBonus - ); - payload.execute(); - } - - // Same as testFailCollateralsUpdatesNoChange, but this time should work, as we are not expecting any event emitted - function testCollateralsUpdatesNoChange() public { - // this asset has been listed before - address asset = tokenList.usdx; - AaveV3MockCollateralUpdateNoChange payload = new AaveV3MockCollateralUpdateNoChange( - asset, - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineCollateralNoChange', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineCollateralNoChange', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineCollateralNoChange', 'postTestEngineCollateralNoChange'); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - function testCollateralUpdateWrongBonus() public { - address asset = tokenList.usdx; - AaveV3MockCollateralUpdateWrongBonus payload = new AaveV3MockCollateralUpdateWrongBonus( - asset, - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - vm.expectRevert(bytes('INVALID_LT_LB_RATIO')); - payload.execute(); - } - - function testCollateralUpdateCorrectBonus() public { - address asset = tokenList.usdx; - AaveV3MockCollateralUpdateCorrectBonus payload = new AaveV3MockCollateralUpdateCorrectBonus( - asset, - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineCollateralEdgeBonus', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineCollateralEdgeBonus', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineCollateralEdgeBonus', 'postTestEngineCollateralEdgeBonus'); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - expectedAssetConfig.ltv = 62_00; - expectedAssetConfig.liquidationThreshold = 90_00; - expectedAssetConfig.liquidationBonus = 111_00; // 100_00 + 11_00 - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - function testBorrowsUpdates() public { - address asset = tokenList.usdx; - AaveV3MockBorrowUpdate payload = new AaveV3MockBorrowUpdate(asset, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineBorrow', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineBorrow', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineBorrow', 'postTestEngineBorrow'); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - expectedAssetConfig.reserveFactor = 15_00; - expectedAssetConfig.borrowingEnabled = true; - expectedAssetConfig.isFlashloanable = false; - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - function testBorrowUpdatesNoChange() public { - address asset = tokenList.usdx; - AaveV3MockBorrowUpdateNoChange payload = new AaveV3MockBorrowUpdateNoChange( - asset, - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot( - 'preTestEngineBorrowNoChange', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot( - 'postTestEngineBorrowNoChange', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineBorrowNoChange', 'postTestEngineBorrowNoChange'); - - ReserveConfig memory expectedAssetConfig = _findReserveConfig(allConfigsBefore, asset); - - _validateReserveConfig(expectedAssetConfig, allConfigsAfter); - } - - function testRateStrategiesUpdates() public { - address asset = tokenList.usdx; - AaveV3MockRatesUpdate payload = new AaveV3MockRatesUpdate(asset, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - createConfigurationSnapshot('preTestEngineRates', IPool(address(contracts.poolProxy))); - - payload.execute(); - - createConfigurationSnapshot('postTestEngineRates', IPool(address(contracts.poolProxy))); - - diffReports('preTestEngineRates', 'postTestEngineRates'); - - _validateInterestRateStrategy( - asset, - contracts.protocolDataProvider.getInterestRateStrategyAddress(asset), - AaveV3ConfigEngine(configEngine).DEFAULT_INTEREST_RATE_STRATEGY(), - IDefaultInterestRateStrategyV2.InterestRateDataRay({ - optimalUsageRatio: _bpsToRay(payload.rateStrategiesUpdates()[0].params.optimalUsageRatio), - baseVariableBorrowRate: _bpsToRay( - payload.rateStrategiesUpdates()[0].params.baseVariableBorrowRate - ), - variableRateSlope1: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope1), - variableRateSlope2: _bpsToRay(payload.rateStrategiesUpdates()[0].params.variableRateSlope2) - }) - ); - } - - function testPriceFeedsUpdates() public { - address asset = tokenList.usdx; - address newFeed = address(new MockAggregator(int256(1.05e8))); - AaveV3MockPriceFeedUpdate payload = new AaveV3MockPriceFeedUpdate(asset, newFeed, configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - createConfigurationSnapshot('preTestEnginePriceFeed', IPool(address(contracts.poolProxy))); - - payload.execute(); - - createConfigurationSnapshot('postTestEnginePriceFeed', IPool(address(contracts.poolProxy))); - - diffReports('preTestEnginePriceFeed', 'postTestEnginePriceFeed'); - - _validateAssetSourceOnOracle( - IPoolAddressesProvider(address(contracts.poolAddressesProvider)), - asset, - newFeed - ); - } - - function testEModeCategoryUpdates() public { - AaveV3MockEModeCategoryUpdate payload = new AaveV3MockEModeCategoryUpdate(configEngine); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - contracts.poolProxy.getEModeCategoryData(1); - - createConfigurationSnapshot( - 'preTestEngineEModeCategoryUpdate', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - createConfigurationSnapshot( - 'postTestEngineEModeCategoryUpdate', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineEModeCategoryUpdate', 'postTestEngineEModeCategoryUpdate'); - - DataTypeOld.EModeCategory memory prevEmodeCategoryData; - prevEmodeCategoryData.ltv = 97_40; - prevEmodeCategoryData.liquidationThreshold = 97_60; - prevEmodeCategoryData.liquidationBonus = 101_50; // 100_00 + 1_50 - prevEmodeCategoryData.priceSource = address(0); - prevEmodeCategoryData.label = 'ETH Correlated'; - - _validateEmodeCategory( - IPoolAddressesProvider(address(contracts.poolAddressesProvider)), - 1, - prevEmodeCategoryData - ); - } - - function testEModeCategoryUpdatesWrongBonus() public { - AaveV3MockEModeCategoryUpdateEdgeBonus payload = new AaveV3MockEModeCategoryUpdateEdgeBonus( - configEngine - ); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - vm.expectRevert(bytes('INVALID_LT_LB_RATIO')); - payload.execute(); - } - - // TODO manage this after testFail* deprecation. - function testFailEModeCategoryUpdatesNoChange() public { - AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange( - configEngine - ); - - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts - .poolProxy - .getEModeCategoryData(1); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - vm.expectEmit(true, true, true, true); - emit EModeCategoryAdded( - 1, - eModeCategoryDataBefore.ltv, - eModeCategoryDataBefore.liquidationThreshold, - eModeCategoryDataBefore.liquidationBonus, - eModeCategoryDataBefore.priceSource, - eModeCategoryDataBefore.label - ); - payload.execute(); - } - - // Same as testFailEModeCategoryUpdatesNoChange, but this time should work, as we are not expecting any event emitted - function testEModeCategoryUpdatesNoChange() public { - AaveV3MockEModeCategoryUpdateNoChange payload = new AaveV3MockEModeCategoryUpdateNoChange( - configEngine - ); - - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts - .poolProxy - .getEModeCategoryData(1); - - vm.prank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - - createConfigurationSnapshot( - 'preTestEngineEModeCategoryNoChange', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - createConfigurationSnapshot( - 'postTestEngineEModeCategoryNoChange', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineEModeCategoryNoChange', 'postTestEngineEModeCategoryNoChange'); - - DataTypeOld.EModeCategory memory prevEmodeCategoryData; - prevEmodeCategoryData.ltv = eModeCategoryDataBefore.ltv; - prevEmodeCategoryData.liquidationThreshold = eModeCategoryDataBefore.liquidationThreshold; - prevEmodeCategoryData.liquidationBonus = eModeCategoryDataBefore.liquidationBonus; - prevEmodeCategoryData.priceSource = eModeCategoryDataBefore.priceSource; - prevEmodeCategoryData.label = eModeCategoryDataBefore.label; - - _validateEmodeCategory( - IPoolAddressesProvider(address(contracts.poolAddressesProvider)), - 1, - prevEmodeCategoryData - ); - } - - function testAssetEModeUpdates() public { - address asset = tokenList.usdx; - - AaveV3MockEModeCategoryUpdate payloadToAddEMode = new AaveV3MockEModeCategoryUpdate( - configEngine - ); - AaveV3MockAssetEModeUpdate payload = new AaveV3MockAssetEModeUpdate(asset, configEngine); - - vm.startPrank(roleList.marketOwner); - contracts.aclManager.addPoolAdmin(address(payload)); - contracts.aclManager.addPoolAdmin(address(payloadToAddEMode)); - vm.stopPrank(); - - payloadToAddEMode.execute(); - - createConfigurationSnapshot( - 'preTestEngineAssetEModeUpdate', - IPool(address(contracts.poolProxy)) - ); - - payload.execute(); - - createConfigurationSnapshot( - 'postTestEngineAssetEModeUpdate', - IPool(address(contracts.poolProxy)) - ); - - diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); - - assertEq(contracts.protocolDataProvider.getReserveEModeCategory(asset), 1); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol deleted file mode 100644 index 5e2d45ac..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock asset e-mode update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockAssetEModeUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function assetsEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { - IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](1); - - eModeUpdate[0] = IEngine.AssetEModeUpdate({asset: ASSET_ADDRESS, eModeCategory: 1}); - - return eModeUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol deleted file mode 100644 index d397e9f1..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock borrow update, to be able to test - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine - * @author BGD Labs - */ -contract AaveV3MockBorrowUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function borrowsUpdates() public view override returns (IEngine.BorrowUpdate[] memory) { - IEngine.BorrowUpdate[] memory borrowsUpdate = new IEngine.BorrowUpdate[](1); - - borrowsUpdate[0] = IEngine.BorrowUpdate({ - asset: ASSET_ADDRESS, - enabledToBorrow: EngineFlags.ENABLED, - flashloanable: EngineFlags.DISABLED, - stableRateModeEnabled: EngineFlags.KEEP_CURRENT, - borrowableInIsolation: EngineFlags.KEEP_CURRENT, - withSiloedBorrowing: EngineFlags.KEEP_CURRENT, - reserveFactor: 15_00 - }); - - return borrowsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol deleted file mode 100644 index b7176035..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock borrow update with no change, to be able to test - * @author BGD Labs - */ -contract AaveV3MockBorrowUpdateNoChange is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function borrowsUpdates() public view override returns (IEngine.BorrowUpdate[] memory) { - IEngine.BorrowUpdate[] memory borrowsUpdate = new IEngine.BorrowUpdate[](1); - - borrowsUpdate[0] = IEngine.BorrowUpdate({ - asset: ASSET_ADDRESS, - enabledToBorrow: EngineFlags.KEEP_CURRENT, - flashloanable: EngineFlags.KEEP_CURRENT, - stableRateModeEnabled: EngineFlags.KEEP_CURRENT, - borrowableInIsolation: EngineFlags.KEEP_CURRENT, - withSiloedBorrowing: EngineFlags.KEEP_CURRENT, - reserveFactor: EngineFlags.KEEP_CURRENT - }); - - return borrowsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol deleted file mode 100644 index 7575fa20..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock caps update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockCapUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function capsUpdates() public view override returns (IEngine.CapsUpdate[] memory) { - IEngine.CapsUpdate[] memory capsUpdate = new IEngine.CapsUpdate[](1); - - capsUpdate[0] = IEngine.CapsUpdate({ - asset: ASSET_ADDRESS, - supplyCap: 1_000_000, - borrowCap: EngineFlags.KEEP_CURRENT - }); - - return capsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol deleted file mode 100644 index 70e38f1e..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock collateral update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockCollateralUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { - IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); - - collateralsUpdate[0] = IEngine.CollateralUpdate({ - asset: ASSET_ADDRESS, - ltv: 62_00, - liqThreshold: 72_00, - liqBonus: 6_00, - debtCeiling: EngineFlags.KEEP_CURRENT, - liqProtocolFee: EngineFlags.KEEP_CURRENT - }); - - return collateralsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol deleted file mode 100644 index 12c9221f..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock collateral update with no changes, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockCollateralUpdateNoChange is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { - IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); - - collateralsUpdate[0] = IEngine.CollateralUpdate({ - asset: ASSET_ADDRESS, - ltv: EngineFlags.KEEP_CURRENT, - liqThreshold: EngineFlags.KEEP_CURRENT, - liqBonus: EngineFlags.KEEP_CURRENT, - debtCeiling: EngineFlags.KEEP_CURRENT, - liqProtocolFee: EngineFlags.KEEP_CURRENT - }); - - return collateralsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol deleted file mode 100644 index b41f26d5..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contracts for a mock collateral update, with wrong LT/LB ratio - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockCollateralUpdateWrongBonus is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { - IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); - - collateralsUpdate[0] = IEngine.CollateralUpdate({ - asset: ASSET_ADDRESS, - ltv: 62_00, - liqThreshold: 90_00, - liqBonus: 12_00, - debtCeiling: EngineFlags.KEEP_CURRENT, - liqProtocolFee: EngineFlags.KEEP_CURRENT - }); - - return collateralsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Avalanche', networkAbbreviation: 'Ava'}); - } -} - -/** - * @dev Smart contracts for a mock collateral update, with correct (but edge) LT/LB ratio - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockCollateralUpdateCorrectBonus is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function collateralsUpdates() public view override returns (IEngine.CollateralUpdate[] memory) { - IEngine.CollateralUpdate[] memory collateralsUpdate = new IEngine.CollateralUpdate[](1); - - collateralsUpdate[0] = IEngine.CollateralUpdate({ - asset: ASSET_ADDRESS, - ltv: 62_00, - liqThreshold: 90_00, - liqBonus: 11_00, - debtCeiling: EngineFlags.KEEP_CURRENT, - liqProtocolFee: EngineFlags.KEEP_CURRENT - }); - - return collateralsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol deleted file mode 100644 index 796b4009..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock emode category update, to be able to test - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine - * @author BGD Labs - */ -contract AaveV3MockEModeCategoryUpdate is AaveV3Payload { - constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} - - function eModeCategoriesUpdates() - public - pure - override - returns (IEngine.EModeCategoryUpdate[] memory) - { - IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); - - eModeUpdates[0] = IEngine.EModeCategoryUpdate({ - eModeCategory: 1, - ltv: 97_40, - liqThreshold: 97_60, - liqBonus: 1_50, - priceSource: address(0), - label: 'ETH Correlated' - }); - - return eModeUpdates; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Polygon', networkAbbreviation: 'Pol'}); - } -} - -/** - * @dev Smart contract for a mock emode category update, to be able to test - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine - * @author BGD Labs - */ -contract AaveV3MockEModeCategoryUpdateEdgeBonus is AaveV3Payload { - constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} - - function eModeCategoriesUpdates() - public - pure - override - returns (IEngine.EModeCategoryUpdate[] memory) - { - IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); - - eModeUpdates[0] = IEngine.EModeCategoryUpdate({ - eModeCategory: 1, - ltv: 97_40, - liqThreshold: 97_60, - liqBonus: 2_50, - priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, - label: EngineFlags.KEEP_CURRENT_STRING - }); - - return eModeUpdates; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol deleted file mode 100644 index b36ce80c..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock e-mode category update with no changes, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockEModeCategoryUpdateNoChange is AaveV3Payload { - constructor(address customEngine) AaveV3Payload(IEngine(customEngine)) {} - - function eModeCategoriesUpdates() - public - pure - override - returns (IEngine.EModeCategoryUpdate[] memory) - { - IEngine.EModeCategoryUpdate[] memory eModeUpdates = new IEngine.EModeCategoryUpdate[](1); - - eModeUpdates[0] = IEngine.EModeCategoryUpdate({ - eModeCategory: 1, - ltv: EngineFlags.KEEP_CURRENT, - liqThreshold: EngineFlags.KEEP_CURRENT, - liqBonus: EngineFlags.KEEP_CURRENT, - priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, - label: EngineFlags.KEEP_CURRENT_STRING - }); - - return eModeUpdates; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol deleted file mode 100644 index 825e80ee..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock listing, to be able to test without having a v3 instance on Local - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine - * @author BGD Labs - */ -contract AaveV3MockListing is AaveV3Payload { - address public immutable ASSET_ADDRESS; - address public immutable ASSET_FEED; - - constructor( - address assetAddress, - address assetFeed, - address customEngine - ) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - ASSET_FEED = assetFeed; - } - - function newListings() public view override returns (IEngine.Listing[] memory) { - IEngine.Listing[] memory listings = new IEngine.Listing[](1); - - listings[0] = IEngine.Listing({ - asset: ASSET_ADDRESS, - assetSymbol: '1INCH', - priceFeed: ASSET_FEED, - rateStrategyParams: IEngine.InterestRateInputData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 25, // 0.25% - variableRateSlope1: 3_00, - variableRateSlope2: 75_00 - }), - enabledToBorrow: EngineFlags.ENABLED, - stableRateModeEnabled: EngineFlags.DISABLED, - borrowableInIsolation: EngineFlags.DISABLED, - withSiloedBorrowing: EngineFlags.DISABLED, - flashloanable: EngineFlags.DISABLED, - ltv: 82_50, - liqThreshold: 86_00, - liqBonus: 5_00, - reserveFactor: 10_00, - supplyCap: 85_000, - borrowCap: 60_000, - debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 - }); - - return listings; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol deleted file mode 100644 index dc41c531..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock custom listing update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockListingCustom is AaveV3Payload { - address public immutable ASSET_ADDRESS; - address public immutable ASSET_FEED; - - address public immutable A_TOKEN_IMPL; - address public immutable V_TOKEN_IMPL; - address public immutable S_TOKEN_IMPL; - - constructor( - address assetAddress, - address assetFeed, - address customEngine, - address aTokenImpl, - address vTokenImpl, - address sTokenImpl - ) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - ASSET_FEED = assetFeed; - A_TOKEN_IMPL = aTokenImpl; - V_TOKEN_IMPL = vTokenImpl; - S_TOKEN_IMPL = sTokenImpl; - } - - function newListingsCustom() - public - view - override - returns (IEngine.ListingWithCustomImpl[] memory) - { - IEngine.ListingWithCustomImpl[] memory listingsCustom = new IEngine.ListingWithCustomImpl[](1); - - listingsCustom[0] = IEngine.ListingWithCustomImpl( - IEngine.Listing({ - asset: ASSET_ADDRESS, - assetSymbol: 'PSP', - priceFeed: ASSET_FEED, - rateStrategyParams: IEngine.InterestRateInputData({ - optimalUsageRatio: 80_00, - baseVariableBorrowRate: 25, // 0.25% - variableRateSlope1: 3_00, - variableRateSlope2: 75_00 - }), - enabledToBorrow: EngineFlags.ENABLED, - stableRateModeEnabled: EngineFlags.DISABLED, - borrowableInIsolation: EngineFlags.DISABLED, - withSiloedBorrowing: EngineFlags.DISABLED, - flashloanable: EngineFlags.DISABLED, - ltv: 82_50, - liqThreshold: 86_00, - liqBonus: 5_00, - reserveFactor: 10_00, - supplyCap: 85_000, - borrowCap: 60_000, - debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 - }), - IEngine.TokenImplementations({ - aToken: A_TOKEN_IMPL, - vToken: V_TOKEN_IMPL, - sToken: S_TOKEN_IMPL - }) - ); - - return listingsCustom; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol deleted file mode 100644 index 0b5bd8b1..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock price feed update, to be able to test - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @dev Inheriting directly from AaveV3Payload for being able to inject a custom engine - * @author BGD Labs - */ -contract AaveV3MockPriceFeedUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - address public immutable ASSET_FEED; - - constructor( - address assetAddress, - address feed, - address customEngine - ) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - ASSET_FEED = feed; - } - - function priceFeedsUpdates() public view override returns (IEngine.PriceFeedUpdate[] memory) { - IEngine.PriceFeedUpdate[] memory priceFeedsUpdate = new IEngine.PriceFeedUpdate[](1); - - priceFeedsUpdate[0] = IEngine.PriceFeedUpdate({asset: ASSET_ADDRESS, priceFeed: ASSET_FEED}); - - return priceFeedsUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol deleted file mode 100644 index 42214ccc..00000000 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; - -/** - * @dev Smart contract for a mock rate strategy params update, for testing purposes - * IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION - * @author BGD Labs - */ -contract AaveV3MockRatesUpdate is AaveV3Payload { - address public immutable ASSET_ADDRESS; - - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { - ASSET_ADDRESS = assetAddress; - } - - function rateStrategiesUpdates() - public - view - override - returns (IEngine.RateStrategyUpdate[] memory) - { - IEngine.RateStrategyUpdate[] memory ratesUpdate = new IEngine.RateStrategyUpdate[](1); - - ratesUpdate[0] = IEngine.RateStrategyUpdate({ - asset: ASSET_ADDRESS, - params: IEngine.InterestRateInputData({ - optimalUsageRatio: 50_00, - baseVariableBorrowRate: 30, // 0.30% - variableRateSlope1: 4_00, - variableRateSlope2: 76_00 - }) - }); - - return ratesUpdate; - } - - function getPoolContext() public pure override returns (IEngine.PoolContext memory) { - return IEngine.PoolContext({networkName: 'Local', networkAbbreviation: 'Loc'}); - } -} diff --git a/tests/utils/BatchTestProcedures.sol b/tests/utils/BatchTestProcedures.sol index dfdcd416..ea6dd5b0 100644 --- a/tests/utils/BatchTestProcedures.sol +++ b/tests/utils/BatchTestProcedures.sol @@ -63,7 +63,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput AaveV3GettersBatchOne.GettersReportBatchOne memory gettersReport1, PoolReport memory poolReport, PeripheryReport memory peripheryReport, - MiscReport memory miscReport, + ParaswapReport memory paraswapReport, AaveV3SetupBatch setupContract ) { @@ -92,14 +92,21 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput address(setupContract) ); - miscReport = AaveV3BatchOrchestration._deployMisc( - flags.l2, + paraswapReport = AaveV3BatchOrchestration._deployParaswapAdapters( + roles, + config, initialReport.poolAddressesProvider, - config.l2SequencerUptimeFeed, - config.l2PriceOracleSentinelGracePeriod + peripheryReport.treasury ); - return (initialReport, gettersReport1, poolReport, peripheryReport, miscReport, setupContract); + return ( + initialReport, + gettersReport1, + poolReport, + peripheryReport, + paraswapReport, + setupContract + ); } function deployAndSetup( @@ -116,8 +123,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput PoolReport memory poolReport, SetupReport memory setupReport, PeripheryReport memory peripheryReport, - MiscReport memory miscReport, - AaveV3TokensBatch.TokensReport memory tokensReport, ParaswapReport memory paraswapReport, AaveV3SetupBatch setupContract ) @@ -127,7 +132,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput gettersReport1, poolReport, peripheryReport, - miscReport, + paraswapReport, setupContract ) = deployCoreAndPeriphery(roles, config, flags, deployedContracts); @@ -139,15 +144,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput poolReport.poolConfiguratorImplementation, gettersReport1.protocolDataProvider, peripheryReport.aaveOracle, - peripheryReport.rewardsControllerImplementation, - miscReport.priceOracleSentinel - ); - - paraswapReport = AaveV3BatchOrchestration._deployParaswapAdapters( - roles, - config, - initialReport.poolAddressesProvider, - peripheryReport.treasury + peripheryReport.rewardsControllerImplementation ); gettersReport2 = AaveV3BatchOrchestration._deployGettersBatch2( @@ -157,8 +154,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput flags.l2 ); - tokensReport = AaveV3BatchOrchestration._deployTokens(setupReport.poolProxy); - return ( initialReport, gettersReport1, @@ -166,8 +161,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput poolReport, setupReport, peripheryReport, - miscReport, - tokensReport, paraswapReport, setupContract ); @@ -182,7 +175,10 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput assertTrue(r.poolConfiguratorImplementation != address(0), 'r.poolConfiguratorImplementation'); assertTrue(r.protocolDataProvider != address(0), 'report.protocolDataProvider'); assertTrue(r.aaveOracle != address(0), 'report.aaveOracle'); - assertTrue(r.defaultInterestRateStrategy != address(0), 'report.defaultInterestRateStrategy'); + assertTrue( + r.defaultInterestRateStrategy != address(0), + 'report.defaultInterestRateStrategy' + ); assertTrue(r.aclManager != address(0), 'report.aclManager'); assertTrue(r.treasury != address(0), 'report.treasury'); assertTrue(r.proxyAdmin != address(0), 'report.proxyAdmin'); @@ -198,7 +194,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput if (flags.l2) { assertTrue(r.l2Encoder != address(0), 'report.l2Encoder'); - assertTrue(r.priceOracleSentinel != address(0), 'report.priceOracleSentinel'); } assertTrue(r.aToken != address(0), 'report.aToken'); @@ -210,14 +205,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput 'r.rewardsControllerImplementation' ); assertTrue(r.rewardsControllerProxy != address(0), 'report.rewardsControllerProxy'); - assertTrue(r.configEngine != address(0), 'report.configEngine'); - assertTrue( - r.staticATokenFactoryImplementation != address(0), - 'report.staticATokenFactoryImplementation' - ); - assertTrue(r.staticATokenFactoryProxy != address(0), 'report.staticATokenFactoryProxy'); - assertTrue(r.staticATokenImplementation != address(0), 'report.staticATokenImplementation'); - assertTrue(r.transparentProxyFactory != address(0), 'report.transparentProxyFactory'); } function deployAaveV3Testnet( @@ -229,12 +216,6 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput ) internal returns (MarketReport memory testReport) { detectFoundryLibrariesAndDelete(); - // Etch the create2 factory - vm.etch( - 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, - hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' - ); - vm.startPrank(deployer); MarketReport memory deployReport = AaveV3BatchOrchestration.deployAaveV3( deployer, diff --git a/tests/utils/ConfigEngineDeployer.sol b/tests/utils/ConfigEngineDeployer.sol new file mode 100644 index 00000000..5f3e3bb3 --- /dev/null +++ b/tests/utils/ConfigEngineDeployer.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {Vm} from 'forge-std/Vm.sol'; +import {Create2Utils} from '../../src/deployments/contracts/utilities/Create2Utils.sol'; +import {AaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; +import {IAaveV3ConfigEngine} from '../../src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol'; +import {IPoolAddressesProvider} from '../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {IPool} from '../../src/contracts/interfaces/IPool.sol'; +import {IPoolConfigurator} from '../../src/contracts/interfaces/IPoolConfigurator.sol'; +import {IAaveOracle} from '../../src/contracts/interfaces/IAaveOracle.sol'; +import {CapsEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/CapsEngine.sol'; +import {BorrowEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/BorrowEngine.sol'; +import {CollateralEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol'; +import {RateEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/RateEngine.sol'; +import {PriceFeedEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/PriceFeedEngine.sol'; +import {EModeEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol'; +import {ListingEngine} from '../../src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol'; + +library ConfigEngineDeployer { + function deployEngine(Vm vm, MarketReport memory report) internal returns (address) { + // Etch the create2 factory in the local env + vm.etch( + 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, + hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' + ); + IAaveV3ConfigEngine.EngineLibraries memory engineLibraries = IAaveV3ConfigEngine + .EngineLibraries({ + listingEngine: Create2Utils._create2Deploy('v1', type(ListingEngine).creationCode), + eModeEngine: Create2Utils._create2Deploy('v1', type(EModeEngine).creationCode), + borrowEngine: Create2Utils._create2Deploy('v1', type(BorrowEngine).creationCode), + collateralEngine: Create2Utils._create2Deploy('v1', type(CollateralEngine).creationCode), + priceFeedEngine: Create2Utils._create2Deploy('v1', type(PriceFeedEngine).creationCode), + rateEngine: Create2Utils._create2Deploy('v1', type(RateEngine).creationCode), + capsEngine: Create2Utils._create2Deploy('v1', type(CapsEngine).creationCode) + }); + + IAaveV3ConfigEngine.EngineConstants memory engineConstants = IAaveV3ConfigEngine + .EngineConstants({ + pool: IPool(report.poolProxy), + poolConfigurator: IPoolConfigurator(report.poolConfiguratorProxy), + defaultInterestRateStrategy: report.defaultInterestRateStrategy, + oracle: IAaveOracle(report.aaveOracle), + rewardsController: report.rewardsControllerProxy, + collector: report.treasury + }); + + return + address( + new AaveV3ConfigEngine( + report.aToken, + report.variableDebtToken, + report.stableDebtToken, + engineConstants, + engineLibraries + ) + ); + } +} diff --git a/tests/utils/SigUtils.sol b/tests/utils/SigUtils.sol deleted file mode 100644 index 72aed63c..00000000 --- a/tests/utils/SigUtils.sol +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.10; - -import {IStaticATokenLM} from '../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; - -library SigUtils { - struct Permit { - address owner; - address spender; - uint256 value; - uint256 nonce; - uint256 deadline; - } - - struct WithdrawPermit { - address owner; - address spender; - uint256 staticAmount; - uint256 dynamicAmount; - bool toUnderlying; - uint256 nonce; - uint256 deadline; - } - - struct DepositPermit { - address owner; - address spender; - uint256 value; - uint16 referralCode; - bool fromUnderlying; - uint256 nonce; - uint256 deadline; - IStaticATokenLM.PermitParams permit; - } - - // computes the hash of a permit - function getStructHash(Permit memory _permit, bytes32 typehash) internal pure returns (bytes32) { - return - keccak256( - abi.encode( - typehash, - _permit.owner, - _permit.spender, - _permit.value, - _permit.nonce, - _permit.deadline - ) - ); - } - - function getWithdrawHash( - WithdrawPermit memory permit, - bytes32 typehash - ) internal pure returns (bytes32) { - return - keccak256( - abi.encode( - typehash, - permit.owner, - permit.spender, - permit.staticAmount, - permit.dynamicAmount, - permit.toUnderlying, - permit.nonce, - permit.deadline - ) - ); - } - - function getDepositHash( - DepositPermit memory permit, - bytes32 typehash - ) internal pure returns (bytes32) { - return - keccak256( - abi.encode( - typehash, - permit.owner, - permit.spender, - permit.value, - permit.referralCode, - permit.fromUnderlying, - permit.nonce, - permit.deadline, - permit.permit - ) - ); - } - - // computes the hash of the fully encoded EIP-712 message for the domain, which can be used to recover the signer - function getTypedDataHash( - Permit memory permit, - bytes32 typehash, - bytes32 domainSeparator - ) public pure returns (bytes32) { - return - keccak256(abi.encodePacked('\x19\x01', domainSeparator, getStructHash(permit, typehash))); - } - - function getTypedWithdrawHash( - WithdrawPermit memory permit, - bytes32 typehash, - bytes32 domainSeparator - ) public pure returns (bytes32) { - return - keccak256(abi.encodePacked('\x19\x01', domainSeparator, getWithdrawHash(permit, typehash))); - } - - function getTypedDepositHash( - DepositPermit memory permit, - bytes32 typehash, - bytes32 domainSeparator - ) public pure returns (bytes32) { - return - keccak256(abi.encodePacked('\x19\x01', domainSeparator, getDepositHash(permit, typehash))); - } -} diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index 5d74854a..480c091b 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import '../../src/deployments/interfaces/IMarketReportTypes.sol'; +import {ConfigEngineDeployer} from './ConfigEngineDeployer.sol'; import {DeployUtils} from '../../src/deployments/contracts/utilities/DeployUtils.sol'; import {FfiUtils} from '../../src/deployments/contracts/utilities/FfiUtils.sol'; import {DefaultMarketInput} from '../../src/deployments/inputs/DefaultMarketInput.sol'; @@ -112,13 +113,8 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { MarketReport memory deployedContracts ) = _getMarketInput(poolAdmin); roleList = roles; - flags.l2 = l2; - // Etch the create2 factory - vm.etch( - 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7, - hex'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3' - ); + flags.l2 = l2; (report, tokenList) = deployAaveV3TestnetAssets( poolAdmin, @@ -224,8 +220,10 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { MarketReport memory r = deployAaveV3Testnet(deployer, roles, config, flags, deployedContracts); + address engine = ConfigEngineDeployer.deployEngine(vm, r); + AaveV3TestListing testnetListingPayload = new AaveV3TestListing( - IAaveV3ConfigEngine(r.configEngine), + IAaveV3ConfigEngine(engine), roles.poolAdmin, assetsList.weth, r From 4d2b0700ca4260a6e198a8daf0d99c439909d0cb Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 6 May 2024 17:28:14 +0530 Subject: [PATCH 19/88] fix: tests --- .../PoolConfigurator.reserveRiskConfig.t.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol index caa9dd1e..ab2c00cf 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol @@ -581,7 +581,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], true); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(true); + contracts.poolConfiguratorProxy.setPoolPause(true, 0); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -597,7 +597,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { emit ReservePaused(reserves[x], false); } vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setPoolPause(false); + contracts.poolConfiguratorProxy.setPoolPause(false, 0); for (uint16 x; x < reserves.length; ++x) { bool isPaused = contracts.protocolDataProvider.getPaused(reserves[x]); @@ -740,7 +740,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { } function test_setLiquidationGracePeriodReserve(uint40 gracePeriod) public { - vm.assume(gracePeriod < contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0); + vm.assume(gracePeriod <= contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD()); address asset = tokenList.usdx; From 3244a5b1971a02cb8cf7730ecfeb3a98cb1793e9 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 6 May 2024 17:31:33 +0530 Subject: [PATCH 20/88] fix: lint --- tests/utils/BatchTestProcedures.sol | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/utils/BatchTestProcedures.sol b/tests/utils/BatchTestProcedures.sol index ea6dd5b0..9a2e0984 100644 --- a/tests/utils/BatchTestProcedures.sol +++ b/tests/utils/BatchTestProcedures.sol @@ -175,10 +175,7 @@ contract BatchTestProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput assertTrue(r.poolConfiguratorImplementation != address(0), 'r.poolConfiguratorImplementation'); assertTrue(r.protocolDataProvider != address(0), 'report.protocolDataProvider'); assertTrue(r.aaveOracle != address(0), 'report.aaveOracle'); - assertTrue( - r.defaultInterestRateStrategy != address(0), - 'report.defaultInterestRateStrategy' - ); + assertTrue(r.defaultInterestRateStrategy != address(0), 'report.defaultInterestRateStrategy'); assertTrue(r.aclManager != address(0), 'report.aclManager'); assertTrue(r.treasury != address(0), 'report.treasury'); assertTrue(r.proxyAdmin != address(0), 'report.proxyAdmin'); From f6e6ae67d4d931d99ed3cf1f7b3d0a11587c3faf Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 7 May 2024 15:48:35 +0300 Subject: [PATCH 21/88] remove outdated RatesOverflow --- tests/misc/rates/RatesOverflow.t.sol | 52 ---------------------------- 1 file changed, 52 deletions(-) delete mode 100644 tests/misc/rates/RatesOverflow.t.sol diff --git a/tests/misc/rates/RatesOverflow.t.sol b/tests/misc/rates/RatesOverflow.t.sol deleted file mode 100644 index 770ed78a..00000000 --- a/tests/misc/rates/RatesOverflow.t.sol +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import 'forge-std/Test.sol'; - -import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; -import {MockReserveInterestRateStrategy} from '../../../src/contracts/mocks/tests/MockReserveInterestRateStrategy.sol'; -import {IPoolConfigurator} from '../../../src/contracts/interfaces/IPoolConfigurator.sol'; -import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; -import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; - -// @dev Ignored from coverage report, due Foundry Coverage can not detect functions if they return 0. -contract RatesOverflowCheckTests is TestnetProcedures { - MockReserveInterestRateStrategy internal mockRateStrategy; - - function setUp() public { - initTestEnvironment(); - - mockRateStrategy = new MockReserveInterestRateStrategy(report.poolAddressesProvider); - - vm.prank(carol); - contracts.poolProxy.supply(tokenList.usdx, 100_000e6, carol, 0); - - vm.startPrank(poolAdmin); - IPoolConfigurator(report.poolConfiguratorProxy).setReserveInterestRateStrategyAddress( - tokenList.usdx, - address(mockRateStrategy), - _getDefaultInterestRatesStrategyData() - ); - vm.stopPrank(); - } - - function test_overflow_liquidity_rates() public { - mockRateStrategy.setLiquidityRate(UINT256_MAX); - - vm.expectRevert(bytes("SafeCast: value doesn't fit in 128 bits")); - vm.prank(alice); - contracts.poolProxy.supply(tokenList.usdx, 1000e6, alice, 0); - } - - function test_overflow_variable_rates() public { - vm.prank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 1e8, alice, 0); - - mockRateStrategy.setVariableBorrowRate(UINT256_MAX); - - vm.expectRevert(bytes("SafeCast: value doesn't fit in 128 bits")); - - vm.prank(alice); - contracts.poolProxy.borrow(tokenList.usdx, 10e6, 2, 0, alice); - } -} From a9ee50a4f0627300b2bfa749bc457d9487493184 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 20 Aug 2024 16:02:53 +0300 Subject: [PATCH 22/88] updated InterestRates flag validation, tests --- .../ParaSwapRepayAdapter.sol | 2 +- src/contracts/helpers/L2Encoder.sol | 28 +++---------------- .../helpers/WrappedTokenGatewayV3.sol | 17 +++++++++-- src/contracts/interfaces/IPool.sol | 19 +++++++------ .../mocks/testnet-helpers/TestnetERC20.sol | 3 +- .../protocol/libraries/helpers/Errors.sol | 1 + .../protocol/libraries/logic/BorrowLogic.sol | 9 +++++- .../libraries/logic/CalldataLogic.sol | 24 +--------------- .../libraries/logic/FlashLoanLogic.sol | 3 +- .../libraries/logic/ValidationLogic.sol | 9 ++++++ .../protocol/libraries/types/DataTypes.sol | 3 ++ src/contracts/protocol/pool/Pool.sol | 12 +++++--- tests/protocol/pool/Pool.Borrow.t.sol | 11 ++++++++ tests/protocol/pool/Pool.FlashLoans.t.sol | 24 ++++++++++++++++ tests/protocol/pool/Pool.Repay.t.sol | 14 ++++++++++ tests/protocol/pool/Pool.t.sol | 6 ---- 16 files changed, 114 insertions(+), 71 deletions(-) diff --git a/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol b/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol index b1aa8123..34cf416c 100644 --- a/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol +++ b/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol @@ -207,7 +207,7 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard { address initiator ) private view returns (uint256) { require( - DataTypes.InterestRateMode(rateMode) != DataTypes.InterestRateMode.NONE, + DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE, 'INVALID_RATE_MODE' ); DataTypes.ReserveDataLegacy memory debtReserveData = _getReserveData(address(debtAsset)); diff --git a/src/contracts/helpers/L2Encoder.sol b/src/contracts/helpers/L2Encoder.sol index 5be76302..7c1bd96c 100644 --- a/src/contracts/helpers/L2Encoder.sol +++ b/src/contracts/helpers/L2Encoder.sol @@ -118,7 +118,7 @@ contract L2Encoder { * @dev Without an onBehalfOf parameter as the compact calls to L2Pool will use msg.sender as onBehalfOf * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed - * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 and 2 for Variable (changed on v3.2.0) + * @param interestRateMode The interest rate mode at which the user wants to borrow: 2 for Variable, 1 is deprecated (changed on v3.2.0) * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @return compact representation of withdraw parameters @@ -153,7 +153,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `interestRateMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) * @return compact representation of repay parameters */ function encodeRepayParams( @@ -180,7 +180,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) * @param deadline The deadline timestamp that the permit is valid * @param permitV The V parameter of ERC712 permit sig * @param permitR The R parameter of ERC712 permit sig @@ -226,7 +226,7 @@ contract L2Encoder { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 and 2 for Variable (changed on v3.2.0) + * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) * @return compact representation of repay with aToken parameters */ function encodeRepayWithATokensParams( @@ -237,26 +237,6 @@ contract L2Encoder { return encodeRepayParams(asset, amount, interestRateMode); } - /** - * @notice Encodes swap borrow rate mode parameters from standard input to compact representation of 1 bytes32 - * @param asset The address of the underlying asset borrowed - * @param interestRateMode The current interest rate mode of the position being swapped: 1 and 2 for Variable (changed on v3.2.0) - * @return compact representation of swap borrow rate mode parameters - */ - function encodeSwapBorrowRateMode( - address asset, - uint256 interestRateMode - ) external view returns (bytes32) { - DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); - uint16 assetId = data.id; - uint8 shortenedInterestRateMode = interestRateMode.toUint8(); - bytes32 res; - assembly { - res := add(assetId, shl(16, shortenedInterestRateMode)) - } - return res; - } - /** * @notice Encodes set user use reserve as collateral parameters from standard input to compact representation of 1 bytes32 * @param asset The address of the underlying asset borrowed diff --git a/src/contracts/helpers/WrappedTokenGatewayV3.sol b/src/contracts/helpers/WrappedTokenGatewayV3.sol index 08c53041..7d4e86f0 100644 --- a/src/contracts/helpers/WrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/WrappedTokenGatewayV3.sol @@ -76,9 +76,13 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { function repayETH( address, uint256 amount, - uint256, + uint256 rateMode, address onBehalfOf ) external payable override { + require( + rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), + 'DEPRECATED_BORROW_RATE_MODE' + ); uint256 paybackAmount = DataTypesHelper.getUserCurrentDebt( onBehalfOf, POOL.getReserveData(address(WETH)) @@ -105,7 +109,16 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param amount the amount of ETH to borrow * @param referralCode integrators are assigned a referral code and can potentially receive rewards */ - function borrowETH(address, uint256 amount, uint256, uint16 referralCode) external override { + function borrowETH( + address, + uint256 amount, + uint256 rateMode, + uint16 referralCode + ) external override { + require( + rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), + 'DEPRECATED_BORROW_RATE_MODE' + ); POOL.borrow( address(WETH), amount, diff --git a/src/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol index b435c74e..3372713c 100644 --- a/src/contracts/interfaces/IPool.sol +++ b/src/contracts/interfaces/IPool.sol @@ -67,7 +67,7 @@ interface IPool { * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out - * @param interestRateMode The rate mode: 1 and 2 for Variable (changed on v3.2.0) + * @param interestRateMode The rate mode: 2 for Variable, 1 is deprecated (changed on v3.2.0) * @param borrowRate The numeric rate at which the user has borrowed, expressed in ray * @param referralCode The referral code used */ @@ -101,7 +101,8 @@ interface IPool { * @dev Emitted on swapBorrowRateMode(), DEPRECATED on v3.2.0 * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode - * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable + * @param interestRateMode The current interest rate mode of the position being swapped: + * 1 for Stable (Deprecated on v3.2.0), 2 for Variable */ event SwapBorrowRateMode( address indexed reserve, @@ -150,7 +151,8 @@ interface IPool { * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed - * @param interestRateMode The flashloan mode: 0 for regular flashloan, 1 and 2 for Variable debt (changed on v3.2.0) + * @param interestRateMode The flashloan mode: 0 for regular flashloan, + * 1 for Stable (Deprecated on v3.2.0), 2 for Variable * @param premium The fee flash borrowed * @param referralCode The referral code used */ @@ -293,7 +295,7 @@ interface IPool { * and 100 variable debt tokens * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed - * @param interestRateMode DEPRECATED in v3.2.0 + * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0 * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf The address of the user who will receive the debt. Should be the address of the borrower itself @@ -314,7 +316,7 @@ interface IPool { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode DEPRECATED in v3.2.0 + * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0 * @param onBehalfOf The address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed @@ -333,7 +335,7 @@ interface IPool { * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - * @param interestRateMode DEPRECATED in v3.2.0 + * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0 * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed @@ -408,8 +410,9 @@ interface IPool { * @param amounts The amounts of the assets being flash-borrowed * @param interestRateModes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver - * 1 or 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address - * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 + * 1 -> Deprecated on v3.2.0 + * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * @param onBehalfOf The address that will receive the debt in the case of using 2 on `modes` * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man diff --git a/src/contracts/mocks/testnet-helpers/TestnetERC20.sol b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol index efe94186..0591a01a 100644 --- a/src/contracts/mocks/testnet-helpers/TestnetERC20.sol +++ b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol @@ -74,7 +74,8 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable { * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ - function mint(uint256 value) public virtual onlyOwner returns (bool) { + // TODO: check + function mint(uint256 value) public virtual returns (bool) { _mint(_msgSender(), value); return true; } diff --git a/src/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol index 7d4a7668..b1a640f5 100644 --- a/src/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/contracts/protocol/libraries/helpers/Errors.sol @@ -100,4 +100,5 @@ library Errors { string public constant LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED = '97'; // 'Liquidation grace sentinel validation failed' string public constant INVALID_GRACE_PERIOD = '98'; // Grace period above a valid range string public constant INVALID_FREEZE_STATE = '99'; // Reserve is already in the passed freeze state + string public constant DEPRECATED_BORROW_RATE_MODE = '100'; // User trying to borrow stable, but it's deprecated } diff --git a/src/contracts/protocol/libraries/logic/BorrowLogic.sol b/src/contracts/protocol/libraries/logic/BorrowLogic.sol index 46bb8537..38df8ce2 100644 --- a/src/contracts/protocol/libraries/logic/BorrowLogic.sol +++ b/src/contracts/protocol/libraries/logic/BorrowLogic.sol @@ -86,6 +86,7 @@ library BorrowLogic { asset: params.asset, userAddress: params.onBehalfOf, amount: params.amount, + interestRateMode: params.interestRateMode, reservesCount: params.reservesCount, oracle: params.oracle, userEModeCategory: params.userEModeCategory, @@ -163,7 +164,13 @@ library BorrowLogic { uint256 variableDebt = Helpers.getUserCurrentDebt(params.onBehalfOf, reserveCache); - ValidationLogic.validateRepay(reserveCache, params.amount, params.onBehalfOf, variableDebt); + ValidationLogic.validateRepay( + reserveCache, + params.amount, + params.interestRateMode, + params.onBehalfOf, + variableDebt + ); uint256 paybackAmount = variableDebt; diff --git a/src/contracts/protocol/libraries/logic/CalldataLogic.sol b/src/contracts/protocol/libraries/logic/CalldataLogic.sol index abc65626..32b4ed0d 100644 --- a/src/contracts/protocol/libraries/logic/CalldataLogic.sol +++ b/src/contracts/protocol/libraries/logic/CalldataLogic.sol @@ -114,7 +114,7 @@ library CalldataLogic { * @param args The packed repay params * @return The address of the underlying reserve * @return The amount to repay - * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) + * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) */ function decodeRepayParams( mapping(uint256 => address) storage reservesList, @@ -167,28 +167,6 @@ library CalldataLogic { return (asset, amount, interestRateMode, deadline, permitV); } - /** - * @notice Decodes compressed swap borrow rate mode params to standard params - * @param reservesList The addresses of all the active reserves - * @param args The packed swap borrow rate mode params - * @return The address of the underlying reserve - * @return The interest rate mode, 1 and 2 for variable debt (changed on v3.2.0) - */ - function decodeSwapBorrowRateModeParams( - mapping(uint256 => address) storage reservesList, - bytes32 args - ) internal view returns (address, uint256) { - uint16 assetId; - uint256 interestRateMode; - - assembly { - assetId := and(args, 0xFFFF) - interestRateMode := and(shr(16, args), 0xFF) - } - - return (reservesList[assetId], interestRateMode); - } - /** * @notice Decodes compressed set user use reserve as collateral params to standard params * @param reservesList The addresses of all the active reserves diff --git a/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol b/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol index 02b9025f..31ffb288 100644 --- a/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol +++ b/src/contracts/protocol/libraries/logic/FlashLoanLogic.sol @@ -147,6 +147,7 @@ library FlashLoanLogic { user: msg.sender, onBehalfOf: params.onBehalfOf, amount: vars.currentAmount, + interestRateMode: DataTypes.InterestRateMode(params.interestRateModes[i]), referralCode: params.referralCode, releaseUnderlying: false, reservesCount: IPool(params.pool).getReservesCount(), @@ -268,7 +269,7 @@ library FlashLoanLogic { msg.sender, params.asset, params.amount, - DataTypes.InterestRateMode(0), + DataTypes.InterestRateMode.NONE, params.totalPremium, params.referralCode ); diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 368138df..be669757 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -141,6 +141,10 @@ library ValidationLogic { DataTypes.ValidateBorrowParams memory params ) internal view { require(params.amount != 0, Errors.INVALID_AMOUNT); + require( + params.interestRateMode == DataTypes.InterestRateMode.VARIABLE, + Errors.DEPRECATED_BORROW_RATE_MODE + ); ValidateBorrowLocalVars memory vars; @@ -281,10 +285,15 @@ library ValidationLogic { function validateRepay( DataTypes.ReserveCache memory reserveCache, uint256 amountSent, + DataTypes.InterestRateMode interestRateMode, address onBehalfOf, uint256 debt ) internal view { require(amountSent != 0, Errors.INVALID_AMOUNT); + require( + interestRateMode == DataTypes.InterestRateMode.VARIABLE, + Errors.DEPRECATED_BORROW_RATE_MODE + ); require( amountSent != type(uint256).max || msg.sender == onBehalfOf, Errors.NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 1c522ab3..0b83ec98 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -167,6 +167,7 @@ library DataTypes { address user; address onBehalfOf; uint256 amount; + InterestRateMode interestRateMode; uint16 referralCode; bool releaseUnderlying; uint256 reservesCount; @@ -178,6 +179,7 @@ library DataTypes { struct ExecuteRepayParams { address asset; uint256 amount; + InterestRateMode interestRateMode; address onBehalfOf; bool useATokens; } @@ -259,6 +261,7 @@ library DataTypes { address asset; address userAddress; uint256 amount; + InterestRateMode interestRateMode; uint256 reservesCount; address oracle; uint8 userEModeCategory; diff --git a/src/contracts/protocol/pool/Pool.sol b/src/contracts/protocol/pool/Pool.sol index cb6d3c25..170a762c 100644 --- a/src/contracts/protocol/pool/Pool.sol +++ b/src/contracts/protocol/pool/Pool.sol @@ -212,7 +212,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function borrow( address asset, uint256 amount, - uint256, // @notice deprecated interestRateMode + uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) public virtual override { @@ -226,6 +226,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { user: msg.sender, onBehalfOf: onBehalfOf, amount: amount, + interestRateMode: DataTypes.InterestRateMode(interestRateMode), referralCode: referralCode, releaseUnderlying: true, reservesCount: _reservesCount, @@ -240,7 +241,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repay( address asset, uint256 amount, - uint256, // @notice deprecated interestRateMode + uint256 interestRateMode, address onBehalfOf ) public virtual override returns (uint256) { return @@ -251,6 +252,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, + interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: onBehalfOf, useATokens: false }) @@ -261,7 +263,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repayWithPermit( address asset, uint256 amount, - uint256, // @notice deprecated interestRateMode + uint256 interestRateMode, address onBehalfOf, uint256 deadline, uint8 permitV, @@ -284,6 +286,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams memory params = DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, + interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: onBehalfOf, useATokens: false }); @@ -295,7 +298,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { function repayWithATokens( address asset, uint256 amount, - uint256 // @notice deprecated interestRateMode + uint256 interestRateMode ) public virtual override returns (uint256) { return BorrowLogic.executeRepay( @@ -305,6 +308,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { DataTypes.ExecuteRepayParams({ asset: asset, amount: amount, + interestRateMode: DataTypes.InterestRateMode(interestRateMode), onBehalfOf: msg.sender, useATokens: true }) diff --git a/tests/protocol/pool/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol index be4e59be..7cc08c3b 100644 --- a/tests/protocol/pool/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -199,6 +199,17 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.borrow(tokenList.usdx, borrowAmount, 2, 0, alice); } + function test_reverts_deprecated_stable_borrow() public { + uint256 amount = 2000e6; + uint256 borrowAmount = 100; + vm.startPrank(alice); + contracts.poolProxy.supply(tokenList.usdx, amount, alice, 0); + + vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + + contracts.poolProxy.borrow(tokenList.wbtc, borrowAmount, 1, 0, alice); + } + function test_reverts_borrow_invalidAmount() public { vm.expectRevert(bytes(Errors.INVALID_AMOUNT)); diff --git a/tests/protocol/pool/Pool.FlashLoans.t.sol b/tests/protocol/pool/Pool.FlashLoans.t.sol index 459e3908..97d78fcd 100644 --- a/tests/protocol/pool/Pool.FlashLoans.t.sol +++ b/tests/protocol/pool/Pool.FlashLoans.t.sol @@ -419,6 +419,30 @@ contract PoolFlashLoansTests is TestnetProcedures { ); } + function test_revert_flashloan_borrow_stable() public { + vm.prank(alice); + contracts.poolProxy.supply(tokenList.wbtc, 0.5e8, alice, 0); + + ( + address[] memory assets, + uint256[] memory amounts, + uint256[] memory modes, + bytes memory emptyParams + ) = _defaultInput(false, 1); + + vm.prank(alice); + vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + contracts.poolProxy.flashLoan( + address(mockFlashReceiver), + assets, + amounts, + modes, + alice, + emptyParams, + 0 + ); + } + function _defaultInput() internal returns (address[] memory, uint256[] memory, uint256[] memory, bytes memory) diff --git a/tests/protocol/pool/Pool.Repay.t.sol b/tests/protocol/pool/Pool.Repay.t.sol index cf9ea980..8937d030 100644 --- a/tests/protocol/pool/Pool.Repay.t.sol +++ b/tests/protocol/pool/Pool.Repay.t.sol @@ -88,6 +88,20 @@ contract PoolRepayTests is TestnetProcedures { ); } + function test_revert_repay_full_stable_borrow() public { + uint256 amount = 2000e6; + uint256 borrowAmount = 800e6; + vm.startPrank(alice); + + contracts.poolProxy.supply(tokenList.usdx, amount, alice, 0); + contracts.poolProxy.borrow(tokenList.usdx, borrowAmount, 2, 0, alice); + vm.warp(block.timestamp + 10 days); + + vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + contracts.poolProxy.repay(tokenList.usdx, UINT256_MAX, 2, alice); + vm.stopPrank(); + } + function test_repayWithATokens_full_variable_borrow() public { uint256 amount = 2000e6; uint256 borrowAmount = 800e6; diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 2d9ea860..70e7e32f 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -60,12 +60,6 @@ contract PoolTests is TestnetProcedures { bool useATokens ); - event SwapBorrowRateMode( - address indexed reserve, - address indexed user, - DataTypes.InterestRateMode interestRateMode - ); - event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); event UserEModeSet(address indexed user, uint8 categoryId); From 2a261989619a4c1ccfa3251936365e59df0a1002 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 20 Aug 2024 17:19:36 +0300 Subject: [PATCH 23/88] helpers removal, stable debt test fix --- .../helpers/WrappedTokenGatewayV3.sol | 7 ++---- .../misc/libraries/DataTypesHelper.sol | 25 ------------------- .../protocol/libraries/helpers/Helpers.sol | 24 ------------------ .../protocol/libraries/logic/BorrowLogic.sol | 5 ++-- .../libraries/logic/LiquidationLogic.sol | 9 ++++--- tests/protocol/pool/Pool.Repay.t.sol | 2 +- 6 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 src/contracts/misc/libraries/DataTypesHelper.sol delete mode 100644 src/contracts/protocol/libraries/helpers/Helpers.sol diff --git a/src/contracts/helpers/WrappedTokenGatewayV3.sol b/src/contracts/helpers/WrappedTokenGatewayV3.sol index 7d4e86f0..a9db0242 100644 --- a/src/contracts/helpers/WrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/WrappedTokenGatewayV3.sol @@ -11,7 +11,6 @@ import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveC import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {IWrappedTokenGatewayV3} from './interfaces/IWrappedTokenGatewayV3.sol'; -import {DataTypesHelper} from '../misc/libraries/DataTypesHelper.sol'; /** * @dev This contract is an upgrade of the WrappedTokenGatewayV3 contract, with immutable pool address. @@ -83,10 +82,8 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), 'DEPRECATED_BORROW_RATE_MODE' ); - uint256 paybackAmount = DataTypesHelper.getUserCurrentDebt( - onBehalfOf, - POOL.getReserveData(address(WETH)) - ); + uint256 paybackAmount = IERC20((POOL.getReserveData(address(WETH))).variableDebtTokenAddress) + .balanceOf(onBehalfOf); if (amount < paybackAmount) { paybackAmount = amount; diff --git a/src/contracts/misc/libraries/DataTypesHelper.sol b/src/contracts/misc/libraries/DataTypesHelper.sol deleted file mode 100644 index 242837cb..00000000 --- a/src/contracts/misc/libraries/DataTypesHelper.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.10; - -import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; - -/** - * @title DataTypesHelper - * @author Aave - * @dev Helper library to track user current debt balance, used by WrappedTokenGatewayV3 - */ -library DataTypesHelper { - /** - * @notice Fetches the user current variable debt balances - * @param user The user address - * @param reserve The reserve data object - * @return The variable debt balance - **/ - function getUserCurrentDebt( - address user, - DataTypes.ReserveDataLegacy memory reserve - ) internal view returns (uint256) { - return IERC20(reserve.variableDebtTokenAddress).balanceOf(user); - } -} diff --git a/src/contracts/protocol/libraries/helpers/Helpers.sol b/src/contracts/protocol/libraries/helpers/Helpers.sol deleted file mode 100644 index fe6b07cb..00000000 --- a/src/contracts/protocol/libraries/helpers/Helpers.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; -import {DataTypes} from '../types/DataTypes.sol'; - -/** - * @title Helpers library - * @author Aave - */ -library Helpers { - /** - * @notice Fetches the user current variable debt balance - * @param user The user address - * @param reserveCache The reserve cache data object - * @return The variable debt balance - */ - function getUserCurrentDebt( - address user, - DataTypes.ReserveCache memory reserveCache - ) internal view returns (uint256) { - return IERC20(reserveCache.variableDebtTokenAddress).balanceOf(user); - } -} diff --git a/src/contracts/protocol/libraries/logic/BorrowLogic.sol b/src/contracts/protocol/libraries/logic/BorrowLogic.sol index 38df8ce2..c4ed26ed 100644 --- a/src/contracts/protocol/libraries/logic/BorrowLogic.sol +++ b/src/contracts/protocol/libraries/logic/BorrowLogic.sol @@ -8,7 +8,6 @@ import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; -import {Helpers} from '../helpers/Helpers.sol'; import {DataTypes} from '../types/DataTypes.sol'; import {ValidationLogic} from './ValidationLogic.sol'; import {ReserveLogic} from './ReserveLogic.sol'; @@ -162,7 +161,9 @@ library BorrowLogic { DataTypes.ReserveCache memory reserveCache = reserve.cache(); reserve.updateState(reserveCache); - uint256 variableDebt = Helpers.getUserCurrentDebt(params.onBehalfOf, reserveCache); + uint256 variableDebt = IERC20(reserveCache.variableDebtTokenAddress).balanceOf( + params.onBehalfOf + ); ValidationLogic.validateRepay( reserveCache, diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 80d4d732..3a54ba43 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -5,7 +5,6 @@ import {IERC20} from '../../../dependencies/openzeppelin/contracts//IERC20.sol'; import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; import {PercentageMath} from '../../libraries/math/PercentageMath.sol'; import {WadRayMath} from '../../libraries/math/WadRayMath.sol'; -import {Helpers} from '../../libraries/helpers/Helpers.sol'; import {DataTypes} from '../../libraries/types/DataTypes.sol'; import {ReserveLogic} from './ReserveLogic.sol'; import {ValidationLogic} from './ValidationLogic.sol'; @@ -343,19 +342,21 @@ library LiquidationLogic { DataTypes.ExecuteLiquidationCallParams memory params, uint256 healthFactor ) internal view returns (uint256, uint256) { - uint256 userTotalDebt = Helpers.getUserCurrentDebt(params.user, debtReserveCache); + uint256 userVariableDebt = IERC20(debtReserveCache.variableDebtTokenAddress).balanceOf( + params.user + ); uint256 closeFactor = healthFactor > CLOSE_FACTOR_HF_THRESHOLD ? DEFAULT_LIQUIDATION_CLOSE_FACTOR : MAX_LIQUIDATION_CLOSE_FACTOR; - uint256 maxLiquidatableDebt = userTotalDebt.percentMul(closeFactor); + uint256 maxLiquidatableDebt = userVariableDebt.percentMul(closeFactor); uint256 actualDebtToLiquidate = params.debtToCover > maxLiquidatableDebt ? maxLiquidatableDebt : params.debtToCover; - return (userTotalDebt, actualDebtToLiquidate); + return (userVariableDebt, actualDebtToLiquidate); } /** diff --git a/tests/protocol/pool/Pool.Repay.t.sol b/tests/protocol/pool/Pool.Repay.t.sol index 8937d030..804e2c02 100644 --- a/tests/protocol/pool/Pool.Repay.t.sol +++ b/tests/protocol/pool/Pool.Repay.t.sol @@ -98,7 +98,7 @@ contract PoolRepayTests is TestnetProcedures { vm.warp(block.timestamp + 10 days); vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); - contracts.poolProxy.repay(tokenList.usdx, UINT256_MAX, 2, alice); + contracts.poolProxy.repay(tokenList.usdx, UINT256_MAX, 1, alice); vm.stopPrank(); } From 07e503e3059382bdfa95d0c5a3fb2312e554ea8a Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 20 Aug 2024 17:43:10 +0300 Subject: [PATCH 24/88] remove unused struct, cleanup --- .../protocol/libraries/logic/ReserveLogic.sol | 6 ------ tests/protocol/pool/Pool.t.sol | 14 +++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/ReserveLogic.sol b/src/contracts/protocol/libraries/logic/ReserveLogic.sol index 8e27cdc0..dd5c637d 100644 --- a/src/contracts/protocol/libraries/logic/ReserveLogic.sol +++ b/src/contracts/protocol/libraries/logic/ReserveLogic.sol @@ -150,12 +150,6 @@ library ReserveLogic { reserve.interestRateStrategyAddress = interestRateStrategyAddress; } - struct UpdateInterestRatesAndVirtualBalanceLocalVars { - uint256 nextLiquidityRate; - uint256 nextVariableRate; - uint256 totalVariableDebt; - } - /** * @notice Updates the reserve current variable borrow rate and the current liquidity rate. * @param reserve The reserve reserve to be updated diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 70e7e32f..473a4090 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -657,31 +657,31 @@ contract PoolTests is TestnetProcedures { assertEq(50_000e6, virtualBalance); } - function test_getFlashLoanLogic() public { + function test_getFlashLoanLogic() public view { assertNotEq(pool.getFlashLoanLogic(), address(0)); } - function test_getBorrowLogic() public { + function test_getBorrowLogic() public view { assertNotEq(pool.getBorrowLogic(), address(0)); } - function test_getBridgeLogic() public { + function test_getBridgeLogic() public view { assertNotEq(pool.getBridgeLogic(), address(0)); } - function test_getEModeLogic() public { + function test_getEModeLogic() public view { assertNotEq(pool.getEModeLogic(), address(0)); } - function test_getLiquidationLogic() public { + function test_getLiquidationLogic() public view { assertNotEq(pool.getLiquidationLogic(), address(0)); } - function test_getPoolLogic() public { + function test_getPoolLogic() public view { assertNotEq(pool.getPoolLogic(), address(0)); } - function test_getSupplyLogic() public { + function test_getSupplyLogic() public view { assertNotEq(pool.getSupplyLogic(), address(0)); } From 70f88349722ed8f144c6450f57b98a15e8d8bd0c Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Tue, 20 Aug 2024 17:46:39 +0300 Subject: [PATCH 25/88] removed unused error STABLE_DEBT_NOT_ZERO --- src/contracts/protocol/libraries/helpers/Errors.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol index b1a640f5..37a990ff 100644 --- a/src/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/contracts/protocol/libraries/helpers/Errors.sol @@ -57,7 +57,6 @@ library Errors { string public constant UNBACKED_MINT_CAP_EXCEEDED = '52'; // 'Unbacked mint cap is exceeded' string public constant DEBT_CEILING_EXCEEDED = '53'; // 'Debt ceiling is exceeded' string public constant UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO = '54'; // 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)' - string public constant STABLE_DEBT_NOT_ZERO = '55'; // 'Stable debt supply is not zero' string public constant VARIABLE_DEBT_SUPPLY_NOT_ZERO = '56'; // 'Variable debt supply is not zero' string public constant LTV_VALIDATION_FAILED = '57'; // 'Ltv validation failed' string public constant INCONSISTENT_EMODE_CATEGORY = '58'; // 'Inconsistent eMode category' From 1a15b4e86e49536362577a49c749be15b88fb04f Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Tue, 20 Aug 2024 23:17:43 +0530 Subject: [PATCH 26/88] refactor: move static-a-token to extensions --- .../contracts/dependencies/solmate/ERC20.sol | 2 +- .../extensions}/static-a-token/README.md | 0 .../extensions}/static-a-token/StataOracle.sol | 6 +++--- .../static-a-token/StaticATokenErrors.sol | 0 .../static-a-token/StaticATokenFactory.sol | 2 +- .../extensions}/static-a-token/StaticATokenLM.sol | 14 +++++++------- .../static-a-token/interfaces/IAToken.sol | 0 .../static-a-token/interfaces/IERC4626.sol | 0 .../interfaces/IInitializableStaticATokenLM.sol | 0 .../static-a-token/interfaces/IStataOracle.sol | 0 .../interfaces/IStaticATokenFactory.sol | 0 .../static-a-token/interfaces/IStaticATokenLM.sol | 0 .../procedures/AaveV3HelpersProcedureTwo.sol | 4 ++-- .../static-a-token/StataOracle.t.sol | 4 ++-- .../static-a-token/StaticATokenLM.t.sol | 4 ++-- .../StaticATokenMetaTransactions.t.sol | 2 +- .../static-a-token/StaticATokenNoLM.t.sol | 0 .../static-a-token/TestBase.sol | 4 ++-- .../v3-config-engine/AaveV3ConfigEngineTest.t.sol | 0 .../mocks/AaveV3MockAssetEModeUpdate.sol | 0 .../mocks/AaveV3MockBorrowUpdate.sol | 0 .../mocks/AaveV3MockBorrowUpdateNoChange.sol | 0 .../v3-config-engine/mocks/AaveV3MockCapUpdate.sol | 0 .../mocks/AaveV3MockCollateralUpdate.sol | 0 .../mocks/AaveV3MockCollateralUpdateNoChange.sol | 0 .../mocks/AaveV3MockCollateralUpdateWrongBonus.sol | 0 .../mocks/AaveV3MockEModeCategoryUpdate.sol | 0 .../AaveV3MockEModeCategoryUpdateNoChange.sol | 0 .../v3-config-engine/mocks/AaveV3MockListing.sol | 0 .../mocks/AaveV3MockListingCustom.sol | 0 .../mocks/AaveV3MockPriceFeedUpdate.sol | 0 .../mocks/AaveV3MockRatesUpdate.sol | 0 tests/utils/SigUtils.sol | 2 +- 33 files changed, 22 insertions(+), 22 deletions(-) rename src/{periphery => }/contracts/dependencies/solmate/ERC20.sol (98%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/README.md (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/StataOracle.sol (83%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/StaticATokenErrors.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/StaticATokenFactory.sol (97%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/StaticATokenLM.sol (97%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IAToken.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IERC4626.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IInitializableStaticATokenLM.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IStataOracle.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IStaticATokenFactory.sol (100%) rename src/{periphery/contracts => contracts/extensions}/static-a-token/interfaces/IStaticATokenLM.sol (100%) rename tests/{periphery => extensions}/static-a-token/StataOracle.t.sol (90%) rename tests/{periphery => extensions}/static-a-token/StaticATokenLM.t.sol (98%) rename tests/{periphery => extensions}/static-a-token/StaticATokenMetaTransactions.t.sol (99%) rename tests/{periphery => extensions}/static-a-token/StaticATokenNoLM.t.sol (100%) rename tests/{periphery => extensions}/static-a-token/TestBase.sol (94%) rename tests/{periphery => extensions}/v3-config-engine/AaveV3ConfigEngineTest.t.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockCapUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockListing.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockListingCustom.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol (100%) rename tests/{periphery => extensions}/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol (100%) diff --git a/src/periphery/contracts/dependencies/solmate/ERC20.sol b/src/contracts/dependencies/solmate/ERC20.sol similarity index 98% rename from src/periphery/contracts/dependencies/solmate/ERC20.sol rename to src/contracts/dependencies/solmate/ERC20.sol index e02ff1f8..546df288 100644 --- a/src/periphery/contracts/dependencies/solmate/ERC20.sol +++ b/src/contracts/dependencies/solmate/ERC20.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; -import {ECDSA} from '../../../../contracts/dependencies/openzeppelin/ECDSA.sol'; +import {ECDSA} from '../openzeppelin/ECDSA.sol'; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) diff --git a/src/periphery/contracts/static-a-token/README.md b/src/contracts/extensions/static-a-token/README.md similarity index 100% rename from src/periphery/contracts/static-a-token/README.md rename to src/contracts/extensions/static-a-token/README.md diff --git a/src/periphery/contracts/static-a-token/StataOracle.sol b/src/contracts/extensions/static-a-token/StataOracle.sol similarity index 83% rename from src/periphery/contracts/static-a-token/StataOracle.sol rename to src/contracts/extensions/static-a-token/StataOracle.sol index 46dea3d2..50715593 100644 --- a/src/periphery/contracts/static-a-token/StataOracle.sol +++ b/src/contracts/extensions/static-a-token/StataOracle.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IPool} from '../../../contracts/interfaces/IPool.sol'; -import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol'; -import {IAaveOracle} from '../../../contracts/interfaces/IAaveOracle.sol'; +import {IPool} from '../../interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {IAaveOracle} from '../../interfaces/IAaveOracle.sol'; import {IStataOracle} from './interfaces/IStataOracle.sol'; import {IERC4626} from './interfaces/IERC4626.sol'; diff --git a/src/periphery/contracts/static-a-token/StaticATokenErrors.sol b/src/contracts/extensions/static-a-token/StaticATokenErrors.sol similarity index 100% rename from src/periphery/contracts/static-a-token/StaticATokenErrors.sol rename to src/contracts/extensions/static-a-token/StaticATokenErrors.sol diff --git a/src/periphery/contracts/static-a-token/StaticATokenFactory.sol b/src/contracts/extensions/static-a-token/StaticATokenFactory.sol similarity index 97% rename from src/periphery/contracts/static-a-token/StaticATokenFactory.sol rename to src/contracts/extensions/static-a-token/StaticATokenFactory.sol index ebaec566..bf307197 100644 --- a/src/periphery/contracts/static-a-token/StaticATokenFactory.sol +++ b/src/contracts/extensions/static-a-token/StaticATokenFactory.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IPool, DataTypes} from '../../../contracts/interfaces/IPool.sol'; +import {IPool, DataTypes} from '../../interfaces/IPool.sol'; import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol'; import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; diff --git a/src/periphery/contracts/static-a-token/StaticATokenLM.sol b/src/contracts/extensions/static-a-token/StaticATokenLM.sol similarity index 97% rename from src/periphery/contracts/static-a-token/StaticATokenLM.sol rename to src/contracts/extensions/static-a-token/StaticATokenLM.sol index aa9da8c1..cb74ee88 100644 --- a/src/periphery/contracts/static-a-token/StaticATokenLM.sol +++ b/src/contracts/extensions/static-a-token/StaticATokenLM.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {IPool} from '../../../contracts/interfaces/IPool.sol'; -import {DataTypes, ReserveConfiguration} from '../../../contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {IRewardsController} from '../../../contracts/rewards/interfaces/IRewardsController.sol'; -import {WadRayMath} from '../../../contracts/protocol/libraries/math/WadRayMath.sol'; -import {MathUtils} from '../../../contracts/protocol/libraries/math/MathUtils.sol'; +import {IPool} from '../../interfaces/IPool.sol'; +import {DataTypes, ReserveConfiguration} from '../../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {IRewardsController} from '../../rewards/interfaces/IRewardsController.sol'; +import {WadRayMath} from '../../protocol/libraries/math/WadRayMath.sol'; +import {MathUtils} from '../../protocol/libraries/math/MathUtils.sol'; import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol'; import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; @@ -15,10 +15,10 @@ import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IE import {IStaticATokenLM} from './interfaces/IStaticATokenLM.sol'; import {IAToken} from './interfaces/IAToken.sol'; -import {ERC20} from '../dependencies/solmate/ERC20.sol'; +import {ERC20} from '../../dependencies/solmate/ERC20.sol'; import {IInitializableStaticATokenLM} from './interfaces/IInitializableStaticATokenLM.sol'; import {StaticATokenErrors} from './StaticATokenErrors.sol'; -import {RayMathExplicitRounding, Rounding} from '../../../contracts/misc/libraries/RayMathExplicitRounding.sol'; +import {RayMathExplicitRounding, Rounding} from '../../misc/libraries/RayMathExplicitRounding.sol'; import {IERC4626} from './interfaces/IERC4626.sol'; /** diff --git a/src/periphery/contracts/static-a-token/interfaces/IAToken.sol b/src/contracts/extensions/static-a-token/interfaces/IAToken.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IAToken.sol rename to src/contracts/extensions/static-a-token/interfaces/IAToken.sol diff --git a/src/periphery/contracts/static-a-token/interfaces/IERC4626.sol b/src/contracts/extensions/static-a-token/interfaces/IERC4626.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IERC4626.sol rename to src/contracts/extensions/static-a-token/interfaces/IERC4626.sol diff --git a/src/periphery/contracts/static-a-token/interfaces/IInitializableStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IInitializableStaticATokenLM.sol rename to src/contracts/extensions/static-a-token/interfaces/IInitializableStaticATokenLM.sol diff --git a/src/periphery/contracts/static-a-token/interfaces/IStataOracle.sol b/src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IStataOracle.sol rename to src/contracts/extensions/static-a-token/interfaces/IStataOracle.sol diff --git a/src/periphery/contracts/static-a-token/interfaces/IStaticATokenFactory.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IStaticATokenFactory.sol rename to src/contracts/extensions/static-a-token/interfaces/IStaticATokenFactory.sol diff --git a/src/periphery/contracts/static-a-token/interfaces/IStaticATokenLM.sol b/src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol similarity index 100% rename from src/periphery/contracts/static-a-token/interfaces/IStaticATokenLM.sol rename to src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol index 6d4abb9f..9a92839a 100644 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import '../../interfaces/IMarketReportTypes.sol'; import {TransparentProxyFactory, ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; -import {StaticATokenLM} from 'aave-v3-periphery/contracts/static-a-token/StaticATokenLM.sol'; -import {StaticATokenFactory} from 'aave-v3-periphery/contracts/static-a-token/StaticATokenFactory.sol'; +import {StaticATokenLM} from '../../../contracts/extensions/static-a-token/StaticATokenLM.sol'; +import {StaticATokenFactory} from '../../../contracts/extensions/static-a-token/StaticATokenFactory.sol'; import {IErrors} from '../../interfaces/IErrors.sol'; contract AaveV3HelpersProcedureTwo is IErrors { diff --git a/tests/periphery/static-a-token/StataOracle.t.sol b/tests/extensions/static-a-token/StataOracle.t.sol similarity index 90% rename from tests/periphery/static-a-token/StataOracle.t.sol rename to tests/extensions/static-a-token/StataOracle.t.sol index 3d6b6622..5e6e4efd 100644 --- a/tests/periphery/static-a-token/StataOracle.t.sol +++ b/tests/extensions/static-a-token/StataOracle.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.10; -import {StataOracle} from '../../../src/periphery/contracts/static-a-token/StataOracle.sol'; -import {StaticATokenLM} from '../../../src/periphery/contracts/static-a-token/StaticATokenLM.sol'; +import {StataOracle} from '../../../src/contracts/extensions/static-a-token/StataOracle.sol'; +import {StaticATokenLM} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; import {BaseTest} from './TestBase.sol'; contract StataOracleTest is BaseTest { diff --git a/tests/periphery/static-a-token/StaticATokenLM.t.sol b/tests/extensions/static-a-token/StaticATokenLM.t.sol similarity index 98% rename from tests/periphery/static-a-token/StaticATokenLM.t.sol rename to tests/extensions/static-a-token/StaticATokenLM.t.sol index 55b93669..76f52911 100644 --- a/tests/periphery/static-a-token/StaticATokenLM.t.sol +++ b/tests/extensions/static-a-token/StaticATokenLM.t.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.10; import {AToken} from '../../../src/contracts/protocol/tokenization/AToken.sol'; import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; -import {IERC20, IERC20Metadata} from '../../../src/periphery/contracts/static-a-token/StaticATokenLM.sol'; +import {IERC20, IERC20Metadata} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; import {RayMathExplicitRounding} from '../../../src/contracts/misc/libraries/RayMathExplicitRounding.sol'; import {PullRewardsTransferStrategy} from '../../../src/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; import {RewardsDataTypes} from '../../../src/contracts/rewards/libraries/RewardsDataTypes.sol'; import {ITransferStrategyBase} from '../../../src/contracts/rewards/interfaces/ITransferStrategyBase.sol'; import {IEACAggregatorProxy} from '../../../src/contracts/helpers/interfaces/IEACAggregatorProxy.sol'; -import {IStaticATokenLM} from '../../../src/periphery/contracts/static-a-token/interfaces/IStaticATokenLM.sol'; +import {IStaticATokenLM} from '../../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; import {SigUtils} from '../../utils/SigUtils.sol'; import {BaseTest, TestnetERC20} from './TestBase.sol'; diff --git a/tests/periphery/static-a-token/StaticATokenMetaTransactions.t.sol b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol similarity index 99% rename from tests/periphery/static-a-token/StaticATokenMetaTransactions.t.sol rename to tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol index 62dd690a..4cc133e7 100644 --- a/tests/periphery/static-a-token/StaticATokenMetaTransactions.t.sol +++ b/tests/extensions/static-a-token/StaticATokenMetaTransactions.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.10; import {IERC20WithPermit} from 'solidity-utils/contracts/oz-common/interfaces/IERC20WithPermit.sol'; -import {StaticATokenLM, IStaticATokenLM, IERC20} from '../../../src/periphery/contracts/static-a-token/StaticATokenLM.sol'; +import {StaticATokenLM, IStaticATokenLM, IERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; import {SigUtils} from '../../utils/SigUtils.sol'; import {BaseTest, IAToken, IRewardsController, DataTypes} from './TestBase.sol'; diff --git a/tests/periphery/static-a-token/StaticATokenNoLM.t.sol b/tests/extensions/static-a-token/StaticATokenNoLM.t.sol similarity index 100% rename from tests/periphery/static-a-token/StaticATokenNoLM.t.sol rename to tests/extensions/static-a-token/StaticATokenNoLM.t.sol diff --git a/tests/periphery/static-a-token/TestBase.sol b/tests/extensions/static-a-token/TestBase.sol similarity index 94% rename from tests/periphery/static-a-token/TestBase.sol rename to tests/extensions/static-a-token/TestBase.sol index 568e3519..b035a265 100644 --- a/tests/periphery/static-a-token/TestBase.sol +++ b/tests/extensions/static-a-token/TestBase.sol @@ -5,8 +5,8 @@ import {IRewardsController} from '../../../src//contracts/rewards/interfaces/IRe import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; import {IPool} from '../../../src/contracts/interfaces/IPool.sol'; -import {StaticATokenFactory} from '../../../src/periphery/contracts/static-a-token/StaticATokenFactory.sol'; -import {StaticATokenLM, IStaticATokenLM, IERC20, IERC20Metadata, ERC20} from '../../../src/periphery/contracts/static-a-token/StaticATokenLM.sol'; +import {StaticATokenFactory} from '../../../src/contracts/extensions/static-a-token/StaticATokenFactory.sol'; +import {StaticATokenLM, IStaticATokenLM, IERC20, IERC20Metadata, ERC20} from '../../../src/contracts/extensions/static-a-token/StaticATokenLM.sol'; import {IAToken} from '../../../src/contracts/interfaces/IAToken.sol'; import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol'; import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; diff --git a/tests/periphery/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol similarity index 100% rename from tests/periphery/v3-config-engine/AaveV3ConfigEngineTest.t.sol rename to tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockCapUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockCapUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockListing.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockListing.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockListingCustom.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockListingCustom.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol diff --git a/tests/periphery/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol similarity index 100% rename from tests/periphery/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol rename to tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol diff --git a/tests/utils/SigUtils.sol b/tests/utils/SigUtils.sol index 8c64e400..72aed63c 100644 --- a/tests/utils/SigUtils.sol +++ b/tests/utils/SigUtils.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; -import {IStaticATokenLM} from '../../src/periphery/contracts/static-a-token/interfaces/IStaticATokenLM.sol'; +import {IStaticATokenLM} from '../../src/contracts/extensions/static-a-token/interfaces/IStaticATokenLM.sol'; library SigUtils { struct Permit { From 8710e54f81f56011988bc990b9dfdf9e58bc1fb0 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 21 Aug 2024 10:25:01 +0300 Subject: [PATCH 27/88] change error from DEPRECATED_BORROW_RATE_MODE to existing INVALID_INTEREST_RATE_MODE_SELECTED --- src/contracts/helpers/WrappedTokenGatewayV3.sol | 4 ++-- src/contracts/protocol/libraries/helpers/Errors.sol | 1 - .../protocol/libraries/logic/ValidationLogic.sol | 12 +++++++----- tests/protocol/pool/Pool.Borrow.t.sol | 3 ++- tests/protocol/pool/Pool.FlashLoans.t.sol | 2 +- tests/protocol/pool/Pool.Repay.t.sol | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/contracts/helpers/WrappedTokenGatewayV3.sol b/src/contracts/helpers/WrappedTokenGatewayV3.sol index a9db0242..305003a5 100644 --- a/src/contracts/helpers/WrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/WrappedTokenGatewayV3.sol @@ -80,7 +80,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { ) external payable override { require( rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), - 'DEPRECATED_BORROW_RATE_MODE' + 'INVALID_INTEREST_RATE_MODE_SELECTED' ); uint256 paybackAmount = IERC20((POOL.getReserveData(address(WETH))).variableDebtTokenAddress) .balanceOf(onBehalfOf); @@ -114,7 +114,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { ) external override { require( rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), - 'DEPRECATED_BORROW_RATE_MODE' + 'INVALID_INTEREST_RATE_MODE_SELECTED' ); POOL.borrow( address(WETH), diff --git a/src/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol index 37a990ff..b440c5f0 100644 --- a/src/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/contracts/protocol/libraries/helpers/Errors.sol @@ -99,5 +99,4 @@ library Errors { string public constant LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED = '97'; // 'Liquidation grace sentinel validation failed' string public constant INVALID_GRACE_PERIOD = '98'; // Grace period above a valid range string public constant INVALID_FREEZE_STATE = '99'; // Reserve is already in the passed freeze state - string public constant DEPRECATED_BORROW_RATE_MODE = '100'; // User trying to borrow stable, but it's deprecated } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index be669757..75ec8f8c 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -141,10 +141,6 @@ library ValidationLogic { DataTypes.ValidateBorrowParams memory params ) internal view { require(params.amount != 0, Errors.INVALID_AMOUNT); - require( - params.interestRateMode == DataTypes.InterestRateMode.VARIABLE, - Errors.DEPRECATED_BORROW_RATE_MODE - ); ValidateBorrowLocalVars memory vars; @@ -169,6 +165,12 @@ library ValidationLogic { Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED ); + //validate interest rate mode + require( + params.interestRateMode == DataTypes.InterestRateMode.VARIABLE, + Errors.INVALID_INTEREST_RATE_MODE_SELECTED + ); + vars.reserveDecimals = params.reserveCache.reserveConfiguration.getDecimals(); vars.borrowCap = params.reserveCache.reserveConfiguration.getBorrowCap(); unchecked { @@ -292,7 +294,7 @@ library ValidationLogic { require(amountSent != 0, Errors.INVALID_AMOUNT); require( interestRateMode == DataTypes.InterestRateMode.VARIABLE, - Errors.DEPRECATED_BORROW_RATE_MODE + Errors.INVALID_INTEREST_RATE_MODE_SELECTED ); require( amountSent != type(uint256).max || msg.sender == onBehalfOf, diff --git a/tests/protocol/pool/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol index 7cc08c3b..e97722f6 100644 --- a/tests/protocol/pool/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -204,8 +204,9 @@ contract PoolBorrowTests is TestnetProcedures { uint256 borrowAmount = 100; vm.startPrank(alice); contracts.poolProxy.supply(tokenList.usdx, amount, alice, 0); + contracts.poolProxy.supply(tokenList.wbtc, borrowAmount, bob, 0); - vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + vm.expectRevert(bytes(Errors.INVALID_INTEREST_RATE_MODE_SELECTED)); contracts.poolProxy.borrow(tokenList.wbtc, borrowAmount, 1, 0, alice); } diff --git a/tests/protocol/pool/Pool.FlashLoans.t.sol b/tests/protocol/pool/Pool.FlashLoans.t.sol index 97d78fcd..fadebc78 100644 --- a/tests/protocol/pool/Pool.FlashLoans.t.sol +++ b/tests/protocol/pool/Pool.FlashLoans.t.sol @@ -431,7 +431,7 @@ contract PoolFlashLoansTests is TestnetProcedures { ) = _defaultInput(false, 1); vm.prank(alice); - vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + vm.expectRevert(bytes(Errors.INVALID_INTEREST_RATE_MODE_SELECTED)); contracts.poolProxy.flashLoan( address(mockFlashReceiver), assets, diff --git a/tests/protocol/pool/Pool.Repay.t.sol b/tests/protocol/pool/Pool.Repay.t.sol index 804e2c02..84a39ccb 100644 --- a/tests/protocol/pool/Pool.Repay.t.sol +++ b/tests/protocol/pool/Pool.Repay.t.sol @@ -97,7 +97,7 @@ contract PoolRepayTests is TestnetProcedures { contracts.poolProxy.borrow(tokenList.usdx, borrowAmount, 2, 0, alice); vm.warp(block.timestamp + 10 days); - vm.expectRevert(bytes(Errors.DEPRECATED_BORROW_RATE_MODE)); + vm.expectRevert(bytes(Errors.INVALID_INTEREST_RATE_MODE_SELECTED)); contracts.poolProxy.repay(tokenList.usdx, UINT256_MAX, 1, alice); vm.stopPrank(); } From 9b90fb80014eb97313a693040c0e3b15e8116da1 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 21 Aug 2024 10:45:16 +0300 Subject: [PATCH 28/88] remove unused stable related events --- src/contracts/interfaces/IPool.sol | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol index 3372713c..fd10f4bd 100644 --- a/src/contracts/interfaces/IPool.sol +++ b/src/contracts/interfaces/IPool.sol @@ -97,19 +97,6 @@ interface IPool { bool useATokens ); - /** - * @dev Emitted on swapBorrowRateMode(), DEPRECATED on v3.2.0 - * @param reserve The address of the underlying asset of the reserve - * @param user The address of the user swapping his rate mode - * @param interestRateMode The current interest rate mode of the position being swapped: - * 1 for Stable (Deprecated on v3.2.0), 2 for Variable - */ - event SwapBorrowRateMode( - address indexed reserve, - address indexed user, - DataTypes.InterestRateMode interestRateMode - ); - /** * @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets * @param asset The address of the underlying asset of the reserve @@ -138,13 +125,6 @@ interface IPool { */ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); - /** - * @dev Emitted on rebalanceStableBorrowRate(), DEPRECATED on v3.2.0 - * @param reserve The address of the underlying asset of the reserve - * @param user The address of the user for which the rebalance has been executed - */ - event RebalanceStableBorrowRate(address indexed reserve, address indexed user); - /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract From 489e897c69eb7e6fe1be497e88880e7a45375417 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 23 Aug 2024 15:19:05 +0300 Subject: [PATCH 29/88] update comments on ColldataLogic --- src/contracts/protocol/libraries/logic/CalldataLogic.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/CalldataLogic.sol b/src/contracts/protocol/libraries/logic/CalldataLogic.sol index 32b4ed0d..742cbcbf 100644 --- a/src/contracts/protocol/libraries/logic/CalldataLogic.sol +++ b/src/contracts/protocol/libraries/logic/CalldataLogic.sol @@ -86,7 +86,7 @@ library CalldataLogic { * @param args The packed borrow params * @return The address of the underlying reserve * @return The amount to borrow - * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) + * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) * @return The referralCode */ function decodeBorrowParams( @@ -143,7 +143,7 @@ library CalldataLogic { * @param args The packed repay with permit params * @return The address of the underlying reserve * @return The amount to repay - * @return The interestRateMode, 1 and 2 for variable debt (changed on v3.2.0) + * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) * @return The deadline of the permit * @return The V value of the permit signature */ From 2b4315794a004ffc4ea44d283d92a66f18368439 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 23 Aug 2024 15:39:45 +0300 Subject: [PATCH 30/88] remove unrelated comment --- src/contracts/protocol/pool/PoolConfigurator.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index 0ba15cde..ab993e64 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -245,7 +245,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator bool paused, uint40 gracePeriod ) public override onlyEmergencyOrPoolAdmin { - // Only setting grace period if the transition is not paused if (!paused && gracePeriod != 0) { require(gracePeriod <= MAX_GRACE_PERIOD, Errors.INVALID_GRACE_PERIOD); From 9631de6ed9a3657a7598ccfec3bef0f10e6b495c Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 23 Aug 2024 15:03:44 +0200 Subject: [PATCH 31/88] refactor: remove eModeOracle fix: remove leftover --- .../v3-config-engine/IAaveV3ConfigEngine.sol | 2 - .../libraries/EModeEngine.sol | 7 -- .../helpers/UiPoolDataProviderV3.sol | 2 - .../interfaces/IUiPoolDataProviderV3.sol | 1 - .../interfaces/IPoolConfigurator.sol | 2 - .../protocol/libraries/logic/EModeLogic.sol | 23 ----- .../protocol/libraries/logic/GenericLogic.sol | 13 +-- .../libraries/logic/LiquidationLogic.sol | 11 --- .../libraries/logic/ValidationLogic.sol | 6 +- .../protocol/libraries/types/DataTypes.sol | 3 +- .../protocol/pool/PoolConfigurator.sol | 11 ++- .../AaveV3ConfigEngineTest.t.sol | 4 +- .../mocks/AaveV3MockEModeCategoryUpdate.sol | 2 - .../AaveV3MockEModeCategoryUpdateNoChange.sol | 1 - tests/protocol/pool/Pool.Borrow.t.sol | 9 +- tests/protocol/pool/Pool.Liquidations.t.sol | 89 +---------------- tests/protocol/pool/Pool.t.sol | 54 ++--------- .../PoolConfigurator.ACLModifiers.t.sol | 2 +- .../PoolConfigurator.eMode.sol | 96 +++---------------- tests/utils/ProtocolV3TestBase.sol | 7 +- tests/utils/TestnetProcedures.sol | 5 +- 21 files changed, 42 insertions(+), 308 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index 8ab89982..e6844f52 100644 --- a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -206,7 +206,6 @@ interface IAaveV3ConfigEngine { * ltv: 60_00, * liqThreshold: 70_00, * liqBonus: EngineFlags.KEEP_CURRENT, - * priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, * label: EngineFlags.KEEP_CURRENT_STRING * }) */ @@ -215,7 +214,6 @@ interface IAaveV3ConfigEngine { uint256 ltv; uint256 liqThreshold; uint256 liqBonus; - address priceSource; string label; } diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index 6780a9f6..f27cf22a 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -49,14 +49,12 @@ library EModeEngine { bool atLeastOneKeepCurrent = updates[i].ltv == EngineFlags.KEEP_CURRENT || updates[i].liqThreshold == EngineFlags.KEEP_CURRENT || updates[i].liqBonus == EngineFlags.KEEP_CURRENT || - updates[i].priceSource == EngineFlags.KEEP_CURRENT_ADDRESS || keccak256(abi.encode(updates[i].label)) == keccak256(abi.encode(EngineFlags.KEEP_CURRENT_STRING)); bool notAllKeepCurrent = updates[i].ltv != EngineFlags.KEEP_CURRENT || updates[i].liqThreshold != EngineFlags.KEEP_CURRENT || updates[i].liqBonus != EngineFlags.KEEP_CURRENT || - updates[i].priceSource != EngineFlags.KEEP_CURRENT_ADDRESS || keccak256(abi.encode(updates[i].label)) != keccak256(abi.encode(EngineFlags.KEEP_CURRENT_STRING)); @@ -78,10 +76,6 @@ library EModeEngine { updates[i].liqBonus = configuration.liquidationBonus - 100_00; } - if (updates[i].priceSource == EngineFlags.KEEP_CURRENT_ADDRESS) { - updates[i].priceSource = configuration.priceSource; - } - if ( keccak256(abi.encode(updates[i].label)) == keccak256(abi.encode(EngineFlags.KEEP_CURRENT_STRING)) @@ -104,7 +98,6 @@ library EModeEngine { // For reference, this is to simplify the interaction with the Aave protocol, // as there the definition is as e.g. 105% (5% bonus for liquidators) (100_00 + updates[i].liqBonus).toUint16(), - updates[i].priceSource, updates[i].label ); } diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index 3e71fdcb..2b0eec34 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -153,8 +153,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.eModeLtv = categoryData.ltv; reserveData.eModeLiquidationThreshold = categoryData.liquidationThreshold; reserveData.eModeLiquidationBonus = categoryData.liquidationBonus; - // each eMode category may or may not have a custom oracle to override the individual assets price oracles - reserveData.eModePriceSource = categoryData.priceSource; reserveData.eModeLabel = categoryData.label; reserveData.borrowableInIsolation = reserveConfigurationMap.getBorrowableInIsolation(); diff --git a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index 9ee2402a..4fd0a772 100644 --- a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -71,7 +71,6 @@ interface IUiPoolDataProviderV3 { uint16 eModeLtv; uint16 eModeLiquidationThreshold; uint16 eModeLiquidationBonus; - address eModePriceSource; string eModeLabel; bool borrowableInIsolation; // v3.1 diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 2465e8cb..c94357c2 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -487,7 +487,6 @@ interface IPoolConfigurator { * @param ltv The ltv associated with the category * @param liquidationThreshold The liquidation threshold associated with the category * @param liquidationBonus The liquidation bonus associated with the category - * @param oracle The oracle associated with the category * @param label A label identifying the category */ function setEModeCategory( @@ -495,7 +494,6 @@ interface IPoolConfigurator { uint16 ltv, uint16 liquidationThreshold, uint16 liquidationBonus, - address oracle, string calldata label ) external; diff --git a/src/contracts/protocol/libraries/logic/EModeLogic.sol b/src/contracts/protocol/libraries/logic/EModeLogic.sol index b61e440c..f8acd49b 100644 --- a/src/contracts/protocol/libraries/logic/EModeLogic.sol +++ b/src/contracts/protocol/libraries/logic/EModeLogic.sol @@ -73,29 +73,6 @@ library EModeLogic { emit UserEModeSet(msg.sender, params.categoryId); } - /** - * @notice Gets the eMode configuration and calculates the eMode asset price if a custom oracle is configured - * @dev The eMode asset price returned is 0 if no oracle is specified - * @param category The user eMode category - * @param oracle The price oracle - * @return The eMode ltv - * @return The eMode liquidation threshold - * @return The eMode asset price - */ - function getEModeConfiguration( - DataTypes.EModeCategory storage category, - IPriceOracleGetter oracle - ) internal view returns (uint256, uint256, uint256) { - uint256 eModeAssetPrice = 0; - address eModePriceSource = category.priceSource; - - if (eModePriceSource != address(0)) { - eModeAssetPrice = oracle.getAssetPrice(eModePriceSource); - } - - return (category.ltv, category.liquidationThreshold, eModeAssetPrice); - } - /** * @notice Checks if eMode is active for a user and if yes, if the asset belongs to the eMode category chosen * @param eModeUserCategory The user eMode category diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 254e24ae..415813d8 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -37,7 +37,6 @@ library GenericLogic { uint256 totalDebtInBaseCurrency; uint256 avgLtv; uint256 avgLiquidationThreshold; - uint256 eModeAssetPrice; uint256 eModeLtv; uint256 eModeLiqThreshold; uint256 eModeAssetCategory; @@ -74,11 +73,8 @@ library GenericLogic { CalculateUserAccountDataVars memory vars; if (params.userEModeCategory != 0) { - (vars.eModeLtv, vars.eModeLiqThreshold, vars.eModeAssetPrice) = EModeLogic - .getEModeConfiguration( - eModeCategories[params.userEModeCategory], - IPriceOracleGetter(params.oracle) - ); + vars.eModeLtv = eModeCategories[params.userEModeCategory].ltv; + vars.eModeLiqThreshold = eModeCategories[params.userEModeCategory].liquidationThreshold; } while (vars.i < params.reservesCount) { @@ -113,10 +109,7 @@ library GenericLogic { vars.assetUnit = 10 ** vars.decimals; } - vars.assetPrice = vars.eModeAssetPrice != 0 && - params.userEModeCategory == vars.eModeAssetCategory - ? vars.eModeAssetPrice - : IPriceOracleGetter(params.oracle).getAssetPrice(vars.currentReserveAddress); + vars.assetPrice = IPriceOracleGetter(params.oracle).getAssetPrice(vars.currentReserveAddress); if (vars.liquidationThreshold != 0 && params.userConfig.isUsingAsCollateral(vars.i)) { vars.userBalanceInBaseCurrency = _getUserBalanceInBaseCurrency( diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 3a54ba43..403c1d4b 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -381,8 +381,6 @@ library LiquidationLogic { address debtPriceSource = params.debtAsset; if (params.userEModeCategory != 0) { - address eModePriceSource = eModeCategories[params.userEModeCategory].priceSource; - if ( EModeLogic.isInEModeCategory( params.userEModeCategory, @@ -390,15 +388,6 @@ library LiquidationLogic { ) ) { liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; - - if (eModePriceSource != address(0)) { - collateralPriceSource = eModePriceSource; - } - } - - // when in eMode, debt will always be in the same eMode category, can skip matching category check - if (eModePriceSource != address(0)) { - debtPriceSource = eModePriceSource; } } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 75ec8f8c..1395466c 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -118,7 +118,6 @@ library ValidationLogic { uint256 borrowCap; uint256 amountInBaseCurrency; uint256 assetUnit; - address eModePriceSource; address siloedBorrowingAddress; bool isActive; bool isFrozen; @@ -212,7 +211,6 @@ library ValidationLogic { params.reserveCache.reserveConfiguration.getEModeCategory() == params.userEModeCategory, Errors.INCONSISTENT_EMODE_CATEGORY ); - vars.eModePriceSource = eModeCategories[params.userEModeCategory].priceSource; } ( @@ -244,9 +242,7 @@ library ValidationLogic { ); vars.amountInBaseCurrency = - IPriceOracleGetter(params.oracle).getAssetPrice( - vars.eModePriceSource != address(0) ? vars.eModePriceSource : params.asset - ) * + IPriceOracleGetter(params.oracle).getAssetPrice(params.asset) * params.amount; unchecked { vars.amountInBaseCurrency /= vars.assetUnit; diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 0b83ec98..7c7eb070 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -116,8 +116,7 @@ library DataTypes { uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; - // each eMode category may or may not have a custom oracle to override the individual assets price oracles - address priceSource; + // uint160 placeHolder; string label; } diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index 0ba15cde..ffb4a04b 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -374,7 +374,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator uint16 ltv, uint16 liquidationThreshold, uint16 liquidationBonus, - address oracle, string calldata label ) external override onlyRiskOrPoolAdmins { require(ltv != 0, Errors.INVALID_EMODE_CATEGORY_PARAMS); @@ -419,11 +418,17 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ltv: ltv, liquidationThreshold: liquidationThreshold, liquidationBonus: liquidationBonus, - priceSource: oracle, label: label }) ); - emit EModeCategoryAdded(categoryId, ltv, liquidationThreshold, liquidationBonus, oracle, label); + emit EModeCategoryAdded( + categoryId, + ltv, + liquidationThreshold, + liquidationBonus, + address(0), + label + ); } /// @inheritdoc IPoolConfigurator diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index 63857086..62c8fc36 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -542,7 +542,6 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { prevEmodeCategoryData.ltv = 97_40; prevEmodeCategoryData.liquidationThreshold = 97_60; prevEmodeCategoryData.liquidationBonus = 101_50; // 100_00 + 1_50 - prevEmodeCategoryData.priceSource = address(0); prevEmodeCategoryData.label = 'ETH Correlated'; _validateEmodeCategory( @@ -583,7 +582,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { eModeCategoryDataBefore.ltv, eModeCategoryDataBefore.liquidationThreshold, eModeCategoryDataBefore.liquidationBonus, - eModeCategoryDataBefore.priceSource, + address(0), eModeCategoryDataBefore.label ); payload.execute(); @@ -620,7 +619,6 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { prevEmodeCategoryData.ltv = eModeCategoryDataBefore.ltv; prevEmodeCategoryData.liquidationThreshold = eModeCategoryDataBefore.liquidationThreshold; prevEmodeCategoryData.liquidationBonus = eModeCategoryDataBefore.liquidationBonus; - prevEmodeCategoryData.priceSource = eModeCategoryDataBefore.priceSource; prevEmodeCategoryData.label = eModeCategoryDataBefore.label; _validateEmodeCategory( diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol index 796b4009..19bf1ebb 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol @@ -25,7 +25,6 @@ contract AaveV3MockEModeCategoryUpdate is AaveV3Payload { ltv: 97_40, liqThreshold: 97_60, liqBonus: 1_50, - priceSource: address(0), label: 'ETH Correlated' }); @@ -59,7 +58,6 @@ contract AaveV3MockEModeCategoryUpdateEdgeBonus is AaveV3Payload { ltv: 97_40, liqThreshold: 97_60, liqBonus: 2_50, - priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, label: EngineFlags.KEEP_CURRENT_STRING }); diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol index b36ce80c..0aa0c983 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol @@ -24,7 +24,6 @@ contract AaveV3MockEModeCategoryUpdateNoChange is AaveV3Payload { ltv: EngineFlags.KEEP_CURRENT, liqThreshold: EngineFlags.KEEP_CURRENT, liqBonus: EngineFlags.KEEP_CURRENT, - priceSource: EngineFlags.KEEP_CURRENT_ADDRESS, label: EngineFlags.KEEP_CURRENT_STRING }); diff --git a/tests/protocol/pool/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol index e97722f6..3d964e94 100644 --- a/tests/protocol/pool/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -318,14 +318,7 @@ contract PoolBorrowTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); vm.stopPrank(); diff --git a/tests/protocol/pool/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol index b49a538a..da144259 100644 --- a/tests/protocol/pool/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -615,14 +615,7 @@ contract PoolLiquidationTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); vm.stopPrank(); @@ -684,80 +677,6 @@ contract PoolLiquidationTests is TestnetProcedures { _afterLiquidationChecksVariable(params, bob, liquidatorBalanceBefore, userDebtBefore); } - function test_liquidate_emode_position_with_emode_oracle() public { - EModeCategoryInput memory ct = _genCategoryOne(); - - vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - tokenList.wbtc, - ct.label - ); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); - vm.stopPrank(); - - uint256 amount = 1e8; - uint256 borrowAmount = 0.94e18; - - vm.startPrank(alice); - contracts.poolProxy.setUserEMode(ct.id); - - contracts.poolProxy.supply(tokenList.wbtc, amount, alice, 0); - contracts.poolProxy.borrow(tokenList.weth, borrowAmount, 2, 0, alice); - vm.stopPrank(); - - vm.warp(block.timestamp + 20000 days); - - LiquidationInput memory params = _loadLiquidationInput( - alice, - tokenList.wbtc, - tokenList.weth, - UINT256_MAX, - tokenList.wbtc, - 0 - ); - (, , address varDebtToken) = contracts.protocolDataProvider.getReserveTokensAddresses( - params.debtAsset - ); - uint256 userDebtBefore = IERC20(varDebtToken).balanceOf(params.user); - uint256 liquidatorBalanceBefore; - if (params.receiveAToken) { - (address atoken, , ) = contracts.protocolDataProvider.getReserveTokensAddresses( - params.collateralAsset - ); - liquidatorBalanceBefore = IERC20(atoken).balanceOf(bob); - } else { - liquidatorBalanceBefore = IERC20(params.collateralAsset).balanceOf(bob); - } - - vm.expectEmit(address(contracts.poolProxy)); - emit LiquidationLogic.LiquidationCall( - params.collateralAsset, - params.debtAsset, - params.user, - params.actualDebtToLiquidate, - params.actualCollateralToLiquidate, - bob, - params.receiveAToken - ); - - // Liquidate - vm.prank(bob); - contracts.poolProxy.liquidationCall( - params.collateralAsset, - params.debtAsset, - params.user, - params.liquidationAmountInput, - params.receiveAToken - ); - - _afterLiquidationChecksVariable(params, bob, liquidatorBalanceBefore, userDebtBefore); - } - function _loadLiquidationInput( address user, address collateralAsset, @@ -1090,11 +1009,7 @@ contract PoolLiquidationTests is TestnetProcedures { uint256 id = contracts.poolProxy.getUserEMode(user); if (id != 0) { DataTypes.EModeCategory memory cat = contracts.poolProxy.getEModeCategoryData(uint8(id)); - if (cat.priceSource != address(0)) { - return (cat.liquidationBonus, cat.priceSource, cat.priceSource); - } else { - return (cat.liquidationBonus, collateralAsset, debtAsset); - } + return (cat.liquidationBonus, collateralAsset, debtAsset); } else { DataTypes.ReserveConfigurationMap memory conf = contracts.poolProxy.getConfiguration( debtAsset diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 473a4090..2ba1c018 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -495,14 +495,7 @@ contract PoolTests is TestnetProcedures { function test_setUserEmode() public { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); vm.stopPrank(); @@ -517,22 +510,8 @@ contract PoolTests is TestnetProcedures { EModeCategoryInput memory ct1 = _genCategoryOne(); EModeCategoryInput memory ct2 = _genCategoryTwo(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct1.id, - ct1.ltv, - ct1.lt, - ct1.lb, - ct1.oracle, - ct1.label - ); - contracts.poolConfiguratorProxy.setEModeCategory( - ct2.id, - ct2.ltv, - ct2.lt, - ct2.lb, - ct2.oracle, - ct2.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); @@ -562,22 +541,8 @@ contract PoolTests is TestnetProcedures { EModeCategoryInput memory ct1 = _genCategoryOne(); EModeCategoryInput memory ct2 = _genCategoryTwo(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct1.id, - ct1.ltv, - ct1.lt, - ct1.lb, - ct1.oracle, - ct1.label - ); - contracts.poolConfiguratorProxy.setEModeCategory( - ct2.id, - ct2.ltv, - ct2.lt, - ct2.lb, - ct2.oracle, - ct2.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); @@ -611,14 +576,7 @@ contract PoolTests is TestnetProcedures { EModeCategoryInput memory ct1 = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct1.id, - ct1.ltv, - ct1.lt, - ct1.lb, - address(0), - ct1.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol index 2743f1a6..cebeca45 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol @@ -226,7 +226,7 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); vm.prank(caller); - contracts.poolConfiguratorProxy.setEModeCategory(1, 1, 1, 1, address(0), ''); + contracts.poolConfiguratorProxy.setEModeCategory(1, 1, 1, 1, ''); } function test_reverts_notRiskAdmin_setAssetEModeCategory(address caller) public { diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index d2d47c53..53e02f0c 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -30,23 +30,15 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { function test_configureEmodeCategory() public { EModeCategoryInput memory ct = _genCategoryOne(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit EModeCategoryAdded(ct.id, ct.ltv, ct.lt, ct.lb, ct.oracle, ct.label); + emit EModeCategoryAdded(ct.id, ct.ltv, ct.lt, ct.lb, address(0), ct.label); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); DataTypes.EModeCategory memory emodeConfig = contracts.poolProxy.getEModeCategoryData(ct.id); assertEq(emodeConfig.ltv, ct.ltv); assertEq(emodeConfig.liquidationThreshold, ct.lt); assertEq(emodeConfig.liquidationBonus, ct.lb); - assertEq(emodeConfig.priceSource, ct.oracle); assertEq(emodeConfig.label, ct.label); } @@ -58,14 +50,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); @@ -75,7 +60,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { uint16(currentConfig.getLtv() - 1), uint16(currentConfig.getLiquidationThreshold() + 1), ct.lb, - ct.oracle, ct.label ); vm.stopPrank(); @@ -89,14 +73,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); @@ -106,7 +83,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { uint16(currentConfig.getLtv() + 1), uint16(currentConfig.getLiquidationThreshold() - 1), ct.lb, - ct.oracle, ct.label ); vm.stopPrank(); @@ -119,7 +95,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { 90_00, 92_00, 101_00, - makeAddr('EMODE_ORACLE'), 'GROUP_B' ); @@ -132,7 +107,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { updatedCategory.ltv, updatedCategory.lt, updatedCategory.lb, - updatedCategory.oracle, + address(0), updatedCategory.label ); @@ -141,7 +116,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { updatedCategory.ltv, updatedCategory.lt, updatedCategory.lb, - updatedCategory.oracle, updatedCategory.label ); @@ -151,7 +125,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(emodeConfig.ltv, updatedCategory.ltv); assertEq(emodeConfig.liquidationThreshold, updatedCategory.lt); assertEq(emodeConfig.liquidationBonus, updatedCategory.lb); - assertEq(emodeConfig.priceSource, updatedCategory.oracle); assertEq(emodeConfig.label, updatedCategory.label); } @@ -159,33 +132,33 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 0, 80_00, 105_00, address(0), 'LABEL'); + contracts.poolConfiguratorProxy.setEModeCategory(1, 0, 80_00, 105_00, 'LABEL'); } function test_reverts_setEmodeCategory_zero_liqThreshold() public { vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 0, 105_00, address(0), 'LABEL'); + contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 0, 105_00, 'LABEL'); } function test_reverts_setEmodeCategory_ltv_gt_liqThreshold() public { vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 79_00, 105_00, address(0), 'LABEL'); + contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 79_00, 105_00, 'LABEL'); } function test_reverts_setEmodeCategory_lb_lte_percentageFactor() public { vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 81_00, 100_00, address(0), 'LABEL'); + contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 81_00, 100_00, 'LABEL'); vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 81_00, 99_00, address(0), 'LABEL'); + contracts.poolConfiguratorProxy.setEModeCategory(1, 80_00, 81_00, 99_00, 'LABEL'); } function test_reverts_setEmodeCategory_liquidation_threshold_doesnt_match_bonus() public { @@ -204,7 +177,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { 90_00, liquidationThreshold, liquidationBonus, - address(0), 'LABEL' ); } @@ -213,14 +185,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); (, uint256 ltv, , , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( @@ -233,7 +198,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { uint16(ltv) - 1, ct.lt, ct.lb, - ct.oracle, ct.label ); vm.stopPrank(); @@ -243,14 +207,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); (, uint256 ltv, , , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( @@ -266,7 +223,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { uint16(ltv) - 1, ct.lt, ct.lb, - ct.oracle, ct.label ); vm.stopPrank(); @@ -275,14 +231,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { function test_reverts_configureEmodeCategory_input_lt_lt_reserve_emode_lt() public { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); (, , uint256 lt, , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( @@ -295,7 +244,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { ct.ltv, uint16(lt) - 1, ct.lb, - ct.oracle, ct.label ); vm.stopPrank(); @@ -316,14 +264,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { test_setAssetEModeCategory(); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - ct.lt, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); vm.expectEmit(address(contracts.poolConfiguratorProxy)); emit EModeAssetCategoryChanged(tokenList.usdx, prevCt.id, ct.id); @@ -346,14 +287,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - 50_00, - 51_00, - ct.lb, - ct.oracle, - ct.label - ); + contracts.poolConfiguratorProxy.setEModeCategory(ct.id, 50_00, 51_00, ct.lb, ct.label); vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_ASSIGNMENT)); vm.prank(poolAdmin); diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index a66622c2..8a844e55 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -174,8 +174,7 @@ contract ProtocolV3TestBase is DiffUtils { vm.serializeString(key, 'label', category.label); vm.serializeUint(key, 'ltv', category.ltv); vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); - vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); - string memory object = vm.serializeAddress(key, 'priceSource', category.priceSource); + string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); content = vm.serializeString(eModesKey, key, object); } } @@ -871,10 +870,6 @@ contract ProtocolV3TestBase is DiffUtils { currentCategoryData.liquidationBonus == expectedCategoryData.liquidationBonus, '_validateEmodeCategory(): INVALID_LB' ); - require( - currentCategoryData.priceSource == expectedCategoryData.priceSource, - '_validateEmodeCategory(): INVALID_PRICE_SOURCE' - ); } /** diff --git a/tests/utils/TestnetProcedures.sol b/tests/utils/TestnetProcedures.sol index f13cdfc7..7f12bc76 100644 --- a/tests/utils/TestnetProcedures.sol +++ b/tests/utils/TestnetProcedures.sol @@ -83,7 +83,6 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { uint16 ltv; uint16 lt; uint16 lb; - address oracle; string label; } @@ -345,11 +344,11 @@ contract TestnetProcedures is Test, DeployUtils, FfiUtils, DefaultMarketInput { } function _genCategoryOne() internal pure returns (EModeCategoryInput memory) { - return EModeCategoryInput(1, 95_00, 96_00, 101_00, address(0x0), 'GROUP_A'); + return EModeCategoryInput(1, 95_00, 96_00, 101_00, 'GROUP_A'); } function _genCategoryTwo() internal pure returns (EModeCategoryInput memory) { - return EModeCategoryInput(2, 96_00, 97_00, 101_50, address(0x0), 'GROUP_B'); + return EModeCategoryInput(2, 96_00, 97_00, 101_50, 'GROUP_B'); } function _calcPrice(uint256 price, uint256 percent) public pure returns (uint256) { From 496cf89c1f432e15a32c6cde1ce4181700fe7cf3 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 23 Aug 2024 15:36:22 +0200 Subject: [PATCH 32/88] feat: add borrowable in eMode tests: fix tests fix: linting --- .../interfaces/IPoolConfigurator.sol | 17 +++++++ .../configuration/EModeConfiguration.sol | 47 +++++++++++++++++++ .../protocol/libraries/helpers/Errors.sol | 1 + .../libraries/logic/ValidationLogic.sol | 8 +++- .../protocol/libraries/types/DataTypes.sol | 1 + .../protocol/pool/PoolConfigurator.sol | 18 ++++++- tests/protocol/pool/Pool.Liquidations.t.sol | 1 + tests/protocol/pool/Pool.t.sol | 2 + 8 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/contracts/protocol/libraries/configuration/EModeConfiguration.sol diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index c94357c2..68e3859b 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -165,6 +165,14 @@ interface IPoolConfigurator { */ event EModeAssetCategoryChanged(address indexed asset, uint8 oldCategoryId, uint8 newCategoryId); + /** + * @dev Emitted when the borrowability of an asset in an eMode changed. + * @param asset The address of the underlying asset of the reserve + * @param categoryId The eMode asset category + * @param borrowable True if the asset is borrowable + */ + event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable); + /** * @dev Emitted when a new eMode category is added. * @param categoryId The new eMode category id @@ -477,6 +485,15 @@ interface IPoolConfigurator { */ function setAssetEModeCategory(address asset, uint8 newCategoryId) external; + /** + * @notice Allows an asset to be borrowed in the specified eMode. + * - eMode.borrowable always has less priotiry then reserve.eMode + * @param asset The address of the underlying asset of the reserve + * @param categoryId The category id + * @param borrowable True if the asset should be borrowable + */ + function setAssetBorrowableInEMode(address asset, uint8 categoryId, bool borrowable) external; + /** * @notice Adds a new efficiency mode (eMode) category. * @dev If zero is provided as oracle address, the default asset oracles will be used to compute the overall debt and diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol new file mode 100644 index 00000000..af7805cf --- /dev/null +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {Errors} from '../helpers/Errors.sol'; +import {DataTypes} from '../types/DataTypes.sol'; +import {ReserveConfiguration} from './ReserveConfiguration.sol'; + +/** + * @title EModeConfiguration library + * @author BGD Labs + * @notice Implements the bitmap logic to handle the eMode configuration + */ +library EModeConfiguration { + /** + * @notice Sets if the asset is borrowable in the given eMode + * @param self The configuration object + * @param reserveIndex The index of the reserve in the bitmap + * @param borrowable True if the asset should be borrowable, false otherwise + */ + function setBorrowable( + DataTypes.EModeCategory memory self, + uint256 reserveIndex, + bool borrowable + ) internal pure { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + uint128 bit = uint128(1 << reserveIndex); + if (borrowable) { + self.borrowableMask |= bit; + } else { + self.borrowableMask &= ~bit; + } + } + + /** + * @notice Validates if a reserve can be borrowed in a selected eMode + * @param self The configuration object + * @param reserveIndex The index of the reserve in the bitmap + * @return True if the reserve is borrowable + */ + function isBorrowable( + DataTypes.EModeCategory memory self, + uint256 reserveIndex + ) internal pure returns (bool) { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + return (self.borrowableMask >> reserveIndex) & 1 != 0; + } +} diff --git a/src/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol index b440c5f0..e24d42a7 100644 --- a/src/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/contracts/protocol/libraries/helpers/Errors.sol @@ -99,4 +99,5 @@ library Errors { string public constant LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED = '97'; // 'Liquidation grace sentinel validation failed' string public constant INVALID_GRACE_PERIOD = '98'; // Grace period above a valid range string public constant INVALID_FREEZE_STATE = '99'; // Reserve is already in the passed freeze state + string public constant NOT_BORROWABLE_IN_EMODE = '100'; } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 1395466c..b03850a4 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -13,6 +13,7 @@ import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider import {IAccessControl} from '../../../dependencies/openzeppelin/contracts/IAccessControl.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {EModeConfiguration} from '../configuration/EModeConfiguration.sol'; import {Errors} from '../helpers/Errors.sol'; import {WadRayMath} from '../math/WadRayMath.sol'; import {PercentageMath} from '../math/PercentageMath.sol'; @@ -35,6 +36,7 @@ library ValidationLogic { using GPv2SafeERC20 for IERC20; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using UserConfiguration for DataTypes.UserConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; using Address for address; // Factor to apply to "only-variable-debt" liquidity rate to get threshold for rebalancing, expressed in bps @@ -207,10 +209,12 @@ library ValidationLogic { } if (params.userEModeCategory != 0) { + DataTypes.EModeCategory memory category = eModeCategories[params.userEModeCategory]; require( params.reserveCache.reserveConfiguration.getEModeCategory() == params.userEModeCategory, Errors.INCONSISTENT_EMODE_CATEGORY ); + require(category.isBorrowable(reservesData[params.asset].id), Errors.NOT_BORROWABLE_IN_EMODE); } ( @@ -554,9 +558,10 @@ library ValidationLogic { uint256 reservesCount, uint8 categoryId ) internal view { + DataTypes.EModeCategory memory eModeCategory = eModeCategories[categoryId]; // category is invalid if the liq threshold is not set require( - categoryId == 0 || eModeCategories[categoryId].liquidationThreshold != 0, + categoryId == 0 || eModeCategory.liquidationThreshold != 0, Errors.INCONSISTENT_EMODE_CATEGORY ); @@ -577,6 +582,7 @@ library ValidationLogic { configuration.getEModeCategory() == categoryId, Errors.INCONSISTENT_EMODE_CATEGORY ); + require(eModeCategory.isBorrowable(i), Errors.NOT_BORROWABLE_IN_EMODE); } } } diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 7c7eb070..2c7ac2ef 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -116,6 +116,7 @@ library DataTypes { uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; + uint128 borrowableMask; // uint160 placeHolder; string label; } diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index ffb4a04b..ab780a29 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.10; import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {EModeConfiguration} from '../libraries/configuration/EModeConfiguration.sol'; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; @@ -25,6 +26,7 @@ import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20De abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; IPoolAddressesProvider internal _addressesProvider; IPool internal _pool; @@ -418,7 +420,8 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ltv: ltv, liquidationThreshold: liquidationThreshold, liquidationBonus: liquidationBonus, - label: label + label: label, + borrowableMask: 0 }) ); emit EModeCategoryAdded( @@ -451,6 +454,19 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator emit EModeAssetCategoryChanged(asset, uint8(oldCategoryId), newCategoryId); } + /// @inheritdoc IPoolConfigurator + function setAssetBorrowableInEMode( + address asset, + uint8 categoryId, + bool borrowable + ) external override onlyRiskOrPoolAdmins { + DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + categoryData.setBorrowable(reserveData.id, borrowable); + _pool.configureEModeCategory(categoryId, categoryData); + emit AssetBorrowableInEModeChanged(asset, categoryId, borrowable); + } + /// @inheritdoc IPoolConfigurator function setUnbackedMintCap( address asset, diff --git a/tests/protocol/pool/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol index da144259..3e1d2c48 100644 --- a/tests/protocol/pool/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -618,6 +618,7 @@ contract PoolLiquidationTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct.id, true); vm.stopPrank(); uint256 amount = 1e8; diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 2ba1c018..a4e8a0fa 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -546,6 +546,7 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id); vm.stopPrank(); @@ -580,6 +581,7 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); vm.stopPrank(); vm.prank(alice); From 08b11822d567b9ee4dcee2102af60d180e81b664 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 23 Aug 2024 23:18:12 +0200 Subject: [PATCH 33/88] feat: multi eModes tests: patch tests feat: add gas diff fix: update diff perf: use unchecked fix: use unchecked perf: use storage to not read all slots always fix: add gas diff fix: don't lint perf: view getters accept storage refactor: use collateral test fix: cleanup fix: add gas diff lint: fix fix: rename mask --- docs/gas-diff.md | 1434 +++++++++++++++++ .../libraries/CollateralEngine.sol | 1 - .../libraries/EModeEngine.sol | 4 +- .../helpers/AaveProtocolDataProvider.sol | 9 +- .../helpers/UiPoolDataProviderV3.sol | 25 +- .../interfaces/IUiPoolDataProviderV3.sol | 6 - .../interfaces/IPoolConfigurator.sol | 23 +- .../interfaces/IPoolDataProvider.sol | 7 - .../helpers/MockReserveConfiguration.sol | 20 +- .../configuration/EModeConfiguration.sol | 62 +- .../configuration/ReserveConfiguration.sol | 37 +- .../protocol/libraries/helpers/Errors.sol | 2 +- .../libraries/logic/ConfiguratorLogic.sol | 4 +- .../protocol/libraries/logic/EModeLogic.sol | 40 +- .../protocol/libraries/logic/GenericLogic.sol | 20 +- .../libraries/logic/LiquidationLogic.sol | 9 +- .../libraries/logic/ValidationLogic.sol | 18 +- .../protocol/libraries/types/DataTypes.sol | 2 +- .../protocol/pool/PoolConfigurator.sol | 40 +- .../AaveV3ConfigEngineTest.t.sol | 4 +- tests/protocol/pool/Pool.Borrow.t.sol | 4 +- tests/protocol/pool/Pool.Liquidations.t.sol | 4 +- tests/protocol/pool/Pool.t.sol | 26 +- .../PoolConfigurator.ACLModifiers.t.sol | 2 +- .../PoolConfigurator.eMode.sol | 140 +- tests/utils/ProtocolV3TestBase.sol | 72 +- 26 files changed, 1620 insertions(+), 395 deletions(-) create mode 100644 docs/gas-diff.md diff --git a/docs/gas-diff.md b/docs/gas-diff.md new file mode 100644 index 00000000..4027bf67 --- /dev/null +++ b/docs/gas-diff.md @@ -0,0 +1,1434 @@ +```diff +diff --git a/reports/gas.old b/reports/gas.new +index 0dec812..b5b683a 100644 +--- a/reports/gas.old ++++ b/reports/gas.new +@@ -27,37 +27,37 @@ + | claimRewardsOnBehalf | 41981 | 41981 | 41981 | 41981 | 1 | + | claimRewardsToSelf | 61212 | 143791 | 147239 | 188315 | 8 | + | collectAndUpdateRewards | 60947 | 102021 | 102021 | 143096 | 2 | +-| convertToAssets | 3348 | 3493 | 3496 | 3496 | 261 | +-| convertToShares | 22946 | 22946 | 22946 | 22946 | 1 | +-| createStaticATokens | 2375769 | 2375769 | 2375769 | 2375769 | 46 | ++| convertToAssets | 3370 | 3515 | 3518 | 3518 | 261 | ++| convertToShares | 22968 | 22968 | 22968 | 22968 | 1 | ++| createStaticATokens | 2375835 | 2375835 | 2375835 | 2375835 | 46 | + | decimals | 3154 | 3154 | 3154 | 3154 | 1 | +-| deposit | 216564 | 235000 | 237907 | 237919 | 22 | ++| deposit | 216608 | 235044 | 237951 | 237963 | 22 | + | getClaimableRewards | 7438 | 9046 | 7653 | 12042 | 17 | + | getStaticAToken | 1414 | 1414 | 1414 | 1414 | 52 | + | getStaticATokens | 16900 | 16900 | 16900 | 16900 | 2 | + | getTotalClaimableRewards | 8608 | 10621 | 10429 | 14208 | 9 | + | getUnclaimedRewards | 1590 | 1590 | 1590 | 1590 | 2 | +-| maxDeposit | 33171 | 37914 | 33690 | 44759 | 5 | +-| maxMint | 9226 | 57576 | 57765 | 57765 | 257 | +-| maxRedeem | 10705 | 13359 | 14138 | 14600 | 18 | +-| maxWithdraw | 14471 | 15471 | 15471 | 16471 | 2 | +-| metaDeposit | 285952 | 343531 | 354571 | 390070 | 3 | +-| metaWithdraw | 211664 | 211664 | 211664 | 211664 | 1 | +-| mint | 76230 | 188856 | 188856 | 301483 | 2 | ++| maxDeposit | 33193 | 37936 | 33712 | 44781 | 5 | ++| maxMint | 9248 | 57620 | 57809 | 57809 | 257 | ++| maxRedeem | 10727 | 13402 | 14182 | 14644 | 18 | ++| maxWithdraw | 14537 | 15537 | 15537 | 16537 | 2 | ++| metaDeposit | 285996 | 343575 | 354615 | 390114 | 3 | ++| metaWithdraw | 211708 | 211708 | 211708 | 211708 | 1 | ++| mint | 76274 | 188911 | 188911 | 301549 | 2 | + | name | 10556 | 10556 | 10556 | 10556 | 1 | + | nonces | 3433 | 7147 | 9933 | 9933 | 7 | + | permit | 31503 | 58858 | 60440 | 84631 | 3 | +-| previewDeposit | 3445 | 10445 | 10945 | 16445 | 4 | +-| previewMint | 3687 | 3687 | 3687 | 3687 | 1 | +-| previewRedeem | 3539 | 3539 | 3539 | 3539 | 3 | +-| previewWithdraw | 3662 | 3662 | 3662 | 3662 | 1 | +-| rate | 3037 | 3037 | 3037 | 3037 | 1 | +-| redeem(uint256,address,address) | 76729 | 231188 | 257218 | 318137 | 9 | +-| redeem(uint256,address,address,bool) | 181326 | 181326 | 181326 | 181326 | 1 | ++| previewDeposit | 3467 | 10467 | 10967 | 16467 | 4 | ++| previewMint | 3709 | 3709 | 3709 | 3709 | 1 | ++| previewRedeem | 3561 | 3561 | 3561 | 3561 | 3 | ++| previewWithdraw | 3684 | 3684 | 3684 | 3684 | 1 | ++| rate | 3059 | 3059 | 3059 | 3059 | 1 | ++| redeem(uint256,address,address) | 76773 | 231269 | 257306 | 318225 | 9 | ++| redeem(uint256,address,address,bool) | 181370 | 181370 | 181370 | 181370 | 1 | + | refreshRewardTokens | 128879 | 128879 | 128879 | 128879 | 33 | + | symbol | 4143 | 4143 | 4143 | 4143 | 1 | + | transfer | 101595 | 101595 | 101595 | 101595 | 1 | +-| withdraw | 239849 | 239849 | 239849 | 239849 | 1 | ++| withdraw | 239959 | 239959 | 239959 | 239959 | 1 | + + + | src/contracts/dependencies/weth/WETH9.sol:WETH9 contract | | | | | | +@@ -66,9 +66,9 @@ + | 546391 | 2423 | | | | | + | Function Name | min | avg | median | max | # calls | + | allowance | 803 | 803 | 803 | 803 | 20 | +-| approve | 29055 | 46249 | 46467 | 46467 | 1806 | +-| balanceOf | 541 | 989 | 541 | 2541 | 9310 | +-| decimals | 2313 | 2313 | 2313 | 2313 | 636 | ++| approve | 29055 | 46246 | 46467 | 46467 | 1785 | ++| balanceOf | 541 | 989 | 541 | 2541 | 9205 | ++| decimals | 2313 | 2313 | 2313 | 2313 | 629 | + | symbol | 1213 | 2250 | 3213 | 3213 | 27 | + + +@@ -91,7 +91,7 @@ + | 2050064 | 10159 | | | | | + | Function Name | min | avg | median | max | # calls | + | owner | 386 | 386 | 386 | 386 | 1 | +-| swapAndDeposit | 352192 | 443390 | 475524 | 502455 | 3 | ++| swapAndDeposit | 352280 | 443455 | 475577 | 502508 | 3 | + + + | src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol:ParaSwapRepayAdapter contract | | | | | | +@@ -101,7 +101,7 @@ + | Function Name | min | avg | median | max | # calls | + | owner | 408 | 408 | 408 | 408 | 1 | + | rescueTokens | 36133 | 36133 | 36133 | 36133 | 1 | +-| swapAndRepay | 405121 | 515303 | 535881 | 584329 | 4 | ++| swapAndRepay | 407258 | 517408 | 537975 | 586423 | 4 | + + + | src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol:ParaSwapWithdrawSwapAdapter contract | | | | | | +@@ -110,7 +110,7 @@ + | 1757703 | 8731 | | | | | + | Function Name | min | avg | median | max | # calls | + | owner | 408 | 408 | 408 | 408 | 1 | +-| withdrawAndSwap | 352139 | 378370 | 371176 | 411796 | 3 | ++| withdrawAndSwap | 352227 | 378435 | 371229 | 411849 | 3 | + + + | src/contracts/extensions/static-a-token/StataOracle.sol:StataOracle contract | | | | | | +@@ -118,8 +118,8 @@ + | Deployment Cost | Deployment Size | | | | | + | 349225 | 1737 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getAssetPrice | 14792 | 14877 | 14792 | 36792 | 257 | +-| getAssetsPrices | 87496 | 87496 | 87496 | 87496 | 1 | ++| getAssetPrice | 14814 | 14899 | 14814 | 36814 | 257 | ++| getAssetsPrices | 87562 | 87562 | 87562 | 87562 | 1 | + + + | src/contracts/extensions/static-a-token/StaticATokenFactory.sol:StaticATokenFactory contract | | | | | | +@@ -128,10 +128,10 @@ + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | + | STATIC_A_TOKEN_IMPL | 228 | 228 | 228 | 228 | 1 | +-| createStaticATokens | 2345990 | 2345990 | 2345990 | 2345990 | 46 | ++| createStaticATokens | 2346056 | 2346056 | 2346056 | 2346056 | 46 | + | getStaticAToken | 616 | 616 | 616 | 616 | 52 | + | getStaticATokens | 9587 | 9587 | 9587 | 9587 | 2 | +-| initialize | 24131 | 24131 | 24131 | 24131 | 624 | ++| initialize | 24131 | 24131 | 24131 | 24131 | 617 | + + + | src/contracts/extensions/static-a-token/StaticATokenLM.sol:StaticATokenLM contract | | | | | | +@@ -153,35 +153,35 @@ + | claimRewardsOnBehalf | 12204 | 12204 | 12204 | 12204 | 1 | + | claimRewardsToSelf | 32183 | 127811 | 128173 | 179199 | 8 | + | collectAndUpdateRewards | 32217 | 73291 | 73291 | 114366 | 2 | +-| convertToAssets | 2550 | 2695 | 2698 | 2698 | 261 | +-| convertToShares | 15648 | 15648 | 15648 | 15648 | 1 | ++| convertToAssets | 2572 | 2717 | 2720 | 2720 | 261 | ++| convertToShares | 15670 | 15670 | 15670 | 15670 | 1 | + | decimals | 2359 | 2359 | 2359 | 2359 | 1 | +-| deposit | 196987 | 215388 | 218294 | 218294 | 22 | ++| deposit | 197031 | 215432 | 218338 | 218338 | 22 | + | getClaimableRewards | 6637 | 8244 | 6852 | 11241 | 17 | + | getTotalClaimableRewards | 7810 | 9823 | 9631 | 13410 | 9 | + | getUnclaimedRewards | 789 | 789 | 789 | 789 | 2 | + | initialize | 25757 | 181941 | 180780 | 187780 | 139 | +-| maxDeposit | 25873 | 30616 | 26392 | 37461 | 5 | +-| maxMint | 8428 | 50303 | 50467 | 50467 | 257 | +-| maxRedeem | 9907 | 12561 | 13340 | 13802 | 18 | +-| maxWithdraw | 13673 | 14673 | 14673 | 15673 | 2 | +-| metaDeposit | 272703 | 338943 | 347430 | 396697 | 3 | +-| metaWithdraw | 180770 | 180770 | 180770 | 180770 | 1 | +-| mint | 47284 | 169867 | 169867 | 292450 | 2 | ++| maxDeposit | 25895 | 30638 | 26414 | 37483 | 5 | ++| maxMint | 8450 | 50347 | 50511 | 50511 | 257 | ++| maxRedeem | 9929 | 12604 | 13384 | 13846 | 18 | ++| maxWithdraw | 13739 | 14739 | 14739 | 15739 | 2 | ++| metaDeposit | 272747 | 338987 | 347474 | 396741 | 3 | ++| metaWithdraw | 180814 | 180814 | 180814 | 180814 | 1 | ++| mint | 47328 | 169922 | 169922 | 292516 | 2 | + | name | 3255 | 3255 | 3255 | 3255 | 1 | + | nonces | 2635 | 2635 | 2635 | 2635 | 7 | + | permit | 834 | 28265 | 29975 | 53987 | 3 | +-| previewDeposit | 2647 | 9647 | 10147 | 15647 | 4 | +-| previewMint | 2889 | 2889 | 2889 | 2889 | 1 | +-| previewRedeem | 2741 | 2741 | 2741 | 2741 | 3 | +-| previewWithdraw | 2864 | 2864 | 2864 | 2864 | 1 | +-| rate | 2242 | 2242 | 2242 | 2242 | 1 | +-| redeem(uint256,address,address) | 47400 | 211478 | 237511 | 293630 | 9 | +-| redeem(uint256,address,address,bool) | 166282 | 166282 | 166282 | 166282 | 1 | ++| previewDeposit | 2669 | 9669 | 10169 | 15669 | 4 | ++| previewMint | 2911 | 2911 | 2911 | 2911 | 1 | ++| previewRedeem | 2763 | 2763 | 2763 | 2763 | 3 | ++| previewWithdraw | 2886 | 2886 | 2886 | 2886 | 1 | ++| rate | 2264 | 2264 | 2264 | 2264 | 1 | ++| redeem(uint256,address,address) | 47444 | 211559 | 237599 | 293718 | 9 | ++| redeem(uint256,address,address,bool) | 166326 | 166326 | 166326 | 166326 | 1 | + | refreshRewardTokens | 100523 | 100523 | 100523 | 100523 | 33 | + | symbol | 3342 | 3342 | 3342 | 3342 | 1 | + | transfer | 72662 | 72662 | 72662 | 72662 | 1 | +-| withdraw | 224942 | 224942 | 224942 | 224942 | 1 | ++| withdraw | 225052 | 225052 | 225052 | 225052 | 1 | + + + | src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol:AaveV3ConfigEngine contract | | | | | | +@@ -189,16 +189,16 @@ + | Deployment Cost | Deployment Size | | | | | + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | +-| DEFAULT_INTEREST_RATE_STRATEGY | 337 | 337 | 337 | 337 | 5 | +-| listAssets | 1844953 | 1844953 | 1844953 | 1844953 | 1 | +-| listAssetsCustom | 1844210 | 5301679 | 5307465 | 5307465 | 620 | +-| updateAssetsEMode | 68531 | 68531 | 68531 | 68531 | 1 | +-| updateBorrowSide | 20079 | 76359 | 76359 | 132640 | 2 | +-| updateCaps | 59884 | 59884 | 59884 | 59884 | 1 | +-| updateCollateralSide | 8777 | 30468 | 8903 | 62879 | 5 | +-| updateEModeCategories | 11063 | 61143 | 27080 | 128256 | 5 | +-| updatePriceFeeds | 39338 | 39338 | 39338 | 39338 | 1 | +-| updateRateStrategies | 122092 | 122092 | 122092 | 122092 | 1 | ++| DEFAULT_INTEREST_RATE_STRATEGY | 227 | 227 | 227 | 227 | 5 | ++| listAssets | 1832666 | 1832666 | 1832666 | 1832666 | 1 | ++| listAssetsCustom | 1831923 | 5264667 | 5270468 | 5270468 | 613 | ++| updateAssetsEMode | 109952 | 109952 | 109952 | 109952 | 1 | ++| updateBorrowSide | 20101 | 76447 | 76447 | 132793 | 2 | ++| updateCaps | 59905 | 59905 | 59905 | 59905 | 1 | ++| updateCollateralSide | 8777 | 30508 | 8903 | 62979 | 5 | ++| updateEModeCategories | 10592 | 51848 | 29691 | 104184 | 5 | ++| updatePriceFeeds | 39360 | 39360 | 39360 | 39360 | 1 | ++| updateRateStrategies | 122115 | 122115 | 122115 | 122115 | 1 | + + + | src/contracts/helpers/AaveProtocolDataProvider.sol:AaveProtocolDataProvider contract | | | | | | +@@ -206,22 +206,21 @@ + | Deployment Cost | Deployment Size | | | | | + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getATokenTotalSupply | 11863 | 14153 | 11907 | 24953 | 2140 | +-| getAllReservesTokens | 16222 | 28423 | 31722 | 39722 | 27 | ++| getATokenTotalSupply | 11863 | 14172 | 11907 | 24975 | 2119 | ++| getAllReservesTokens | 16155 | 28653 | 39655 | 39655 | 27 | + | getDebtCeiling | 3263 | 3263 | 3263 | 3263 | 4 | +-| getDebtCeilingDecimals | 237 | 237 | 237 | 237 | 1 | ++| getDebtCeilingDecimals | 215 | 215 | 215 | 215 | 1 | + | getFlashLoanEnabled | 3236 | 4236 | 4236 | 5236 | 512 | +-| getInterestRateStrategyAddress | 8453 | 19448 | 8453 | 39953 | 9 | +-| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 8116 | +-| getLiquidationProtocolFee | 3174 | 9951 | 5674 | 16674 | 9 | +-| getPaused | 3219 | 3325 | 3263 | 5263 | 8383 | ++| getInterestRateStrategyAddress | 8563 | 19558 | 8563 | 40063 | 9 | ++| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 9311 | ++| getLiquidationProtocolFee | 3285 | 10062 | 5785 | 16785 | 9 | ++| getPaused | 3330 | 3375 | 3374 | 5374 | 9324 | + | getReserveCaps | 3286 | 8168 | 3286 | 16786 | 47 | +-| getReserveConfigurationData | 3565 | 3773 | 3609 | 17109 | 9714 | +-| getReserveEModeCategory | 3199 | 3199 | 3199 | 3199 | 1 | +-| getReserveTokensAddresses | 8541 | 14283 | 14585 | 40085 | 9574 | ++| getReserveConfigurationData | 3662 | 3852 | 3706 | 17206 | 10906 | ++| getReserveTokensAddresses | 8541 | 14319 | 14585 | 40085 | 10764 | + | getSiloedBorrowing | 3289 | 3289 | 3289 | 3289 | 1 | +-| getTotalDebt | 51955 | 51955 | 51955 | 51955 | 3 | +-| getUserReserveData | 18944 | 26800 | 27034 | 43944 | 1302 | ++| getTotalDebt | 51890 | 51890 | 51890 | 51890 | 3 | ++| getUserReserveData | 18988 | 26794 | 27013 | 43988 | 1301 | + + + | src/contracts/helpers/L2Encoder.sol:L2Encoder contract | | | | | | +@@ -229,15 +228,15 @@ + | Deployment Cost | Deployment Size | | | | | + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | +-| encodeBorrowParams | 7859 | 7859 | 7859 | 7859 | 3 | +-| encodeLiquidationCall | 19245 | 19245 | 19245 | 19245 | 1 | +-| encodeRepayParams | 7742 | 7742 | 7742 | 7742 | 1 | +-| encodeRepayWithATokensParams | 7770 | 7770 | 7770 | 7770 | 1 | +-| encodeRepayWithPermitParams | 10231 | 10231 | 10231 | 10231 | 256 | +-| encodeSetUserUseReserveAsCollateral | 7679 | 7679 | 7679 | 7679 | 1 | +-| encodeSupplyParams | 34785 | 34785 | 34785 | 34785 | 7 | +-| encodeSupplyWithPermitParams | 35144 | 35144 | 35144 | 35144 | 256 | +-| encodeWithdrawParams | 7625 | 7659 | 7659 | 7693 | 2 | ++| encodeBorrowParams | 7881 | 7881 | 7881 | 7881 | 3 | ++| encodeLiquidationCall | 19289 | 19289 | 19289 | 19289 | 1 | ++| encodeRepayParams | 7764 | 7764 | 7764 | 7764 | 1 | ++| encodeRepayWithATokensParams | 7792 | 7792 | 7792 | 7792 | 1 | ++| encodeRepayWithPermitParams | 10253 | 10253 | 10253 | 10253 | 256 | ++| encodeSetUserUseReserveAsCollateral | 7701 | 7701 | 7701 | 7701 | 1 | ++| encodeSupplyParams | 34807 | 34807 | 34807 | 34807 | 7 | ++| encodeSupplyWithPermitParams | 35166 | 35166 | 35166 | 35166 | 256 | ++| encodeWithdrawParams | 7647 | 7681 | 7681 | 7715 | 2 | + + + | src/contracts/helpers/WrappedTokenGatewayV3.sol:WrappedTokenGatewayV3 contract | | | | | | +@@ -245,16 +244,16 @@ + | Deployment Cost | Deployment Size | | | | | + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | +-| borrowETH | 253365 | 253365 | 253365 | 253365 | 1 | ++| borrowETH | 255413 | 255413 | 255413 | 255413 | 1 | + | depositETH | 240170 | 240170 | 240170 | 240170 | 8 | + | emergencyEtherTransfer | 33801 | 33801 | 33801 | 33801 | 1 | + | emergencyTokenTransfer | 52810 | 52810 | 52810 | 52810 | 1 | + | getWETHAddress | 245 | 245 | 245 | 245 | 1 | + | owner | 308 | 308 | 308 | 308 | 1 | + | receive | 21206 | 21206 | 21206 | 21206 | 1 | +-| repayETH | 175754 | 179762 | 177644 | 187475 | 5 | +-| withdrawETH | 231257 | 235319 | 235319 | 239381 | 2 | +-| withdrawETHWithPermit | 275525 | 278408 | 278408 | 281291 | 2 | ++| repayETH | 175668 | 179676 | 177558 | 187389 | 5 | ++| withdrawETH | 231328 | 235398 | 235398 | 239469 | 2 | ++| withdrawETHWithPermit | 275613 | 278496 | 278496 | 281379 | 2 | + + + | src/contracts/instances/ATokenInstance.sol:ATokenInstance contract | | | | | | +@@ -264,35 +263,35 @@ + | Function Name | min | avg | median | max | # calls | + | DOMAIN_SEPARATOR | 458 | 2275 | 2458 | 3543 | 5 | + | POOL | 327 | 327 | 327 | 327 | 151 | +-| RESERVE_TREASURY_ADDRESS | 420 | 783 | 420 | 2420 | 9917 | +-| UNDERLYING_ASSET_ADDRESS | 442 | 475 | 442 | 2442 | 8251 | ++| RESERVE_TREASURY_ADDRESS | 420 | 744 | 420 | 2420 | 11111 | ++| UNDERLYING_ASSET_ADDRESS | 442 | 471 | 442 | 2442 | 9446 | + | allowance | 785 | 1554 | 785 | 2785 | 26 | + | approve | 24590 | 24590 | 24590 | 24590 | 39 | +-| balanceOf | 2744 | 5319 | 4744 | 17744 | 4799 | +-| burn | 911 | 35660 | 37180 | 81176 | 2111 | +-| decimals | 357 | 403 | 357 | 2357 | 8304 | ++| balanceOf | 2766 | 5342 | 4766 | 17766 | 4796 | ++| burn | 911 | 35659 | 37180 | 81176 | 2110 | ++| decimals | 357 | 397 | 357 | 2357 | 9499 | + | decreaseAllowance | 7709 | 7709 | 7709 | 7709 | 1 | +-| getIncentivesController | 475 | 475 | 475 | 2475 | 8116 | ++| getIncentivesController | 475 | 475 | 475 | 2475 | 9311 | + | getPreviousIndex | 654 | 654 | 654 | 654 | 39 | + | getScaledUserBalanceAndSupply | 830 | 2419 | 2830 | 4830 | 39 | +-| handleRepayment | 597 | 597 | 597 | 597 | 2599 | ++| handleRepayment | 597 | 597 | 597 | 597 | 2598 | + | increaseAllowance | 7776 | 20601 | 24876 | 24876 | 4 | +-| initialize | 146515 | 228079 | 231709 | 321646 | 43251 | +-| mint | 940 | 59706 | 64435 | 72198 | 4166 | ++| initialize | 146515 | 232852 | 231746 | 321646 | 44425 | ++| mint | 940 | 59703 | 64435 | 72198 | 4163 | + | mintToTreasury | 444 | 43943 | 49223 | 66323 | 6 | +-| name | 1009 | 1454 | 1326 | 3264 | 8351 | ++| name | 1009 | 1449 | 1326 | 3264 | 9546 | + | nonces | 655 | 1988 | 2655 | 2655 | 9 | + | permit | 1117 | 33566 | 43549 | 53499 | 16 | + | rescueTokens | 12040 | 24418 | 14258 | 46957 | 3 | +-| scaledBalanceOf | 691 | 1986 | 2691 | 2691 | 10419 | ++| scaledBalanceOf | 691 | 1988 | 2691 | 2691 | 10445 | + | scaledTotalSupply | 375 | 2181 | 2375 | 2375 | 414 | + | setIncentivesController | 11941 | 14316 | 14316 | 16691 | 2 | +-| symbol | 1074 | 1515 | 1391 | 3329 | 8333 | +-| totalSupply | 411 | 4892 | 6457 | 10457 | 4903 | +-| transfer | 580 | 117377 | 122690 | 140646 | 275 | +-| transferFrom | 87624 | 120965 | 130243 | 145830 | 43 | +-| transferOnLiquidation | 988 | 30249 | 37526 | 44326 | 1807 | +-| transferUnderlyingTo | 802 | 18573 | 16500 | 33639 | 2704 | ++| symbol | 1074 | 1510 | 1391 | 3329 | 9528 | ++| totalSupply | 411 | 4911 | 6479 | 10479 | 4881 | ++| transfer | 580 | 117116 | 122712 | 142783 | 275 | ++| transferFrom | 87646 | 121183 | 130265 | 147966 | 43 | ++| transferOnLiquidation | 988 | 30267 | 37548 | 44348 | 1806 | ++| transferUnderlyingTo | 802 | 18574 | 16500 | 33639 | 2703 | + + + | src/contracts/instances/L2PoolInstance.sol:L2PoolInstance contract | | | | | | +@@ -302,154 +301,155 @@ + | Function Name | min | avg | median | max | # calls | + | ADDRESSES_PROVIDER | 352 | 352 | 352 | 352 | 126 | + | FLASHLOAN_PREMIUM_TOTAL | 389 | 1389 | 1389 | 2389 | 124 | +-| FLASHLOAN_PREMIUM_TO_PROTOCOL | 482 | 482 | 482 | 482 | 124 | +-| borrow(address,uint256,uint256,uint16,address) | 198181 | 204033 | 203781 | 238990 | 266 | +-| borrow(bytes32) | 203802 | 203802 | 203802 | 203802 | 3 | +-| configureEModeCategory | 7230 | 8196 | 7230 | 49447 | 262 | +-| dropReserve | 6336 | 6631 | 6336 | 82330 | 257 | +-| getBorrowLogic | 282 | 282 | 282 | 282 | 1 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 415 | 415 | 415 | 124 | ++| borrow(address,uint256,uint256,uint16,address) | 200230 | 206064 | 205830 | 240946 | 266 | ++| borrow(bytes32) | 205829 | 205829 | 205829 | 205829 | 3 | ++| configureEModeCategory | 7310 | 8723 | 7310 | 51792 | 276 | ++| dropReserve | 6270 | 6565 | 6270 | 82286 | 257 | ++| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | + | getBridgeLogic | 346 | 346 | 346 | 346 | 1 | +-| getConfiguration | 682 | 728 | 682 | 2682 | 1636 | +-| getEModeCategoryData | 6141 | 6141 | 6141 | 6141 | 12 | ++| getConfiguration | 704 | 714 | 704 | 2704 | 1462 | ++| getEModeCategoryData | 8379 | 8379 | 8379 | 8379 | 14 | + | getEModeLogic | 279 | 279 | 279 | 279 | 1 | +-| getFlashLoanLogic | 348 | 348 | 348 | 348 | 1 | +-| getLiquidationGracePeriod | 2659 | 2659 | 2659 | 2659 | 256 | +-| getLiquidationLogic | 326 | 326 | 326 | 326 | 1 | +-| getPoolLogic | 303 | 303 | 303 | 303 | 1 | +-| getReserveData | 4195 | 11606 | 6195 | 24195 | 839 | +-| getReserveNormalizedIncome | 892 | 893 | 892 | 1354 | 292 | +-| getReserveNormalizedVariableDebt | 849 | 868 | 849 | 2849 | 264 | +-| getReservesList | 11117 | 11117 | 11117 | 11117 | 262 | +-| getSupplyLogic | 368 | 368 | 368 | 368 | 1 | +-| getUserAccountData | 22727 | 22727 | 22727 | 22727 | 1 | +-| getVirtualUnderlyingBalance | 682 | 682 | 682 | 682 | 4 | +-| initReserve | 6553 | 41017 | 6553 | 167529 | 656 | +-| initialize | 45403 | 45403 | 45403 | 45403 | 62 | +-| liquidationCall | 377264 | 377264 | 377264 | 377264 | 1 | +-| mintToTreasury | 77299 | 78694 | 78694 | 80089 | 2 | +-| repay(address,uint256,uint256,address) | 164697 | 164697 | 164697 | 164697 | 2 | +-| repay(bytes32) | 135689 | 135689 | 135689 | 135689 | 1 | +-| repayWithATokens | 138810 | 138810 | 138810 | 138810 | 1 | +-| repayWithPermit | 183122 | 199089 | 206994 | 210215 | 256 | +-| rescueTokens | 48197 | 48197 | 48197 | 48197 | 256 | ++| getFlashLoanLogic | 281 | 281 | 281 | 281 | 1 | ++| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 256 | ++| getLiquidationLogic | 348 | 348 | 348 | 348 | 1 | ++| getPoolLogic | 325 | 325 | 325 | 325 | 1 | ++| getReserveData | 4217 | 11834 | 6217 | 24217 | 853 | ++| getReserveNormalizedIncome | 827 | 828 | 827 | 1289 | 292 | ++| getReserveNormalizedVariableDebt | 871 | 890 | 871 | 2871 | 264 | ++| getReservesList | 11139 | 11139 | 11139 | 11139 | 256 | ++| getSupplyLogic | 282 | 282 | 282 | 282 | 1 | ++| getUserAccountData | 22775 | 22775 | 22775 | 22775 | 1 | ++| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 4 | ++| initReserve | 6575 | 41039 | 6575 | 167551 | 656 | ++| initialize | 45425 | 45425 | 45425 | 45425 | 62 | ++| liquidationCall | 379271 | 379271 | 379271 | 379271 | 1 | ++| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | ++| repay(address,uint256,uint256,address) | 164652 | 164652 | 164652 | 164652 | 2 | ++| repay(bytes32) | 135733 | 135733 | 135733 | 135733 | 1 | ++| repayWithATokens | 138767 | 138767 | 138767 | 138767 | 1 | ++| repayWithPermit | 183077 | 199967 | 210169 | 210439 | 256 | ++| rescueTokens | 48219 | 48219 | 48219 | 48219 | 256 | + | resetIsolationModeTotalDebt | 4276 | 5590 | 6269 | 15276 | 402 | +-| setConfiguration | 2178 | 4409 | 2178 | 24334 | 2004 | +-| setLiquidationGracePeriod | 6352 | 11369 | 10840 | 17003 | 768 | +-| setReserveInterestRateStrategyAddress | 6394 | 7969 | 6503 | 15791 | 769 | +-| setUserEMode | 22040 | 42082 | 40260 | 87614 | 7 | +-| setUserUseReserveAsCollateral(address,bool) | 53653 | 69628 | 71674 | 103062 | 17 | +-| setUserUseReserveAsCollateral(bytes32) | 73824 | 73824 | 73824 | 73824 | 1 | +-| supply(address,uint256,address,uint16) | 157289 | 207630 | 208589 | 208589 | 284 | ++| setConfiguration | 2178 | 4547 | 2178 | 24334 | 1848 | ++| setLiquidationGracePeriod | 6374 | 11394 | 10862 | 17025 | 768 | ++| setReserveInterestRateStrategyAddress | 6416 | 7991 | 6525 | 15813 | 769 | ++| setUserEMode | 17811 | 42125 | 40892 | 89706 | 7 | ++| setUserUseReserveAsCollateral(address,bool) | 53610 | 69578 | 71631 | 102908 | 17 | ++| setUserUseReserveAsCollateral(bytes32) | 73781 | 73781 | 73781 | 73781 | 1 | ++| supply(address,uint256,address,uint16) | 157311 | 207652 | 208611 | 208611 | 284 | + | supply(bytes32) | 210669 | 210669 | 210669 | 210669 | 7 | +-| supplyWithPermit | 259858 | 259858 | 259858 | 259858 | 256 | +-| syncIndexesState | 7317 | 13950 | 7317 | 27217 | 144 | +-| syncRatesState | 16050 | 16050 | 16050 | 16050 | 144 | +-| updateBridgeProtocolFee | 6240 | 6240 | 6240 | 6240 | 256 | +-| updateFlashloanPremiums | 1749 | 8143 | 6422 | 21649 | 380 | +-| withdraw | 126597 | 129039 | 129039 | 131482 | 2 | ++| supplyWithPermit | 259880 | 259880 | 259880 | 259880 | 256 | ++| syncIndexesState | 7251 | 13884 | 7251 | 27151 | 144 | ++| syncRatesState | 16072 | 16072 | 16072 | 16072 | 144 | ++| updateBridgeProtocolFee | 6262 | 6262 | 6262 | 6262 | 256 | ++| updateFlashloanPremiums | 1771 | 8165 | 6444 | 21671 | 380 | ++| withdraw | 126619 | 129061 | 129061 | 131504 | 2 | + + + | src/contracts/instances/PoolConfiguratorInstance.sol:PoolConfiguratorInstance contract | | | | | | + |----------------------------------------------------------------------------------------|-----------------|----------|---------|-----------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 4442338 | 20353 | | | | | ++| 4446043 | 20370 | | | | | + | Function Name | min | avg | median | max | # calls | +-| MAX_GRACE_PERIOD | 305 | 305 | 305 | 305 | 1792 | +-| configureReserveAsCollateral | 12205 | 26298 | 17314 | 95608 | 4169 | +-| disableLiquidationGracePeriod | 17326 | 28493 | 39617 | 39617 | 513 | +-| dropReserve | 14069 | 14927 | 14069 | 104794 | 261 | +-| getConfiguratorLogic | 240 | 240 | 240 | 240 | 1 | +-| getPendingLtv | 599 | 599 | 599 | 599 | 771 | +-| initReserves | 17491 | 25585884 | 1659867 | 216850380 | 2670 | +-| initialize | 72581 | 90426 | 90481 | 90481 | 651 | +-| setAssetEModeCategory | 11337 | 12907 | 11403 | 52868 | 2156 | +-| setBorrowCap | 11197 | 12183 | 11263 | 44219 | 2126 | +-| setBorrowableInIsolation | 10808 | 11146 | 10874 | 43820 | 1872 | +-| setDebtCeiling | 17279 | 39386 | 39794 | 94867 | 2133 | +-| setEModeCategory | 17852 | 27224 | 17852 | 107759 | 297 | +-| setLiquidationProtocolFee | 11246 | 11455 | 11312 | 44268 | 1867 | +-| setPoolPause(bool) | 17312 | 17735 | 17312 | 90088 | 515 | +-| setPoolPause(bool,uint40) | 17337 | 61920 | 48309 | 107843 | 512 | +-| setReserveActive | 14202 | 17104 | 14202 | 91368 | 267 | +-| setReserveBorrowing | 10894 | 17630 | 11116 | 41770 | 2628 | +-| setReserveFactor | 17302 | 40360 | 36815 | 125123 | 2118 | +-| setReserveFlashLoaning | 10959 | 17722 | 11025 | 43991 | 2373 | +-| setReserveFreeze | 20558 | 48100 | 52947 | 73153 | 783 | +-| setReserveInterestRateData | 17561 | 18227 | 17561 | 103603 | 258 | +-| setReserveInterestRateStrategyAddress | 17671 | 34391 | 17671 | 162415 | 300 | +-| setReservePause(address,bool) | 17348 | 17531 | 17348 | 41048 | 258 | +-| setReservePause(address,bool,uint40) | 14442 | 39080 | 47073 | 52185 | 3084 | +-| setSiloedBorrowing | 11266 | 11497 | 11332 | 91271 | 1862 | +-| setSupplyCap | 11199 | 12951 | 11265 | 44221 | 2139 | +-| setUnbackedMintCap | 44189 | 44189 | 44189 | 44189 | 7 | +-| updateAToken | 14141 | 14621 | 14141 | 137683 | 257 | +-| updateBridgeProtocolFee | 14119 | 49368 | 52080 | 52080 | 14 | +-| updateFlashloanPremiumToProtocol | 10139 | 11301 | 10139 | 36939 | 907 | +-| updateFlashloanPremiumTotal | 14136 | 27000 | 32071 | 36971 | 907 | +-| updateVariableDebtToken | 14141 | 14597 | 14141 | 131538 | 257 | ++| MAX_GRACE_PERIOD | 283 | 283 | 283 | 283 | 1538 | ++| configureReserveAsCollateral | 12305 | 26463 | 17380 | 95730 | 4148 | ++| disableLiquidationGracePeriod | 17259 | 28403 | 39505 | 39505 | 513 | ++| dropReserve | 14135 | 14992 | 14135 | 104817 | 261 | ++| getConfiguratorLogic | 306 | 306 | 306 | 306 | 1 | ++| getPendingLtv | 576 | 576 | 576 | 576 | 771 | ++| initReserves | 17468 | 26428054 | 1659789 | 213990395 | 2663 | ++| initialize | 72603 | 90447 | 90503 | 90503 | 644 | ++| setAssetBorrowableInEMode | 76938 | 76990 | 77026 | 77026 | 5 | ++| setAssetEModeCategory | 17454 | 25380 | 17454 | 94158 | 289 | ++| setBorrowCap | 11241 | 12233 | 11307 | 44263 | 2105 | ++| setBorrowableInIsolation | 10786 | 11127 | 10852 | 43798 | 1851 | ++| setDebtCeiling | 17323 | 39443 | 39882 | 94955 | 2112 | ++| setEModeCategory | 17827 | 23075 | 17827 | 84268 | 285 | ++| setLiquidationProtocolFee | 11290 | 11500 | 11356 | 44312 | 1846 | ++| setPoolPause(bool) | 17269 | 17692 | 17269 | 90066 | 515 | ++| setPoolPause(bool,uint40) | 17359 | 61611 | 48341 | 107751 | 512 | ++| setReserveActive | 14157 | 17061 | 14157 | 91367 | 267 | ++| setReserveBorrowing | 10982 | 17769 | 11204 | 41858 | 2607 | ++| setReserveFactor | 17279 | 40357 | 36858 | 125166 | 2097 | ++| setReserveFlashLoaning | 10981 | 17803 | 11047 | 44013 | 2352 | ++| setReserveFreeze | 20624 | 48153 | 53035 | 73241 | 782 | ++| setReserveInterestRateData | 17518 | 18185 | 17518 | 103626 | 258 | ++| setReserveInterestRateStrategyAddress | 17648 | 34381 | 17648 | 162480 | 300 | ++| setReservePause(address,bool) | 17414 | 17597 | 17414 | 41136 | 258 | ++| setReservePause(address,bool,uint40) | 14486 | 36220 | 47094 | 52206 | 2068 | ++| setSiloedBorrowing | 11244 | 11477 | 11310 | 91184 | 1841 | ++| setSupplyCap | 11198 | 12957 | 11264 | 44220 | 2118 | ++| setUnbackedMintCap | 44233 | 44233 | 44233 | 44233 | 7 | ++| updateAToken | 14096 | 14576 | 14096 | 137662 | 257 | ++| updateBridgeProtocolFee | 14141 | 49349 | 52058 | 52058 | 14 | ++| updateFlashloanPremiumToProtocol | 10205 | 11357 | 10205 | 37005 | 900 | ++| updateFlashloanPremiumTotal | 14113 | 26963 | 32092 | 36992 | 900 | ++| updateVariableDebtToken | 14097 | 14553 | 14097 | 131512 | 257 | + + + | src/contracts/instances/PoolInstance.sol:PoolInstance contract | | | | | | + |----------------------------------------------------------------|-----------------|--------|--------|--------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 4668760 | 21651 | | | | | ++| 4697379 | 21784 | | | | | + | Function Name | min | avg | median | max | # calls | +-| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3066 | +-| BRIDGE_PROTOCOL_FEE | 416 | 2176 | 2416 | 2416 | 25 | +-| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1182 | +-| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 416 | 415 | 2415 | 1179 | ++| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3052 | ++| BRIDGE_PROTOCOL_FEE | 350 | 2110 | 2350 | 2350 | 25 | ++| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1168 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1165 | + | MAX_NUMBER_RESERVES | 309 | 309 | 309 | 309 | 514 | +-| backUnbacked | 98453 | 114633 | 112032 | 133026 | 9 | +-| borrow | 46669 | 219345 | 222815 | 262245 | 2435 | +-| configureEModeCategory | 7207 | 10703 | 7207 | 49424 | 280 | ++| backUnbacked | 98475 | 114655 | 112054 | 133048 | 9 | ++| borrow | 46603 | 221407 | 224863 | 264427 | 2434 | ++| configureEModeCategory | 7332 | 10631 | 7332 | 51814 | 297 | + | deposit | 32854 | 190352 | 208588 | 214736 | 80 | +-| dropReserve | 6270 | 7104 | 6270 | 82308 | 262 | +-| finalizeTransfer | 20766 | 45533 | 48574 | 88370 | 317 | +-| flashLoan | 29742 | 80321 | 61019 | 320939 | 267 | +-| flashLoanSimple | 23431 | 343312 | 189538 | 757563 | 11 | +-| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | ++| dropReserve | 6292 | 7125 | 6292 | 82265 | 262 | ++| finalizeTransfer | 20766 | 45315 | 48574 | 90485 | 317 | ++| flashLoan | 29764 | 85592 | 73125 | 323033 | 267 | ++| flashLoanSimple | 23453 | 343384 | 189604 | 757609 | 11 | ++| getBorrowLogic | 326 | 326 | 326 | 326 | 1 | + | getBridgeLogic | 280 | 280 | 280 | 280 | 1 | +-| getConfiguration | 726 | 968 | 726 | 2726 | 53149 | +-| getEModeCategoryData | 1908 | 5110 | 6163 | 6163 | 43 | ++| getConfiguration | 748 | 946 | 748 | 2748 | 53424 | ++| getEModeCategoryData | 2146 | 6907 | 8401 | 8401 | 37 | + | getEModeLogic | 301 | 301 | 301 | 301 | 1 | +-| getFlashLoanLogic | 303 | 303 | 303 | 303 | 1 | +-| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 2014 | +-| getLiquidationLogic | 281 | 281 | 281 | 281 | 1 | +-| getPoolLogic | 280 | 280 | 280 | 280 | 1 | +-| getReserveAddressById | 665 | 665 | 665 | 665 | 1 | +-| getReserveData | 4239 | 8268 | 6239 | 24239 | 18252 | +-| getReserveDataExtended | 3416 | 4082 | 3416 | 5416 | 6 | +-| getReserveNormalizedIncome | 849 | 1126 | 849 | 5311 | 10501 | +-| getReserveNormalizedVariableDebt | 893 | 1071 | 893 | 6491 | 7171 | +-| getReservesCount | 437 | 437 | 437 | 437 | 2 | +-| getReservesList | 3161 | 12139 | 11161 | 101874 | 1902 | +-| getSupplyLogic | 304 | 304 | 304 | 304 | 1 | +-| getUserAccountData | 18124 | 21525 | 22624 | 29389 | 1036 | +-| getUserConfiguration | 706 | 748 | 706 | 2706 | 1822 | +-| getUserEMode | 659 | 659 | 659 | 659 | 1037 | +-| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 2157 | +-| initReserve | 6597 | 179856 | 179637 | 207301 | 43619 | +-| initialize | 45447 | 45546 | 45447 | 66968 | 593 | +-| liquidationCall | 53261 | 228680 | 324198 | 376813 | 3491 | +-| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | +-| mintUnbacked | 12222 | 118445 | 103571 | 165915 | 17 | +-| repay | 33239 | 99467 | 95964 | 164674 | 21 | +-| repayWithATokens | 128274 | 154025 | 155469 | 166111 | 261 | +-| repayWithPermit | 127104 | 165503 | 154197 | 209900 | 768 | +-| rescueTokens | 48154 | 48154 | 48154 | 48154 | 256 | +-| resetIsolationModeTotalDebt | 4298 | 4568 | 4298 | 15298 | 1974 | +-| setConfiguration | 2200 | 16547 | 24200 | 24356 | 67500 | +-| setLiquidationGracePeriod | 6374 | 12458 | 14525 | 17025 | 3476 | +-| setReserveInterestRateStrategyAddress | 6416 | 7955 | 6525 | 15813 | 813 | +-| setUserEMode | 21974 | 41470 | 40194 | 87548 | 10 | +-| setUserUseReserveAsCollateral | 53632 | 72191 | 71653 | 103041 | 25 | +-| supply | 29467 | 187262 | 208611 | 216374 | 3016 | ++| getFlashLoanLogic | 325 | 325 | 325 | 325 | 1 | ++| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 982 | ++| getLiquidationLogic | 303 | 303 | 303 | 303 | 1 | ++| getPoolLogic | 302 | 302 | 302 | 302 | 1 | ++| getReserveAddressById | 620 | 620 | 620 | 620 | 1 | ++| getReserveData | 4261 | 8438 | 10261 | 24261 | 19421 | ++| getReserveDataExtended | 3438 | 4104 | 3438 | 5438 | 6 | ++| getReserveNormalizedIncome | 871 | 1149 | 871 | 5333 | 10496 | ++| getReserveNormalizedVariableDebt | 828 | 1004 | 828 | 6426 | 7194 | ++| getReservesCount | 373 | 373 | 373 | 373 | 2 | ++| getReservesList | 3116 | 12621 | 11116 | 102626 | 1874 | ++| getSupplyLogic | 326 | 326 | 326 | 326 | 1 | ++| getUserAccountData | 18261 | 21664 | 22761 | 29751 | 1035 | ++| getUserConfiguration | 728 | 774 | 728 | 2728 | 1821 | ++| getUserEMode | 659 | 659 | 659 | 659 | 1036 | ++| getVirtualUnderlyingBalance | 726 | 726 | 726 | 726 | 2155 | ++| initReserve | 6552 | 179813 | 179592 | 207256 | 44793 | ++| initialize | 45382 | 45482 | 45382 | 66903 | 586 | ++| liquidationCall | 53261 | 229958 | 317741 | 379178 | 3520 | ++| mintToTreasury | 77343 | 78738 | 78738 | 80133 | 2 | ++| mintUnbacked | 12177 | 118400 | 103526 | 165870 | 17 | ++| repay | 33261 | 99436 | 95921 | 164631 | 21 | ++| repayWithATokens | 128164 | 154207 | 155359 | 166023 | 261 | ++| repayWithPermit | 127039 | 165678 | 154132 | 210104 | 768 | ++| rescueTokens | 48176 | 48176 | 48176 | 48176 | 256 | ++| resetIsolationModeTotalDebt | 4298 | 4570 | 4298 | 15298 | 1953 | ++| setConfiguration | 2200 | 17256 | 24200 | 24356 | 65703 | ++| setLiquidationGracePeriod | 6329 | 12079 | 12480 | 16980 | 2970 | ++| setReserveInterestRateStrategyAddress | 6438 | 7977 | 6547 | 15835 | 813 | ++| setUserEMode | 17833 | 41873 | 40914 | 89728 | 9 | ++| setUserUseReserveAsCollateral | 53676 | 72230 | 71697 | 102974 | 25 | ++| supply | 29401 | 187180 | 208545 | 216308 | 3013 | + | supplyWithPermit | 113813 | 196609 | 218266 | 257750 | 768 | +-| syncIndexesState | 7251 | 13978 | 7251 | 62644 | 1763 | +-| syncRatesState | 13531 | 16046 | 16072 | 22572 | 1763 | +-| updateBridgeProtocolFee | 6195 | 7025 | 6195 | 23375 | 269 | +-| updateFlashloanPremiums | 1704 | 10703 | 6377 | 21604 | 1432 | +-| withdraw | 39229 | 105506 | 87802 | 177983 | 51 | ++| syncIndexesState | 7273 | 14001 | 7273 | 62666 | 1742 | ++| syncRatesState | 13553 | 16068 | 16094 | 22594 | 1742 | ++| updateBridgeProtocolFee | 6217 | 7047 | 6217 | 23397 | 269 | ++| updateFlashloanPremiums | 1726 | 10716 | 6399 | 21626 | 1418 | ++| withdraw | 39251 | 105570 | 87824 | 180119 | 51 | + + + | src/contracts/instances/VariableDebtTokenInstance.sol:VariableDebtTokenInstance contract | | | | | | +@@ -457,22 +457,22 @@ + | Deployment Cost | Deployment Size | | | | | + | 1723145 | 8349 | | | | | + | Function Name | min | avg | median | max | # calls | +-| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8112 | ++| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 9307 | + | approveDelegation | 27012 | 27012 | 27012 | 27012 | 1 | +-| balanceOf | 681 | 4986 | 4771 | 10365 | 7692 | ++| balanceOf | 681 | 4925 | 4706 | 10300 | 7718 | + | borrowAllowance | 831 | 831 | 831 | 831 | 5 | +-| burn | 19204 | 26197 | 26204 | 26205 | 3108 | +-| decimals | 335 | 335 | 335 | 335 | 8112 | ++| burn | 19204 | 26197 | 26204 | 26205 | 3107 | ++| decimals | 335 | 335 | 335 | 335 | 9307 | + | delegationWithSig | 1052 | 28689 | 21662 | 55862 | 7 | +-| getIncentivesController | 431 | 431 | 431 | 431 | 8112 | +-| initialize | 123620 | 207871 | 209041 | 299205 | 43251 | +-| mint | 26385 | 62549 | 62585 | 72374 | 2687 | +-| name | 1009 | 1421 | 1264 | 3264 | 8202 | ++| getIncentivesController | 431 | 431 | 431 | 431 | 9307 | ++| initialize | 123620 | 207931 | 209041 | 299205 | 44425 | ++| mint | 26385 | 62549 | 62585 | 72374 | 2686 | ++| name | 1009 | 1423 | 1326 | 3264 | 9397 | + | nonces | 577 | 577 | 577 | 577 | 1 | +-| scaledBalanceOf | 691 | 1887 | 2691 | 2691 | 5867 | +-| scaledTotalSupply | 419 | 2102 | 2419 | 2419 | 18707 | +-| symbol | 1030 | 1440 | 1347 | 3285 | 8195 | +-| totalSupply | 4079 | 7582 | 6481 | 19079 | 15 | ++| scaledBalanceOf | 691 | 1891 | 2691 | 2691 | 5894 | ++| scaledTotalSupply | 419 | 2105 | 2419 | 2419 | 18688 | ++| symbol | 1030 | 1439 | 1347 | 3285 | 9390 | ++| totalSupply | 4014 | 7523 | 6416 | 19014 | 15 | + + + | src/contracts/misc/AaveOracle.sol:AaveOracle contract | | | | | | +@@ -482,10 +482,10 @@ + | Function Name | min | avg | median | max | # calls | + | BASE_CURRENCY | 293 | 293 | 293 | 293 | 3 | + | BASE_CURRENCY_UNIT | 262 | 262 | 262 | 262 | 1 | +-| getAssetPrice | 679 | 4746 | 7873 | 7873 | 22337 | ++| getAssetPrice | 679 | 4755 | 7873 | 7873 | 22388 | + | getAssetsPrices | 2300 | 3404 | 2300 | 5614 | 3 | + | getFallbackOracle | 365 | 1031 | 365 | 2365 | 3 | +-| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1140 | ++| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1139 | + | setAssetSources | 37348 | 52896 | 61947 | 62187 | 9 | + | setFallbackOracle | 59544 | 59544 | 59544 | 59544 | 4 | + +@@ -499,7 +499,7 @@ + | MAX_BORROW_RATE | 240 | 240 | 240 | 240 | 5382 | + | MAX_OPTIMAL_POINT | 262 | 262 | 262 | 262 | 6918 | + | MIN_OPTIMAL_POINT | 261 | 261 | 261 | 261 | 6918 | +-| calculateInterestRates | 0 | 4436 | 4271 | 5999 | 16046 | ++| calculateInterestRates | 0 | 4438 | 4271 | 5999 | 16019 | + | getBaseVariableBorrowRate | 748 | 776 | 748 | 2748 | 2908 | + | getInterestRateData | 1804 | 1804 | 1804 | 1804 | 256 | + | getInterestRateDataBps | 987 | 987 | 987 | 987 | 256 | +@@ -507,8 +507,8 @@ + | getOptimalUsageRatio | 738 | 738 | 738 | 2738 | 2136 | + | getVariableRateSlope1 | 778 | 778 | 778 | 778 | 2140 | + | getVariableRateSlope2 | 799 | 799 | 799 | 799 | 1368 | +-| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29729 | 29075 | 36816 | 2816 | +-| setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | ++| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29728 | 29075 | 36804 | 2816 | ++| setInterestRateParams(address,bytes) | 28636 | 33084 | 29860 | 37156 | 6405 | + + + | src/contracts/misc/PriceOracleSentinel.sol:PriceOracleSentinel contract | | | | | | +@@ -530,26 +530,26 @@ + | Deployment Cost | Deployment Size | | | | | + | 465623 | 2115 | | | | | + | Function Name | min | avg | median | max | # calls | +-| ADDRESSES_PROVIDER | 898 | 4368 | 5398 | 5465 | 3190 | +-| BRIDGE_PROTOCOL_FEE | 1029 | 5311 | 7529 | 7529 | 23 | ++| ADDRESSES_PROVIDER | 898 | 4373 | 5398 | 5465 | 3176 | ++| BRIDGE_PROTOCOL_FEE | 963 | 5245 | 7463 | 7463 | 23 | + | DOMAIN_SEPARATOR | 1071 | 4688 | 4156 | 7571 | 5 | +-| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 650 | +-| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1304 | +-| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1039 | 1028 | 7528 | 1301 | +-| MAX_GRACE_PERIOD | 5418 | 5418 | 5418 | 5418 | 1792 | ++| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 643 | ++| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1290 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1287 | ++| MAX_GRACE_PERIOD | 5396 | 5396 | 5396 | 5396 | 1538 | + | MAX_NUMBER_RESERVES | 922 | 922 | 922 | 922 | 512 | + | POOL | 940 | 940 | 940 | 940 | 151 | +-| RESERVE_TREASURY_ADDRESS | 1033 | 1397 | 1033 | 7533 | 9918 | ++| RESERVE_TREASURY_ADDRESS | 1033 | 1357 | 1033 | 7533 | 11112 | + | REVISION | 874 | 874 | 874 | 874 | 8 | +-| UNDERLYING_ASSET_ADDRESS | 1011 | 1050 | 1055 | 3055 | 16363 | ++| UNDERLYING_ASSET_ADDRESS | 1011 | 1047 | 1055 | 3055 | 18753 | + | admin | 21390 | 21390 | 21390 | 21390 | 8 | + | allowance | 1404 | 3173 | 3404 | 7904 | 26 | + | approve | 51293 | 51357 | 51341 | 51653 | 39 | + | approveDelegation | 53760 | 53760 | 53760 | 53760 | 1 | +-| backUnbacked | 125314 | 140965 | 138917 | 159923 | 9 | +-| balanceOf | 1297 | 5849 | 5387 | 22860 | 12491 | +-| borrow(address,uint256,uint256,uint16,address) | 74012 | 244274 | 250193 | 289647 | 2700 | +-| borrow(bytes32) | 230155 | 230155 | 230155 | 230155 | 3 | ++| backUnbacked | 125336 | 140987 | 138939 | 159945 | 9 | ++| balanceOf | 1297 | 5820 | 5382 | 22882 | 12514 | ++| borrow(address,uint256,uint256,uint16,address) | 73946 | 246332 | 252241 | 291829 | 2699 | ++| borrow(bytes32) | 232182 | 232182 | 232182 | 232182 | 3 | + | borrowAllowance | 1450 | 1450 | 1450 | 1450 | 5 | + | burn | 28132 | 40754 | 28464 | 65668 | 3 | + | claimAllRewards | 119578 | 119578 | 119578 | 119578 | 1 | +@@ -558,128 +558,129 @@ + | claimRewards | 28668 | 77756 | 84171 | 114016 | 4 | + | claimRewardsOnBehalf | 116579 | 116579 | 116579 | 116579 | 1 | + | claimRewardsToSelf | 113333 | 113333 | 113333 | 113333 | 1 | +-| configureEModeCategory | 34496 | 34507 | 34507 | 34519 | 512 | +-| configureReserveAsCollateral | 44067 | 64524 | 57732 | 122552 | 2308 | +-| decimals | 948 | 982 | 970 | 7470 | 16416 | ++| configureEModeCategory | 34733 | 34744 | 34744 | 34755 | 512 | ++| configureReserveAsCollateral | 44133 | 64613 | 57820 | 122674 | 2308 | ++| decimals | 948 | 979 | 970 | 7470 | 18806 | + | decreaseAllowance | 34424 | 34424 | 34424 | 34424 | 1 | + | delegationWithSig | 29263 | 56402 | 45264 | 84300 | 7 | + | deposit | 91067 | 215461 | 232188 | 235808 | 64 | +-| disableLiquidationGracePeriod | 43659 | 55004 | 66162 | 66162 | 513 | +-| dropReserve | 32591 | 35715 | 32657 | 105072 | 775 | +-| flashLoan | 59293 | 162000 | 126617 | 374226 | 267 | +-| flashLoanSimple | 50944 | 311491 | 177238 | 642906 | 11 | ++| disableLiquidationGracePeriod | 43592 | 54913 | 66050 | 66050 | 513 | ++| dropReserve | 32591 | 35723 | 32613 | 105090 | 775 | ++| flashLoan | 59315 | 173232 | 148808 | 374248 | 267 | ++| flashLoanSimple | 50966 | 311558 | 177304 | 642952 | 11 | + | getAllUserRewards | 9271 | 9271 | 9271 | 9271 | 1 | + | getAssetDecimals | 1275 | 1275 | 1275 | 1275 | 2 | + | getAssetIndex | 3708 | 11517 | 14698 | 21619 | 90 | +-| getBorrowLogic | 5395 | 5406 | 5406 | 5417 | 2 | ++| getBorrowLogic | 5417 | 5428 | 5428 | 5439 | 2 | + | getBridgeLogic | 5393 | 5426 | 5426 | 5459 | 2 | + | getClaimer | 1244 | 3410 | 1244 | 7744 | 3 | +-| getConfiguration | 1298 | 1892 | 1342 | 7842 | 54785 | +-| getConfiguratorLogic | 5353 | 5353 | 5353 | 5353 | 1 | ++| getConfiguration | 1320 | 1824 | 1364 | 7864 | 54886 | ++| getConfiguratorLogic | 5419 | 5419 | 5419 | 5419 | 1 | + | getDistributionEnd | 1411 | 1411 | 1411 | 1411 | 1 | +-| getEModeCategoryData | 2554 | 6313 | 6815 | 11054 | 55 | ++| getEModeCategoryData | 2798 | 11674 | 13537 | 13559 | 51 | + | getEModeLogic | 5392 | 5403 | 5403 | 5414 | 2 | +-| getFlashLoanLogic | 5416 | 5438 | 5438 | 5461 | 2 | +-| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 16230 | +-| getLiquidationGracePeriod | 29207 | 29226 | 29229 | 29229 | 2270 | +-| getLiquidationLogic | 5394 | 5416 | 5416 | 5439 | 2 | +-| getPendingLtv | 1215 | 1215 | 1215 | 1215 | 771 | +-| getPoolLogic | 5393 | 5404 | 5404 | 5416 | 2 | ++| getFlashLoanLogic | 5394 | 5416 | 5416 | 5438 | 2 | ++| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 18620 | ++| getLiquidationGracePeriod | 29229 | 29246 | 29251 | 29251 | 1238 | ++| getLiquidationLogic | 5416 | 5438 | 5438 | 5461 | 2 | ++| getPendingLtv | 1192 | 1192 | 1192 | 1192 | 771 | ++| getPoolLogic | 5415 | 5426 | 5426 | 5438 | 2 | + | getPreviousIndex | 1270 | 1270 | 1270 | 1270 | 39 | +-| getReserveAddressById | 1281 | 1281 | 1281 | 1281 | 1 | +-| getReserveData | 4889 | 9269 | 6933 | 29433 | 19091 | +-| getReserveDataExtended | 4122 | 4788 | 4122 | 6122 | 6 | +-| getReserveNormalizedIncome | 1465 | 1970 | 1465 | 10427 | 10793 | +-| getReserveNormalizedVariableDebt | 1465 | 1681 | 1509 | 11607 | 7435 | +-| getReservesCount | 1050 | 1050 | 1050 | 1050 | 2 | +-| getReservesList | 3792 | 16242 | 16292 | 103281 | 2164 | ++| getReserveAddressById | 1236 | 1236 | 1236 | 1236 | 1 | ++| getReserveData | 4911 | 9427 | 10955 | 29455 | 20274 | ++| getReserveDataExtended | 4144 | 4810 | 4144 | 6144 | 6 | ++| getReserveNormalizedIncome | 1443 | 1991 | 1487 | 10449 | 10788 | ++| getReserveNormalizedVariableDebt | 1444 | 1618 | 1444 | 11542 | 7458 | ++| getReservesCount | 986 | 986 | 986 | 986 | 2 | ++| getReservesList | 3747 | 16659 | 16247 | 104040 | 2130 | + | getRewardOracle | 1268 | 1268 | 1268 | 1268 | 1 | + | getRewardsByAsset | 2399 | 5698 | 3672 | 10899 | 201 | + | getRewardsData | 1610 | 1610 | 1610 | 1610 | 3 | + | getRewardsList | 1736 | 1736 | 1736 | 1736 | 30 | + | getScaledUserBalanceAndSupply | 1449 | 4192 | 3449 | 9949 | 39 | +-| getSupplyLogic | 5417 | 5449 | 5449 | 5481 | 2 | ++| getSupplyLogic | 5395 | 5417 | 5417 | 5439 | 2 | + | getTransferStrategy | 1267 | 1267 | 1267 | 1267 | 1 | +-| getUserAccountData | 18764 | 22167 | 23264 | 30029 | 1037 | ++| getUserAccountData | 18901 | 22305 | 23401 | 30391 | 1036 | + | getUserAccruedRewards | 2267 | 2267 | 2267 | 2267 | 1 | + | getUserAssetIndex | 1634 | 1634 | 1634 | 1634 | 1 | +-| getUserConfiguration | 1322 | 1364 | 1322 | 3322 | 1822 | +-| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1037 | ++| getUserConfiguration | 1344 | 1390 | 1344 | 3344 | 1821 | ++| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1036 | + | getUserRewards | 5237 | 7340 | 7469 | 10837 | 19 | +-| getVirtualUnderlyingBalance | 1298 | 1319 | 1320 | 1320 | 2161 | ++| getVirtualUnderlyingBalance | 1320 | 1341 | 1342 | 1342 | 2159 | + | increaseAllowance | 34491 | 47316 | 51591 | 51591 | 4 | +-| initReserve | 33270 | 33292 | 33292 | 33314 | 1024 | +-| initReserves | 45755 | 32070878 | 1608802 | 218102716 | 2049 | +-| liquidationCall(address,address,address,uint256,bool) | 80856 | 256275 | 351792 | 404755 | 3491 | +-| liquidationCall(bytes32,bytes32) | 404144 | 404144 | 404144 | 404144 | 1 | ++| initReserve | 33269 | 33280 | 33280 | 33292 | 1024 | ++| initReserves | 45732 | 33065878 | 1608721 | 217363244 | 2049 | ++| liquidationCall(address,address,address,uint256,bool) | 80856 | 257552 | 345335 | 407120 | 3520 | ++| liquidationCall(bytes32,bytes32) | 406151 | 406151 | 406151 | 406151 | 1 | + | mint | 28161 | 73503 | 91286 | 91766 | 7 | +-| mintToTreasury(address[]) | 99333 | 100926 | 100926 | 102519 | 4 | ++| mintToTreasury(address[]) | 99355 | 100948 | 100948 | 102541 | 4 | + | mintToTreasury(uint256,uint256) | 26988 | 59951 | 59951 | 92915 | 2 | +-| mintUnbacked | 39431 | 145665 | 130791 | 193135 | 17 | +-| name | 1625 | 2063 | 1945 | 8383 | 16555 | ++| mintUnbacked | 39386 | 145620 | 130746 | 193090 | 17 | ++| name | 1625 | 2061 | 1945 | 8383 | 18945 | + | nonces | 1193 | 2463 | 3271 | 3271 | 10 | + | permit | 29304 | 46376 | 37841 | 81937 | 8 | +-| repay(address,uint256,uint256,address) | 60448 | 129350 | 167720 | 187144 | 13 | +-| repay(bytes32) | 157401 | 157401 | 157401 | 157401 | 1 | +-| repayWithATokens(address,uint256,uint256) | 155111 | 180842 | 182318 | 193320 | 261 | +-| repayWithATokens(bytes32) | 160522 | 160522 | 160522 | 160522 | 1 | +-| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155668 | 185855 | 182856 | 218694 | 768 | +-| repayWithPermit(bytes32,bytes32,bytes32) | 190465 | 206566 | 214543 | 217860 | 256 | +-| rescueTokens | 39115 | 70318 | 70428 | 70471 | 515 | ++| repay(address,uint256,uint256,address) | 60470 | 129327 | 167677 | 187099 | 13 | ++| repay(bytes32) | 157445 | 157445 | 157445 | 157445 | 1 | ++| repayWithATokens(address,uint256,uint256) | 155013 | 181024 | 182208 | 193232 | 261 | ++| repayWithATokens(bytes32) | 160479 | 160479 | 160479 | 160479 | 1 | ++| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155615 | 186012 | 182767 | 218815 | 768 | ++| repayWithPermit(bytes32,bytes32,bytes32) | 187632 | 207467 | 217671 | 217964 | 256 | ++| rescueTokens | 39115 | 70340 | 70450 | 70493 | 515 | + | resetIsolationModeTotalDebt | 32590 | 32636 | 32612 | 41843 | 514 | +-| scaledBalanceOf | 1307 | 3741 | 3307 | 7807 | 16286 | +-| scaledTotalSupply | 988 | 5835 | 7532 | 7532 | 19121 | +-| setAssetEModeCategory | 43877 | 48422 | 43877 | 79556 | 296 | +-| setBorrowCap | 43786 | 44743 | 43786 | 70919 | 267 | +-| setBorrowableInIsolation | 67706 | 70116 | 70508 | 70508 | 13 | ++| scaledBalanceOf | 1307 | 3748 | 3307 | 7807 | 16339 | ++| scaledTotalSupply | 988 | 5846 | 7532 | 7532 | 19102 | ++| setAssetBorrowableInEMode | 103772 | 103824 | 103860 | 103860 | 5 | ++| setAssetEModeCategory | 44061 | 51757 | 44061 | 120992 | 288 | ++| setBorrowCap | 43808 | 44766 | 43808 | 70963 | 267 | ++| setBorrowableInIsolation | 67684 | 70094 | 70486 | 70486 | 13 | + | setConfiguration | 32805 | 32816 | 32816 | 32827 | 512 | +-| setDebtCeiling | 43743 | 48112 | 43743 | 121555 | 274 | +-| setEModeCategory | 45031 | 53892 | 45031 | 135431 | 295 | ++| setDebtCeiling | 43787 | 48159 | 43787 | 121643 | 274 | ++| setEModeCategory | 44872 | 49711 | 44872 | 111566 | 283 | + | setIncentivesController | 38502 | 40869 | 40869 | 43236 | 2 | +-| setLiquidationGracePeriod | 32828 | 37932 | 37350 | 43761 | 1536 | +-| setLiquidationProtocolFee | 43996 | 60606 | 69878 | 70968 | 8 | +-| setPoolPause(bool) | 43633 | 44062 | 43633 | 116393 | 515 | +-| setPoolPause(bool,uint40) | 43789 | 88393 | 74789 | 134303 | 512 | +-| setReserveActive | 40906 | 43807 | 40906 | 118044 | 267 | +-| setReserveBorrowing | 43833 | 60242 | 68446 | 68448 | 768 | +-| setReserveFactor | 43766 | 44186 | 43766 | 151823 | 258 | +-| setReserveFlashLoaning | 68511 | 68516 | 68513 | 70667 | 513 | +-| setReserveFreeze | 47022 | 73129 | 74823 | 99841 | 783 | +-| setReserveInterestRateData | 44326 | 44812 | 44554 | 131069 | 257 | +-| setReserveInterestRateStrategyAddress(address,address) | 32846 | 34588 | 33195 | 42729 | 1538 | +-| setReserveInterestRateStrategyAddress(address,address,bytes) | 44558 | 61418 | 44558 | 190255 | 300 | +-| setReservePause(address,bool) | 43812 | 44147 | 44040 | 67736 | 258 | +-| setReservePause(address,bool,uint40) | 41277 | 65905 | 73907 | 79019 | 3084 | +-| setSiloedBorrowing | 102106 | 111956 | 115803 | 117959 | 3 | +-| setSupplyCap | 43788 | 45799 | 43788 | 70921 | 279 | +-| setUnbackedMintCap | 70889 | 70889 | 70889 | 70889 | 7 | +-| setUserEMode | 48307 | 68041 | 66511 | 113935 | 17 | +-| setUserUseReserveAsCollateral(address,bool) | 80336 | 96356 | 93550 | 129754 | 42 | +-| setUserUseReserveAsCollateral(bytes32) | 95329 | 95329 | 95329 | 95329 | 1 | ++| setLiquidationGracePeriod | 32805 | 37917 | 37338 | 43761 | 1536 | ++| setLiquidationProtocolFee | 44018 | 60642 | 69922 | 71012 | 8 | ++| setPoolPause(bool) | 43590 | 44019 | 43602 | 116371 | 515 | ++| setPoolPause(bool,uint40) | 43811 | 88084 | 74821 | 134211 | 512 | ++| setReserveActive | 40861 | 43764 | 40861 | 118043 | 267 | ++| setReserveBorrowing | 43899 | 60323 | 68534 | 68536 | 768 | ++| setReserveFactor | 43743 | 44163 | 43743 | 151866 | 258 | ++| setReserveFlashLoaning | 68533 | 68538 | 68535 | 70689 | 513 | ++| setReserveFreeze | 47088 | 73180 | 74911 | 99929 | 782 | ++| setReserveInterestRateData | 44283 | 44771 | 44511 | 131092 | 257 | ++| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34618 | 33217 | 42751 | 1538 | ++| setReserveInterestRateStrategyAddress(address,address,bytes) | 44535 | 61408 | 44535 | 190320 | 300 | ++| setReservePause(address,bool) | 43878 | 44235 | 44106 | 67824 | 258 | ++| setReservePause(address,bool,uint40) | 41333 | 63041 | 73928 | 79040 | 2068 | ++| setSiloedBorrowing | 101997 | 111861 | 115716 | 117872 | 3 | ++| setSupplyCap | 43765 | 45778 | 43765 | 70920 | 279 | ++| setUnbackedMintCap | 70933 | 70933 | 70933 | 70933 | 7 | ++| setUserEMode | 44144 | 68303 | 67220 | 116049 | 16 | ++| setUserUseReserveAsCollateral(address,bool) | 80314 | 96359 | 93573 | 129666 | 42 | ++| setUserUseReserveAsCollateral(bytes32) | 95286 | 95286 | 95286 | 95286 | 1 | + | setValue | 31574 | 31590 | 31598 | 31598 | 3 | +-| supply(address,uint256,address,uint16) | 56664 | 214087 | 231043 | 243594 | 3300 | ++| supply(address,uint256,address,uint16) | 56598 | 214018 | 231043 | 243528 | 3297 | + | supply(bytes32) | 237010 | 237010 | 237010 | 237010 | 7 | +-| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216977 | 242026 | 266578 | 768 | +-| supplyWithPermit(bytes32,bytes32,bytes32) | 262532 | 262616 | 262592 | 262736 | 256 | +-| symbol | 1646 | 2128 | 1966 | 8448 | 16530 | ++| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216981 | 242026 | 266578 | 768 | ++| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262643 | 262614 | 262758 | 256 | ++| symbol | 1646 | 2121 | 1966 | 8448 | 18920 | + | text | 1789 | 1789 | 1789 | 1789 | 8 | +-| totalSupply | 1024 | 8279 | 11570 | 15570 | 4914 | +-| transfer | 27662 | 144188 | 149393 | 167373 | 273 | +-| transferFrom | 138702 | 138822 | 138822 | 138942 | 2 | ++| totalSupply | 1024 | 8310 | 11592 | 15592 | 4892 | ++| transfer | 27662 | 143924 | 149415 | 169510 | 273 | ++| transferFrom | 138724 | 138844 | 138844 | 138964 | 2 | + | transferOnLiquidation | 28063 | 28063 | 28063 | 28063 | 1 | + | transferUnderlyingTo | 27506 | 27506 | 27506 | 27506 | 1 | +-| updateAToken | 41856 | 42264 | 41856 | 146869 | 257 | +-| updateBridgeProtocolFee | 32528 | 33698 | 32573 | 78409 | 526 | +-| updateFlashloanPremiumToProtocol | 40448 | 40536 | 40448 | 63268 | 258 | +-| updateFlashloanPremiumTotal | 40469 | 40558 | 40469 | 63300 | 258 | +-| updateFlashloanPremiums | 32853 | 32875 | 32875 | 32898 | 512 | +-| updateVariableDebtToken | 41710 | 42095 | 41710 | 140758 | 257 | ++| updateAToken | 41811 | 42219 | 41811 | 146848 | 257 | ++| updateBridgeProtocolFee | 32550 | 33719 | 32595 | 78387 | 526 | ++| updateFlashloanPremiumToProtocol | 40470 | 40559 | 40470 | 63334 | 258 | ++| updateFlashloanPremiumTotal | 40446 | 40535 | 40446 | 63321 | 258 | ++| updateFlashloanPremiums | 32875 | 32897 | 32897 | 32920 | 512 | ++| updateVariableDebtToken | 41666 | 42051 | 41666 | 140732 | 257 | + | upgradeTo | 26855 | 28742 | 28742 | 30629 | 2 | + | upgradeToAndCall | 28758 | 152638 | 187413 | 187413 | 8 | + | value | 931 | 931 | 931 | 931 | 11 | + | values | 1213 | 1213 | 1213 | 1213 | 16 | +-| withdraw(address,uint256,address) | 66340 | 134756 | 141964 | 205094 | 23 | +-| withdraw(bytes32) | 138782 | 145861 | 145861 | 152941 | 2 | ++| withdraw(address,uint256,address) | 66362 | 134870 | 141986 | 207230 | 23 | ++| withdraw(bytes32) | 138804 | 145883 | 145883 | 152963 | 2 | + + + | src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol:MockFlashLoanReceiver contract | | | | | | +@@ -703,9 +704,9 @@ + | src/contracts/mocks/helpers/MockPool.sol:MockPoolInherited contract | | | | | | + |---------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 4732690 | 21870 | | | | | ++| 4761368 | 22003 | | | | | + | Function Name | min | avg | median | max | # calls | +-| initialize | 28462 | 28462 | 28462 | 28462 | 2 | ++| initialize | 28397 | 28397 | 28397 | 28397 | 2 | + + + | src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol:MockAggregator contract | | | | | | +@@ -713,10 +714,10 @@ + | Deployment Cost | Deployment Size | | | | | + | 109507 | 321 | | | | | + | Function Name | min | avg | median | max | # calls | +-| _latestAnswer | 317 | 317 | 317 | 317 | 4160 | ++| _latestAnswer | 317 | 317 | 317 | 317 | 4156 | + | decimals | 144 | 144 | 144 | 144 | 83 | + | description | 170 | 170 | 170 | 170 | 83 | +-| latestAnswer | 281 | 1395 | 2281 | 2281 | 24197 | ++| latestAnswer | 281 | 1396 | 2281 | 2281 | 24227 | + | name | 170 | 170 | 170 | 170 | 83 | + + +@@ -735,7 +736,7 @@ + | 278266 | 1393 | | | | | + | Function Name | min | avg | median | max | # calls | + | latestRoundData | 730 | 1533 | 735 | 4735 | 10 | +-| setAnswer | 26207 | 27452 | 26207 | 46119 | 73 | ++| setAnswer | 26207 | 27469 | 26207 | 46119 | 72 | + + + | src/contracts/mocks/swap/MockParaSwapAugustus.sol:MockParaSwapAugustus contract | | | | | | +@@ -773,13 +774,13 @@ + | Function Name | min | avg | median | max | # calls | + | DOMAIN_SEPARATOR | 2340 | 2340 | 2340 | 2340 | 1 | + | allowance | 836 | 836 | 836 | 836 | 9 | +-| approve | 29140 | 46510 | 46588 | 46588 | 4618 | +-| balanceOf | 651 | 991 | 651 | 2651 | 12549 | +-| decimals | 312 | 1481 | 2312 | 2312 | 73384 | +-| mint | 36480 | 58491 | 53592 | 70740 | 4133 | ++| approve | 29140 | 46510 | 46588 | 46588 | 4576 | ++| balanceOf | 651 | 991 | 651 | 2651 | 12547 | ++| decimals | 312 | 1440 | 2312 | 2312 | 78150 | ++| mint | 36480 | 58483 | 53592 | 70740 | 4091 | + | name | 3241 | 3241 | 3241 | 3241 | 2048 | + | nonces | 2604 | 2604 | 2604 | 2604 | 1 | +-| permit | 76466 | 76512 | 76502 | 76670 | 512 | ++| permit | 76466 | 76515 | 76502 | 76670 | 512 | + | symbol | 1328 | 2328 | 2328 | 3328 | 56 | + | transfer | 46931 | 51023 | 51707 | 51707 | 7 | + | transferOwnership | 28800 | 28800 | 28800 | 28800 | 30 | +@@ -801,10 +802,10 @@ + | Deployment Cost | Deployment Size | | | | | + | 119707 | 340 | | | | | + | Function Name | min | avg | median | max | # calls | +-| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 448 | +-| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 689 | +-| percentDiv | 321 | 426 | 432 | 432 | 259 | +-| percentMul | 338 | 411 | 435 | 435 | 259 | ++| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 425 | ++| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 657 | ++| percentDiv | 321 | 420 | 432 | 432 | 259 | ++| percentMul | 338 | 403 | 435 | 435 | 259 | + + + | src/contracts/mocks/tests/WadRayMathWrapper.sol:WadRayMathWrapper contract | | | | | | +@@ -813,16 +814,16 @@ + | 233882 | 871 | | | | | + | Function Name | min | avg | median | max | # calls | + | HALF_RAY | 247 | 247 | 247 | 247 | 1 | +-| HALF_WAD | 224 | 224 | 224 | 224 | 443 | ++| HALF_WAD | 224 | 224 | 224 | 224 | 435 | + | RAY | 225 | 225 | 225 | 225 | 1 | +-| WAD | 180 | 180 | 180 | 180 | 658 | +-| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1762 | ++| WAD | 180 | 180 | 180 | 180 | 648 | ++| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1764 | + | rayDiv | 498 | 498 | 498 | 498 | 4 | + | rayMul | 501 | 501 | 501 | 501 | 3 | + | rayToWad | 387 | 390 | 387 | 401 | 515 | +-| wadDiv | 431 | 524 | 542 | 542 | 260 | +-| wadMul | 338 | 409 | 435 | 435 | 262 | +-| wadToRay | 284 | 355 | 360 | 360 | 485 | ++| wadDiv | 431 | 523 | 542 | 542 | 260 | ++| wadMul | 338 | 406 | 435 | 435 | 262 | ++| wadToRay | 284 | 355 | 360 | 360 | 487 | + + + | src/contracts/mocks/tokens/MockATokenRepayment.sol:MockATokenRepayment contract | | | | | | +@@ -907,23 +908,23 @@ + | Deployment Cost | Deployment Size | | | | | + | 864174 | 4235 | | | | | + | Function Name | min | avg | median | max | # calls | +-| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1318 | ++| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1304 | + | FLASH_BORROWER_ROLE | 317 | 317 | 317 | 317 | 20 | +-| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 649 | ++| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 642 | + | addAssetListingAdmin | 50962 | 50962 | 50962 | 50962 | 3 | + | addBridge | 51028 | 51028 | 51028 | 51028 | 14 | + | addEmergencyAdmin | 50963 | 50963 | 50963 | 50963 | 3 | + | addFlashBorrower | 50984 | 52203 | 50984 | 55863 | 4 | +-| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 639 | ++| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 632 | + | addRiskAdmin | 51028 | 51028 | 51028 | 51028 | 14 | + | grantRole | 51480 | 52091 | 51480 | 56370 | 8 | + | hasRole | 740 | 2622 | 2740 | 2740 | 17 | +-| isAssetListingAdmin | 814 | 2465 | 2814 | 2814 | 3562 | ++| isAssetListingAdmin | 814 | 2467 | 2814 | 2814 | 3548 | + | isBridge | 2791 | 2791 | 2791 | 2791 | 26 | + | isEmergencyAdmin | 747 | 2746 | 2747 | 2747 | 3843 | + | isFlashBorrower | 2833 | 2833 | 2833 | 2833 | 268 | +-| isPoolAdmin | 757 | 1741 | 757 | 2757 | 45593 | +-| isRiskAdmin | 747 | 1420 | 747 | 2747 | 29906 | ++| isPoolAdmin | 757 | 1764 | 2757 | 2757 | 42464 | ++| isRiskAdmin | 747 | 1469 | 747 | 2747 | 27821 | + | removeAssetListingAdmin | 29054 | 29054 | 29054 | 29054 | 2 | + | removeBridge | 29023 | 29023 | 29023 | 29023 | 1 | + | removeEmergencyAdmin | 28999 | 28999 | 28999 | 28999 | 1 | +@@ -938,24 +939,24 @@ + | Deployment Cost | Deployment Size | | | | | + | 1604102 | 8368 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getACLAdmin | 480 | 551 | 480 | 2480 | 676 | +-| getACLManager | 534 | 1369 | 534 | 2534 | 39760 | +-| getAddress | 546 | 549 | 546 | 2546 | 657 | ++| getACLAdmin | 480 | 551 | 480 | 2480 | 669 | ++| getACLManager | 534 | 1383 | 534 | 2534 | 36631 | ++| getAddress | 546 | 549 | 546 | 2546 | 650 | + | getMarketId | 1351 | 1351 | 1351 | 1351 | 6 | +-| getPool | 469 | 682 | 469 | 2469 | 43331 | +-| getPoolConfigurator | 512 | 774 | 512 | 2512 | 182138 | +-| getPoolDataProvider | 489 | 1325 | 489 | 2489 | 2203 | +-| getPriceOracle | 577 | 2281 | 2577 | 2577 | 7894 | +-| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6231 | +-| owner | 365 | 365 | 365 | 365 | 653 | ++| getPool | 469 | 651 | 469 | 2469 | 47804 | ++| getPoolConfigurator | 512 | 763 | 512 | 2512 | 181974 | ++| getPoolDataProvider | 489 | 1326 | 489 | 2489 | 2182 | ++| getPriceOracle | 577 | 2282 | 2577 | 2577 | 7920 | ++| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6259 | ++| owner | 365 | 365 | 365 | 365 | 646 | + | setACLAdmin | 24016 | 45798 | 47621 | 47621 | 24 | + | setACLManager | 24059 | 37487 | 39114 | 47664 | 4 | + | setAddress | 24625 | 35611 | 31540 | 48640 | 5 | + | setAddressAsProxy | 24331 | 228775 | 57063 | 518962 | 5 | + | setMarketId | 24424 | 28561 | 28561 | 32699 | 2 | +-| setPoolConfiguratorImpl | 24015 | 292593 | 300665 | 545030 | 4 | ++| setPoolConfiguratorImpl | 24015 | 292591 | 300650 | 545052 | 4 | + | setPoolDataProvider | 24104 | 37532 | 39159 | 47709 | 4 | +-| setPoolImpl | 24060 | 279069 | 287138 | 517941 | 4 | ++| setPoolImpl | 24060 | 279024 | 287080 | 517876 | 4 | + | setPriceOracle | 24083 | 37511 | 39138 | 47688 | 4 | + | setPriceOracleSentinel | 24126 | 40946 | 47731 | 47731 | 6 | + +@@ -968,7 +969,7 @@ + | getAddressesProviderAddressById | 522 | 522 | 522 | 522 | 4 | + | getAddressesProviderIdByAddress | 559 | 1225 | 559 | 2559 | 6 | + | getAddressesProvidersList | 673 | 3403 | 3292 | 5018 | 5 | +-| owner | 331 | 2327 | 2331 | 2331 | 650 | ++| owner | 331 | 2327 | 2331 | 2331 | 643 | + | registerAddressesProvider | 24444 | 104012 | 119926 | 119926 | 6 | + | unregisterAddressesProvider | 26448 | 39029 | 40004 | 49662 | 4 | + +@@ -996,7 +997,7 @@ + | Deployment Cost | Deployment Size | | | | | + | 3183382 | 14716 | | | | | + | Function Name | min | avg | median | max | # calls | +-| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 653 | ++| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 646 | + | claimAllRewards | 92349 | 92349 | 92349 | 92349 | 1 | + | claimAllRewardsOnBehalf | 94649 | 94649 | 94649 | 94649 | 1 | + | claimAllRewardsToSelf | 92147 | 92147 | 92147 | 92147 | 1 | +@@ -1018,8 +1019,8 @@ + | getUserAccruedRewards | 1648 | 1648 | 1648 | 1648 | 1 | + | getUserAssetIndex | 1009 | 1009 | 1009 | 1009 | 1 | + | getUserRewards | 4600 | 6703 | 6832 | 10200 | 19 | +-| handleAction | 732 | 2337 | 2732 | 38089 | 17852 | +-| initialize | 26067 | 45246 | 45252 | 53156 | 652 | ++| handleAction | 732 | 2337 | 2732 | 38089 | 17844 | ++| initialize | 26067 | 45246 | 45252 | 53156 | 645 | + | setClaimer | 24282 | 24282 | 24282 | 24282 | 4 | + | setDistributionEnd | 8888 | 8888 | 8888 | 8888 | 2 | + | setEmissionPerSecond | 24335 | 24335 | 24335 | 24335 | 2 | +@@ -1055,15 +1056,15 @@ + | Deployment Cost | Deployment Size | | | | | + | 0 | 0 | | | | | + | Function Name | min | avg | median | max | # calls | +-| initialize | 90684 | 90684 | 90684 | 90684 | 674 | ++| initialize | 90684 | 90684 | 90684 | 90684 | 667 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol:AaveV3GettersBatchOne contract | | | | | | + |-----------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| + | Deployment Cost | Deployment Size | | | | | +-| 5190134 | 33125 | | | | | ++| 5144006 | 33345 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getGettersReportOne | 971 | 971 | 971 | 971 | 672 | ++| getGettersReportOne | 971 | 971 | 971 | 971 | 665 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol:AaveV3GettersBatchTwo contract | | | | | | +@@ -1071,15 +1072,15 @@ + | Deployment Cost | Deployment Size | | | | | + | 1583555 | 11792 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getGettersReportTwo | 535 | 535 | 535 | 535 | 647 | ++| getGettersReportTwo | 535 | 535 | 535 | 535 | 640 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol:AaveV3HelpersBatchOne contract | | | | | | + |-----------------------------------------------------------------------------------------------------------|-----------------|------|--------|------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 7434786 | 35360 | | | | | ++| 7379990 | 35117 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 622 | ++| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 615 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol:AaveV3HelpersBatchTwo contract | | | | | | +@@ -1087,15 +1088,15 @@ + | Deployment Cost | Deployment Size | | | | | + | 7169046 | 31590 | | | | | + | Function Name | min | avg | median | max | # calls | +-| staticATokenReport | 971 | 971 | 971 | 971 | 622 | ++| staticATokenReport | 971 | 971 | 971 | 971 | 615 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol:AaveV3L2PoolBatch contract | | | | | | + |---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| + | Deployment Cost | Deployment Size | | | | | +-| 9289812 | 42653 | | | | | ++| 9322127 | 42803 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getPoolReport | 535 | 535 | 535 | 535 | 672 | ++| getPoolReport | 535 | 535 | 535 | 535 | 665 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol:AaveV3MiscBatch contract | | | | | | +@@ -1103,7 +1104,7 @@ + | Deployment Cost | Deployment Size | | | | | + | 1062926 | 7122 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getMiscReport | 535 | 535 | 535 | 535 | 672 | ++| getMiscReport | 535 | 535 | 535 | 535 | 665 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol:AaveV3ParaswapBatch contract | | | | | | +@@ -1119,7 +1120,7 @@ + | Deployment Cost | Deployment Size | | | | | + | 7573451 | 38861 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 672 | ++| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 665 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol:AaveV3SetupBatch contract | | | | | | +@@ -1127,9 +1128,9 @@ + | Deployment Cost | Deployment Size | | | | | + | 5147688 | 28075 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getInitialReport | 554 | 554 | 554 | 554 | 672 | +-| setMarketReport | 632455 | 634818 | 632455 | 773435 | 622 | +-| setupAaveV3Market | 2709798 | 2710437 | 2709798 | 2736039 | 649 | ++| getInitialReport | 554 | 554 | 554 | 554 | 665 | ++| setMarketReport | 632455 | 634845 | 632455 | 773435 | 615 | ++| setupAaveV3Market | 2709842 | 2710480 | 2709842 | 2735992 | 642 | + + + | src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol:AaveV3TokensBatch contract | | | | | | +@@ -1137,53 +1138,53 @@ + | Deployment Cost | Deployment Size | | | | | + | 4294582 | 20766 | | | | | + | Function Name | min | avg | median | max | # calls | +-| getTokensReport | 535 | 535 | 535 | 535 | 647 | ++| getTokensReport | 535 | 535 | 535 | 535 | 640 | + + +-| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | +-|------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +-| Deployment Cost | Deployment Size | | | | | +-| 751213 | 3484 | | | | | +-| Function Name | min | avg | median | max | # calls | +-| execute | 94550 | 94550 | 94550 | 94550 | 1 | ++| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | ++|------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| ++| Deployment Cost | Deployment Size | | | | | ++| 747109 | 3465 | | | | | ++| Function Name | min | avg | median | max | # calls | ++| execute | 135971 | 135971 | 135971 | 135971 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol:AaveV3MockBorrowUpdate contract | | | | | | + |----------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 783501 | 3634 | | | | | ++| 775935 | 3599 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 159425 | 159425 | 159425 | 159425 | 1 | ++| execute | 159578 | 159578 | 159578 | 159578 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol:AaveV3MockBorrowUpdateNoChange contract | | | | | | + |--------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 790396 | 3666 | | | | | ++| 782829 | 3631 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 47089 | 47089 | 47089 | 47089 | 1 | ++| execute | 47111 | 47111 | 47111 | 47111 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol:AaveV3MockCapUpdate contract | | | | | | + |----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 770601 | 3574 | | | | | ++| 763034 | 3539 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 86135 | 86135 | 86135 | 86135 | 1 | ++| execute | 86156 | 86156 | 86156 | 86156 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol:AaveV3MockCollateralUpdate contract | | | | | | + |------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 784137 | 3637 | | | | | ++| 776595 | 3602 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 89667 | 89667 | 89667 | 89667 | 1 | ++| execute | 89767 | 89767 | 89767 | 89767 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol:AaveV3MockCollateralUpdateNoChange contract | | | | | | + |----------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 790576 | 3667 | | | | | ++| 783009 | 3632 | | | | | + | Function Name | min | avg | median | max | # calls | + | execute | 35916 | 35916 | 35916 | 35916 | 2 | + +@@ -1191,15 +1192,15 @@ + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateCorrectBonus contract | | | | | | + |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 784137 | 3637 | | | | | ++| 776595 | 3602 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 89667 | 89667 | 89667 | 89667 | 1 | ++| execute | 89767 | 89767 | 89767 | 89767 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateWrongBonus contract | | | | | | + |--------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 785049 | 3641 | | | | | ++| 777483 | 3606 | | | | | + | Function Name | min | avg | median | max | # calls | + | execute | 35332 | 35332 | 35332 | 35332 | 1 | + +@@ -1207,59 +1208,59 @@ + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdate contract | | | | | | + |------------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 756400 | 3425 | | | | | ++| 745395 | 3374 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 155461 | 155461 | 155461 | 155461 | 2 | ++| execute | 131198 | 131198 | 131198 | 131198 | 2 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdateEdgeBonus contract | | | | | | + |---------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 757072 | 3428 | | | | | ++| 746007 | 3377 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 53964 | 53964 | 53964 | 53964 | 1 | ++| execute | 56384 | 56384 | 56384 | 56384 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol:AaveV3MockEModeCategoryUpdateNoChange contract | | | | | | + |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 770849 | 3492 | | | | | ++| 759832 | 3441 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 38497 | 38497 | 38497 | 38497 | 2 | ++| execute | 37835 | 37835 | 37835 | 37835 | 2 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol:AaveV3MockListing contract | | | | | | + |------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 853685 | 4030 | | | | | ++| 849574 | 4011 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 1836009 | 1836009 | 1836009 | 1836009 | 1 | ++| execute | 1823722 | 1823722 | 1823722 | 1823722 | 1 | + | newListings | 2820 | 2820 | 2820 | 2820 | 4 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol:AaveV3MockListingCustom contract | | | | | | + |------------------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 918454 | 4491 | | | | | ++| 914350 | 4472 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 1835953 | 1835953 | 1835953 | 1835953 | 1 | ++| execute | 1823666 | 1823666 | 1823666 | 1823666 | 1 | + | newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol:AaveV3MockPriceFeedUpdate contract | | | | | | + |----------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 774000 | 3660 | | | | | ++| 769896 | 3641 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 65371 | 65371 | 65371 | 65371 | 1 | ++| execute | 65393 | 65393 | 65393 | 65393 | 1 | + + + | tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol:AaveV3MockRatesUpdate contract | | | | | | + |--------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 772773 | 3584 | | | | | ++| 768681 | 3565 | | | | | + | Function Name | min | avg | median | max | # calls | +-| execute | 148663 | 148663 | 148663 | 148663 | 1 | ++| execute | 148686 | 148686 | 148686 | 148686 | 1 | + | rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | + + +@@ -1273,17 +1274,17 @@ + | UNDERLYING_ASSET_ADDRESS | 376 | 1200 | 376 | 2376 | 4354 | + | allowance | 909 | 909 | 909 | 909 | 1 | + | approve | 22107 | 22107 | 22107 | 22107 | 1 | +-| approveDelegation | 48608 | 48637 | 48632 | 48680 | 256 | +-| burn | 52036 | 52064 | 52060 | 52108 | 512 | ++| approveDelegation | 48608 | 48635 | 48632 | 48680 | 256 | ++| burn | 52036 | 52066 | 52060 | 52108 | 512 | + | decimals | 335 | 335 | 335 | 335 | 3330 | + | decreaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | + | getIncentivesController | 431 | 431 | 431 | 431 | 3330 | + | increaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | +-| initialize | 29524 | 148072 | 179097 | 270713 | 2048 | ++| initialize | 29318 | 148429 | 179133 | 270761 | 2048 | + | mint | 86763 | 88040 | 86799 | 91824 | 1024 | +-| name | 1009 | 1332 | 1264 | 1796 | 3330 | ++| name | 1009 | 1333 | 1264 | 1796 | 3330 | + | scaledBalanceOf | 691 | 691 | 691 | 691 | 1024 | +-| symbol | 1030 | 1351 | 1285 | 1817 | 3330 | ++| symbol | 1030 | 1353 | 1285 | 1817 | 3330 | + | transfer | 22150 | 22150 | 22150 | 22150 | 1 | + | transferFrom | 22377 | 22377 | 22377 | 22377 | 1 | + +@@ -1291,11 +1292,11 @@ + | tests/mocks/AaveV3TestListing.sol:AaveV3TestListing contract | | | | | | + |--------------------------------------------------------------|-----------------|---------|---------|---------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 3392063 | 13846 | | | | | ++| 3391415 | 13843 | | | | | + | Function Name | min | avg | median | max | # calls | +-| USDX_ADDRESS | 294 | 294 | 294 | 294 | 617 | +-| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 617 | +-| execute | 5227666 | 5230040 | 5230240 | 5230240 | 619 | ++| USDX_ADDRESS | 294 | 294 | 294 | 294 | 610 | ++| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 610 | ++| execute | 5190804 | 5193051 | 5193243 | 5193243 | 612 | + + + | tests/mocks/AugustusRegistryMock.sol:AugustusRegistryMock contract | | | | | | +@@ -1332,4 +1333,10 @@ + + + +-Ran 56 test suites in 75.93s (123.90s CPU time): 694 tests passed, 0 failed, 0 skipped (694 total tests) ++Ran 56 test suites in 71.64s (197.77s CPU time): 686 tests passed, 1 failed, 0 skipped (687 total tests) ++ ++Failing tests: ++Encountered 1 failing test in tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol:PoolConfiguratorReserveRiskConfigs ++[FAIL. Reason: log != expected log; counterexample: calldata=0xb887fffe0000000000000000000000000000000000000000000000000000000000003840 args=[14400 [1.44e4]]] test_setLiquidationGracePeriodReserve(uint40) (runs: 1, μ: 447430, ~: 447430) ++ ++Encountered a total of 1 failing tests, 686 tests succeeded +``` diff --git a/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol index 174068bd..3bd70a3c 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/CollateralEngine.sol @@ -44,7 +44,6 @@ library CollateralEngine { uint256 currentLiqThreshold, uint256 currentLiqBonus, , - , ) = configuration.getParams(); diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index f27cf22a..1da58b11 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -34,8 +34,8 @@ library EModeEngine { IEngine.AssetEModeUpdate[] memory updates ) internal { for (uint256 i = 0; i < updates.length; i++) { - if (updates[i].eModeCategory != EngineFlags.KEEP_CURRENT) { - poolConfigurator.setAssetEModeCategory(updates[i].asset, updates[i].eModeCategory); + if (updates[i].eModeCategory != 0 && updates[i].eModeCategory != EngineFlags.KEEP_CURRENT) { + poolConfigurator.setAssetEModeCategory(updates[i].asset, updates[i].eModeCategory, true); } } } diff --git a/src/contracts/helpers/AaveProtocolDataProvider.sol b/src/contracts/helpers/AaveProtocolDataProvider.sol index 41fa1c9b..671b658b 100644 --- a/src/contracts/helpers/AaveProtocolDataProvider.sol +++ b/src/contracts/helpers/AaveProtocolDataProvider.sol @@ -95,7 +95,7 @@ contract AaveProtocolDataProvider is IPoolDataProvider { DataTypes.ReserveConfigurationMap memory configuration = IPool(ADDRESSES_PROVIDER.getPool()) .getConfiguration(asset); - (ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor, ) = configuration + (ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor) = configuration .getParams(); (isActive, isFrozen, borrowingEnabled, ) = configuration.getFlags(); @@ -106,13 +106,6 @@ contract AaveProtocolDataProvider is IPoolDataProvider { usageAsCollateralEnabled = liquidationThreshold != 0; } - /// @inheritdoc IPoolDataProvider - function getReserveEModeCategory(address asset) external view override returns (uint256) { - DataTypes.ReserveConfigurationMap memory configuration = IPool(ADDRESSES_PROVIDER.getPool()) - .getConfiguration(asset); - return configuration.getEModeCategory(); - } - /// @inheritdoc IPoolDataProvider function getReserveCaps( address asset diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index 2b0eec34..d261b900 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -98,14 +98,12 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { //stores the reserve configuration DataTypes.ReserveConfigurationMap memory reserveConfigurationMap = baseData.configuration; - uint256 eModeCategoryId; ( reserveData.baseLTVasCollateral, reserveData.reserveLiquidationThreshold, reserveData.reserveLiquidationBonus, reserveData.decimals, - reserveData.reserveFactor, - eModeCategoryId + reserveData.reserveFactor ) = reserveConfigurationMap.getParams(); reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0; @@ -129,7 +127,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { } catch {} // v3 only - reserveData.eModeCategoryId = uint8(eModeCategoryId); reserveData.debtCeiling = reserveConfigurationMap.getDebtCeiling(); reserveData.debtCeilingDecimals = poolDataProvider.getDebtCeilingDecimals(); (reserveData.borrowCap, reserveData.supplyCap) = reserveConfigurationMap.getCaps(); @@ -147,14 +144,6 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { reserveData.isolationModeTotalDebt = baseData.isolationModeTotalDebt; reserveData.accruedToTreasury = baseData.accruedToTreasury; - DataTypes.EModeCategory memory categoryData = pool.getEModeCategoryData( - reserveData.eModeCategoryId - ); - reserveData.eModeLtv = categoryData.ltv; - reserveData.eModeLiquidationThreshold = categoryData.liquidationThreshold; - reserveData.eModeLiquidationBonus = categoryData.liquidationBonus; - reserveData.eModeLabel = categoryData.label; - reserveData.borrowableInIsolation = reserveConfigurationMap.getBorrowableInIsolation(); try poolDataProvider.getIsVirtualAccActive(reserveData.underlyingAsset) returns ( @@ -193,6 +182,18 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { return (reservesData, baseCurrencyInfo); } + function getEModes( + IPoolAddressesProvider provider, + uint256[] memory eModes + ) external view returns (DataTypes.EModeCategory[] memory) { + IPool pool = IPool(provider.getPool()); + DataTypes.EModeCategory[] memory categories = new DataTypes.EModeCategory[](eModes.length); + for (uint8 i = 0; i < eModes.length; i++) { + categories[i] = pool.getEModeCategoryData(uint8(eModes[i])); + } + return categories; + } + function getUserReservesData( IPoolAddressesProvider provider, address user diff --git a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index 4fd0a772..31433522 100644 --- a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -64,14 +64,8 @@ interface IUiPoolDataProviderV3 { // uint256 debtCeiling; uint256 debtCeilingDecimals; - uint8 eModeCategoryId; uint256 borrowCap; uint256 supplyCap; - // eMode - uint16 eModeLtv; - uint16 eModeLiquidationThreshold; - uint16 eModeLiquidationBonus; - string eModeLabel; bool borrowableInIsolation; // v3.1 bool virtualAccActive; diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 68e3859b..407bef57 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -158,12 +158,12 @@ interface IPoolConfigurator { ); /** - * @dev Emitted when the category of an asset in eMode is changed. + * @dev Emitted when the asset of 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 + * @param categoryId The old eMode asset category + * @param allowed True if the asset was added to the eMode */ - event EModeAssetCategoryChanged(address indexed asset, uint8 oldCategoryId, uint8 newCategoryId); + event AssetEModeCategoryChanged(address indexed asset, uint8 categoryId, bool allowed); /** * @dev Emitted when the borrowability of an asset in an eMode changed. @@ -478,13 +478,6 @@ interface IPoolConfigurator { */ function setUnbackedMintCap(address asset, uint256 newUnbackedMintCap) external; - /** - * @notice Assign an efficiency mode (eMode) category to asset. - * @param asset The address of the underlying asset of the reserve - * @param newCategoryId The new category id of the asset - */ - function setAssetEModeCategory(address asset, uint8 newCategoryId) external; - /** * @notice Allows an asset to be borrowed in the specified eMode. * - eMode.borrowable always has less priotiry then reserve.eMode @@ -494,6 +487,14 @@ interface IPoolConfigurator { */ function setAssetBorrowableInEMode(address asset, uint8 categoryId, bool borrowable) external; + /** + * @notice Assign an asset to an efficiency mode (eMode) category. + * @param asset The address of the underlying asset of the reserve + * @param categoryId The new category id of the asset + * @param allowed If the asset should be allowed + */ + function setAssetEModeCategory(address asset, uint8 categoryId, bool allowed) external; + /** * @notice Adds a new efficiency mode (eMode) category. * @dev If zero is provided as oracle address, the default asset oracles will be used to compute the overall debt and diff --git a/src/contracts/interfaces/IPoolDataProvider.sol b/src/contracts/interfaces/IPoolDataProvider.sol index 46ae139b..793d184d 100644 --- a/src/contracts/interfaces/IPoolDataProvider.sol +++ b/src/contracts/interfaces/IPoolDataProvider.sol @@ -66,13 +66,6 @@ interface IPoolDataProvider { 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 diff --git a/src/contracts/mocks/helpers/MockReserveConfiguration.sol b/src/contracts/mocks/helpers/MockReserveConfiguration.sol index 6d9738d6..ff747ee4 100644 --- a/src/contracts/mocks/helpers/MockReserveConfiguration.sol +++ b/src/contracts/mocks/helpers/MockReserveConfiguration.sol @@ -89,15 +89,11 @@ contract MockReserveConfiguration { return configuration.getBorrowCap(); } - function getEModeCategory() external view returns (uint256) { - return configuration.getEModeCategory(); - } - - function setEModeCategory(uint256 categoryId) external { - DataTypes.ReserveConfigurationMap memory config = configuration; - config.setEModeCategory(categoryId); - configuration = config; - } + // function setEModeCategory(uint256 categoryId) external { + // DataTypes.ReserveConfigurationMap memory config = configuration; + // config.setEModeCategory(categoryId); + // configuration = config; + // } function setFlashLoanEnabled(bool enabled) external { DataTypes.ReserveConfigurationMap memory config = configuration; @@ -143,11 +139,7 @@ contract MockReserveConfiguration { return configuration.getFlags(); } - function getParams() - external - view - returns (uint256, uint256, uint256, uint256, uint256, uint256) - { + function getParams() external view returns (uint256, uint256, uint256, uint256, uint256) { return configuration.getParams(); } diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index af7805cf..5785c02e 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -11,6 +11,44 @@ import {ReserveConfiguration} from './ReserveConfiguration.sol'; * @notice Implements the bitmap logic to handle the eMode configuration */ library EModeConfiguration { + /** + * @notice Sets if the asset is collateral in the given eMode + * @param self The configuration object + * @param reserveIndex The index of the reserve in the bitmap + * @param collateral True if the asset should be collateral, false otherwise + */ + function setCollateralAsset( + DataTypes.EModeCategory memory self, + uint256 reserveIndex, + bool collateral + ) internal pure { + unchecked { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + uint128 bit = uint128(1 << reserveIndex); + if (collateral) { + self.collateralMask |= bit; + } else { + self.collateralMask &= ~bit; + } + } + } + + /** + * @notice Validates if a reserve can be used as collaterl in a selected eMode + * @param self The configuration object + * @param reserveIndex The index of the reserve in the bitmap + * @return True if the reserve is collateral + */ + function isCollateralAsset( + DataTypes.EModeCategory storage self, + uint256 reserveIndex + ) internal view returns (bool) { + unchecked { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + return (self.collateralMask >> reserveIndex) & 1 != 0; + } + } + /** * @notice Sets if the asset is borrowable in the given eMode * @param self The configuration object @@ -22,12 +60,14 @@ library EModeConfiguration { uint256 reserveIndex, bool borrowable ) internal pure { - require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - uint128 bit = uint128(1 << reserveIndex); - if (borrowable) { - self.borrowableMask |= bit; - } else { - self.borrowableMask &= ~bit; + unchecked { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + uint128 bit = uint128(1 << reserveIndex); + if (borrowable) { + self.borrowableMask |= bit; + } else { + self.borrowableMask &= ~bit; + } } } @@ -38,10 +78,12 @@ library EModeConfiguration { * @return True if the reserve is borrowable */ function isBorrowable( - DataTypes.EModeCategory memory self, + DataTypes.EModeCategory storage self, uint256 reserveIndex - ) internal pure returns (bool) { - require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (self.borrowableMask >> reserveIndex) & 1 != 0; + ) internal view returns (bool) { + unchecked { + require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); + return (self.borrowableMask >> reserveIndex) & 1 != 0; + } } } diff --git a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol index 5299c991..5472972e 100644 --- a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol @@ -25,7 +25,7 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SUPPLY_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant LIQUIDATION_PROTOCOL_FEE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore - uint256 internal constant EMODE_CATEGORY_MASK = 0xFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore + uint256 internal constant DEPRECATED_EMODE_CATEGORY_MASK = 0xFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant UNBACKED_MINT_CAP_MASK = 0xFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant DEBT_CEILING_MASK = 0xF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant VIRTUAL_ACC_ACTIVE_MASK = 0xEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore @@ -45,7 +45,7 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_START_BIT_POSITION = 80; uint256 internal constant SUPPLY_CAP_START_BIT_POSITION = 116; uint256 internal constant LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION = 152; - uint256 internal constant EMODE_CATEGORY_START_BIT_POSITION = 168; + // uint256 internal constant DEPRECATED_EMODE_CATEGORY_START_BIT_POSITION = 168; uint256 internal constant UNBACKED_MINT_CAP_START_BIT_POSITION = 176; uint256 internal constant DEBT_CEILING_START_BIT_POSITION = 212; uint256 internal constant VIRTUAL_ACC_START_BIT_POSITION = 252; @@ -58,7 +58,7 @@ library ReserveConfiguration { uint256 internal constant MAX_VALID_BORROW_CAP = 68719476735; uint256 internal constant MAX_VALID_SUPPLY_CAP = 68719476735; uint256 internal constant MAX_VALID_LIQUIDATION_PROTOCOL_FEE = 65535; - uint256 internal constant MAX_VALID_EMODE_CATEGORY = 255; + // uint256 internal constant DEPRECATED_MAX_VALID_EMODE_CATEGORY = 255; uint256 internal constant MAX_VALID_UNBACKED_MINT_CAP = 68719476735; uint256 internal constant MAX_VALID_DEBT_CEILING = 1099511627775; @@ -469,31 +469,6 @@ library ReserveConfiguration { return (self.data & ~UNBACKED_MINT_CAP_MASK) >> UNBACKED_MINT_CAP_START_BIT_POSITION; } - /** - * @notice Sets the eMode asset category - * @param self The reserve configuration - * @param category The asset category when the user selects the eMode - */ - function setEModeCategory( - DataTypes.ReserveConfigurationMap memory self, - uint256 category - ) internal pure { - require(category <= MAX_VALID_EMODE_CATEGORY, Errors.INVALID_EMODE_CATEGORY); - - self.data = (self.data & EMODE_CATEGORY_MASK) | (category << EMODE_CATEGORY_START_BIT_POSITION); - } - - /** - * @dev Gets the eMode asset category - * @param self The reserve configuration - * @return The eMode category for the asset - */ - function getEModeCategory( - DataTypes.ReserveConfigurationMap memory self - ) internal pure returns (uint256) { - return (self.data & ~EMODE_CATEGORY_MASK) >> EMODE_CATEGORY_START_BIT_POSITION; - } - /** * @notice Sets the flashloanable flag for the reserve * @param self The reserve configuration @@ -575,11 +550,10 @@ library ReserveConfiguration { * @return The state param representing liquidation bonus * @return The state param representing reserve decimals * @return The state param representing reserve factor - * @return The state param representing eMode category */ function getParams( DataTypes.ReserveConfigurationMap memory self - ) internal pure returns (uint256, uint256, uint256, uint256, uint256, uint256) { + ) internal pure returns (uint256, uint256, uint256, uint256, uint256) { uint256 dataLocal = self.data; return ( @@ -587,8 +561,7 @@ library ReserveConfiguration { (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, - (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION, - (dataLocal & ~EMODE_CATEGORY_MASK) >> EMODE_CATEGORY_START_BIT_POSITION + (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); } diff --git a/src/contracts/protocol/libraries/helpers/Errors.sol b/src/contracts/protocol/libraries/helpers/Errors.sol index e24d42a7..d3f564cb 100644 --- a/src/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/contracts/protocol/libraries/helpers/Errors.sol @@ -99,5 +99,5 @@ library Errors { string public constant LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED = '97'; // 'Liquidation grace sentinel validation failed' string public constant INVALID_GRACE_PERIOD = '98'; // Grace period above a valid range string public constant INVALID_FREEZE_STATE = '99'; // Reserve is already in the passed freeze state - string public constant NOT_BORROWABLE_IN_EMODE = '100'; + string public constant NOT_BORROWABLE_IN_EMODE = '100'; // Asset not borrowable in eMode } diff --git a/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol index 5f5457aa..2d39226d 100644 --- a/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol +++ b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol @@ -126,7 +126,7 @@ library ConfiguratorLogic { ) external { DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); - (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParams(); bytes memory encodedCall = abi.encodeWithSelector( IInitializableAToken.initialize.selector, @@ -157,7 +157,7 @@ library ConfiguratorLogic { ) external { DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); - (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParams(); bytes memory encodedCall = abi.encodeWithSelector( IInitializableDebtToken.initialize.selector, diff --git a/src/contracts/protocol/libraries/logic/EModeLogic.sol b/src/contracts/protocol/libraries/logic/EModeLogic.sol index f8acd49b..b3ee42a3 100644 --- a/src/contracts/protocol/libraries/logic/EModeLogic.sol +++ b/src/contracts/protocol/libraries/logic/EModeLogic.sol @@ -5,6 +5,7 @@ import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC2 import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {EModeConfiguration} from '../configuration/EModeConfiguration.sol'; import {WadRayMath} from '../math/WadRayMath.sol'; import {PercentageMath} from '../math/PercentageMath.sol'; import {DataTypes} from '../types/DataTypes.sol'; @@ -21,6 +22,7 @@ library EModeLogic { using ReserveLogic for DataTypes.ReserveData; using GPv2SafeERC20 for IERC20; using UserConfiguration for DataTypes.UserConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; using WadRayMath for uint256; using PercentageMath for uint256; @@ -47,42 +49,24 @@ library EModeLogic { DataTypes.ExecuteSetUserEModeParams memory params ) external { ValidationLogic.validateSetUserEMode( - reservesData, - reservesList, eModeCategories, userConfig, params.reservesCount, params.categoryId ); - uint8 prevCategoryId = usersEModeCategory[msg.sender]; usersEModeCategory[msg.sender] = params.categoryId; - if (prevCategoryId != 0) { - ValidationLogic.validateHealthFactor( - reservesData, - reservesList, - eModeCategories, - userConfig, - msg.sender, - params.categoryId, - params.reservesCount, - params.oracle - ); - } + ValidationLogic.validateHealthFactor( + reservesData, + reservesList, + eModeCategories, + userConfig, + msg.sender, + params.categoryId, + params.reservesCount, + params.oracle + ); emit UserEModeSet(msg.sender, params.categoryId); } - - /** - * @notice Checks if eMode is active for a user and if yes, if the asset belongs to the eMode category chosen - * @param eModeUserCategory The user eMode category - * @param eModeAssetCategory The asset eMode category - * @return True if eMode is active and the asset belongs to the eMode category chosen by the user, false otherwise - */ - function isInEModeCategory( - uint256 eModeUserCategory, - uint256 eModeAssetCategory - ) internal pure returns (bool) { - return (eModeUserCategory != 0 && eModeAssetCategory == eModeUserCategory); - } } diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 415813d8..5b756754 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -6,6 +6,7 @@ import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {EModeConfiguration} from '../configuration/EModeConfiguration.sol'; import {PercentageMath} from '../math/PercentageMath.sol'; import {WadRayMath} from '../math/WadRayMath.sol'; import {DataTypes} from '../types/DataTypes.sol'; @@ -23,6 +24,7 @@ library GenericLogic { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using UserConfiguration for DataTypes.UserConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; struct CalculateUserAccountDataVars { uint256 assetPrice; @@ -96,14 +98,9 @@ library GenericLogic { DataTypes.ReserveData storage currentReserve = reservesData[vars.currentReserveAddress]; - ( - vars.ltv, - vars.liquidationThreshold, - , - vars.decimals, - , - vars.eModeAssetCategory - ) = currentReserve.configuration.getParams(); + (vars.ltv, vars.liquidationThreshold, , vars.decimals, ) = currentReserve + .configuration + .getParams(); unchecked { vars.assetUnit = 10 ** vars.decimals; @@ -121,10 +118,9 @@ library GenericLogic { vars.totalCollateralInBaseCurrency += vars.userBalanceInBaseCurrency; - vars.isInEModeCategory = EModeLogic.isInEModeCategory( - params.userEModeCategory, - vars.eModeAssetCategory - ); + vars.isInEModeCategory = + params.userEModeCategory == 0 && + eModeCategories[params.userEModeCategory].isCollateralAsset(vars.i); if (vars.ltv != 0) { vars.avgLtv += diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 403c1d4b..e7469e2b 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -13,6 +13,7 @@ import {IsolationModeLogic} from './IsolationModeLogic.sol'; import {EModeLogic} from './EModeLogic.sol'; import {UserConfiguration} from '../../libraries/configuration/UserConfiguration.sol'; import {ReserveConfiguration} from '../../libraries/configuration/ReserveConfiguration.sol'; +import {EModeConfiguration} from '../../libraries/configuration/EModeConfiguration.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; @@ -29,6 +30,7 @@ library LiquidationLogic { using ReserveLogic for DataTypes.ReserveData; using UserConfiguration for DataTypes.UserConfigurationMap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; using GPv2SafeERC20 for IERC20; // See `IPool` for descriptions @@ -381,12 +383,7 @@ library LiquidationLogic { address debtPriceSource = params.debtAsset; if (params.userEModeCategory != 0) { - if ( - EModeLogic.isInEModeCategory( - params.userEModeCategory, - collateralReserve.configuration.getEModeCategory() - ) - ) { + if (eModeCategories[params.userEModeCategory].isCollateralAsset(collateralReserve.id)) { liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; } } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index b03850a4..060d28d5 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -209,12 +209,10 @@ library ValidationLogic { } if (params.userEModeCategory != 0) { - DataTypes.EModeCategory memory category = eModeCategories[params.userEModeCategory]; require( - params.reserveCache.reserveConfiguration.getEModeCategory() == params.userEModeCategory, - Errors.INCONSISTENT_EMODE_CATEGORY + eModeCategories[params.userEModeCategory].isBorrowable(reservesData[params.asset].id), + Errors.NOT_BORROWABLE_IN_EMODE ); - require(category.isBorrowable(reservesData[params.asset].id), Errors.NOT_BORROWABLE_IN_EMODE); } ( @@ -543,22 +541,18 @@ library ValidationLogic { /** * @notice Validates the action of setting efficiency mode. - * @param reservesData The state of all the reserves - * @param reservesList The addresses of all the active reserves * @param eModeCategories a mapping storing configurations for all efficiency mode categories * @param userConfig the user configuration * @param reservesCount The total number of valid reserves * @param categoryId The id of the category */ function validateSetUserEMode( - mapping(address => DataTypes.ReserveData) storage reservesData, - mapping(uint256 => address) storage reservesList, mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, DataTypes.UserConfigurationMap memory userConfig, uint256 reservesCount, uint8 categoryId ) internal view { - DataTypes.EModeCategory memory eModeCategory = eModeCategories[categoryId]; + DataTypes.EModeCategory storage eModeCategory = eModeCategories[categoryId]; // category is invalid if the liq threshold is not set require( categoryId == 0 || eModeCategory.liquidationThreshold != 0, @@ -576,12 +570,6 @@ library ValidationLogic { unchecked { for (uint256 i = 0; i < reservesCount; i++) { if (userConfig.isBorrowing(i)) { - DataTypes.ReserveConfigurationMap memory configuration = reservesData[reservesList[i]] - .configuration; - require( - configuration.getEModeCategory() == categoryId, - Errors.INCONSISTENT_EMODE_CATEGORY - ); require(eModeCategory.isBorrowable(i), Errors.NOT_BORROWABLE_IN_EMODE); } } diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 2c7ac2ef..b95398e5 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -117,8 +117,8 @@ library DataTypes { uint16 liquidationThreshold; uint16 liquidationBonus; uint128 borrowableMask; - // uint160 placeHolder; string label; + uint128 collateralMask; } enum InterestRateMode { diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index ab780a29..e2f083ec 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -398,22 +398,6 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator Errors.INVALID_EMODE_CATEGORY_PARAMS ); - address[] memory reserves = _pool.getReservesList(); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(reserves[i]); - if (categoryId == currentConfig.getEModeCategory()) { - uint256 currentLtv = currentConfig.getFrozen() - ? _pendingLtv[reserves[i]] - : currentConfig.getLtv(); - require(ltv > currentLtv, Errors.INVALID_EMODE_CATEGORY_PARAMS); - - require( - liquidationThreshold > currentConfig.getLiquidationThreshold(), - Errors.INVALID_EMODE_CATEGORY_PARAMS - ); - } - } - _pool.configureEModeCategory( categoryId, DataTypes.EModeCategory({ @@ -421,7 +405,8 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator liquidationThreshold: liquidationThreshold, liquidationBonus: liquidationBonus, label: label, - borrowableMask: 0 + borrowableMask: 0, + collateralMask: 0 }) ); emit EModeCategoryAdded( @@ -437,21 +422,14 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator /// @inheritdoc IPoolConfigurator function setAssetEModeCategory( address asset, - uint8 newCategoryId + uint8 categoryId, + bool allowed ) external override onlyRiskOrPoolAdmins { - DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - - if (newCategoryId != 0) { - DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(newCategoryId); - require( - categoryData.liquidationThreshold > currentConfig.getLiquidationThreshold(), - Errors.INVALID_EMODE_CATEGORY_ASSIGNMENT - ); - } - uint256 oldCategoryId = currentConfig.getEModeCategory(); - currentConfig.setEModeCategory(newCategoryId); - _pool.setConfiguration(asset, currentConfig); - emit EModeAssetCategoryChanged(asset, uint8(oldCategoryId), newCategoryId); + DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + categoryData.setCollateralAsset(reserveData.id, allowed); + _pool.configureEModeCategory(categoryId, categoryData); + emit AssetEModeCategoryChanged(asset, uint8(categoryId), allowed); } /// @inheritdoc IPoolConfigurator diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index 62c8fc36..9ab6d7ec 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -97,7 +97,6 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { supplyCap: 85_000, borrowCap: 60_000, debtCeiling: 0, - eModeCategory: 0, virtualAccActive: true, virtualBalance: 0, aTokenUnderlyingBalance: 0 @@ -195,7 +194,6 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { supplyCap: 85_000, borrowCap: 60_000, debtCeiling: 0, - eModeCategory: 0, virtualAccActive: true, virtualBalance: 0, aTokenUnderlyingBalance: 0 @@ -657,6 +655,6 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); - assertEq(contracts.protocolDataProvider.getReserveEModeCategory(asset), 1); + // assertEq(contracts.protocolDataProvider.getReserveEModeCategory(asset), 1); } } diff --git a/tests/protocol/pool/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol index 3d964e94..623a0638 100644 --- a/tests/protocol/pool/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -319,7 +319,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); vm.stopPrank(); vm.startPrank(alice); @@ -328,7 +328,7 @@ contract PoolBorrowTests is TestnetProcedures { contracts.poolProxy.supply(tokenList.wbtc, 0.5e8, alice, 0); - vm.expectRevert(bytes(Errors.INCONSISTENT_EMODE_CATEGORY)); + vm.expectRevert(bytes(Errors.NOT_BORROWABLE_IN_EMODE)); contracts.poolProxy.borrow(tokenList.usdx, 10001e6, 2, 0, alice); vm.stopPrank(); } diff --git a/tests/protocol/pool/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol index 3e1d2c48..7de7f9aa 100644 --- a/tests/protocol/pool/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -616,8 +616,8 @@ contract PoolLiquidationTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct.id, true); vm.stopPrank(); diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index a4e8a0fa..8f900417 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -496,8 +496,8 @@ contract PoolTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); emit UserEModeSet(alice, ct.id); @@ -513,10 +513,10 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); @@ -544,11 +544,11 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); @@ -563,7 +563,7 @@ contract PoolTests is TestnetProcedures { pool.supply(tokenList.wbtc, amount, alice, 0); pool.borrow(tokenList.weth, borrowAmount, 2, 0, alice); - vm.expectRevert(bytes(Errors.INCONSISTENT_EMODE_CATEGORY)); + vm.expectRevert(bytes(Errors.NOT_BORROWABLE_IN_EMODE)); pool.setUserEMode(ct2.id); vm.stopPrank(); @@ -579,8 +579,8 @@ contract PoolTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); vm.stopPrank(); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol index cebeca45..1d4885c1 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol @@ -239,7 +239,7 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); vm.prank(caller); - contracts.poolConfiguratorProxy.setAssetEModeCategory(address(0), 1); + contracts.poolConfiguratorProxy.setAssetEModeCategory(address(0), 1, true); } function test_reverts_setDebtCeiling(address caller) public { diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index 53e02f0c..a5f164d4 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -21,7 +21,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { string label ); - event EModeAssetCategoryChanged(address indexed asset, uint8 oldCategoryId, uint8 newCategoryId); + event AssetEModeCategoryChanged(address indexed asset, uint8 categoryId, bool allowed); function setUp() public { initTestEnvironment(); @@ -42,52 +42,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(emodeConfig.label, ct.label); } - function test_reverts_configureEmodeCategory_bad_ltv() public { - DataTypes.ReserveConfigurationMap memory currentConfig = contracts.poolProxy.getConfiguration( - tokenList.wbtc - ); - - EModeCategoryInput memory ct = _genCategoryOne(); - - vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); - - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); - - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - uint16(currentConfig.getLtv() - 1), - uint16(currentConfig.getLiquidationThreshold() + 1), - ct.lb, - ct.label - ); - vm.stopPrank(); - } - - function test_reverts_configureEmodeCategory_bad_lq() public { - DataTypes.ReserveConfigurationMap memory currentConfig = contracts.poolProxy.getConfiguration( - tokenList.wbtc - ); - - EModeCategoryInput memory ct = _genCategoryOne(); - - vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id); - - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); - - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - uint16(currentConfig.getLtv() + 1), - uint16(currentConfig.getLiquidationThreshold() - 1), - ct.lb, - ct.label - ); - vm.stopPrank(); - } - function test_updateEModeCategory() public { EModeCategoryInput memory ogCategory = _genCategoryOne(); EModeCategoryInput memory updatedCategory = EModeCategoryInput( @@ -181,85 +135,16 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { ); } - function test_reverts_configureEmodeCategory_input_ltv_lt_reserve_emode_ltv() public { - EModeCategoryInput memory ct = _genCategoryOne(); - vm.startPrank(poolAdmin); - - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); - - (, uint256 ltv, , , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( - tokenList.usdx - ); - - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - uint16(ltv) - 1, - ct.lt, - ct.lb, - ct.label - ); - vm.stopPrank(); - } - - function test_reverts_configureEmodeCategory_input_ltv_lt_reserve_emode_pendingLtv() public { - EModeCategoryInput memory ct = _genCategoryOne(); - vm.startPrank(poolAdmin); - - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); - - (, uint256 ltv, , , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( - tokenList.usdx - ); - - // freeze asset - contracts.poolConfiguratorProxy.setReserveFreeze(tokenList.usdx, true); - - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - uint16(ltv) - 1, - ct.lt, - ct.lb, - ct.label - ); - vm.stopPrank(); - } - - function test_reverts_configureEmodeCategory_input_lt_lt_reserve_emode_lt() public { - EModeCategoryInput memory ct = _genCategoryOne(); - vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); - - (, , uint256 lt, , , , , , , ) = contracts.protocolDataProvider.getReserveConfigurationData( - tokenList.usdx - ); - - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_PARAMS)); - contracts.poolConfiguratorProxy.setEModeCategory( - ct.id, - ct.ltv, - uint16(lt) - 1, - ct.lb, - ct.label - ); - vm.stopPrank(); - } - function test_setAssetEModeCategory() public { EModeCategoryInput memory input = _genCategoryOne(); test_configureEmodeCategory(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit EModeAssetCategoryChanged(tokenList.usdx, 0, input.id); + emit AssetEModeCategoryChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, input.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, input.id, true); } function test_updateAssetEModeCategory() public { - EModeCategoryInput memory prevCt = _genCategoryOne(); EModeCategoryInput memory ct = _genCategoryTwo(); test_setAssetEModeCategory(); @@ -267,30 +152,19 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit EModeAssetCategoryChanged(tokenList.usdx, prevCt.id, ct.id); + emit AssetEModeCategoryChanged(tokenList.usdx, ct.id, true); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id, true); } function test_removeEModeCategoryFromAsset() public { EModeCategoryInput memory prevCt = _genCategoryOne(); test_setAssetEModeCategory(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit EModeAssetCategoryChanged(tokenList.usdx, prevCt.id, 0); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, 0); - } - - function test_reverts_setAssetEModeCategory_invalid() public { - EModeCategoryInput memory ct = _genCategoryOne(); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, 50_00, 51_00, ct.lb, ct.label); + emit AssetEModeCategoryChanged(tokenList.usdx, prevCt.id, false); - vm.expectRevert(bytes(Errors.INVALID_EMODE_CATEGORY_ASSIGNMENT)); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, prevCt.id, false); } } diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 8a844e55..7bfd123f 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -99,7 +99,6 @@ struct ReserveConfig { uint256 supplyCap; uint256 borrowCap; uint256 debtCeiling; - uint256 eModeCategory; bool virtualAccActive; uint256 virtualBalance; uint256 aTokenUnderlyingBalance; @@ -163,21 +162,21 @@ contract ProtocolV3TestBase is DiffUtils { string memory content = '{}'; uint256[] memory usedCategories = new uint256[](configs.length); - for (uint256 i = 0; i < configs.length; i++) { - if (!_isInUint256Array(usedCategories, configs[i].eModeCategory)) { - usedCategories[i] = configs[i].eModeCategory; - DataTypes.EModeCategory memory category = pool.getEModeCategoryData( - uint8(configs[i].eModeCategory) - ); - string memory key = vm.toString(configs[i].eModeCategory); - vm.serializeUint(key, 'eModeCategory', configs[i].eModeCategory); - vm.serializeString(key, 'label', category.label); - vm.serializeUint(key, 'ltv', category.ltv); - vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); - string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); - content = vm.serializeString(eModesKey, key, object); - } - } + // for (uint256 i = 0; i < configs.length; i++) { + // if (!_isInUint256Array(usedCategories, configs[i].eModeCategory)) { + // usedCategories[i] = configs[i].eModeCategory; + // DataTypes.EModeCategory memory category = pool.getEModeCategoryData( + // uint8(configs[i].eModeCategory) + // ); + // string memory key = vm.toString(configs[i].eModeCategory); + // vm.serializeUint(key, 'eModeCategory', configs[i].eModeCategory); + // vm.serializeString(key, 'label', category.label); + // vm.serializeUint(key, 'ltv', category.ltv); + // vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); + // string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); + // content = vm.serializeString(eModesKey, key, object); + // } + // } string memory output = vm.serializeString('root', 'eModes', content); vm.writeJson(output, path); } @@ -261,7 +260,6 @@ contract ProtocolV3TestBase is DiffUtils { vm.serializeUint(key, 'borrowCap', config.borrowCap); vm.serializeUint(key, 'supplyCap', config.supplyCap); vm.serializeUint(key, 'debtCeiling', config.debtCeiling); - vm.serializeUint(key, 'eModeCategory', config.eModeCategory); vm.serializeBool(key, 'usageAsCollateralEnabled', config.usageAsCollateralEnabled); vm.serializeBool(key, 'borrowingEnabled', config.borrowingEnabled); vm.serializeBool(key, 'isPaused', config.isPaused); @@ -426,8 +424,7 @@ contract ProtocolV3TestBase is DiffUtils { localConfig.liquidationThreshold, localConfig.liquidationBonus, localConfig.decimals, - localConfig.reserveFactor, - localConfig.eModeCategory + localConfig.reserveFactor ) = configuration.getParams(); ( localConfig.isActive, @@ -486,7 +483,6 @@ contract ProtocolV3TestBase is DiffUtils { supplyCap: config.supplyCap, borrowCap: config.borrowCap, debtCeiling: config.debtCeiling, - eModeCategory: config.eModeCategory, virtualAccActive: config.virtualAccActive, virtualBalance: config.virtualBalance, aTokenUnderlyingBalance: config.aTokenUnderlyingBalance @@ -593,10 +589,6 @@ contract ProtocolV3TestBase is DiffUtils { config.debtCeiling == expectedConfig.debtCeiling, '_validateReserveConfig: INVALID_DEBT_CEILING' ); - require( - config.eModeCategory == expectedConfig.eModeCategory, - '_validateReserveConfig: INVALID_EMODE_CATEGORY' - ); require( config.interestRateStrategy == expectedConfig.interestRateStrategy, '_validateReserveConfig: INVALID_INTEREST_RATE_STRATEGY' @@ -769,10 +761,6 @@ contract ProtocolV3TestBase is DiffUtils { config1.debtCeiling == config2.debtCeiling, '_noReservesConfigsChangesApartNewListings() : UNEXPECTED_DEBT_CEILING_CHANGED' ); - require( - config1.eModeCategory == config2.eModeCategory, - '_noReservesConfigsChangesApartNewListings() : UNEXPECTED_E_MODE_CATEGORY_CHANGED' - ); } function _validateCountOfListings( @@ -826,20 +814,20 @@ contract ProtocolV3TestBase is DiffUtils { string[] memory assetsInCategory = new string[](assetsConfigs.length); uint256 countCategory; - for (uint256 i = 0; i < assetsConfigs.length; i++) { - if (assetsConfigs[i].eModeCategory == category) { - assetsInCategory[countCategory] = assetsConfigs[i].symbol; - require( - keccak256(bytes(assetsInCategory[countCategory])) == - keccak256(bytes(expectedAssets[countCategory])), - '_getAssetOnEmodeCategory(): INCONSISTENT_ASSETS' - ); - countCategory++; - if (countCategory > expectedAssets.length) { - revert('_getAssetOnEmodeCategory(): MORE_ASSETS_IN_CATEGORY_THAN_EXPECTED'); - } - } - } + // for (uint256 i = 0; i < assetsConfigs.length; i++) { + // if (assetsConfigs[i].eModeCategory == category) { + // assetsInCategory[countCategory] = assetsConfigs[i].symbol; + // require( + // keccak256(bytes(assetsInCategory[countCategory])) == + // keccak256(bytes(expectedAssets[countCategory])), + // '_getAssetOnEmodeCategory(): INCONSISTENT_ASSETS' + // ); + // countCategory++; + // if (countCategory > expectedAssets.length) { + // revert('_getAssetOnEmodeCategory(): MORE_ASSETS_IN_CATEGORY_THAN_EXPECTED'); + // } + // } + // } if (countCategory < expectedAssets.length) { revert('_getAssetOnEmodeCategory(): LESS_ASSETS_IN_CATEGORY_THAN_EXPECTED'); } From 185918d27136c0dc14da083fbdc35249cdcc2a59 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Mon, 26 Aug 2024 14:41:45 +0300 Subject: [PATCH 34/88] remove TODO, fix test_revert_flashloan_borrow_stable --- src/contracts/helpers/UiIncentiveDataProviderV3.sol | 1 - src/contracts/interfaces/IPoolDataProvider.sol | 1 - src/contracts/mocks/testnet-helpers/TestnetERC20.sol | 3 +-- .../protocol/libraries/logic/ValidationLogic.sol | 2 +- src/contracts/protocol/libraries/types/DataTypes.sol | 2 +- tests/protocol/pool/Pool.FlashLoans.t.sol | 12 ++++-------- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/contracts/helpers/UiIncentiveDataProviderV3.sol b/src/contracts/helpers/UiIncentiveDataProviderV3.sol index b06b6095..79a1829d 100644 --- a/src/contracts/helpers/UiIncentiveDataProviderV3.sol +++ b/src/contracts/helpers/UiIncentiveDataProviderV3.sol @@ -47,7 +47,6 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { DataTypes.ReserveDataLegacy memory baseData = pool.getReserveData(reserves[i]); // Get aTokens rewards information - // TODO: check that this is deployed correctly on contract and remove casting IRewardsController aTokenIncentiveController = IRewardsController( address(IncentivizedERC20(baseData.aTokenAddress).getIncentivesController()) ); diff --git a/src/contracts/interfaces/IPoolDataProvider.sol b/src/contracts/interfaces/IPoolDataProvider.sol index 46ae139b..9e5e4266 100644 --- a/src/contracts/interfaces/IPoolDataProvider.sol +++ b/src/contracts/interfaces/IPoolDataProvider.sol @@ -214,7 +214,6 @@ interface IPoolDataProvider { * @return stableDebtTokenAddress DEPRECATED in v3.2.0 * @return variableDebtTokenAddress The VariableDebtToken address of the reserve */ - // TODO: decide function getReserveTokensAddresses( address asset ) diff --git a/src/contracts/mocks/testnet-helpers/TestnetERC20.sol b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol index 0591a01a..efe94186 100644 --- a/src/contracts/mocks/testnet-helpers/TestnetERC20.sol +++ b/src/contracts/mocks/testnet-helpers/TestnetERC20.sol @@ -74,8 +74,7 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable { * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ - // TODO: check - function mint(uint256 value) public virtual returns (bool) { + function mint(uint256 value) public virtual onlyOwner returns (bool) { _mint(_msgSender(), value); return true; } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 75ec8f8c..017e7314 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -305,7 +305,7 @@ library ValidationLogic { require(isActive, Errors.RESERVE_INACTIVE); require(!isPaused, Errors.RESERVE_PAUSED); - require(debt != 0, Errors.NO_DEBT_OF_SELECTED_TYPE); // TODO: maybe not needed, rename error + require(debt != 0, Errors.NO_DEBT_OF_SELECTED_TYPE); } /** diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 0b83ec98..58c5ca59 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -84,7 +84,7 @@ library DataTypes { //bit 56: reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled - //bit 59: DEPRECATED: stable rate borrowing enabled // TODO: wipe it and reuse + //bit 59: DEPRECATED: stable rate borrowing enabled //bit 60: asset is paused //bit 61: borrowing in isolation mode is enabled //bit 62: siloed borrowing enabled diff --git a/tests/protocol/pool/Pool.FlashLoans.t.sol b/tests/protocol/pool/Pool.FlashLoans.t.sol index fadebc78..d30f87a5 100644 --- a/tests/protocol/pool/Pool.FlashLoans.t.sol +++ b/tests/protocol/pool/Pool.FlashLoans.t.sol @@ -420,9 +420,6 @@ contract PoolFlashLoansTests is TestnetProcedures { } function test_revert_flashloan_borrow_stable() public { - vm.prank(alice); - contracts.poolProxy.supply(tokenList.wbtc, 0.5e8, alice, 0); - ( address[] memory assets, uint256[] memory amounts, @@ -462,13 +459,12 @@ contract PoolFlashLoansTests is TestnetProcedures { assets[0] = tokenList.usdx; amounts[0] = 12e6; modes[0] = mode; + for (uint8 x; x < assets.length; x++) { + vm.prank(poolAdmin); + TestnetERC20(assets[x]).transferOwnership(address(mockFlashReceiver)); + } if (checkEvents) { - for (uint8 x; x < assets.length; x++) { - vm.prank(poolAdmin); - TestnetERC20(assets[x]).transferOwnership(address(mockFlashReceiver)); - } - _checkFlashLoanEvents(assets, amounts, modes); } return (assets, amounts, modes, emptyParams); From 3c56e136eff5db28e264943a77536781b2fc5d23 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 26 Aug 2024 22:44:05 +0200 Subject: [PATCH 35/88] typo: fix --- .../protocol/libraries/logic/GenericLogic.sol | 2 +- tests/protocol/pool/Pool.EMode.sol | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 tests/protocol/pool/Pool.EMode.sol diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 5b756754..96f8b015 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -119,7 +119,7 @@ library GenericLogic { vars.totalCollateralInBaseCurrency += vars.userBalanceInBaseCurrency; vars.isInEModeCategory = - params.userEModeCategory == 0 && + params.userEModeCategory != 0 && eModeCategories[params.userEModeCategory].isCollateralAsset(vars.i); if (vars.ltv != 0) { diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol new file mode 100644 index 00000000..800baeaf --- /dev/null +++ b/tests/protocol/pool/Pool.EMode.sol @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; +import 'forge-std/StdStorage.sol'; + +import {IPriceOracleGetter} from '../../../src/contracts/interfaces/IPriceOracleGetter.sol'; +import {IAToken, IERC20} from '../../../src/contracts/interfaces/IAToken.sol'; +import {IPool, DataTypes} from '../../../src/contracts/interfaces/IPool.sol'; +import {IPoolAddressesProvider} from '../../../src/contracts/interfaces/IPoolAddressesProvider.sol'; +import {PoolInstance} from '../../../src/contracts/instances/PoolInstance.sol'; +import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; +import {ReserveConfiguration} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; +import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; +import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; + +contract PoolEModeTests is TestnetProcedures { + using stdStorage for StdStorage; + + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using WadRayMath for uint256; + + event UserEModeSet(address indexed user, uint8 categoryId); + + IPool internal pool; + // @notice number of eModes that are created per default + uint256 constant E_MODES_SETUP = 2; + + function setUp() public virtual { + initTestEnvironment(false); + + pool = PoolInstance(report.poolProxy); + } + + function test_setUserEmode(uint8 eMode) public { + // create 2 emodes + // 1) wbtc/weth collateral; + // 2) wbtc/usdc collateral; + EModeCategoryInput memory ct1 = _genCategoryOne(); + EModeCategoryInput memory ct2 = _genCategoryTwo(); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); + vm.stopPrank(); + + eMode = uint8(bound(eMode, 0, E_MODES_SETUP)); + vm.expectEmit(address(pool)); + emit UserEModeSet(alice, eMode); + + vm.prank(alice); + pool.setUserEMode(eMode); + assertEq(pool.getUserEMode(alice), eMode); + + // switching eMode should work as well + eMode = uint8(bound(eMode + 1, 0, E_MODES_SETUP)); + vm.prank(alice); + pool.setUserEMode(eMode); + assertEq(pool.getUserEMode(alice), eMode); + } + + function test_setUserEmode_switchToBetterEModeShouldBePossible(uint104 amount) public { + amount = uint104(bound(amount, 1 ether, type(uint104).max)); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + contracts.poolConfiguratorProxy.setEModeCategory(2, 9000, 9700, 10050, 'usdx eMode high'); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, 2, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 2, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(1); + _mintTestnetToken(tokenList.usdx, alice, amount); + _supplyToPool(tokenList.usdx, alice, amount); + _borrowMaxLt(tokenList.wbtc, alice); + + (, , , , , uint256 hfBefore) = contracts.poolProxy.getUserAccountData(alice); + vm.prank(alice); + pool.setUserEMode(2); + (, , , , , uint256 hfAfter) = contracts.poolProxy.getUserAccountData(alice); + assertLt(hfBefore, hfAfter); + } + + function _mintTestnetToken(address erc20, address user, uint256 amount) internal { + vm.prank(poolAdmin); + TestnetERC20(erc20).mint(user, amount); + } + + function _supplyToPool(address erc20, address user, uint256 amount) internal { + vm.startPrank(user); + IERC20(erc20).approve(address(contracts.poolProxy), amount); + contracts.poolProxy.supply(erc20, amount, user, 0); + vm.stopPrank(); + } + + function _borrowMaxLt(address erc20, address user) internal { + (uint256 totalCollateralBase, , , uint256 currentLt, , ) = contracts + .poolProxy + .getUserAccountData(user); + uint256 maxBorrowInBase = (totalCollateralBase * currentLt) / 1e4; + uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); + uint256 borrowAmount = (maxBorrowInBase / debtPrice) * 10 ** TestnetERC20(erc20).decimals(); + _mintTestnetToken(erc20, bob, borrowAmount); // todo: better not bob + _supplyToPool(erc20, bob, borrowAmount); + + vm.mockCall( + address(contracts.aaveOracle), + abi.encodeWithSelector(IPriceOracleGetter.getAssetPrice.selector, address(erc20)), + abi.encode(0) + ); + vm.prank(user); + contracts.poolProxy.borrow(erc20, borrowAmount, 2, 0, user); + vm.clearMockedCalls(); + } +} From 24de1dfcb45c2a98b4bc4f5ffdcfdc6317b1b745 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 10:47:27 +0200 Subject: [PATCH 36/88] fix: rename some things & update gas diff --- docs/gas-diff.md | 739 +++++++++--------- .../libraries/EModeEngine.sol | 6 +- .../interfaces/IPoolConfigurator.sol | 4 +- .../protocol/libraries/types/DataTypes.sol | 4 +- .../protocol/pool/PoolConfigurator.sol | 4 +- tests/protocol/pool/Pool.Borrow.t.sol | 2 +- tests/protocol/pool/Pool.EMode.sol | 33 +- tests/protocol/pool/Pool.Liquidations.t.sol | 4 +- tests/protocol/pool/Pool.t.sol | 24 +- .../PoolConfigurator.ACLModifiers.t.sol | 4 +- .../PoolConfigurator.eMode.sol | 20 +- 11 files changed, 429 insertions(+), 415 deletions(-) diff --git a/docs/gas-diff.md b/docs/gas-diff.md index 4027bf67..2a3f8254 100644 --- a/docs/gas-diff.md +++ b/docs/gas-diff.md @@ -1,6 +1,6 @@ ```diff diff --git a/reports/gas.old b/reports/gas.new -index 0dec812..b5b683a 100644 +index 0dec812..9ce5779 100644 --- a/reports/gas.old +++ b/reports/gas.new @@ -27,37 +27,37 @@ @@ -10,7 +10,7 @@ index 0dec812..b5b683a 100644 -| convertToAssets | 3348 | 3493 | 3496 | 3496 | 261 | -| convertToShares | 22946 | 22946 | 22946 | 22946 | 1 | -| createStaticATokens | 2375769 | 2375769 | 2375769 | 2375769 | 46 | -+| convertToAssets | 3370 | 3515 | 3518 | 3518 | 261 | ++| convertToAssets | 3370 | 3516 | 3518 | 3518 | 261 | +| convertToShares | 22968 | 22968 | 22968 | 22968 | 1 | +| createStaticATokens | 2375835 | 2375835 | 2375835 | 2375835 | 46 | | decimals | 3154 | 3154 | 3154 | 3154 | 1 | @@ -57,8 +57,8 @@ index 0dec812..b5b683a 100644 | transfer | 101595 | 101595 | 101595 | 101595 | 1 | -| withdraw | 239849 | 239849 | 239849 | 239849 | 1 | +| withdraw | 239959 | 239959 | 239959 | 239959 | 1 | - - + + | src/contracts/dependencies/weth/WETH9.sol:WETH9 contract | | | | | | @@ -66,9 +66,9 @@ | 546391 | 2423 | | | | | @@ -69,27 +69,27 @@ index 0dec812..b5b683a 100644 -| decimals | 2313 | 2313 | 2313 | 2313 | 636 | +| approve | 29055 | 46246 | 46467 | 46467 | 1785 | +| balanceOf | 541 | 989 | 541 | 2541 | 9205 | -+| decimals | 2313 | 2313 | 2313 | 2313 | 629 | ++| decimals | 2313 | 2313 | 2313 | 2313 | 632 | | symbol | 1213 | 2250 | 3213 | 3213 | 27 | - - + + @@ -91,7 +91,7 @@ | 2050064 | 10159 | | | | | | Function Name | min | avg | median | max | # calls | | owner | 386 | 386 | 386 | 386 | 1 | -| swapAndDeposit | 352192 | 443390 | 475524 | 502455 | 3 | +| swapAndDeposit | 352280 | 443455 | 475577 | 502508 | 3 | - - + + | src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol:ParaSwapRepayAdapter contract | | | | | | @@ -101,7 +101,7 @@ | Function Name | min | avg | median | max | # calls | | owner | 408 | 408 | 408 | 408 | 1 | | rescueTokens | 36133 | 36133 | 36133 | 36133 | 1 | -| swapAndRepay | 405121 | 515303 | 535881 | 584329 | 4 | -+| swapAndRepay | 407258 | 517408 | 537975 | 586423 | 4 | - - ++| swapAndRepay | 404879 | 515029 | 535596 | 584044 | 4 | + + | src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol:ParaSwapWithdrawSwapAdapter contract | | | | | | @@ -110,7 +110,7 @@ | 1757703 | 8731 | | | | | @@ -97,8 +97,8 @@ index 0dec812..b5b683a 100644 | owner | 408 | 408 | 408 | 408 | 1 | -| withdrawAndSwap | 352139 | 378370 | 371176 | 411796 | 3 | +| withdrawAndSwap | 352227 | 378435 | 371229 | 411849 | 3 | - - + + | src/contracts/extensions/static-a-token/StataOracle.sol:StataOracle contract | | | | | | @@ -118,8 +118,8 @@ | Deployment Cost | Deployment Size | | | | | @@ -108,8 +108,8 @@ index 0dec812..b5b683a 100644 -| getAssetsPrices | 87496 | 87496 | 87496 | 87496 | 1 | +| getAssetPrice | 14814 | 14899 | 14814 | 36814 | 257 | +| getAssetsPrices | 87562 | 87562 | 87562 | 87562 | 1 | - - + + | src/contracts/extensions/static-a-token/StaticATokenFactory.sol:StaticATokenFactory contract | | | | | | @@ -128,10 +128,10 @@ | 0 | 0 | | | | | @@ -120,9 +120,9 @@ index 0dec812..b5b683a 100644 | getStaticAToken | 616 | 616 | 616 | 616 | 52 | | getStaticATokens | 9587 | 9587 | 9587 | 9587 | 2 | -| initialize | 24131 | 24131 | 24131 | 24131 | 624 | -+| initialize | 24131 | 24131 | 24131 | 24131 | 617 | - - ++| initialize | 24131 | 24131 | 24131 | 24131 | 620 | + + | src/contracts/extensions/static-a-token/StaticATokenLM.sol:StaticATokenLM contract | | | | | | @@ -153,35 +153,35 @@ | claimRewardsOnBehalf | 12204 | 12204 | 12204 | 12204 | 1 | @@ -130,7 +130,7 @@ index 0dec812..b5b683a 100644 | collectAndUpdateRewards | 32217 | 73291 | 73291 | 114366 | 2 | -| convertToAssets | 2550 | 2695 | 2698 | 2698 | 261 | -| convertToShares | 15648 | 15648 | 15648 | 15648 | 1 | -+| convertToAssets | 2572 | 2717 | 2720 | 2720 | 261 | ++| convertToAssets | 2572 | 2718 | 2720 | 2720 | 261 | +| convertToShares | 15670 | 15670 | 15670 | 15670 | 1 | | decimals | 2359 | 2359 | 2359 | 2359 | 1 | -| deposit | 196987 | 215388 | 218294 | 218294 | 22 | @@ -175,8 +175,8 @@ index 0dec812..b5b683a 100644 | transfer | 72662 | 72662 | 72662 | 72662 | 1 | -| withdraw | 224942 | 224942 | 224942 | 224942 | 1 | +| withdraw | 225052 | 225052 | 225052 | 225052 | 1 | - - + + | src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol:AaveV3ConfigEngine contract | | | | | | @@ -189,16 +189,16 @@ | Deployment Cost | Deployment Size | | | | | @@ -193,17 +193,17 @@ index 0dec812..b5b683a 100644 -| updatePriceFeeds | 39338 | 39338 | 39338 | 39338 | 1 | -| updateRateStrategies | 122092 | 122092 | 122092 | 122092 | 1 | +| DEFAULT_INTEREST_RATE_STRATEGY | 227 | 227 | 227 | 227 | 5 | -+| listAssets | 1832666 | 1832666 | 1832666 | 1832666 | 1 | -+| listAssetsCustom | 1831923 | 5264667 | 5270468 | 5270468 | 613 | -+| updateAssetsEMode | 109952 | 109952 | 109952 | 109952 | 1 | -+| updateBorrowSide | 20101 | 76447 | 76447 | 132793 | 2 | -+| updateCaps | 59905 | 59905 | 59905 | 59905 | 1 | -+| updateCollateralSide | 8777 | 30508 | 8903 | 62979 | 5 | ++| listAssets | 1832667 | 1832667 | 1832667 | 1832667 | 1 | ++| listAssetsCustom | 1831924 | 5264742 | 5270515 | 5270515 | 616 | ++| updateAssetsEMode | 92916 | 92916 | 92916 | 92916 | 1 | ++| updateBorrowSide | 20101 | 76458 | 76458 | 132816 | 2 | ++| updateCaps | 59883 | 59883 | 59883 | 59883 | 1 | ++| updateCollateralSide | 8777 | 30499 | 8903 | 62957 | 5 | +| updateEModeCategories | 10592 | 51848 | 29691 | 104184 | 5 | +| updatePriceFeeds | 39360 | 39360 | 39360 | 39360 | 1 | -+| updateRateStrategies | 122115 | 122115 | 122115 | 122115 | 1 | - - ++| updateRateStrategies | 122202 | 122202 | 122202 | 122202 | 1 | + + | src/contracts/helpers/AaveProtocolDataProvider.sol:AaveProtocolDataProvider contract | | | | | | @@ -206,22 +206,21 @@ | Deployment Cost | Deployment Size | | | | | @@ -211,7 +211,7 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| getATokenTotalSupply | 11863 | 14153 | 11907 | 24953 | 2140 | -| getAllReservesTokens | 16222 | 28423 | 31722 | 39722 | 27 | -+| getATokenTotalSupply | 11863 | 14172 | 11907 | 24975 | 2119 | ++| getATokenTotalSupply | 11863 | 14165 | 11907 | 24975 | 2128 | +| getAllReservesTokens | 16155 | 28653 | 39655 | 39655 | 27 | | getDebtCeiling | 3263 | 3263 | 3263 | 3263 | 4 | -| getDebtCeilingDecimals | 237 | 237 | 237 | 237 | 1 | @@ -222,22 +222,22 @@ index 0dec812..b5b683a 100644 -| getLiquidationProtocolFee | 3174 | 9951 | 5674 | 16674 | 9 | -| getPaused | 3219 | 3325 | 3263 | 5263 | 8383 | +| getInterestRateStrategyAddress | 8563 | 19558 | 8563 | 40063 | 9 | -+| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 9311 | ++| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 9373 | +| getLiquidationProtocolFee | 3285 | 10062 | 5785 | 16785 | 9 | -+| getPaused | 3330 | 3375 | 3374 | 5374 | 9324 | ++| getPaused | 3330 | 3427 | 3374 | 5374 | 9640 | | getReserveCaps | 3286 | 8168 | 3286 | 16786 | 47 | -| getReserveConfigurationData | 3565 | 3773 | 3609 | 17109 | 9714 | -| getReserveEModeCategory | 3199 | 3199 | 3199 | 3199 | 1 | -| getReserveTokensAddresses | 8541 | 14283 | 14585 | 40085 | 9574 | -+| getReserveConfigurationData | 3662 | 3852 | 3706 | 17206 | 10906 | -+| getReserveTokensAddresses | 8541 | 14319 | 14585 | 40085 | 10764 | ++| getReserveConfigurationData | 3662 | 3851 | 3706 | 17206 | 10968 | ++| getReserveTokensAddresses | 8541 | 14320 | 14585 | 40085 | 10826 | | getSiloedBorrowing | 3289 | 3289 | 3289 | 3289 | 1 | -| getTotalDebt | 51955 | 51955 | 51955 | 51955 | 3 | -| getUserReserveData | 18944 | 26800 | 27034 | 43944 | 1302 | +| getTotalDebt | 51890 | 51890 | 51890 | 51890 | 3 | -+| getUserReserveData | 18988 | 26794 | 27013 | 43988 | 1301 | - - ++| getUserReserveData | 18988 | 26798 | 27013 | 43988 | 1301 | + + | src/contracts/helpers/L2Encoder.sol:L2Encoder contract | | | | | | @@ -229,15 +228,15 @@ | Deployment Cost | Deployment Size | | | | | @@ -261,15 +261,15 @@ index 0dec812..b5b683a 100644 +| encodeSupplyParams | 34807 | 34807 | 34807 | 34807 | 7 | +| encodeSupplyWithPermitParams | 35166 | 35166 | 35166 | 35166 | 256 | +| encodeWithdrawParams | 7647 | 7681 | 7681 | 7715 | 2 | - - + + | src/contracts/helpers/WrappedTokenGatewayV3.sol:WrappedTokenGatewayV3 contract | | | | | | @@ -245,16 +244,16 @@ | Deployment Cost | Deployment Size | | | | | | 0 | 0 | | | | | | Function Name | min | avg | median | max | # calls | -| borrowETH | 253365 | 253365 | 253365 | 253365 | 1 | -+| borrowETH | 255413 | 255413 | 255413 | 255413 | 1 | ++| borrowETH | 253033 | 253033 | 253033 | 253033 | 1 | | depositETH | 240170 | 240170 | 240170 | 240170 | 8 | | emergencyEtherTransfer | 33801 | 33801 | 33801 | 33801 | 1 | | emergencyTokenTransfer | 52810 | 52810 | 52810 | 52810 | 1 | @@ -282,8 +282,8 @@ index 0dec812..b5b683a 100644 +| repayETH | 175668 | 179676 | 177558 | 187389 | 5 | +| withdrawETH | 231328 | 235398 | 235398 | 239469 | 2 | +| withdrawETHWithPermit | 275613 | 278496 | 278496 | 281379 | 2 | - - + + | src/contracts/instances/ATokenInstance.sol:ATokenInstance contract | | | | | | @@ -264,35 +263,35 @@ | Function Name | min | avg | median | max | # calls | @@ -291,8 +291,8 @@ index 0dec812..b5b683a 100644 | POOL | 327 | 327 | 327 | 327 | 151 | -| RESERVE_TREASURY_ADDRESS | 420 | 783 | 420 | 2420 | 9917 | -| UNDERLYING_ASSET_ADDRESS | 442 | 475 | 442 | 2442 | 8251 | -+| RESERVE_TREASURY_ADDRESS | 420 | 744 | 420 | 2420 | 11111 | -+| UNDERLYING_ASSET_ADDRESS | 442 | 471 | 442 | 2442 | 9446 | ++| RESERVE_TREASURY_ADDRESS | 420 | 742 | 420 | 2420 | 11173 | ++| UNDERLYING_ASSET_ADDRESS | 442 | 471 | 442 | 2442 | 9508 | | allowance | 785 | 1554 | 785 | 2785 | 26 | | approve | 24590 | 24590 | 24590 | 24590 | 39 | -| balanceOf | 2744 | 5319 | 4744 | 17744 | 4799 | @@ -300,10 +300,10 @@ index 0dec812..b5b683a 100644 -| decimals | 357 | 403 | 357 | 2357 | 8304 | +| balanceOf | 2766 | 5342 | 4766 | 17766 | 4796 | +| burn | 911 | 35659 | 37180 | 81176 | 2110 | -+| decimals | 357 | 397 | 357 | 2357 | 9499 | ++| decimals | 357 | 397 | 357 | 2357 | 9561 | | decreaseAllowance | 7709 | 7709 | 7709 | 7709 | 1 | -| getIncentivesController | 475 | 475 | 475 | 2475 | 8116 | -+| getIncentivesController | 475 | 475 | 475 | 2475 | 9311 | ++| getIncentivesController | 475 | 475 | 475 | 2475 | 9373 | | getPreviousIndex | 654 | 654 | 654 | 654 | 39 | | getScaledUserBalanceAndSupply | 830 | 2419 | 2830 | 4830 | 39 | -| handleRepayment | 597 | 597 | 597 | 597 | 2599 | @@ -311,16 +311,16 @@ index 0dec812..b5b683a 100644 | increaseAllowance | 7776 | 20601 | 24876 | 24876 | 4 | -| initialize | 146515 | 228079 | 231709 | 321646 | 43251 | -| mint | 940 | 59706 | 64435 | 72198 | 4166 | -+| initialize | 146515 | 232852 | 231746 | 321646 | 44425 | -+| mint | 940 | 59703 | 64435 | 72198 | 4163 | ++| initialize | 146515 | 231136 | 231709 | 321646 | 44496 | ++| mint | 940 | 60222 | 64435 | 72198 | 4676 | | mintToTreasury | 444 | 43943 | 49223 | 66323 | 6 | -| name | 1009 | 1454 | 1326 | 3264 | 8351 | -+| name | 1009 | 1449 | 1326 | 3264 | 9546 | ++| name | 1009 | 1448 | 1326 | 3264 | 9608 | | nonces | 655 | 1988 | 2655 | 2655 | 9 | | permit | 1117 | 33566 | 43549 | 53499 | 16 | | rescueTokens | 12040 | 24418 | 14258 | 46957 | 3 | -| scaledBalanceOf | 691 | 1986 | 2691 | 2691 | 10419 | -+| scaledBalanceOf | 691 | 1988 | 2691 | 2691 | 10445 | ++| scaledBalanceOf | 691 | 1933 | 2691 | 2691 | 11720 | | scaledTotalSupply | 375 | 2181 | 2375 | 2375 | 414 | | setIncentivesController | 11941 | 14316 | 14316 | 16691 | 2 | -| symbol | 1074 | 1515 | 1391 | 3329 | 8333 | @@ -329,14 +329,14 @@ index 0dec812..b5b683a 100644 -| transferFrom | 87624 | 120965 | 130243 | 145830 | 43 | -| transferOnLiquidation | 988 | 30249 | 37526 | 44326 | 1807 | -| transferUnderlyingTo | 802 | 18573 | 16500 | 33639 | 2704 | -+| symbol | 1074 | 1510 | 1391 | 3329 | 9528 | -+| totalSupply | 411 | 4911 | 6479 | 10479 | 4881 | -+| transfer | 580 | 117116 | 122712 | 142783 | 275 | -+| transferFrom | 87646 | 121183 | 130265 | 147966 | 43 | ++| symbol | 1074 | 1513 | 1391 | 3329 | 9590 | ++| totalSupply | 411 | 4985 | 6479 | 10479 | 5146 | ++| transfer | 580 | 116801 | 122712 | 140404 | 275 | ++| transferFrom | 87646 | 120962 | 130265 | 145587 | 43 | +| transferOnLiquidation | 988 | 30267 | 37548 | 44348 | 1806 | -+| transferUnderlyingTo | 802 | 18574 | 16500 | 33639 | 2703 | - - ++| transferUnderlyingTo | 802 | 19862 | 16500 | 33639 | 2959 | + + | src/contracts/instances/L2PoolInstance.sol:L2PoolInstance contract | | | | | | @@ -302,154 +301,155 @@ | Function Name | min | avg | median | max | # calls | @@ -349,9 +349,9 @@ index 0dec812..b5b683a 100644 -| dropReserve | 6336 | 6631 | 6336 | 82330 | 257 | -| getBorrowLogic | 282 | 282 | 282 | 282 | 1 | +| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 415 | 415 | 415 | 124 | -+| borrow(address,uint256,uint256,uint16,address) | 200230 | 206064 | 205830 | 240946 | 266 | -+| borrow(bytes32) | 205829 | 205829 | 205829 | 205829 | 3 | -+| configureEModeCategory | 7310 | 8723 | 7310 | 51792 | 276 | ++| borrow(address,uint256,uint256,uint16,address) | 197850 | 203970 | 203450 | 238567 | 266 | ++| borrow(bytes32) | 203449 | 203449 | 203449 | 203449 | 3 | ++| configureEModeCategory | 7310 | 8476 | 7310 | 51792 | 276 | +| dropReserve | 6270 | 6565 | 6270 | 82286 | 257 | +| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | | getBridgeLogic | 346 | 346 | 346 | 346 | 1 | @@ -389,16 +389,16 @@ index 0dec812..b5b683a 100644 +| getReserveNormalizedVariableDebt | 871 | 890 | 871 | 2871 | 264 | +| getReservesList | 11139 | 11139 | 11139 | 11139 | 256 | +| getSupplyLogic | 282 | 282 | 282 | 282 | 1 | -+| getUserAccountData | 22775 | 22775 | 22775 | 22775 | 1 | ++| getUserAccountData | 22396 | 22396 | 22396 | 22396 | 1 | +| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 4 | +| initReserve | 6575 | 41039 | 6575 | 167551 | 656 | +| initialize | 45425 | 45425 | 45425 | 45425 | 62 | -+| liquidationCall | 379271 | 379271 | 379271 | 379271 | 1 | ++| liquidationCall | 376891 | 376891 | 376891 | 376891 | 1 | +| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | +| repay(address,uint256,uint256,address) | 164652 | 164652 | 164652 | 164652 | 2 | +| repay(bytes32) | 135733 | 135733 | 135733 | 135733 | 1 | +| repayWithATokens | 138767 | 138767 | 138767 | 138767 | 1 | -+| repayWithPermit | 183077 | 199967 | 210169 | 210439 | 256 | ++| repayWithPermit | 183077 | 199368 | 206950 | 210170 | 256 | +| rescueTokens | 48219 | 48219 | 48219 | 48219 | 256 | | resetIsolationModeTotalDebt | 4276 | 5590 | 6269 | 15276 | 402 | -| setConfiguration | 2178 | 4409 | 2178 | 24334 | 2004 | @@ -409,9 +409,9 @@ index 0dec812..b5b683a 100644 -| setUserUseReserveAsCollateral(bytes32) | 73824 | 73824 | 73824 | 73824 | 1 | -| supply(address,uint256,address,uint16) | 157289 | 207630 | 208589 | 208589 | 284 | +| setConfiguration | 2178 | 4547 | 2178 | 24334 | 1848 | -+| setLiquidationGracePeriod | 6374 | 11394 | 10862 | 17025 | 768 | ++| setLiquidationGracePeriod | 6374 | 11387 | 10862 | 17025 | 768 | +| setReserveInterestRateStrategyAddress | 6416 | 7991 | 6525 | 15813 | 769 | -+| setUserEMode | 17811 | 42125 | 40892 | 89706 | 7 | ++| setUserEMode | 19813 | 42071 | 40892 | 87328 | 7 | +| setUserUseReserveAsCollateral(address,bool) | 53610 | 69578 | 71631 | 102908 | 17 | +| setUserUseReserveAsCollateral(bytes32) | 73781 | 73781 | 73781 | 73781 | 1 | +| supply(address,uint256,address,uint16) | 157311 | 207652 | 208611 | 208611 | 284 | @@ -428,13 +428,13 @@ index 0dec812..b5b683a 100644 +| updateBridgeProtocolFee | 6262 | 6262 | 6262 | 6262 | 256 | +| updateFlashloanPremiums | 1771 | 8165 | 6444 | 21671 | 380 | +| withdraw | 126619 | 129061 | 129061 | 131504 | 2 | - - + + | src/contracts/instances/PoolConfiguratorInstance.sol:PoolConfiguratorInstance contract | | | | | | |----------------------------------------------------------------------------------------|-----------------|----------|---------|-----------|---------| | Deployment Cost | Deployment Size | | | | | -| 4442338 | 20353 | | | | | -+| 4446043 | 20370 | | | | | ++| 4446007 | 20370 | | | | | | Function Name | min | avg | median | max | # calls | -| MAX_GRACE_PERIOD | 305 | 305 | 305 | 305 | 1792 | -| configureReserveAsCollateral | 12205 | 26298 | 17314 | 95608 | 4169 | @@ -469,42 +469,42 @@ index 0dec812..b5b683a 100644 -| updateFlashloanPremiumToProtocol | 10139 | 11301 | 10139 | 36939 | 907 | -| updateFlashloanPremiumTotal | 14136 | 27000 | 32071 | 36971 | 907 | -| updateVariableDebtToken | 14141 | 14597 | 14141 | 131538 | 257 | -+| MAX_GRACE_PERIOD | 283 | 283 | 283 | 283 | 1538 | -+| configureReserveAsCollateral | 12305 | 26463 | 17380 | 95730 | 4148 | ++| MAX_GRACE_PERIOD | 261 | 261 | 261 | 261 | 1792 | ++| configureReserveAsCollateral | 12283 | 26410 | 17358 | 95708 | 4157 | +| disableLiquidationGracePeriod | 17259 | 28403 | 39505 | 39505 | 513 | -+| dropReserve | 14135 | 14992 | 14135 | 104817 | 261 | -+| getConfiguratorLogic | 306 | 306 | 306 | 306 | 1 | -+| getPendingLtv | 576 | 576 | 576 | 576 | 771 | -+| initReserves | 17468 | 26428054 | 1659789 | 213990395 | 2663 | -+| initialize | 72603 | 90447 | 90503 | 90503 | 644 | -+| setAssetBorrowableInEMode | 76938 | 76990 | 77026 | 77026 | 5 | -+| setAssetEModeCategory | 17454 | 25380 | 17454 | 94158 | 289 | -+| setBorrowCap | 11241 | 12233 | 11307 | 44263 | 2105 | -+| setBorrowableInIsolation | 10786 | 11127 | 10852 | 43798 | 1851 | -+| setDebtCeiling | 17323 | 39443 | 39882 | 94955 | 2112 | -+| setEModeCategory | 17827 | 23075 | 17827 | 84268 | 285 | -+| setLiquidationProtocolFee | 11290 | 11500 | 11356 | 44312 | 1846 | -+| setPoolPause(bool) | 17269 | 17692 | 17269 | 90066 | 515 | -+| setPoolPause(bool,uint40) | 17359 | 61611 | 48341 | 107751 | 512 | -+| setReserveActive | 14157 | 17061 | 14157 | 91367 | 267 | -+| setReserveBorrowing | 10982 | 17769 | 11204 | 41858 | 2607 | -+| setReserveFactor | 17279 | 40357 | 36858 | 125166 | 2097 | -+| setReserveFlashLoaning | 10981 | 17803 | 11047 | 44013 | 2352 | -+| setReserveFreeze | 20624 | 48153 | 53035 | 73241 | 782 | -+| setReserveInterestRateData | 17518 | 18185 | 17518 | 103626 | 258 | -+| setReserveInterestRateStrategyAddress | 17648 | 34381 | 17648 | 162480 | 300 | -+| setReservePause(address,bool) | 17414 | 17597 | 17414 | 41136 | 258 | -+| setReservePause(address,bool,uint40) | 14486 | 36220 | 47094 | 52206 | 2068 | -+| setSiloedBorrowing | 11244 | 11477 | 11310 | 91184 | 1841 | -+| setSupplyCap | 11198 | 12957 | 11264 | 44220 | 2118 | ++| dropReserve | 14113 | 14970 | 14113 | 104795 | 261 | ++| getConfiguratorLogic | 284 | 284 | 284 | 284 | 1 | ++| getPendingLtv | 643 | 643 | 643 | 643 | 771 | ++| initReserves | 17446 | 26379812 | 1659772 | 213979799 | 2666 | ++| initialize | 72581 | 90425 | 90481 | 90481 | 647 | ++| setAssetBorrowableInEMode | 94038 | 94125 | 94126 | 94126 | 517 | ++| setAssetCollateralInEMode | 17518 | 68765 | 77122 | 77123 | 1826 | ++| setBorrowCap | 11219 | 12208 | 11285 | 44241 | 2114 | ++| setBorrowableInIsolation | 10786 | 11126 | 10852 | 43798 | 1860 | ++| setDebtCeiling | 17301 | 39432 | 39860 | 94933 | 2121 | ++| setEModeCategory | 17827 | 70955 | 84268 | 84268 | 1310 | ++| setLiquidationProtocolFee | 11290 | 11499 | 11356 | 44312 | 1855 | ++| setPoolPause(bool) | 17247 | 17670 | 17247 | 90044 | 515 | ++| setPoolPause(bool,uint40) | 17359 | 61722 | 48341 | 107751 | 512 | ++| setReserveActive | 14224 | 17128 | 14224 | 91434 | 267 | ++| setReserveBorrowing | 10960 | 17724 | 11182 | 41836 | 2616 | ++| setReserveFactor | 17346 | 40438 | 36925 | 125233 | 2106 | ++| setReserveFlashLoaning | 10959 | 17755 | 11025 | 43991 | 2361 | ++| setReserveFreeze | 20602 | 48131 | 53013 | 73219 | 782 | ++| setReserveInterestRateData | 17605 | 18272 | 17605 | 103713 | 258 | ++| setReserveInterestRateStrategyAddress | 17626 | 34359 | 17626 | 162458 | 300 | ++| setReservePause(address,bool) | 17392 | 17575 | 17392 | 41114 | 258 | ++| setReservePause(address,bool,uint40) | 14464 | 39159 | 47072 | 52184 | 3084 | ++| setSiloedBorrowing | 11332 | 11564 | 11398 | 91272 | 1850 | ++| setSupplyCap | 11176 | 12931 | 11242 | 44198 | 2127 | +| setUnbackedMintCap | 44233 | 44233 | 44233 | 44233 | 7 | -+| updateAToken | 14096 | 14576 | 14096 | 137662 | 257 | ++| updateAToken | 14074 | 14554 | 14074 | 137640 | 257 | +| updateBridgeProtocolFee | 14141 | 49349 | 52058 | 52058 | 14 | -+| updateFlashloanPremiumToProtocol | 10205 | 11357 | 10205 | 37005 | 900 | -+| updateFlashloanPremiumTotal | 14113 | 26963 | 32092 | 36992 | 900 | -+| updateVariableDebtToken | 14097 | 14553 | 14097 | 131512 | 257 | - - ++| updateFlashloanPremiumToProtocol | 10205 | 11353 | 10205 | 37005 | 903 | ++| updateFlashloanPremiumTotal | 14091 | 26958 | 32070 | 36970 | 903 | ++| updateVariableDebtToken | 14075 | 14531 | 14075 | 131490 | 257 | + + | src/contracts/instances/PoolInstance.sol:PoolInstance contract | | | | | | |----------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -515,17 +515,17 @@ index 0dec812..b5b683a 100644 -| BRIDGE_PROTOCOL_FEE | 416 | 2176 | 2416 | 2416 | 25 | -| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1182 | -| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 416 | 415 | 2415 | 1179 | -+| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3052 | ++| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3058 | +| BRIDGE_PROTOCOL_FEE | 350 | 2110 | 2350 | 2350 | 25 | -+| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1168 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1165 | ++| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1174 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1171 | | MAX_NUMBER_RESERVES | 309 | 309 | 309 | 309 | 514 | -| backUnbacked | 98453 | 114633 | 112032 | 133026 | 9 | -| borrow | 46669 | 219345 | 222815 | 262245 | 2435 | -| configureEModeCategory | 7207 | 10703 | 7207 | 49424 | 280 | +| backUnbacked | 98475 | 114655 | 112054 | 133048 | 9 | -+| borrow | 46603 | 221407 | 224863 | 264427 | 2434 | -+| configureEModeCategory | 7332 | 10631 | 7332 | 51814 | 297 | ++| borrow | 46603 | 220726 | 222483 | 261668 | 2690 | ++| configureEModeCategory | 7332 | 24595 | 8814 | 51814 | 3371 | | deposit | 32854 | 190352 | 208588 | 214736 | 80 | -| dropReserve | 6270 | 7104 | 6270 | 82308 | 262 | -| finalizeTransfer | 20766 | 45533 | 48574 | 88370 | 317 | @@ -533,15 +533,15 @@ index 0dec812..b5b683a 100644 -| flashLoanSimple | 23431 | 343312 | 189538 | 757563 | 11 | -| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | +| dropReserve | 6292 | 7125 | 6292 | 82265 | 262 | -+| finalizeTransfer | 20766 | 45315 | 48574 | 90485 | 317 | -+| flashLoan | 29764 | 85592 | 73125 | 323033 | 267 | ++| finalizeTransfer | 20766 | 45011 | 48574 | 88106 | 317 | ++| flashLoan | 29764 | 82208 | 65635 | 320653 | 267 | +| flashLoanSimple | 23453 | 343384 | 189604 | 757609 | 11 | +| getBorrowLogic | 326 | 326 | 326 | 326 | 1 | | getBridgeLogic | 280 | 280 | 280 | 280 | 1 | -| getConfiguration | 726 | 968 | 726 | 2726 | 53149 | -| getEModeCategoryData | 1908 | 5110 | 6163 | 6163 | 43 | -+| getConfiguration | 748 | 946 | 748 | 2748 | 53424 | -+| getEModeCategoryData | 2146 | 6907 | 8401 | 8401 | 37 | ++| getConfiguration | 748 | 978 | 748 | 2748 | 54971 | ++| getEModeCategoryData | 2146 | 8374 | 8401 | 8401 | 2086 | | getEModeLogic | 301 | 301 | 301 | 301 | 1 | -| getFlashLoanLogic | 303 | 303 | 303 | 303 | 1 | -| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 2014 | @@ -576,143 +576,141 @@ index 0dec812..b5b683a 100644 -| setUserUseReserveAsCollateral | 53632 | 72191 | 71653 | 103041 | 25 | -| supply | 29467 | 187262 | 208611 | 216374 | 3016 | +| getFlashLoanLogic | 325 | 325 | 325 | 325 | 1 | -+| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 982 | ++| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 2005 | +| getLiquidationLogic | 303 | 303 | 303 | 303 | 1 | +| getPoolLogic | 302 | 302 | 302 | 302 | 1 | +| getReserveAddressById | 620 | 620 | 620 | 620 | 1 | -+| getReserveData | 4261 | 8438 | 10261 | 24261 | 19421 | ++| getReserveData | 4261 | 9945 | 10261 | 24261 | 21550 | +| getReserveDataExtended | 3438 | 4104 | 3438 | 5438 | 6 | -+| getReserveNormalizedIncome | 871 | 1149 | 871 | 5333 | 10496 | -+| getReserveNormalizedVariableDebt | 828 | 1004 | 828 | 6426 | 7194 | ++| getReserveNormalizedIncome | 871 | 1142 | 871 | 5333 | 10752 | ++| getReserveNormalizedVariableDebt | 828 | 1005 | 828 | 6426 | 7186 | +| getReservesCount | 373 | 373 | 373 | 373 | 2 | -+| getReservesList | 3116 | 12621 | 11116 | 102626 | 1874 | ++| getReservesList | 3116 | 12647 | 11116 | 102626 | 1874 | +| getSupplyLogic | 326 | 326 | 326 | 326 | 1 | -+| getUserAccountData | 18261 | 21664 | 22761 | 29751 | 1035 | -+| getUserConfiguration | 728 | 774 | 728 | 2728 | 1821 | -+| getUserEMode | 659 | 659 | 659 | 659 | 1036 | ++| getUserAccountData | 17882 | 21571 | 22382 | 28994 | 1804 | ++| getUserConfiguration | 728 | 777 | 728 | 2728 | 1821 | ++| getUserEMode | 659 | 659 | 659 | 659 | 1548 | +| getVirtualUnderlyingBalance | 726 | 726 | 726 | 726 | 2155 | -+| initReserve | 6552 | 179813 | 179592 | 207256 | 44793 | -+| initialize | 45382 | 45482 | 45382 | 66903 | 586 | -+| liquidationCall | 53261 | 229958 | 317741 | 379178 | 3520 | ++| initReserve | 6552 | 179760 | 179592 | 207256 | 44864 | ++| initialize | 45382 | 45482 | 45382 | 66903 | 589 | ++| liquidationCall | 53261 | 227732 | 315362 | 376486 | 3514 | +| mintToTreasury | 77343 | 78738 | 78738 | 80133 | 2 | +| mintUnbacked | 12177 | 118400 | 103526 | 165870 | 17 | +| repay | 33261 | 99436 | 95921 | 164631 | 21 | -+| repayWithATokens | 128164 | 154207 | 155359 | 166023 | 261 | -+| repayWithPermit | 127039 | 165678 | 154132 | 210104 | 768 | ++| repayWithATokens | 128164 | 154520 | 155359 | 166023 | 261 | ++| repayWithPermit | 127039 | 165709 | 154132 | 209835 | 768 | +| rescueTokens | 48176 | 48176 | 48176 | 48176 | 256 | -+| resetIsolationModeTotalDebt | 4298 | 4570 | 4298 | 15298 | 1953 | -+| setConfiguration | 2200 | 17256 | 24200 | 24356 | 65703 | -+| setLiquidationGracePeriod | 6329 | 12079 | 12480 | 16980 | 2970 | ++| resetIsolationModeTotalDebt | 4298 | 4569 | 4298 | 15298 | 1962 | ++| setConfiguration | 2200 | 17083 | 24200 | 24356 | 66881 | ++| setLiquidationGracePeriod | 6329 | 12432 | 14480 | 16980 | 3485 | +| setReserveInterestRateStrategyAddress | 6438 | 7977 | 6547 | 15835 | 813 | -+| setUserEMode | 17833 | 41873 | 40914 | 89728 | 9 | ++| setUserEMode | 18886 | 49402 | 40914 | 94583 | 1034 | +| setUserUseReserveAsCollateral | 53676 | 72230 | 71697 | 102974 | 25 | -+| supply | 29401 | 187180 | 208545 | 216308 | 3013 | ++| supply | 29401 | 190289 | 208545 | 216308 | 3526 | | supplyWithPermit | 113813 | 196609 | 218266 | 257750 | 768 | -| syncIndexesState | 7251 | 13978 | 7251 | 62644 | 1763 | -| syncRatesState | 13531 | 16046 | 16072 | 22572 | 1763 | -| updateBridgeProtocolFee | 6195 | 7025 | 6195 | 23375 | 269 | -| updateFlashloanPremiums | 1704 | 10703 | 6377 | 21604 | 1432 | -| withdraw | 39229 | 105506 | 87802 | 177983 | 51 | -+| syncIndexesState | 7273 | 14001 | 7273 | 62666 | 1742 | -+| syncRatesState | 13553 | 16068 | 16094 | 22594 | 1742 | ++| syncIndexesState | 7273 | 14001 | 7273 | 62666 | 1751 | ++| syncRatesState | 13553 | 16068 | 16094 | 22594 | 1751 | +| updateBridgeProtocolFee | 6217 | 7047 | 6217 | 23397 | 269 | -+| updateFlashloanPremiums | 1726 | 10716 | 6399 | 21626 | 1418 | -+| withdraw | 39251 | 105570 | 87824 | 180119 | 51 | - - ++| updateFlashloanPremiums | 1726 | 10720 | 6399 | 21626 | 1424 | ++| withdraw | 39251 | 105523 | 87824 | 177740 | 51 | + + | src/contracts/instances/VariableDebtTokenInstance.sol:VariableDebtTokenInstance contract | | | | | | @@ -457,22 +457,22 @@ | Deployment Cost | Deployment Size | | | | | | 1723145 | 8349 | | | | | | Function Name | min | avg | median | max | # calls | -| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8112 | -+| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 9307 | ++| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 9369 | | approveDelegation | 27012 | 27012 | 27012 | 27012 | 1 | -| balanceOf | 681 | 4986 | 4771 | 10365 | 7692 | -+| balanceOf | 681 | 4925 | 4706 | 10300 | 7718 | ++| balanceOf | 681 | 4925 | 4706 | 10300 | 7712 | | borrowAllowance | 831 | 831 | 831 | 831 | 5 | -| burn | 19204 | 26197 | 26204 | 26205 | 3108 | -| decimals | 335 | 335 | 335 | 335 | 8112 | +| burn | 19204 | 26197 | 26204 | 26205 | 3107 | -+| decimals | 335 | 335 | 335 | 335 | 9307 | ++| decimals | 335 | 335 | 335 | 335 | 9369 | | delegationWithSig | 1052 | 28689 | 21662 | 55862 | 7 | -| getIncentivesController | 431 | 431 | 431 | 431 | 8112 | -| initialize | 123620 | 207871 | 209041 | 299205 | 43251 | -| mint | 26385 | 62549 | 62585 | 72374 | 2687 | -| name | 1009 | 1421 | 1264 | 3264 | 8202 | -+| getIncentivesController | 431 | 431 | 431 | 431 | 9307 | -+| initialize | 123620 | 207931 | 209041 | 299205 | 44425 | -+| mint | 26385 | 62549 | 62585 | 72374 | 2686 | -+| name | 1009 | 1423 | 1326 | 3264 | 9397 | ++| getIncentivesController | 431 | 431 | 431 | 431 | 9369 | ++| initialize | 123620 | 206084 | 209041 | 299205 | 44496 | ++| mint | 26385 | 62552 | 62585 | 72374 | 2942 | ++| name | 1009 | 1419 | 1264 | 3264 | 9459 | | nonces | 577 | 577 | 577 | 577 | 1 | -| scaledBalanceOf | 691 | 1887 | 2691 | 2691 | 5867 | -| scaledTotalSupply | 419 | 2102 | 2419 | 2419 | 18707 | -| symbol | 1030 | 1440 | 1347 | 3285 | 8195 | -| totalSupply | 4079 | 7582 | 6481 | 19079 | 15 | -+| scaledBalanceOf | 691 | 1891 | 2691 | 2691 | 5894 | -+| scaledTotalSupply | 419 | 2105 | 2419 | 2419 | 18688 | -+| symbol | 1030 | 1439 | 1347 | 3285 | 9390 | ++| scaledBalanceOf | 691 | 1829 | 2691 | 2691 | 6656 | ++| scaledTotalSupply | 419 | 2116 | 2419 | 2419 | 19469 | ++| symbol | 1030 | 1440 | 1347 | 3285 | 9452 | +| totalSupply | 4014 | 7523 | 6416 | 19014 | 15 | - - + + | src/contracts/misc/AaveOracle.sol:AaveOracle contract | | | | | | @@ -482,10 +482,10 @@ | Function Name | min | avg | median | max | # calls | | BASE_CURRENCY | 293 | 293 | 293 | 293 | 3 | | BASE_CURRENCY_UNIT | 262 | 262 | 262 | 262 | 1 | -| getAssetPrice | 679 | 4746 | 7873 | 7873 | 22337 | -+| getAssetPrice | 679 | 4755 | 7873 | 7873 | 22388 | ++| getAssetPrice | 0 | 4726 | 7873 | 7873 | 24937 | | getAssetsPrices | 2300 | 3404 | 2300 | 5614 | 3 | | getFallbackOracle | 365 | 1031 | 365 | 2365 | 3 | -| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1140 | +| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1139 | | setAssetSources | 37348 | 52896 | 61947 | 62187 | 9 | | setFallbackOracle | 59544 | 59544 | 59544 | 59544 | 4 | - + @@ -499,7 +499,7 @@ | MAX_BORROW_RATE | 240 | 240 | 240 | 240 | 5382 | | MAX_OPTIMAL_POINT | 262 | 262 | 262 | 262 | 6918 | | MIN_OPTIMAL_POINT | 261 | 261 | 261 | 261 | 6918 | -| calculateInterestRates | 0 | 4436 | 4271 | 5999 | 16046 | -+| calculateInterestRates | 0 | 4438 | 4271 | 5999 | 16019 | ++| calculateInterestRates | 0 | 4456 | 4271 | 5999 | 16797 | | getBaseVariableBorrowRate | 748 | 776 | 748 | 2748 | 2908 | | getInterestRateData | 1804 | 1804 | 1804 | 1804 | 256 | | getInterestRateDataBps | 987 | 987 | 987 | 987 | 256 | -@@ -507,8 +507,8 @@ +@@ -507,7 +507,7 @@ | getOptimalUsageRatio | 738 | 738 | 738 | 2738 | 2136 | | getVariableRateSlope1 | 778 | 778 | 778 | 778 | 2140 | | getVariableRateSlope2 | 799 | 799 | 799 | 799 | 1368 | -| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29729 | 29075 | 36816 | 2816 | --| setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | -+| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29728 | 29075 | 36804 | 2816 | -+| setInterestRateParams(address,bytes) | 28636 | 33084 | 29860 | 37156 | 6405 | - - - | src/contracts/misc/PriceOracleSentinel.sol:PriceOracleSentinel contract | | | | | | ++| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28290 | 29729 | 29075 | 36804 | 2816 | + | setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | + + @@ -530,26 +530,26 @@ | Deployment Cost | Deployment Size | | | | | | 465623 | 2115 | | | | | | Function Name | min | avg | median | max | # calls | -| ADDRESSES_PROVIDER | 898 | 4368 | 5398 | 5465 | 3190 | -| BRIDGE_PROTOCOL_FEE | 1029 | 5311 | 7529 | 7529 | 23 | -+| ADDRESSES_PROVIDER | 898 | 4373 | 5398 | 5465 | 3176 | ++| ADDRESSES_PROVIDER | 898 | 4371 | 5398 | 5465 | 3182 | +| BRIDGE_PROTOCOL_FEE | 963 | 5245 | 7463 | 7463 | 23 | | DOMAIN_SEPARATOR | 1071 | 4688 | 4156 | 7571 | 5 | -| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 650 | -| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1304 | -| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1039 | 1028 | 7528 | 1301 | -| MAX_GRACE_PERIOD | 5418 | 5418 | 5418 | 5418 | 1792 | -+| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 643 | -+| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1290 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1287 | -+| MAX_GRACE_PERIOD | 5396 | 5396 | 5396 | 5396 | 1538 | ++| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 646 | ++| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1296 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1293 | ++| MAX_GRACE_PERIOD | 5374 | 5374 | 5374 | 5374 | 1792 | | MAX_NUMBER_RESERVES | 922 | 922 | 922 | 922 | 512 | | POOL | 940 | 940 | 940 | 940 | 151 | -| RESERVE_TREASURY_ADDRESS | 1033 | 1397 | 1033 | 7533 | 9918 | -+| RESERVE_TREASURY_ADDRESS | 1033 | 1357 | 1033 | 7533 | 11112 | ++| RESERVE_TREASURY_ADDRESS | 1033 | 1356 | 1033 | 7533 | 11174 | | REVISION | 874 | 874 | 874 | 874 | 8 | -| UNDERLYING_ASSET_ADDRESS | 1011 | 1050 | 1055 | 3055 | 16363 | -+| UNDERLYING_ASSET_ADDRESS | 1011 | 1047 | 1055 | 3055 | 18753 | ++| UNDERLYING_ASSET_ADDRESS | 1011 | 1047 | 1055 | 3055 | 18877 | | admin | 21390 | 21390 | 21390 | 21390 | 8 | | allowance | 1404 | 3173 | 3404 | 7904 | 26 | | approve | 51293 | 51357 | 51341 | 51653 | 39 | @@ -722,9 +720,9 @@ index 0dec812..b5b683a 100644 -| borrow(address,uint256,uint256,uint16,address) | 74012 | 244274 | 250193 | 289647 | 2700 | -| borrow(bytes32) | 230155 | 230155 | 230155 | 230155 | 3 | +| backUnbacked | 125336 | 140987 | 138939 | 159945 | 9 | -+| balanceOf | 1297 | 5820 | 5382 | 22882 | 12514 | -+| borrow(address,uint256,uint256,uint16,address) | 73946 | 246332 | 252241 | 291829 | 2699 | -+| borrow(bytes32) | 232182 | 232182 | 232182 | 232182 | 3 | ++| balanceOf | 1297 | 5820 | 5382 | 22882 | 12508 | ++| borrow(address,uint256,uint256,uint16,address) | 73946 | 244911 | 249861 | 289070 | 2955 | ++| borrow(bytes32) | 229802 | 229802 | 229802 | 229802 | 3 | | borrowAllowance | 1450 | 1450 | 1450 | 1450 | 5 | | burn | 28132 | 40754 | 28464 | 65668 | 3 | | claimAllRewards | 119578 | 119578 | 119578 | 119578 | 1 | @@ -736,8 +734,8 @@ index 0dec812..b5b683a 100644 -| configureReserveAsCollateral | 44067 | 64524 | 57732 | 122552 | 2308 | -| decimals | 948 | 982 | 970 | 7470 | 16416 | +| configureEModeCategory | 34733 | 34744 | 34744 | 34755 | 512 | -+| configureReserveAsCollateral | 44133 | 64613 | 57820 | 122674 | 2308 | -+| decimals | 948 | 979 | 970 | 7470 | 18806 | ++| configureReserveAsCollateral | 44111 | 64591 | 57798 | 122652 | 2308 | ++| decimals | 948 | 979 | 970 | 7470 | 18930 | | decreaseAllowance | 34424 | 34424 | 34424 | 34424 | 1 | | delegationWithSig | 29263 | 56402 | 45264 | 84300 | 7 | | deposit | 91067 | 215461 | 232188 | 235808 | 64 | @@ -745,9 +743,9 @@ index 0dec812..b5b683a 100644 -| dropReserve | 32591 | 35715 | 32657 | 105072 | 775 | -| flashLoan | 59293 | 162000 | 126617 | 374226 | 267 | -| flashLoanSimple | 50944 | 311491 | 177238 | 642906 | 11 | -+| disableLiquidationGracePeriod | 43592 | 54913 | 66050 | 66050 | 513 | -+| dropReserve | 32591 | 35723 | 32613 | 105090 | 775 | -+| flashLoan | 59315 | 173232 | 148808 | 374248 | 267 | ++| disableLiquidationGracePeriod | 43592 | 54914 | 66050 | 66050 | 513 | ++| dropReserve | 32591 | 35715 | 32613 | 105072 | 775 | ++| flashLoan | 59315 | 165996 | 134021 | 374248 | 267 | +| flashLoanSimple | 50966 | 311558 | 177304 | 642952 | 11 | | getAllUserRewards | 9271 | 9271 | 9271 | 9271 | 1 | | getAssetDecimals | 1275 | 1275 | 1275 | 1275 | 2 | @@ -758,11 +756,11 @@ index 0dec812..b5b683a 100644 | getClaimer | 1244 | 3410 | 1244 | 7744 | 3 | -| getConfiguration | 1298 | 1892 | 1342 | 7842 | 54785 | -| getConfiguratorLogic | 5353 | 5353 | 5353 | 5353 | 1 | -+| getConfiguration | 1320 | 1824 | 1364 | 7864 | 54886 | -+| getConfiguratorLogic | 5419 | 5419 | 5419 | 5419 | 1 | ++| getConfiguration | 1320 | 1888 | 1364 | 7864 | 56433 | ++| getConfiguratorLogic | 5397 | 5397 | 5397 | 5397 | 1 | | getDistributionEnd | 1411 | 1411 | 1411 | 1411 | 1 | -| getEModeCategoryData | 2554 | 6313 | 6815 | 11054 | 55 | -+| getEModeCategoryData | 2798 | 11674 | 13537 | 13559 | 51 | ++| getEModeCategoryData | 2798 | 13513 | 13559 | 13559 | 2100 | | getEModeLogic | 5392 | 5403 | 5403 | 5414 | 2 | -| getFlashLoanLogic | 5416 | 5438 | 5438 | 5461 | 2 | -| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 16230 | @@ -771,10 +769,10 @@ index 0dec812..b5b683a 100644 -| getPendingLtv | 1215 | 1215 | 1215 | 1215 | 771 | -| getPoolLogic | 5393 | 5404 | 5404 | 5416 | 2 | +| getFlashLoanLogic | 5394 | 5416 | 5416 | 5438 | 2 | -+| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 18620 | -+| getLiquidationGracePeriod | 29229 | 29246 | 29251 | 29251 | 1238 | ++| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 18744 | ++| getLiquidationGracePeriod | 29229 | 29248 | 29251 | 29251 | 2261 | +| getLiquidationLogic | 5416 | 5438 | 5438 | 5461 | 2 | -+| getPendingLtv | 1192 | 1192 | 1192 | 1192 | 771 | ++| getPendingLtv | 1259 | 1259 | 1259 | 1259 | 771 | +| getPoolLogic | 5415 | 5426 | 5426 | 5438 | 2 | | getPreviousIndex | 1270 | 1270 | 1270 | 1270 | 39 | -| getReserveAddressById | 1281 | 1281 | 1281 | 1281 | 1 | @@ -785,12 +783,12 @@ index 0dec812..b5b683a 100644 -| getReservesCount | 1050 | 1050 | 1050 | 1050 | 2 | -| getReservesList | 3792 | 16242 | 16292 | 103281 | 2164 | +| getReserveAddressById | 1236 | 1236 | 1236 | 1236 | 1 | -+| getReserveData | 4911 | 9427 | 10955 | 29455 | 20274 | ++| getReserveData | 4911 | 10848 | 10955 | 29455 | 22403 | +| getReserveDataExtended | 4144 | 4810 | 4144 | 6144 | 6 | -+| getReserveNormalizedIncome | 1443 | 1991 | 1487 | 10449 | 10788 | -+| getReserveNormalizedVariableDebt | 1444 | 1618 | 1444 | 11542 | 7458 | ++| getReserveNormalizedIncome | 1443 | 1979 | 1487 | 10449 | 11044 | ++| getReserveNormalizedVariableDebt | 1444 | 1618 | 1444 | 11542 | 7450 | +| getReservesCount | 986 | 986 | 986 | 986 | 2 | -+| getReservesList | 3747 | 16659 | 16247 | 104040 | 2130 | ++| getReservesList | 3747 | 16682 | 16247 | 104040 | 2130 | | getRewardOracle | 1268 | 1268 | 1268 | 1268 | 1 | | getRewardsByAsset | 2399 | 5698 | 3672 | 10899 | 201 | | getRewardsData | 1610 | 1610 | 1610 | 1610 | 3 | @@ -800,13 +798,13 @@ index 0dec812..b5b683a 100644 +| getSupplyLogic | 5395 | 5417 | 5417 | 5439 | 2 | | getTransferStrategy | 1267 | 1267 | 1267 | 1267 | 1 | -| getUserAccountData | 18764 | 22167 | 23264 | 30029 | 1037 | -+| getUserAccountData | 18901 | 22305 | 23401 | 30391 | 1036 | ++| getUserAccountData | 18522 | 22212 | 23022 | 29634 | 1805 | | getUserAccruedRewards | 2267 | 2267 | 2267 | 2267 | 1 | | getUserAssetIndex | 1634 | 1634 | 1634 | 1634 | 1 | -| getUserConfiguration | 1322 | 1364 | 1322 | 3322 | 1822 | -| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1037 | -+| getUserConfiguration | 1344 | 1390 | 1344 | 3344 | 1821 | -+| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1036 | ++| getUserConfiguration | 1344 | 1393 | 1344 | 3344 | 1821 | ++| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1548 | | getUserRewards | 5237 | 7340 | 7469 | 10837 | 19 | -| getVirtualUnderlyingBalance | 1298 | 1319 | 1320 | 1320 | 2161 | +| getVirtualUnderlyingBalance | 1320 | 1341 | 1342 | 1342 | 2159 | @@ -816,9 +814,9 @@ index 0dec812..b5b683a 100644 -| liquidationCall(address,address,address,uint256,bool) | 80856 | 256275 | 351792 | 404755 | 3491 | -| liquidationCall(bytes32,bytes32) | 404144 | 404144 | 404144 | 404144 | 1 | +| initReserve | 33269 | 33280 | 33280 | 33292 | 1024 | -+| initReserves | 45732 | 33065878 | 1608721 | 217363244 | 2049 | -+| liquidationCall(address,address,address,uint256,bool) | 80856 | 257552 | 345335 | 407120 | 3520 | -+| liquidationCall(bytes32,bytes32) | 406151 | 406151 | 406151 | 406151 | 1 | ++| initReserves | 45710 | 33036201 | 1608627 | 216658072 | 2049 | ++| liquidationCall(address,address,address,uint256,bool) | 80856 | 255326 | 342956 | 404416 | 3514 | ++| liquidationCall(bytes32,bytes32) | 403771 | 403771 | 403771 | 403771 | 1 | | mint | 28161 | 73503 | 91286 | 91766 | 7 | -| mintToTreasury(address[]) | 99333 | 100926 | 100926 | 102519 | 4 | +| mintToTreasury(address[]) | 99355 | 100948 | 100948 | 102541 | 4 | @@ -826,7 +824,7 @@ index 0dec812..b5b683a 100644 -| mintUnbacked | 39431 | 145665 | 130791 | 193135 | 17 | -| name | 1625 | 2063 | 1945 | 8383 | 16555 | +| mintUnbacked | 39386 | 145620 | 130746 | 193090 | 17 | -+| name | 1625 | 2061 | 1945 | 8383 | 18945 | ++| name | 1625 | 2058 | 1945 | 8383 | 19069 | | nonces | 1193 | 2463 | 3271 | 3271 | 10 | | permit | 29304 | 46376 | 37841 | 81937 | 8 | -| repay(address,uint256,uint256,address) | 60448 | 129350 | 167720 | 187144 | 13 | @@ -838,10 +836,10 @@ index 0dec812..b5b683a 100644 -| rescueTokens | 39115 | 70318 | 70428 | 70471 | 515 | +| repay(address,uint256,uint256,address) | 60470 | 129327 | 167677 | 187099 | 13 | +| repay(bytes32) | 157445 | 157445 | 157445 | 157445 | 1 | -+| repayWithATokens(address,uint256,uint256) | 155013 | 181024 | 182208 | 193232 | 261 | ++| repayWithATokens(address,uint256,uint256) | 155001 | 181337 | 182208 | 193232 | 261 | +| repayWithATokens(bytes32) | 160479 | 160479 | 160479 | 160479 | 1 | -+| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155615 | 186012 | 182767 | 218815 | 768 | -+| repayWithPermit(bytes32,bytes32,bytes32) | 187632 | 207467 | 217671 | 217964 | 256 | ++| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155591 | 186031 | 182803 | 218606 | 768 | ++| repayWithPermit(bytes32,bytes32,bytes32) | 190590 | 206885 | 214480 | 217827 | 256 | +| rescueTokens | 39115 | 70340 | 70450 | 70493 | 515 | | resetIsolationModeTotalDebt | 32590 | 32636 | 32612 | 41843 | 514 | -| scaledBalanceOf | 1307 | 3741 | 3307 | 7807 | 16286 | @@ -849,17 +847,17 @@ index 0dec812..b5b683a 100644 -| setAssetEModeCategory | 43877 | 48422 | 43877 | 79556 | 296 | -| setBorrowCap | 43786 | 44743 | 43786 | 70919 | 267 | -| setBorrowableInIsolation | 67706 | 70116 | 70508 | 70508 | 13 | -+| scaledBalanceOf | 1307 | 3748 | 3307 | 7807 | 16339 | -+| scaledTotalSupply | 988 | 5846 | 7532 | 7532 | 19102 | -+| setAssetBorrowableInEMode | 103772 | 103824 | 103860 | 103860 | 5 | -+| setAssetEModeCategory | 44061 | 51757 | 44061 | 120992 | 288 | -+| setBorrowCap | 43808 | 44766 | 43808 | 70963 | 267 | ++| scaledBalanceOf | 1307 | 3711 | 3307 | 7807 | 18376 | ++| scaledTotalSupply | 988 | 5907 | 7532 | 7532 | 19883 | ++| setAssetBorrowableInEMode | 120872 | 120959 | 120960 | 120960 | 517 | ++| setAssetCollateralInEMode | 44125 | 95562 | 103956 | 103956 | 1825 | ++| setBorrowCap | 43786 | 44744 | 43786 | 70941 | 267 | +| setBorrowableInIsolation | 67684 | 70094 | 70486 | 70486 | 13 | | setConfiguration | 32805 | 32816 | 32816 | 32827 | 512 | -| setDebtCeiling | 43743 | 48112 | 43743 | 121555 | 274 | -| setEModeCategory | 45031 | 53892 | 45031 | 135431 | 295 | -+| setDebtCeiling | 43787 | 48159 | 43787 | 121643 | 274 | -+| setEModeCategory | 44872 | 49711 | 44872 | 111566 | 283 | ++| setDebtCeiling | 43765 | 48137 | 43765 | 121621 | 274 | ++| setEModeCategory | 44872 | 98218 | 111566 | 111662 | 1308 | | setIncentivesController | 38502 | 40869 | 40869 | 43236 | 2 | -| setLiquidationGracePeriod | 32828 | 37932 | 37350 | 43761 | 1536 | -| setLiquidationProtocolFee | 43996 | 60606 | 69878 | 70968 | 8 | @@ -868,7 +866,14 @@ index 0dec812..b5b683a 100644 -| setReserveActive | 40906 | 43807 | 40906 | 118044 | 267 | -| setReserveBorrowing | 43833 | 60242 | 68446 | 68448 | 768 | -| setReserveFactor | 43766 | 44186 | 43766 | 151823 | 258 | --| setReserveFlashLoaning | 68511 | 68516 | 68513 | 70667 | 513 | ++| setLiquidationGracePeriod | 32805 | 37924 | 37338 | 43761 | 1536 | ++| setLiquidationProtocolFee | 44018 | 60642 | 69922 | 71012 | 8 | ++| setPoolPause(bool) | 43568 | 43997 | 43568 | 116349 | 515 | ++| setPoolPause(bool,uint40) | 43811 | 88193 | 74821 | 134211 | 512 | ++| setReserveActive | 40928 | 43831 | 40928 | 118110 | 267 | ++| setReserveBorrowing | 43877 | 60301 | 68512 | 68514 | 768 | ++| setReserveFactor | 43810 | 44230 | 43810 | 151933 | 258 | + | setReserveFlashLoaning | 68511 | 68516 | 68513 | 70667 | 513 | -| setReserveFreeze | 47022 | 73129 | 74823 | 99841 | 783 | -| setReserveInterestRateData | 44326 | 44812 | 44554 | 131069 | 257 | -| setReserveInterestRateStrategyAddress(address,address) | 32846 | 34588 | 33195 | 42729 | 1538 | @@ -881,42 +886,34 @@ index 0dec812..b5b683a 100644 -| setUserEMode | 48307 | 68041 | 66511 | 113935 | 17 | -| setUserUseReserveAsCollateral(address,bool) | 80336 | 96356 | 93550 | 129754 | 42 | -| setUserUseReserveAsCollateral(bytes32) | 95329 | 95329 | 95329 | 95329 | 1 | -+| setLiquidationGracePeriod | 32805 | 37917 | 37338 | 43761 | 1536 | -+| setLiquidationProtocolFee | 44018 | 60642 | 69922 | 71012 | 8 | -+| setPoolPause(bool) | 43590 | 44019 | 43602 | 116371 | 515 | -+| setPoolPause(bool,uint40) | 43811 | 88084 | 74821 | 134211 | 512 | -+| setReserveActive | 40861 | 43764 | 40861 | 118043 | 267 | -+| setReserveBorrowing | 43899 | 60323 | 68534 | 68536 | 768 | -+| setReserveFactor | 43743 | 44163 | 43743 | 151866 | 258 | -+| setReserveFlashLoaning | 68533 | 68538 | 68535 | 70689 | 513 | -+| setReserveFreeze | 47088 | 73180 | 74911 | 99929 | 782 | -+| setReserveInterestRateData | 44283 | 44771 | 44511 | 131092 | 257 | -+| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34618 | 33217 | 42751 | 1538 | -+| setReserveInterestRateStrategyAddress(address,address,bytes) | 44535 | 61408 | 44535 | 190320 | 300 | -+| setReservePause(address,bool) | 43878 | 44235 | 44106 | 67824 | 258 | -+| setReservePause(address,bool,uint40) | 41333 | 63041 | 73928 | 79040 | 2068 | -+| setSiloedBorrowing | 101997 | 111861 | 115716 | 117872 | 3 | -+| setSupplyCap | 43765 | 45778 | 43765 | 70920 | 279 | ++| setReserveFreeze | 47066 | 73158 | 74889 | 99907 | 782 | ++| setReserveInterestRateData | 44370 | 44851 | 44598 | 131179 | 257 | ++| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34612 | 33217 | 42751 | 1538 | ++| setReserveInterestRateStrategyAddress(address,address,bytes) | 44513 | 61386 | 44513 | 190298 | 300 | ++| setReservePause(address,bool) | 43856 | 44188 | 44084 | 67802 | 258 | ++| setReservePause(address,bool,uint40) | 41299 | 65986 | 73906 | 79018 | 3084 | ++| setSiloedBorrowing | 102085 | 111949 | 115804 | 117960 | 3 | ++| setSupplyCap | 43743 | 45756 | 43743 | 70898 | 279 | +| setUnbackedMintCap | 70933 | 70933 | 70933 | 70933 | 7 | -+| setUserEMode | 44144 | 68303 | 67220 | 116049 | 16 | ++| setUserEMode | 43191 | 75378 | 67231 | 120900 | 1041 | +| setUserUseReserveAsCollateral(address,bool) | 80314 | 96359 | 93573 | 129666 | 42 | +| setUserUseReserveAsCollateral(bytes32) | 95286 | 95286 | 95286 | 95286 | 1 | | setValue | 31574 | 31590 | 31598 | 31598 | 3 | -| supply(address,uint256,address,uint16) | 56664 | 214087 | 231043 | 243594 | 3300 | -+| supply(address,uint256,address,uint16) | 56598 | 214018 | 231043 | 243528 | 3297 | ++| supply(address,uint256,address,uint16) | 56598 | 215668 | 226285 | 243528 | 3810 | | supply(bytes32) | 237010 | 237010 | 237010 | 237010 | 7 | -| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216977 | 242026 | 266578 | 768 | -| supplyWithPermit(bytes32,bytes32,bytes32) | 262532 | 262616 | 262592 | 262736 | 256 | -| symbol | 1646 | 2128 | 1966 | 8448 | 16530 | +| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216981 | 242026 | 266578 | 768 | -+| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262643 | 262614 | 262758 | 256 | -+| symbol | 1646 | 2121 | 1966 | 8448 | 18920 | ++| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262636 | 262614 | 262758 | 256 | ++| symbol | 1646 | 2123 | 1988 | 8448 | 19044 | | text | 1789 | 1789 | 1789 | 1789 | 8 | -| totalSupply | 1024 | 8279 | 11570 | 15570 | 4914 | -| transfer | 27662 | 144188 | 149393 | 167373 | 273 | -| transferFrom | 138702 | 138822 | 138822 | 138942 | 2 | -+| totalSupply | 1024 | 8310 | 11592 | 15592 | 4892 | -+| transfer | 27662 | 143924 | 149415 | 169510 | 273 | ++| totalSupply | 1024 | 8463 | 11592 | 15592 | 5157 | ++| transfer | 27662 | 143606 | 149415 | 167131 | 273 | +| transferFrom | 138724 | 138844 | 138844 | 138964 | 2 | | transferOnLiquidation | 28063 | 28063 | 28063 | 28063 | 1 | | transferUnderlyingTo | 27506 | 27506 | 27506 | 27506 | 1 | @@ -926,22 +923,22 @@ index 0dec812..b5b683a 100644 -| updateFlashloanPremiumTotal | 40469 | 40558 | 40469 | 63300 | 258 | -| updateFlashloanPremiums | 32853 | 32875 | 32875 | 32898 | 512 | -| updateVariableDebtToken | 41710 | 42095 | 41710 | 140758 | 257 | -+| updateAToken | 41811 | 42219 | 41811 | 146848 | 257 | ++| updateAToken | 41789 | 42197 | 41789 | 146826 | 257 | +| updateBridgeProtocolFee | 32550 | 33719 | 32595 | 78387 | 526 | +| updateFlashloanPremiumToProtocol | 40470 | 40559 | 40470 | 63334 | 258 | -+| updateFlashloanPremiumTotal | 40446 | 40535 | 40446 | 63321 | 258 | ++| updateFlashloanPremiumTotal | 40424 | 40513 | 40424 | 63299 | 258 | +| updateFlashloanPremiums | 32875 | 32897 | 32897 | 32920 | 512 | -+| updateVariableDebtToken | 41666 | 42051 | 41666 | 140732 | 257 | ++| updateVariableDebtToken | 41644 | 42029 | 41644 | 140710 | 257 | | upgradeTo | 26855 | 28742 | 28742 | 30629 | 2 | | upgradeToAndCall | 28758 | 152638 | 187413 | 187413 | 8 | | value | 931 | 931 | 931 | 931 | 11 | | values | 1213 | 1213 | 1213 | 1213 | 16 | -| withdraw(address,uint256,address) | 66340 | 134756 | 141964 | 205094 | 23 | -| withdraw(bytes32) | 138782 | 145861 | 145861 | 152941 | 2 | -+| withdraw(address,uint256,address) | 66362 | 134870 | 141986 | 207230 | 23 | ++| withdraw(address,uint256,address) | 66362 | 134766 | 141986 | 204851 | 23 | +| withdraw(bytes32) | 138804 | 145883 | 145883 | 152963 | 2 | - - + + | src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol:MockFlashLoanReceiver contract | | | | | | @@ -703,9 +704,9 @@ | src/contracts/mocks/helpers/MockPool.sol:MockPoolInherited contract | | | | | | @@ -952,8 +949,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| initialize | 28462 | 28462 | 28462 | 28462 | 2 | +| initialize | 28397 | 28397 | 28397 | 28397 | 2 | - - + + | src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol:MockAggregator contract | | | | | | @@ -713,10 +714,10 @@ | Deployment Cost | Deployment Size | | | | | @@ -964,18 +961,22 @@ index 0dec812..b5b683a 100644 | decimals | 144 | 144 | 144 | 144 | 83 | | description | 170 | 170 | 170 | 170 | 83 | -| latestAnswer | 281 | 1395 | 2281 | 2281 | 24197 | -+| latestAnswer | 281 | 1396 | 2281 | 2281 | 24227 | ++| latestAnswer | 281 | 1396 | 2281 | 2281 | 26529 | | name | 170 | 170 | 170 | 170 | 83 | - - -@@ -735,7 +736,7 @@ - | 278266 | 1393 | | | | | + + +@@ -732,10 +733,10 @@ + | src/contracts/mocks/oracle/SequencerOracle.sol:SequencerOracle contract | | | | | | + |-------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| + | Deployment Cost | Deployment Size | | | | | +-| 278266 | 1393 | | | | | ++| 278290 | 1393 | | | | | | Function Name | min | avg | median | max | # calls | | latestRoundData | 730 | 1533 | 735 | 4735 | 10 | -| setAnswer | 26207 | 27452 | 26207 | 46119 | 73 | +| setAnswer | 26207 | 27469 | 26207 | 46119 | 72 | - - + + | src/contracts/mocks/swap/MockParaSwapAugustus.sol:MockParaSwapAugustus contract | | | | | | @@ -773,13 +774,13 @@ | Function Name | min | avg | median | max | # calls | @@ -985,14 +986,14 @@ index 0dec812..b5b683a 100644 -| balanceOf | 651 | 991 | 651 | 2651 | 12549 | -| decimals | 312 | 1481 | 2312 | 2312 | 73384 | -| mint | 36480 | 58491 | 53592 | 70740 | 4133 | -+| approve | 29140 | 46510 | 46588 | 46588 | 4576 | ++| approve | 29140 | 46492 | 46588 | 46588 | 5089 | +| balanceOf | 651 | 991 | 651 | 2651 | 12547 | -+| decimals | 312 | 1440 | 2312 | 2312 | 78150 | -+| mint | 36480 | 58483 | 53592 | 70740 | 4091 | ++| decimals | 312 | 1441 | 2312 | 2312 | 78660 | ++| mint | 36480 | 59853 | 53592 | 70800 | 4604 | | name | 3241 | 3241 | 3241 | 3241 | 2048 | | nonces | 2604 | 2604 | 2604 | 2604 | 1 | -| permit | 76466 | 76512 | 76502 | 76670 | 512 | -+| permit | 76466 | 76515 | 76502 | 76670 | 512 | ++| permit | 76454 | 76517 | 76502 | 76670 | 512 | | symbol | 1328 | 2328 | 2328 | 3328 | 56 | | transfer | 46931 | 51023 | 51707 | 51707 | 7 | | transferOwnership | 28800 | 28800 | 28800 | 28800 | 30 | @@ -1002,65 +1003,63 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 448 | -| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 689 | --| percentDiv | 321 | 426 | 432 | 432 | 259 | ++| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 422 | ++| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 667 | + | percentDiv | 321 | 426 | 432 | 432 | 259 | -| percentMul | 338 | 411 | 435 | 435 | 259 | -+| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 425 | -+| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 657 | -+| percentDiv | 321 | 420 | 432 | 432 | 259 | -+| percentMul | 338 | 403 | 435 | 435 | 259 | - - ++| percentMul | 338 | 402 | 435 | 435 | 259 | + + | src/contracts/mocks/tests/WadRayMathWrapper.sol:WadRayMathWrapper contract | | | | | | @@ -813,16 +814,16 @@ | 233882 | 871 | | | | | | Function Name | min | avg | median | max | # calls | | HALF_RAY | 247 | 247 | 247 | 247 | 1 | -| HALF_WAD | 224 | 224 | 224 | 224 | 443 | -+| HALF_WAD | 224 | 224 | 224 | 224 | 435 | ++| HALF_WAD | 224 | 224 | 224 | 224 | 433 | | RAY | 225 | 225 | 225 | 225 | 1 | -| WAD | 180 | 180 | 180 | 180 | 658 | -| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1762 | -+| WAD | 180 | 180 | 180 | 180 | 648 | -+| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1764 | ++| WAD | 180 | 180 | 180 | 180 | 649 | ++| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1765 | | rayDiv | 498 | 498 | 498 | 498 | 4 | | rayMul | 501 | 501 | 501 | 501 | 3 | | rayToWad | 387 | 390 | 387 | 401 | 515 | --| wadDiv | 431 | 524 | 542 | 542 | 260 | + | wadDiv | 431 | 524 | 542 | 542 | 260 | -| wadMul | 338 | 409 | 435 | 435 | 262 | -| wadToRay | 284 | 355 | 360 | 360 | 485 | -+| wadDiv | 431 | 523 | 542 | 542 | 260 | +| wadMul | 338 | 406 | 435 | 435 | 262 | -+| wadToRay | 284 | 355 | 360 | 360 | 487 | - - ++| wadToRay | 284 | 355 | 360 | 360 | 488 | + + | src/contracts/mocks/tokens/MockATokenRepayment.sol:MockATokenRepayment contract | | | | | | @@ -907,23 +908,23 @@ | Deployment Cost | Deployment Size | | | | | | 864174 | 4235 | | | | | | Function Name | min | avg | median | max | # calls | -| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1318 | -+| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1304 | ++| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1310 | | FLASH_BORROWER_ROLE | 317 | 317 | 317 | 317 | 20 | -| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 649 | -+| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 642 | ++| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 645 | | addAssetListingAdmin | 50962 | 50962 | 50962 | 50962 | 3 | | addBridge | 51028 | 51028 | 51028 | 51028 | 14 | | addEmergencyAdmin | 50963 | 50963 | 50963 | 50963 | 3 | | addFlashBorrower | 50984 | 52203 | 50984 | 55863 | 4 | -| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 639 | -+| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 632 | ++| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 635 | | addRiskAdmin | 51028 | 51028 | 51028 | 51028 | 14 | | grantRole | 51480 | 52091 | 51480 | 56370 | 8 | | hasRole | 740 | 2622 | 2740 | 2740 | 17 | -| isAssetListingAdmin | 814 | 2465 | 2814 | 2814 | 3562 | -+| isAssetListingAdmin | 814 | 2467 | 2814 | 2814 | 3548 | ++| isAssetListingAdmin | 814 | 2466 | 2814 | 2814 | 3554 | | isBridge | 2791 | 2791 | 2791 | 2791 | 26 | | isEmergencyAdmin | 747 | 2746 | 2747 | 2747 | 3843 | | isFlashBorrower | 2833 | 2833 | 2833 | 2833 | 268 | -| isPoolAdmin | 757 | 1741 | 757 | 2757 | 45593 | -| isRiskAdmin | 747 | 1420 | 747 | 2747 | 29906 | -+| isPoolAdmin | 757 | 1764 | 2757 | 2757 | 42464 | -+| isRiskAdmin | 747 | 1469 | 747 | 2747 | 27821 | ++| isPoolAdmin | 757 | 1849 | 2757 | 2757 | 46656 | ++| isRiskAdmin | 747 | 1594 | 747 | 2747 | 30985 | | removeAssetListingAdmin | 29054 | 29054 | 29054 | 29054 | 2 | | removeBridge | 29023 | 29023 | 29023 | 29023 | 1 | | removeEmergencyAdmin | 28999 | 28999 | 28999 | 28999 | 1 | @@ -1071,9 +1070,9 @@ index 0dec812..b5b683a 100644 -| getACLAdmin | 480 | 551 | 480 | 2480 | 676 | -| getACLManager | 534 | 1369 | 534 | 2534 | 39760 | -| getAddress | 546 | 549 | 546 | 2546 | 657 | -+| getACLAdmin | 480 | 551 | 480 | 2480 | 669 | -+| getACLManager | 534 | 1383 | 534 | 2534 | 36631 | -+| getAddress | 546 | 549 | 546 | 2546 | 650 | ++| getACLAdmin | 480 | 551 | 480 | 2480 | 672 | ++| getACLManager | 534 | 1497 | 534 | 2534 | 40823 | ++| getAddress | 546 | 549 | 546 | 2546 | 653 | | getMarketId | 1351 | 1351 | 1351 | 1351 | 6 | -| getPool | 469 | 682 | 469 | 2469 | 43331 | -| getPoolConfigurator | 512 | 774 | 512 | 2512 | 182138 | @@ -1081,40 +1080,40 @@ index 0dec812..b5b683a 100644 -| getPriceOracle | 577 | 2281 | 2577 | 2577 | 7894 | -| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6231 | -| owner | 365 | 365 | 365 | 365 | 653 | -+| getPool | 469 | 651 | 469 | 2469 | 47804 | -+| getPoolConfigurator | 512 | 763 | 512 | 2512 | 181974 | -+| getPoolDataProvider | 489 | 1326 | 489 | 2489 | 2182 | -+| getPriceOracle | 577 | 2282 | 2577 | 2577 | 7920 | -+| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6259 | -+| owner | 365 | 365 | 365 | 365 | 646 | ++| getPool | 469 | 660 | 469 | 2469 | 48324 | ++| getPoolConfigurator | 512 | 800 | 512 | 2512 | 186919 | ++| getPoolDataProvider | 489 | 1326 | 489 | 2489 | 2191 | ++| getPriceOracle | 577 | 2188 | 2577 | 2577 | 9964 | ++| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6509 | ++| owner | 365 | 365 | 365 | 365 | 649 | | setACLAdmin | 24016 | 45798 | 47621 | 47621 | 24 | | setACLManager | 24059 | 37487 | 39114 | 47664 | 4 | | setAddress | 24625 | 35611 | 31540 | 48640 | 5 | | setAddressAsProxy | 24331 | 228775 | 57063 | 518962 | 5 | | setMarketId | 24424 | 28561 | 28561 | 32699 | 2 | -| setPoolConfiguratorImpl | 24015 | 292593 | 300665 | 545030 | 4 | -+| setPoolConfiguratorImpl | 24015 | 292591 | 300650 | 545052 | 4 | ++| setPoolConfiguratorImpl | 24015 | 292580 | 300639 | 545030 | 4 | | setPoolDataProvider | 24104 | 37532 | 39159 | 47709 | 4 | -| setPoolImpl | 24060 | 279069 | 287138 | 517941 | 4 | +| setPoolImpl | 24060 | 279024 | 287080 | 517876 | 4 | | setPriceOracle | 24083 | 37511 | 39138 | 47688 | 4 | | setPriceOracleSentinel | 24126 | 40946 | 47731 | 47731 | 6 | - + @@ -968,7 +969,7 @@ | getAddressesProviderAddressById | 522 | 522 | 522 | 522 | 4 | | getAddressesProviderIdByAddress | 559 | 1225 | 559 | 2559 | 6 | | getAddressesProvidersList | 673 | 3403 | 3292 | 5018 | 5 | -| owner | 331 | 2327 | 2331 | 2331 | 650 | -+| owner | 331 | 2327 | 2331 | 2331 | 643 | ++| owner | 331 | 2327 | 2331 | 2331 | 646 | | registerAddressesProvider | 24444 | 104012 | 119926 | 119926 | 6 | | unregisterAddressesProvider | 26448 | 39029 | 40004 | 49662 | 4 | - + @@ -996,7 +997,7 @@ | Deployment Cost | Deployment Size | | | | | | 3183382 | 14716 | | | | | | Function Name | min | avg | median | max | # calls | -| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 653 | -+| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 646 | ++| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 649 | | claimAllRewards | 92349 | 92349 | 92349 | 92349 | 1 | | claimAllRewardsOnBehalf | 94649 | 94649 | 94649 | 94649 | 1 | | claimAllRewardsToSelf | 92147 | 92147 | 92147 | 92147 | 1 | @@ -1124,8 +1123,8 @@ index 0dec812..b5b683a 100644 | getUserRewards | 4600 | 6703 | 6832 | 10200 | 19 | -| handleAction | 732 | 2337 | 2732 | 38089 | 17852 | -| initialize | 26067 | 45246 | 45252 | 53156 | 652 | -+| handleAction | 732 | 2337 | 2732 | 38089 | 17844 | -+| initialize | 26067 | 45246 | 45252 | 53156 | 645 | ++| handleAction | 732 | 2354 | 2732 | 38089 | 18613 | ++| initialize | 26067 | 45246 | 45252 | 53156 | 648 | | setClaimer | 24282 | 24282 | 24282 | 24282 | 4 | | setDistributionEnd | 8888 | 8888 | 8888 | 8888 | 2 | | setEmissionPerSecond | 24335 | 24335 | 24335 | 24335 | 2 | @@ -1134,9 +1133,9 @@ index 0dec812..b5b683a 100644 | 0 | 0 | | | | | | Function Name | min | avg | median | max | # calls | -| initialize | 90684 | 90684 | 90684 | 90684 | 674 | -+| initialize | 90684 | 90684 | 90684 | 90684 | 667 | - - ++| initialize | 90684 | 90684 | 90684 | 90684 | 670 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol:AaveV3GettersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | @@ -1144,18 +1143,18 @@ index 0dec812..b5b683a 100644 +| 5144006 | 33345 | | | | | | Function Name | min | avg | median | max | # calls | -| getGettersReportOne | 971 | 971 | 971 | 971 | 672 | -+| getGettersReportOne | 971 | 971 | 971 | 971 | 665 | - - ++| getGettersReportOne | 971 | 971 | 971 | 971 | 668 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol:AaveV3GettersBatchTwo contract | | | | | | @@ -1071,15 +1072,15 @@ | Deployment Cost | Deployment Size | | | | | | 1583555 | 11792 | | | | | | Function Name | min | avg | median | max | # calls | -| getGettersReportTwo | 535 | 535 | 535 | 535 | 647 | -+| getGettersReportTwo | 535 | 535 | 535 | 535 | 640 | - - ++| getGettersReportTwo | 535 | 535 | 535 | 535 | 643 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol:AaveV3HelpersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|------|--------|------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1163,46 +1162,46 @@ index 0dec812..b5b683a 100644 +| 7379990 | 35117 | | | | | | Function Name | min | avg | median | max | # calls | -| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 622 | -+| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 615 | - - ++| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 618 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol:AaveV3HelpersBatchTwo contract | | | | | | @@ -1087,15 +1088,15 @@ | Deployment Cost | Deployment Size | | | | | | 7169046 | 31590 | | | | | | Function Name | min | avg | median | max | # calls | -| staticATokenReport | 971 | 971 | 971 | 971 | 622 | -+| staticATokenReport | 971 | 971 | 971 | 971 | 615 | - - ++| staticATokenReport | 971 | 971 | 971 | 971 | 618 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol:AaveV3L2PoolBatch contract | | | | | | |---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | -| 9289812 | 42653 | | | | | -+| 9322127 | 42803 | | | | | ++| 9322069 | 42803 | | | | | | Function Name | min | avg | median | max | # calls | -| getPoolReport | 535 | 535 | 535 | 535 | 672 | -+| getPoolReport | 535 | 535 | 535 | 535 | 665 | - - ++| getPoolReport | 535 | 535 | 535 | 535 | 668 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol:AaveV3MiscBatch contract | | | | | | @@ -1103,7 +1104,7 @@ | Deployment Cost | Deployment Size | | | | | | 1062926 | 7122 | | | | | | Function Name | min | avg | median | max | # calls | -| getMiscReport | 535 | 535 | 535 | 535 | 672 | -+| getMiscReport | 535 | 535 | 535 | 535 | 665 | - - ++| getMiscReport | 535 | 535 | 535 | 535 | 668 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol:AaveV3ParaswapBatch contract | | | | | | @@ -1119,7 +1120,7 @@ | Deployment Cost | Deployment Size | | | | | | 7573451 | 38861 | | | | | | Function Name | min | avg | median | max | # calls | -| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 672 | -+| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 665 | - - ++| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 668 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol:AaveV3SetupBatch contract | | | | | | @@ -1127,9 +1128,9 @@ | Deployment Cost | Deployment Size | | | | | @@ -1211,20 +1210,20 @@ index 0dec812..b5b683a 100644 -| getInitialReport | 554 | 554 | 554 | 554 | 672 | -| setMarketReport | 632455 | 634818 | 632455 | 773435 | 622 | -| setupAaveV3Market | 2709798 | 2710437 | 2709798 | 2736039 | 649 | -+| getInitialReport | 554 | 554 | 554 | 554 | 665 | -+| setMarketReport | 632455 | 634845 | 632455 | 773435 | 615 | -+| setupAaveV3Market | 2709842 | 2710480 | 2709842 | 2735992 | 642 | - - ++| getInitialReport | 554 | 554 | 554 | 554 | 668 | ++| setMarketReport | 632455 | 634834 | 632455 | 773435 | 618 | ++| setupAaveV3Market | 2709798 | 2710433 | 2709798 | 2735948 | 645 | + + | src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol:AaveV3TokensBatch contract | | | | | | @@ -1137,53 +1138,53 @@ | Deployment Cost | Deployment Size | | | | | | 4294582 | 20766 | | | | | | Function Name | min | avg | median | max | # calls | -| getTokensReport | 535 | 535 | 535 | 535 | 647 | -+| getTokensReport | 535 | 535 | 535 | 535 | 640 | - - ++| getTokensReport | 535 | 535 | 535 | 535 | 643 | + + -| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | -|------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| -| Deployment Cost | Deployment Size | | | | | @@ -1236,9 +1235,9 @@ index 0dec812..b5b683a 100644 +| Deployment Cost | Deployment Size | | | | | +| 747109 | 3465 | | | | | +| Function Name | min | avg | median | max | # calls | -+| execute | 135971 | 135971 | 135971 | 135971 | 1 | - - ++| execute | 118935 | 118935 | 118935 | 118935 | 1 | + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol:AaveV3MockBorrowUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1246,9 +1245,9 @@ index 0dec812..b5b683a 100644 +| 775935 | 3599 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 159425 | 159425 | 159425 | 159425 | 1 | -+| execute | 159578 | 159578 | 159578 | 159578 | 1 | - - ++| execute | 159601 | 159601 | 159601 | 159601 | 1 | + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol:AaveV3MockBorrowUpdateNoChange contract | | | | | | |--------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1257,8 +1256,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| execute | 47089 | 47089 | 47089 | 47089 | 1 | +| execute | 47111 | 47111 | 47111 | 47111 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol:AaveV3MockCapUpdate contract | | | | | | |----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1266,9 +1265,9 @@ index 0dec812..b5b683a 100644 +| 763034 | 3539 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 86135 | 86135 | 86135 | 86135 | 1 | -+| execute | 86156 | 86156 | 86156 | 86156 | 1 | - - ++| execute | 86134 | 86134 | 86134 | 86134 | 1 | + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol:AaveV3MockCollateralUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1276,9 +1275,9 @@ index 0dec812..b5b683a 100644 +| 776595 | 3602 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89767 | 89767 | 89767 | 89767 | 1 | - - ++| execute | 89745 | 89745 | 89745 | 89745 | 1 | + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol:AaveV3MockCollateralUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1286,7 +1285,7 @@ index 0dec812..b5b683a 100644 +| 783009 | 3632 | | | | | | Function Name | min | avg | median | max | # calls | | execute | 35916 | 35916 | 35916 | 35916 | 2 | - + @@ -1191,15 +1192,15 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateCorrectBonus contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| @@ -1295,9 +1294,9 @@ index 0dec812..b5b683a 100644 +| 776595 | 3602 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89767 | 89767 | 89767 | 89767 | 1 | - - ++| execute | 89745 | 89745 | 89745 | 89745 | 1 | + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateWrongBonus contract | | | | | | |--------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1305,7 +1304,7 @@ index 0dec812..b5b683a 100644 +| 777483 | 3606 | | | | | | Function Name | min | avg | median | max | # calls | | execute | 35332 | 35332 | 35332 | 35332 | 1 | - + @@ -1207,59 +1208,59 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| @@ -1315,8 +1314,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| execute | 155461 | 155461 | 155461 | 155461 | 2 | +| execute | 131198 | 131198 | 131198 | 131198 | 2 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdateEdgeBonus contract | | | | | | |---------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1325,8 +1324,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| execute | 53964 | 53964 | 53964 | 53964 | 1 | +| execute | 56384 | 56384 | 56384 | 56384 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol:AaveV3MockEModeCategoryUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1335,8 +1334,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| execute | 38497 | 38497 | 38497 | 38497 | 2 | +| execute | 37835 | 37835 | 37835 | 37835 | 2 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol:AaveV3MockListing contract | | | | | | |------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1344,10 +1343,10 @@ index 0dec812..b5b683a 100644 +| 849574 | 4011 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 1836009 | 1836009 | 1836009 | 1836009 | 1 | -+| execute | 1823722 | 1823722 | 1823722 | 1823722 | 1 | ++| execute | 1823723 | 1823723 | 1823723 | 1823723 | 1 | | newListings | 2820 | 2820 | 2820 | 2820 | 4 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol:AaveV3MockListingCustom contract | | | | | | |------------------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1355,10 +1354,10 @@ index 0dec812..b5b683a 100644 +| 914350 | 4472 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 1835953 | 1835953 | 1835953 | 1835953 | 1 | -+| execute | 1823666 | 1823666 | 1823666 | 1823666 | 1 | ++| execute | 1823667 | 1823667 | 1823667 | 1823667 | 1 | | newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol:AaveV3MockPriceFeedUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1367,8 +1366,8 @@ index 0dec812..b5b683a 100644 | Function Name | min | avg | median | max | # calls | -| execute | 65371 | 65371 | 65371 | 65371 | 1 | +| execute | 65393 | 65393 | 65393 | 65393 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol:AaveV3MockRatesUpdate contract | | | | | | |--------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1376,33 +1375,31 @@ index 0dec812..b5b683a 100644 +| 768681 | 3565 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 148663 | 148663 | 148663 | 148663 | 1 | -+| execute | 148686 | 148686 | 148686 | 148686 | 1 | ++| execute | 148773 | 148773 | 148773 | 148773 | 1 | | rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | - - -@@ -1273,17 +1274,17 @@ + + +@@ -1273,15 +1274,15 @@ | UNDERLYING_ASSET_ADDRESS | 376 | 1200 | 376 | 2376 | 4354 | | allowance | 909 | 909 | 909 | 909 | 1 | | approve | 22107 | 22107 | 22107 | 22107 | 1 | -| approveDelegation | 48608 | 48637 | 48632 | 48680 | 256 | -| burn | 52036 | 52064 | 52060 | 52108 | 512 | -+| approveDelegation | 48608 | 48635 | 48632 | 48680 | 256 | -+| burn | 52036 | 52066 | 52060 | 52108 | 512 | ++| approveDelegation | 48608 | 48638 | 48632 | 48680 | 256 | ++| burn | 52036 | 52063 | 52060 | 52108 | 512 | | decimals | 335 | 335 | 335 | 335 | 3330 | | decreaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | | getIncentivesController | 431 | 431 | 431 | 431 | 3330 | | increaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | -| initialize | 29524 | 148072 | 179097 | 270713 | 2048 | -+| initialize | 29318 | 148429 | 179133 | 270761 | 2048 | - | mint | 86763 | 88040 | 86799 | 91824 | 1024 | +-| mint | 86763 | 88040 | 86799 | 91824 | 1024 | -| name | 1009 | 1332 | 1264 | 1796 | 3330 | -+| name | 1009 | 1333 | 1264 | 1796 | 3330 | ++| initialize | 29500 | 146691 | 179067 | 270797 | 2048 | ++| mint | 86763 | 88039 | 86799 | 91824 | 1024 | ++| name | 1009 | 1328 | 1264 | 1796 | 3330 | | scaledBalanceOf | 691 | 691 | 691 | 691 | 1024 | --| symbol | 1030 | 1351 | 1285 | 1817 | 3330 | -+| symbol | 1030 | 1353 | 1285 | 1817 | 3330 | + | symbol | 1030 | 1351 | 1285 | 1817 | 3330 | | transfer | 22150 | 22150 | 22150 | 22150 | 1 | - | transferFrom | 22377 | 22377 | 22377 | 22377 | 1 | - @@ -1291,11 +1292,11 @@ | tests/mocks/AaveV3TestListing.sol:AaveV3TestListing contract | | | | | | |--------------------------------------------------------------|-----------------|---------|---------|---------|---------| @@ -1413,22 +1410,16 @@ index 0dec812..b5b683a 100644 -| USDX_ADDRESS | 294 | 294 | 294 | 294 | 617 | -| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 617 | -| execute | 5227666 | 5230040 | 5230240 | 5230240 | 619 | -+| USDX_ADDRESS | 294 | 294 | 294 | 294 | 610 | -+| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 610 | -+| execute | 5190804 | 5193051 | 5193243 | 5193243 | 612 | - - ++| USDX_ADDRESS | 294 | 294 | 294 | 294 | 613 | ++| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 613 | ++| execute | 5190851 | 5193099 | 5193290 | 5193290 | 615 | + + | tests/mocks/AugustusRegistryMock.sol:AugustusRegistryMock contract | | | | | | -@@ -1332,4 +1333,10 @@ - - - +@@ -1332,4 +1333,4 @@ + + + -Ran 56 test suites in 75.93s (123.90s CPU time): 694 tests passed, 0 failed, 0 skipped (694 total tests) -+Ran 56 test suites in 71.64s (197.77s CPU time): 686 tests passed, 1 failed, 0 skipped (687 total tests) -+ -+Failing tests: -+Encountered 1 failing test in tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol:PoolConfiguratorReserveRiskConfigs -+[FAIL. Reason: log != expected log; counterexample: calldata=0xb887fffe0000000000000000000000000000000000000000000000000000000000003840 args=[14400 [1.44e4]]] test_setLiquidationGracePeriodReserve(uint40) (runs: 1, μ: 447430, ~: 447430) -+ -+Encountered a total of 1 failing tests, 686 tests succeeded ++Ran 57 test suites in 74.55s (146.31s CPU time): 690 tests passed, 0 failed, 0 skipped (690 total tests) ``` diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index 1da58b11..ee92da30 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -35,7 +35,11 @@ library EModeEngine { ) internal { for (uint256 i = 0; i < updates.length; i++) { if (updates[i].eModeCategory != 0 && updates[i].eModeCategory != EngineFlags.KEEP_CURRENT) { - poolConfigurator.setAssetEModeCategory(updates[i].asset, updates[i].eModeCategory, true); + poolConfigurator.setAssetCollateralInEMode( + updates[i].asset, + updates[i].eModeCategory, + true + ); } } } diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 407bef57..540535ce 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -163,7 +163,7 @@ interface IPoolConfigurator { * @param categoryId The old eMode asset category * @param allowed True if the asset was added to the eMode */ - event AssetEModeCategoryChanged(address indexed asset, uint8 categoryId, bool allowed); + event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool allowed); /** * @dev Emitted when the borrowability of an asset in an eMode changed. @@ -493,7 +493,7 @@ interface IPoolConfigurator { * @param categoryId The new category id of the asset * @param allowed If the asset should be allowed */ - function setAssetEModeCategory(address asset, uint8 categoryId, bool allowed) external; + function setAssetCollateralInEMode(address asset, uint8 categoryId, bool allowed) external; /** * @notice Adds a new efficiency mode (eMode) category. diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index b95398e5..ca9d2e50 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -116,9 +116,9 @@ library DataTypes { uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; - uint128 borrowableMask; - string label; uint128 collateralMask; + string label; + uint128 borrowableMask; } enum InterestRateMode { diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index e2f083ec..e71a4f48 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -420,7 +420,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator } /// @inheritdoc IPoolConfigurator - function setAssetEModeCategory( + function setAssetCollateralInEMode( address asset, uint8 categoryId, bool allowed @@ -429,7 +429,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); categoryData.setCollateralAsset(reserveData.id, allowed); _pool.configureEModeCategory(categoryId, categoryData); - emit AssetEModeCategoryChanged(asset, uint8(categoryId), allowed); + emit AssetCollateralInEModeChanged(asset, uint8(categoryId), allowed); } /// @inheritdoc IPoolConfigurator diff --git a/tests/protocol/pool/Pool.Borrow.t.sol b/tests/protocol/pool/Pool.Borrow.t.sol index 623a0638..3245feab 100644 --- a/tests/protocol/pool/Pool.Borrow.t.sol +++ b/tests/protocol/pool/Pool.Borrow.t.sol @@ -319,7 +319,7 @@ contract PoolBorrowTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct.id, true); vm.stopPrank(); vm.startPrank(alice); diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 800baeaf..d0823614 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -34,7 +34,26 @@ contract PoolEModeTests is TestnetProcedures { pool = PoolInstance(report.poolProxy); } - function test_setUserEmode(uint8 eMode) public { + function test_setUserEMode_shouldApplyLtLtv() public { + vm.startPrank(poolAdmin); + EModeCategoryInput memory ct1 = _genCategoryOne(); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct1.id, true); + vm.stopPrank(); + + vm.prank(alice); + vm.expectEmit(address(pool)); + emit UserEModeSet(alice, ct1.id); + pool.setUserEMode(ct1.id); + _mintTestnetToken(tokenList.usdx, alice, 1); + _supplyToPool(tokenList.usdx, alice, 1); + + (, , , uint256 currentLt, uint256 currentLtv, ) = contracts.poolProxy.getUserAccountData(alice); + assertEq(currentLt, ct1.lt); + assertEq(currentLtv, ct1.ltv); + } + + function test_setUserEMode_switchShouldWorkIfNoBorrows(uint8 eMode) public { // create 2 emodes // 1) wbtc/weth collateral; // 2) wbtc/usdc collateral; @@ -43,10 +62,10 @@ contract PoolEModeTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct2.id, true); vm.stopPrank(); eMode = uint8(bound(eMode, 0, E_MODES_SETUP)); @@ -69,8 +88,8 @@ contract PoolEModeTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); contracts.poolConfiguratorProxy.setEModeCategory(2, 9000, 9700, 10050, 'usdx eMode high'); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, 1, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, 2, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 2, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 2, true); vm.stopPrank(); diff --git a/tests/protocol/pool/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol index 7de7f9aa..9e32f271 100644 --- a/tests/protocol/pool/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -616,8 +616,8 @@ contract PoolLiquidationTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct.id, true); vm.stopPrank(); diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 8f900417..5b8907d5 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -496,8 +496,8 @@ contract PoolTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); emit UserEModeSet(alice, ct.id); @@ -513,10 +513,10 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct2.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); @@ -544,11 +544,11 @@ contract PoolTests is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct2.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct2.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct2.id, true); vm.stopPrank(); vm.expectEmit(address(contracts.poolProxy)); @@ -579,8 +579,8 @@ contract PoolTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.wbtc, ct1.id, true); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.weth, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct1.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.weth, ct1.id, true); vm.stopPrank(); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol index 1d4885c1..e3dfdfe3 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.ACLModifiers.t.sol @@ -229,7 +229,7 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { contracts.poolConfiguratorProxy.setEModeCategory(1, 1, 1, 1, ''); } - function test_reverts_notRiskAdmin_setAssetEModeCategory(address caller) public { + function test_reverts_notRiskAdmin_setAssetCollateralInEMode(address caller) public { vm.assume( !contracts.aclManager.isPoolAdmin(caller) && !contracts.aclManager.isRiskAdmin(caller) && @@ -239,7 +239,7 @@ contract PoolConfiguratorACLModifiersTest is TestnetProcedures { vm.expectRevert(bytes(Errors.CALLER_NOT_RISK_OR_POOL_ADMIN)); vm.prank(caller); - contracts.poolConfiguratorProxy.setAssetEModeCategory(address(0), 1, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(address(0), 1, true); } function test_reverts_setDebtCeiling(address caller) public { diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index a5f164d4..a65f1d4c 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -21,7 +21,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { string label ); - event AssetEModeCategoryChanged(address indexed asset, uint8 categoryId, bool allowed); + event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool allowed); function setUp() public { initTestEnvironment(); @@ -135,36 +135,36 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { ); } - function test_setAssetEModeCategory() public { + function test_setAssetCollateralInEMode() public { EModeCategoryInput memory input = _genCategoryOne(); test_configureEmodeCategory(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit AssetEModeCategoryChanged(tokenList.usdx, input.id, true); + emit AssetCollateralInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, input.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, input.id, true); } function test_updateAssetEModeCategory() public { EModeCategoryInput memory ct = _genCategoryTwo(); - test_setAssetEModeCategory(); + test_setAssetCollateralInEMode(); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit AssetEModeCategoryChanged(tokenList.usdx, ct.id, true); + emit AssetCollateralInEModeChanged(tokenList.usdx, ct.id, true); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct.id, true); } function test_removeEModeCategoryFromAsset() public { EModeCategoryInput memory prevCt = _genCategoryOne(); - test_setAssetEModeCategory(); + test_setAssetCollateralInEMode(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit AssetEModeCategoryChanged(tokenList.usdx, prevCt.id, false); + emit AssetCollateralInEModeChanged(tokenList.usdx, prevCt.id, false); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetEModeCategory(tokenList.usdx, prevCt.id, false); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, prevCt.id, false); } } From 62aaf853ccbb7bc8994ff49ba40552eb142c763d Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 11:39:27 +0200 Subject: [PATCH 37/88] fix: improve tests --- tests/protocol/pool/Pool.EMode.sol | 98 ++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index d0823614..6650c3c7 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -25,8 +25,8 @@ contract PoolEModeTests is TestnetProcedures { event UserEModeSet(address indexed user, uint8 categoryId); IPool internal pool; + // @notice number of eModes that are created per default - uint256 constant E_MODES_SETUP = 2; function setUp() public virtual { initTestEnvironment(false); @@ -34,29 +34,50 @@ contract PoolEModeTests is TestnetProcedures { pool = PoolInstance(report.poolProxy); } - function test_setUserEMode_shouldApplyLtLtv() public { + function test_getUserEMode_shouldReflectEMode() public { vm.startPrank(poolAdmin); EModeCategoryInput memory ct1 = _genCategoryOne(); contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct1.id, true); vm.stopPrank(); - vm.prank(alice); vm.expectEmit(address(pool)); emit UserEModeSet(alice, ct1.id); + vm.prank(alice); pool.setUserEMode(ct1.id); + + assertEq(pool.getUserEMode(alice), ct1.id); + } + + function test_getUserAccountData_shouldReflectEmodeParams() public { + vm.startPrank(poolAdmin); + EModeCategoryInput memory ct1 = _genCategoryOne(); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct1.id, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(ct1.id); + // supply some dust so the eMode asset is the only collateral _mintTestnetToken(tokenList.usdx, alice, 1); _supplyToPool(tokenList.usdx, alice, 1); - (, , , uint256 currentLt, uint256 currentLtv, ) = contracts.poolProxy.getUserAccountData(alice); - assertEq(currentLt, ct1.lt); - assertEq(currentLtv, ct1.ltv); + (, , , uint256 emodeLT, uint256 emodeLTV, ) = contracts.poolProxy.getUserAccountData(alice); + assertEq(emodeLT, ct1.lt); + assertEq(emodeLTV, ct1.ltv); + + vm.prank(alice); + pool.setUserEMode(0); + (, uint256 assetBaseLTV, uint256 assetBaseLT, , , , , , , ) = contracts + .protocolDataProvider + .getReserveConfigurationData(tokenList.usdx); + (, , , uint256 baseLT, uint256 baseLTV, ) = contracts.poolProxy.getUserAccountData(alice); + assertEq(assetBaseLTV, baseLTV); + assertEq(assetBaseLT, baseLT); } - function test_setUserEMode_switchShouldWorkIfNoBorrows(uint8 eMode) public { - // create 2 emodes - // 1) wbtc/weth collateral; - // 2) wbtc/usdc collateral; + function test_setUserEMode_shouldAllowSwitchingIfNoBorrows(uint8 eMode) public { + uint256 AVAILABLE_EMODES = 2; EModeCategoryInput memory ct1 = _genCategoryOne(); EModeCategoryInput memory ct2 = _genCategoryTwo(); vm.startPrank(poolAdmin); @@ -68,22 +89,18 @@ contract PoolEModeTests is TestnetProcedures { contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct2.id, true); vm.stopPrank(); - eMode = uint8(bound(eMode, 0, E_MODES_SETUP)); - vm.expectEmit(address(pool)); - emit UserEModeSet(alice, eMode); - + eMode = uint8(bound(eMode, 0, AVAILABLE_EMODES)); vm.prank(alice); pool.setUserEMode(eMode); - assertEq(pool.getUserEMode(alice), eMode); - - // switching eMode should work as well - eMode = uint8(bound(eMode + 1, 0, E_MODES_SETUP)); + eMode = uint8(bound(eMode + 1, 0, AVAILABLE_EMODES)); vm.prank(alice); pool.setUserEMode(eMode); assertEq(pool.getUserEMode(alice), eMode); } - function test_setUserEmode_switchToBetterEModeShouldBePossible(uint104 amount) public { + function test_setUserEmode_shouldAllowSwitchingWhenAssetIsBorrowableInEmode( + uint104 amount + ) public { amount = uint104(bound(amount, 1 ether, type(uint104).max)); vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); @@ -107,6 +124,49 @@ contract PoolEModeTests is TestnetProcedures { assertLt(hfBefore, hfAfter); } + function test_setUserEmode_shouldRevertIfHfWouldFallBelow1(uint104 amount) public { + amount = uint104(bound(amount, 1 ether, type(uint104).max)); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + contracts.poolConfiguratorProxy.setEModeCategory(2, 9000, 9700, 10050, 'usdx eMode high'); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 2, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 2, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(2); + _mintTestnetToken(tokenList.usdx, alice, amount); + _supplyToPool(tokenList.usdx, alice, amount); + _borrowMaxLt(tokenList.wbtc, alice); + + vm.prank(alice); + vm.expectRevert(bytes(Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD)); + pool.setUserEMode(1); + } + + function test_setUserEmode_shouldRevertIfAssetNoLongerBorrowable(uint104 amount) public { + amount = uint104(bound(amount, 1 ether, type(uint104).max)); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + contracts.poolConfiguratorProxy.setEModeCategory(2, 9000, 9700, 10050, 'usdx eMode high'); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 2, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(1); + _mintTestnetToken(tokenList.usdx, alice, amount); + _supplyToPool(tokenList.usdx, alice, amount); + _borrowMaxLt(tokenList.wbtc, alice); + + vm.prank(alice); + vm.expectRevert(bytes(Errors.NOT_BORROWABLE_IN_EMODE)); + pool.setUserEMode(2); + } + function _mintTestnetToken(address erc20, address user, uint256 amount) internal { vm.prank(poolAdmin); TestnetERC20(erc20).mint(user, amount); From a772a28983412c5a91198e303deb5316cc14c2e1 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 12:10:36 +0200 Subject: [PATCH 38/88] test: improve test coverage --- .../configuration/EModeConfiguration.sol | 2 +- .../protocol/pool/PoolConfigurator.sol | 2 +- .../PoolConfigurator.eMode.sol | 88 +++++++++++++++---- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index 5785c02e..80702c14 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -17,7 +17,7 @@ library EModeConfiguration { * @param reserveIndex The index of the reserve in the bitmap * @param collateral True if the asset should be collateral, false otherwise */ - function setCollateralAsset( + function setCollateral( DataTypes.EModeCategory memory self, uint256 reserveIndex, bool collateral diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index e71a4f48..e079dd6e 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -427,7 +427,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ) external override onlyRiskOrPoolAdmins { DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); - categoryData.setCollateralAsset(reserveData.id, allowed); + categoryData.setCollateral(reserveData.id, allowed); _pool.configureEModeCategory(categoryId, categoryData); emit AssetCollateralInEModeChanged(asset, uint8(categoryId), allowed); } diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index a65f1d4c..ba65d340 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -6,11 +6,13 @@ import 'forge-std/Test.sol'; import {Errors} from '../../../../src/contracts/protocol/libraries/helpers/Errors.sol'; import {PercentageMath} from '../../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; import {ReserveConfiguration, DataTypes} from '../../../../src/contracts/protocol/pool/PoolConfigurator.sol'; +import {EModeConfiguration} from '../../../../src/contracts/protocol/libraries/configuration/EModeConfiguration.sol'; import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorEModeConfigTests is TestnetProcedures { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using EModeConfiguration for DataTypes.EModeCategory; event EModeCategoryAdded( uint8 indexed categoryId, @@ -22,6 +24,10 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { ); event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool allowed); + event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable); + + // EModeConfiguration only works with storage, so definint a temp placeholder for assertions + DataTypes.EModeCategory internal tempConfig; function setUp() public { initTestEnvironment(); @@ -40,24 +46,26 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(emodeConfig.liquidationThreshold, ct.lt); assertEq(emodeConfig.liquidationBonus, ct.lb); assertEq(emodeConfig.label, ct.label); + assertEq(emodeConfig.collateralMask, 0); + assertEq(emodeConfig.borrowableMask, 0); } function test_updateEModeCategory() public { - EModeCategoryInput memory ogCategory = _genCategoryOne(); + test_configureEmodeCategory(); + EModeCategoryInput memory ct = _genCategoryOne(); + DataTypes.EModeCategory memory ogCategory = contracts.poolProxy.getEModeCategoryData(ct.id); EModeCategoryInput memory updatedCategory = EModeCategoryInput( - ogCategory.id, + ct.id, 90_00, 92_00, 101_00, 'GROUP_B' ); - test_configureEmodeCategory(); - vm.prank(poolAdmin); vm.expectEmit(address(contracts.poolConfiguratorProxy)); emit EModeCategoryAdded( - ogCategory.id, + ct.id, updatedCategory.ltv, updatedCategory.lt, updatedCategory.lb, @@ -66,20 +74,20 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { ); contracts.poolConfiguratorProxy.setEModeCategory( - ogCategory.id, + ct.id, updatedCategory.ltv, updatedCategory.lt, updatedCategory.lb, updatedCategory.label ); - DataTypes.EModeCategory memory emodeConfig = contracts.poolProxy.getEModeCategoryData( - ogCategory.id - ); + DataTypes.EModeCategory memory emodeConfig = contracts.poolProxy.getEModeCategoryData(ct.id); assertEq(emodeConfig.ltv, updatedCategory.ltv); assertEq(emodeConfig.liquidationThreshold, updatedCategory.lt); assertEq(emodeConfig.liquidationBonus, updatedCategory.lb); assertEq(emodeConfig.label, updatedCategory.label); + assertEq(emodeConfig.collateralMask, ogCategory.collateralMask); + assertEq(emodeConfig.borrowableMask, ogCategory.borrowableMask); } function test_reverts_setEmodeCategory_zero_ltv() public { @@ -142,23 +150,31 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetCollateralInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, input.id, true); + tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + assertEq(tempConfig.isCollateralAsset(reserveData.id), true); } - function test_updateAssetEModeCategory() public { - EModeCategoryInput memory ct = _genCategoryTwo(); + function test_addAnotherAssetCollateralInEMode() public { + EModeCategoryInput memory input = _genCategoryOne(); test_setAssetCollateralInEMode(); vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - - vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit AssetCollateralInEModeChanged(tokenList.usdx, ct.id, true); - - vm.prank(poolAdmin); - contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct.id, true); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, input.id, true); + tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + DataTypes.ReserveDataLegacy memory reserveDataWBTC = contracts.poolProxy.getReserveData( + tokenList.wbtc + ); + assertEq(tempConfig.isCollateralAsset(reserveDataUSDX.id), true); + assertEq(tempConfig.isCollateralAsset(reserveDataWBTC.id), true); } - function test_removeEModeCategoryFromAsset() public { + function test_removeCollateralFromEmode() public { EModeCategoryInput memory prevCt = _genCategoryOne(); test_setAssetCollateralInEMode(); vm.expectEmit(address(contracts.poolConfiguratorProxy)); @@ -166,5 +182,39 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, prevCt.id, false); + + tempConfig = contracts.poolProxy.getEModeCategoryData(prevCt.id); + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + assertEq(tempConfig.isCollateralAsset(reserveData.id), false); + } + + function test_setAssetBorrowableInEMode() public { + EModeCategoryInput memory input = _genCategoryOne(); + test_configureEmodeCategory(); + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, true); + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, true); + tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + assertEq(tempConfig.isBorrowable(reserveData.id), true); + } + + function test_removeBorrowableFromEmode() public { + EModeCategoryInput memory input = _genCategoryOne(); + test_configureEmodeCategory(); + vm.expectEmit(address(contracts.poolConfiguratorProxy)); + emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, false); + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, false); + tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + assertEq(tempConfig.isBorrowable(reserveData.id), false); } } From deadd2cf8a9a1b06861bab7d1a7c03bb24a33425 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 12:33:39 +0200 Subject: [PATCH 39/88] fix: add ui pool data provider method --- .../helpers/UiPoolDataProviderV3.sol | 26 ++++++++++++++----- .../interfaces/IUiPoolDataProviderV3.sol | 6 +++++ .../configuration/ReserveConfiguration.sol | 3 --- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index d261b900..da693e1c 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -182,14 +182,26 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { return (reservesData, baseCurrencyInfo); } - function getEModes( - IPoolAddressesProvider provider, - uint256[] memory eModes - ) external view returns (DataTypes.EModeCategory[] memory) { + function getEModes(IPoolAddressesProvider provider) external view returns (Emode[] memory) { IPool pool = IPool(provider.getPool()); - DataTypes.EModeCategory[] memory categories = new DataTypes.EModeCategory[](eModes.length); - for (uint8 i = 0; i < eModes.length; i++) { - categories[i] = pool.getEModeCategoryData(uint8(eModes[i])); + Emode[] memory tempCategories = new Emode[](256); + uint8 eModesFound = 0; + uint8 missCounter = 0; + for (uint8 i = 1; i < 256; i++) { + DataTypes.EModeCategory memory category = pool.getEModeCategoryData(uint8(i)); + if (category.liquidationThreshold != 0) { + tempCategories[eModesFound] = Emode({eMode: category, id: i}); + ++eModesFound; + missCounter = 0; + } else { + ++missCounter; + } + // assumes there will never be a gap > 2 when setting eModes + if (++missCounter > 2) break; + } + Emode[] memory categories = new Emode[](eModesFound); + for (uint8 i = 0; i < eModesFound; i++) { + categories[i] = tempCategories[i]; } return categories; } diff --git a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index 31433522..f104d047 100644 --- a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.10; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; +import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; interface IUiPoolDataProviderV3 { struct InterestRates { @@ -89,6 +90,11 @@ interface IUiPoolDataProviderV3 { uint8 networkBaseTokenPriceDecimals; } + struct Emode { + uint8 id; + DataTypes.EModeCategory eMode; + } + function getReservesList( IPoolAddressesProvider provider ) external view returns (address[] memory); diff --git a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol index 5472972e..b5d0f0c2 100644 --- a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol @@ -25,7 +25,6 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SUPPLY_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant LIQUIDATION_PROTOCOL_FEE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore - uint256 internal constant DEPRECATED_EMODE_CATEGORY_MASK = 0xFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant UNBACKED_MINT_CAP_MASK = 0xFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant DEBT_CEILING_MASK = 0xF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant VIRTUAL_ACC_ACTIVE_MASK = 0xEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore @@ -45,7 +44,6 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_START_BIT_POSITION = 80; uint256 internal constant SUPPLY_CAP_START_BIT_POSITION = 116; uint256 internal constant LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION = 152; - // uint256 internal constant DEPRECATED_EMODE_CATEGORY_START_BIT_POSITION = 168; uint256 internal constant UNBACKED_MINT_CAP_START_BIT_POSITION = 176; uint256 internal constant DEBT_CEILING_START_BIT_POSITION = 212; uint256 internal constant VIRTUAL_ACC_START_BIT_POSITION = 252; @@ -58,7 +56,6 @@ library ReserveConfiguration { uint256 internal constant MAX_VALID_BORROW_CAP = 68719476735; uint256 internal constant MAX_VALID_SUPPLY_CAP = 68719476735; uint256 internal constant MAX_VALID_LIQUIDATION_PROTOCOL_FEE = 65535; - // uint256 internal constant DEPRECATED_MAX_VALID_EMODE_CATEGORY = 255; uint256 internal constant MAX_VALID_UNBACKED_MINT_CAP = 68719476735; uint256 internal constant MAX_VALID_DEBT_CEILING = 1099511627775; From 73e83a41ef20082e64ed97577ec467f9e745c580 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 12:35:29 +0200 Subject: [PATCH 40/88] fix: lint code --- docs/gas-diff.md | 208 +++++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/docs/gas-diff.md b/docs/gas-diff.md index 2a3f8254..2f4aa2e7 100644 --- a/docs/gas-diff.md +++ b/docs/gas-diff.md @@ -57,8 +57,8 @@ index 0dec812..9ce5779 100644 | transfer | 101595 | 101595 | 101595 | 101595 | 1 | -| withdraw | 239849 | 239849 | 239849 | 239849 | 1 | +| withdraw | 239959 | 239959 | 239959 | 239959 | 1 | - - + + | src/contracts/dependencies/weth/WETH9.sol:WETH9 contract | | | | | | @@ -66,9 +66,9 @@ | 546391 | 2423 | | | | | @@ -71,16 +71,16 @@ index 0dec812..9ce5779 100644 +| balanceOf | 541 | 989 | 541 | 2541 | 9205 | +| decimals | 2313 | 2313 | 2313 | 2313 | 632 | | symbol | 1213 | 2250 | 3213 | 3213 | 27 | - - + + @@ -91,7 +91,7 @@ | 2050064 | 10159 | | | | | | Function Name | min | avg | median | max | # calls | | owner | 386 | 386 | 386 | 386 | 1 | -| swapAndDeposit | 352192 | 443390 | 475524 | 502455 | 3 | +| swapAndDeposit | 352280 | 443455 | 475577 | 502508 | 3 | - - + + | src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol:ParaSwapRepayAdapter contract | | | | | | @@ -101,7 +101,7 @@ | Function Name | min | avg | median | max | # calls | @@ -88,8 +88,8 @@ index 0dec812..9ce5779 100644 | rescueTokens | 36133 | 36133 | 36133 | 36133 | 1 | -| swapAndRepay | 405121 | 515303 | 535881 | 584329 | 4 | +| swapAndRepay | 404879 | 515029 | 535596 | 584044 | 4 | - - + + | src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol:ParaSwapWithdrawSwapAdapter contract | | | | | | @@ -110,7 +110,7 @@ | 1757703 | 8731 | | | | | @@ -97,8 +97,8 @@ index 0dec812..9ce5779 100644 | owner | 408 | 408 | 408 | 408 | 1 | -| withdrawAndSwap | 352139 | 378370 | 371176 | 411796 | 3 | +| withdrawAndSwap | 352227 | 378435 | 371229 | 411849 | 3 | - - + + | src/contracts/extensions/static-a-token/StataOracle.sol:StataOracle contract | | | | | | @@ -118,8 +118,8 @@ | Deployment Cost | Deployment Size | | | | | @@ -108,8 +108,8 @@ index 0dec812..9ce5779 100644 -| getAssetsPrices | 87496 | 87496 | 87496 | 87496 | 1 | +| getAssetPrice | 14814 | 14899 | 14814 | 36814 | 257 | +| getAssetsPrices | 87562 | 87562 | 87562 | 87562 | 1 | - - + + | src/contracts/extensions/static-a-token/StaticATokenFactory.sol:StaticATokenFactory contract | | | | | | @@ -128,10 +128,10 @@ | 0 | 0 | | | | | @@ -121,8 +121,8 @@ index 0dec812..9ce5779 100644 | getStaticATokens | 9587 | 9587 | 9587 | 9587 | 2 | -| initialize | 24131 | 24131 | 24131 | 24131 | 624 | +| initialize | 24131 | 24131 | 24131 | 24131 | 620 | - - + + | src/contracts/extensions/static-a-token/StaticATokenLM.sol:StaticATokenLM contract | | | | | | @@ -153,35 +153,35 @@ | claimRewardsOnBehalf | 12204 | 12204 | 12204 | 12204 | 1 | @@ -175,8 +175,8 @@ index 0dec812..9ce5779 100644 | transfer | 72662 | 72662 | 72662 | 72662 | 1 | -| withdraw | 224942 | 224942 | 224942 | 224942 | 1 | +| withdraw | 225052 | 225052 | 225052 | 225052 | 1 | - - + + | src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol:AaveV3ConfigEngine contract | | | | | | @@ -189,16 +189,16 @@ | Deployment Cost | Deployment Size | | | | | @@ -202,8 +202,8 @@ index 0dec812..9ce5779 100644 +| updateEModeCategories | 10592 | 51848 | 29691 | 104184 | 5 | +| updatePriceFeeds | 39360 | 39360 | 39360 | 39360 | 1 | +| updateRateStrategies | 122202 | 122202 | 122202 | 122202 | 1 | - - + + | src/contracts/helpers/AaveProtocolDataProvider.sol:AaveProtocolDataProvider contract | | | | | | @@ -206,22 +206,21 @@ | Deployment Cost | Deployment Size | | | | | @@ -236,8 +236,8 @@ index 0dec812..9ce5779 100644 -| getUserReserveData | 18944 | 26800 | 27034 | 43944 | 1302 | +| getTotalDebt | 51890 | 51890 | 51890 | 51890 | 3 | +| getUserReserveData | 18988 | 26798 | 27013 | 43988 | 1301 | - - + + | src/contracts/helpers/L2Encoder.sol:L2Encoder contract | | | | | | @@ -229,15 +228,15 @@ | Deployment Cost | Deployment Size | | | | | @@ -261,8 +261,8 @@ index 0dec812..9ce5779 100644 +| encodeSupplyParams | 34807 | 34807 | 34807 | 34807 | 7 | +| encodeSupplyWithPermitParams | 35166 | 35166 | 35166 | 35166 | 256 | +| encodeWithdrawParams | 7647 | 7681 | 7681 | 7715 | 2 | - - + + | src/contracts/helpers/WrappedTokenGatewayV3.sol:WrappedTokenGatewayV3 contract | | | | | | @@ -245,16 +244,16 @@ | Deployment Cost | Deployment Size | | | | | @@ -282,8 +282,8 @@ index 0dec812..9ce5779 100644 +| repayETH | 175668 | 179676 | 177558 | 187389 | 5 | +| withdrawETH | 231328 | 235398 | 235398 | 239469 | 2 | +| withdrawETHWithPermit | 275613 | 278496 | 278496 | 281379 | 2 | - - + + | src/contracts/instances/ATokenInstance.sol:ATokenInstance contract | | | | | | @@ -264,35 +263,35 @@ | Function Name | min | avg | median | max | # calls | @@ -335,8 +335,8 @@ index 0dec812..9ce5779 100644 +| transferFrom | 87646 | 120962 | 130265 | 145587 | 43 | +| transferOnLiquidation | 988 | 30267 | 37548 | 44348 | 1806 | +| transferUnderlyingTo | 802 | 19862 | 16500 | 33639 | 2959 | - - + + | src/contracts/instances/L2PoolInstance.sol:L2PoolInstance contract | | | | | | @@ -302,154 +301,155 @@ | Function Name | min | avg | median | max | # calls | @@ -428,8 +428,8 @@ index 0dec812..9ce5779 100644 +| updateBridgeProtocolFee | 6262 | 6262 | 6262 | 6262 | 256 | +| updateFlashloanPremiums | 1771 | 8165 | 6444 | 21671 | 380 | +| withdraw | 126619 | 129061 | 129061 | 131504 | 2 | - - + + | src/contracts/instances/PoolConfiguratorInstance.sol:PoolConfiguratorInstance contract | | | | | | |----------------------------------------------------------------------------------------|-----------------|----------|---------|-----------|---------| | Deployment Cost | Deployment Size | | | | | @@ -503,8 +503,8 @@ index 0dec812..9ce5779 100644 +| updateFlashloanPremiumToProtocol | 10205 | 11353 | 10205 | 37005 | 903 | +| updateFlashloanPremiumTotal | 14091 | 26958 | 32070 | 36970 | 903 | +| updateVariableDebtToken | 14075 | 14531 | 14075 | 131490 | 257 | - - + + | src/contracts/instances/PoolInstance.sol:PoolInstance contract | | | | | | |----------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -618,8 +618,8 @@ index 0dec812..9ce5779 100644 +| updateBridgeProtocolFee | 6217 | 7047 | 6217 | 23397 | 269 | +| updateFlashloanPremiums | 1726 | 10720 | 6399 | 21626 | 1424 | +| withdraw | 39251 | 105523 | 87824 | 177740 | 51 | - - + + | src/contracts/instances/VariableDebtTokenInstance.sol:VariableDebtTokenInstance contract | | | | | | @@ -457,22 +457,22 @@ | Deployment Cost | Deployment Size | | | | | @@ -653,8 +653,8 @@ index 0dec812..9ce5779 100644 +| scaledTotalSupply | 419 | 2116 | 2419 | 2419 | 19469 | +| symbol | 1030 | 1440 | 1347 | 3285 | 9452 | +| totalSupply | 4014 | 7523 | 6416 | 19014 | 15 | - - + + | src/contracts/misc/AaveOracle.sol:AaveOracle contract | | | | | | @@ -482,10 +482,10 @@ | Function Name | min | avg | median | max | # calls | @@ -668,7 +668,7 @@ index 0dec812..9ce5779 100644 +| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1139 | | setAssetSources | 37348 | 52896 | 61947 | 62187 | 9 | | setFallbackOracle | 59544 | 59544 | 59544 | 59544 | 4 | - + @@ -499,7 +499,7 @@ | MAX_BORROW_RATE | 240 | 240 | 240 | 240 | 5382 | | MAX_OPTIMAL_POINT | 262 | 262 | 262 | 262 | 6918 | @@ -685,8 +685,8 @@ index 0dec812..9ce5779 100644 -| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29729 | 29075 | 36816 | 2816 | +| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28290 | 29729 | 29075 | 36804 | 2816 | | setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | - - + + @@ -530,26 +530,26 @@ | Deployment Cost | Deployment Size | | | | | | 465623 | 2115 | | | | | @@ -937,8 +937,8 @@ index 0dec812..9ce5779 100644 -| withdraw(bytes32) | 138782 | 145861 | 145861 | 152941 | 2 | +| withdraw(address,uint256,address) | 66362 | 134766 | 141986 | 204851 | 23 | +| withdraw(bytes32) | 138804 | 145883 | 145883 | 152963 | 2 | - - + + | src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol:MockFlashLoanReceiver contract | | | | | | @@ -703,9 +704,9 @@ | src/contracts/mocks/helpers/MockPool.sol:MockPoolInherited contract | | | | | | @@ -949,8 +949,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| initialize | 28462 | 28462 | 28462 | 28462 | 2 | +| initialize | 28397 | 28397 | 28397 | 28397 | 2 | - - + + | src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol:MockAggregator contract | | | | | | @@ -713,10 +714,10 @@ | Deployment Cost | Deployment Size | | | | | @@ -963,8 +963,8 @@ index 0dec812..9ce5779 100644 -| latestAnswer | 281 | 1395 | 2281 | 2281 | 24197 | +| latestAnswer | 281 | 1396 | 2281 | 2281 | 26529 | | name | 170 | 170 | 170 | 170 | 83 | - - + + @@ -732,10 +733,10 @@ | src/contracts/mocks/oracle/SequencerOracle.sol:SequencerOracle contract | | | | | | |-------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| @@ -975,8 +975,8 @@ index 0dec812..9ce5779 100644 | latestRoundData | 730 | 1533 | 735 | 4735 | 10 | -| setAnswer | 26207 | 27452 | 26207 | 46119 | 73 | +| setAnswer | 26207 | 27469 | 26207 | 46119 | 72 | - - + + | src/contracts/mocks/swap/MockParaSwapAugustus.sol:MockParaSwapAugustus contract | | | | | | @@ -773,13 +774,13 @@ | Function Name | min | avg | median | max | # calls | @@ -1008,8 +1008,8 @@ index 0dec812..9ce5779 100644 | percentDiv | 321 | 426 | 432 | 432 | 259 | -| percentMul | 338 | 411 | 435 | 435 | 259 | +| percentMul | 338 | 402 | 435 | 435 | 259 | - - + + | src/contracts/mocks/tests/WadRayMathWrapper.sol:WadRayMathWrapper contract | | | | | | @@ -813,16 +814,16 @@ | 233882 | 871 | | | | | @@ -1030,8 +1030,8 @@ index 0dec812..9ce5779 100644 -| wadToRay | 284 | 355 | 360 | 360 | 485 | +| wadMul | 338 | 406 | 435 | 435 | 262 | +| wadToRay | 284 | 355 | 360 | 360 | 488 | - - + + | src/contracts/mocks/tokens/MockATokenRepayment.sol:MockATokenRepayment contract | | | | | | @@ -907,23 +908,23 @@ | Deployment Cost | Deployment Size | | | | | @@ -1098,7 +1098,7 @@ index 0dec812..9ce5779 100644 +| setPoolImpl | 24060 | 279024 | 287080 | 517876 | 4 | | setPriceOracle | 24083 | 37511 | 39138 | 47688 | 4 | | setPriceOracleSentinel | 24126 | 40946 | 47731 | 47731 | 6 | - + @@ -968,7 +969,7 @@ | getAddressesProviderAddressById | 522 | 522 | 522 | 522 | 4 | | getAddressesProviderIdByAddress | 559 | 1225 | 559 | 2559 | 6 | @@ -1107,7 +1107,7 @@ index 0dec812..9ce5779 100644 +| owner | 331 | 2327 | 2331 | 2331 | 646 | | registerAddressesProvider | 24444 | 104012 | 119926 | 119926 | 6 | | unregisterAddressesProvider | 26448 | 39029 | 40004 | 49662 | 4 | - + @@ -996,7 +997,7 @@ | Deployment Cost | Deployment Size | | | | | | 3183382 | 14716 | | | | | @@ -1134,8 +1134,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| initialize | 90684 | 90684 | 90684 | 90684 | 674 | +| initialize | 90684 | 90684 | 90684 | 90684 | 670 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol:AaveV3GettersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | @@ -1144,8 +1144,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getGettersReportOne | 971 | 971 | 971 | 971 | 672 | +| getGettersReportOne | 971 | 971 | 971 | 971 | 668 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol:AaveV3GettersBatchTwo contract | | | | | | @@ -1071,15 +1072,15 @@ | Deployment Cost | Deployment Size | | | | | @@ -1153,8 +1153,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getGettersReportTwo | 535 | 535 | 535 | 535 | 647 | +| getGettersReportTwo | 535 | 535 | 535 | 535 | 643 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol:AaveV3HelpersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|------|--------|------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1163,8 +1163,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 622 | +| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 618 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol:AaveV3HelpersBatchTwo contract | | | | | | @@ -1087,15 +1088,15 @@ | Deployment Cost | Deployment Size | | | | | @@ -1172,8 +1172,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| staticATokenReport | 971 | 971 | 971 | 971 | 622 | +| staticATokenReport | 971 | 971 | 971 | 971 | 618 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol:AaveV3L2PoolBatch contract | | | | | | |---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | @@ -1182,8 +1182,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getPoolReport | 535 | 535 | 535 | 535 | 672 | +| getPoolReport | 535 | 535 | 535 | 535 | 668 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol:AaveV3MiscBatch contract | | | | | | @@ -1103,7 +1104,7 @@ | Deployment Cost | Deployment Size | | | | | @@ -1191,8 +1191,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getMiscReport | 535 | 535 | 535 | 535 | 672 | +| getMiscReport | 535 | 535 | 535 | 535 | 668 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol:AaveV3ParaswapBatch contract | | | | | | @@ -1119,7 +1120,7 @@ | Deployment Cost | Deployment Size | | | | | @@ -1200,8 +1200,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 672 | +| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 668 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol:AaveV3SetupBatch contract | | | | | | @@ -1127,9 +1128,9 @@ | Deployment Cost | Deployment Size | | | | | @@ -1213,8 +1213,8 @@ index 0dec812..9ce5779 100644 +| getInitialReport | 554 | 554 | 554 | 554 | 668 | +| setMarketReport | 632455 | 634834 | 632455 | 773435 | 618 | +| setupAaveV3Market | 2709798 | 2710433 | 2709798 | 2735948 | 645 | - - + + | src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol:AaveV3TokensBatch contract | | | | | | @@ -1137,53 +1138,53 @@ | Deployment Cost | Deployment Size | | | | | @@ -1222,8 +1222,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getTokensReport | 535 | 535 | 535 | 535 | 647 | +| getTokensReport | 535 | 535 | 535 | 535 | 643 | - - + + -| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | -|------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| -| Deployment Cost | Deployment Size | | | | | @@ -1236,8 +1236,8 @@ index 0dec812..9ce5779 100644 +| 747109 | 3465 | | | | | +| Function Name | min | avg | median | max | # calls | +| execute | 118935 | 118935 | 118935 | 118935 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol:AaveV3MockBorrowUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1246,8 +1246,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 159425 | 159425 | 159425 | 159425 | 1 | +| execute | 159601 | 159601 | 159601 | 159601 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol:AaveV3MockBorrowUpdateNoChange contract | | | | | | |--------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1256,8 +1256,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 47089 | 47089 | 47089 | 47089 | 1 | +| execute | 47111 | 47111 | 47111 | 47111 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol:AaveV3MockCapUpdate contract | | | | | | |----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1266,8 +1266,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 86135 | 86135 | 86135 | 86135 | 1 | +| execute | 86134 | 86134 | 86134 | 86134 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol:AaveV3MockCollateralUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1276,8 +1276,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | +| execute | 89745 | 89745 | 89745 | 89745 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol:AaveV3MockCollateralUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1285,7 +1285,7 @@ index 0dec812..9ce5779 100644 +| 783009 | 3632 | | | | | | Function Name | min | avg | median | max | # calls | | execute | 35916 | 35916 | 35916 | 35916 | 2 | - + @@ -1191,15 +1192,15 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateCorrectBonus contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| @@ -1295,8 +1295,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | +| execute | 89745 | 89745 | 89745 | 89745 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateWrongBonus contract | | | | | | |--------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1304,7 +1304,7 @@ index 0dec812..9ce5779 100644 +| 777483 | 3606 | | | | | | Function Name | min | avg | median | max | # calls | | execute | 35332 | 35332 | 35332 | 35332 | 1 | - + @@ -1207,59 +1208,59 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| @@ -1314,8 +1314,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 155461 | 155461 | 155461 | 155461 | 2 | +| execute | 131198 | 131198 | 131198 | 131198 | 2 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdateEdgeBonus contract | | | | | | |---------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1324,8 +1324,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 53964 | 53964 | 53964 | 53964 | 1 | +| execute | 56384 | 56384 | 56384 | 56384 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol:AaveV3MockEModeCategoryUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1334,8 +1334,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 38497 | 38497 | 38497 | 38497 | 2 | +| execute | 37835 | 37835 | 37835 | 37835 | 2 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol:AaveV3MockListing contract | | | | | | |------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1345,8 +1345,8 @@ index 0dec812..9ce5779 100644 -| execute | 1836009 | 1836009 | 1836009 | 1836009 | 1 | +| execute | 1823723 | 1823723 | 1823723 | 1823723 | 1 | | newListings | 2820 | 2820 | 2820 | 2820 | 4 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol:AaveV3MockListingCustom contract | | | | | | |------------------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1356,8 +1356,8 @@ index 0dec812..9ce5779 100644 -| execute | 1835953 | 1835953 | 1835953 | 1835953 | 1 | +| execute | 1823667 | 1823667 | 1823667 | 1823667 | 1 | | newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol:AaveV3MockPriceFeedUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1366,8 +1366,8 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| execute | 65371 | 65371 | 65371 | 65371 | 1 | +| execute | 65393 | 65393 | 65393 | 65393 | 1 | - - + + | tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol:AaveV3MockRatesUpdate contract | | | | | | |--------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | @@ -1377,8 +1377,8 @@ index 0dec812..9ce5779 100644 -| execute | 148663 | 148663 | 148663 | 148663 | 1 | +| execute | 148773 | 148773 | 148773 | 148773 | 1 | | rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | - - + + @@ -1273,15 +1274,15 @@ | UNDERLYING_ASSET_ADDRESS | 376 | 1200 | 376 | 2376 | 4354 | | allowance | 909 | 909 | 909 | 909 | 1 | @@ -1413,13 +1413,13 @@ index 0dec812..9ce5779 100644 +| USDX_ADDRESS | 294 | 294 | 294 | 294 | 613 | +| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 613 | +| execute | 5190851 | 5193099 | 5193290 | 5193290 | 615 | - - + + | tests/mocks/AugustusRegistryMock.sol:AugustusRegistryMock contract | | | | | | @@ -1332,4 +1333,4 @@ - - - + + + -Ran 56 test suites in 75.93s (123.90s CPU time): 694 tests passed, 0 failed, 0 skipped (694 total tests) +Ran 57 test suites in 74.55s (146.31s CPU time): 690 tests passed, 0 failed, 0 skipped (690 total tests) ``` From 294dfef74932380378bd7ddc39faf23df15cbe19 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 14:48:33 +0200 Subject: [PATCH 41/88] feat: config engine refactor --- .../v3-config-engine/AaveV3ConfigEngine.sol | 15 ++++++-- .../v3-config-engine/AaveV3Payload.sol | 30 +++++++++++++--- .../v3-config-engine/IAaveV3ConfigEngine.sol | 35 ++++++++++++++---- .../libraries/EModeEngine.sol | 36 ++++++++++++++----- .../libraries/ListingEngine.sol | 18 ---------- .../mocks/AaveV3MockAssetEModeUpdate.sol | 15 ++++++-- .../mocks/AaveV3MockListing.sol | 3 +- .../mocks/AaveV3MockListingCustom.sol | 3 +- tests/mocks/AaveV3TestListing.sol | 9 ++--- 9 files changed, 111 insertions(+), 53 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol index 3c9df057..0331bfbd 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol @@ -187,10 +187,21 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { } /// @inheritdoc IAaveV3ConfigEngine - function updateAssetsEMode(AssetEModeUpdate[] calldata updates) external { + function updateEModeCollaterals(EModeCollateralUpdate[] calldata updates) external { EMODE_ENGINE.functionDelegateCall( abi.encodeWithSelector( - EModeEngine.executeAssetsEModeUpdate.selector, + EModeEngine.executeEModeCollateralUpdate.selector, + _getEngineConstants(), + updates + ) + ); + } + + /// @inheritdoc IAaveV3ConfigEngine + function updateEModeBorrowables(EModeBorrowableUpdate[] calldata updates) external { + EMODE_ENGINE.functionDelegateCall( + abi.encodeWithSelector( + EModeEngine.executeEModeBorrowableUpdate.selector, _getEngineConstants(), updates ) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol index 9e927ad8..bdaa17c6 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol @@ -49,7 +49,8 @@ abstract contract AaveV3Payload { IEngine.BorrowUpdate[] memory borrows = borrowsUpdates(); IEngine.RateStrategyUpdate[] memory rates = rateStrategiesUpdates(); IEngine.PriceFeedUpdate[] memory priceFeeds = priceFeedsUpdates(); - IEngine.AssetEModeUpdate[] memory assetsEMode = assetsEModeUpdates(); + IEngine.EModeCollateralUpdate[] memory eModeCollaterals = eModeCollateralUpdates(); + IEngine.EModeBorrowableUpdate[] memory eModeBorrowables = eModeBorrowableUpdates(); IEngine.CapsUpdate[] memory caps = capsUpdates(); if (eModeCategories.length != 0) { @@ -98,9 +99,15 @@ abstract contract AaveV3Payload { ); } - if (assetsEMode.length != 0) { + if (eModeCollaterals.length != 0) { address(CONFIG_ENGINE).functionDelegateCall( - abi.encodeWithSelector(CONFIG_ENGINE.updateAssetsEMode.selector, assetsEMode) + abi.encodeWithSelector(CONFIG_ENGINE.updateEModeCollaterals.selector, eModeCollaterals) + ); + } + + if (eModeBorrowables.length != 0) { + address(CONFIG_ENGINE).functionDelegateCall( + abi.encodeWithSelector(CONFIG_ENGINE.updateEModeBorrowables.selector, eModeBorrowables) ); } @@ -151,8 +158,21 @@ abstract contract AaveV3Payload { returns (IEngine.EModeCategoryUpdate[] memory) {} - /// @dev to be defined in the child with a list of assets for which eMode categories to update - function assetsEModeUpdates() public view virtual returns (IEngine.AssetEModeUpdate[] memory) {} + /// @dev to be defined in the child with a list of assets for which eMode collateral to update + function eModeCollateralUpdates() + public + view + virtual + returns (IEngine.EModeCollateralUpdate[] memory) + {} + + /// @dev to be defined in the child with a list of assets for which eMode borrowable to update + function eModeBorrowableUpdates() + public + view + virtual + returns (IEngine.EModeBorrowableUpdate[] memory) + {} /// @dev to be defined in the child with a list of set of parameters of rate strategies function rateStrategiesUpdates() diff --git a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index e6844f52..d716cf9a 100644 --- a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -97,7 +97,6 @@ interface IAaveV3ConfigEngine { uint256 borrowCap; // If passing any value distinct to EngineFlags.KEEP_CURRENT, always configured uint256 debtCeiling; // Only considered if liqThreshold > 0 uint256 liqProtocolFee; // Only considered if liqThreshold > 0 - uint8 eModeCategory; // If `O`, no eMode category will be set } struct RepackedListings { @@ -106,7 +105,6 @@ interface IAaveV3ConfigEngine { BorrowUpdate[] borrowsUpdates; CollateralUpdate[] collateralsUpdates; PriceFeedUpdate[] priceFeedsUpdates; - AssetEModeUpdate[] assetsEModeUpdates; CapsUpdate[] capsUpdates; IDefaultInterestRateStrategyV2.InterestRateData[] rates; } @@ -189,14 +187,30 @@ interface IAaveV3ConfigEngine { /** * @dev Example (mock): - * AssetEModeUpdate({ + * EModeCollateralUpdate({ * asset: AaveV3EthereumAssets.rETH_UNDERLYING, * eModeCategory: 1, // ETH correlated + * enabled: true, * }) */ - struct AssetEModeUpdate { + struct EModeCollateralUpdate { address asset; uint8 eModeCategory; + bool enabled; + } + + /** + * @dev Example (mock): + * EModeBorrowableUpdate({ + * asset: AaveV3EthereumAssets.rETH_UNDERLYING, + * eModeCategory: 1, // ETH correlated + * enabled: true, + * }) + */ + struct EModeBorrowableUpdate { + address asset; + uint8 eModeCategory; + bool enabled; } /** @@ -301,11 +315,18 @@ interface IAaveV3ConfigEngine { function updateEModeCategories(EModeCategoryUpdate[] memory updates) external; /** - * @notice Performs an update of the e-mode category of the assets, in the Aave pool configured in this engine instance - * @param updates `AssetEModeUpdate[]` list of declarative updates containing the new parameters + * @notice Performs an update of the e-mode category collateral, in the Aave pool configured in this engine instance + * @param updates `EModeCollateralUpdate[]` list of declarative updates containing the new parameters + * More information on the documentation of the struct. + */ + function updateEModeCollaterals(EModeCollateralUpdate[] memory updates) external; + + /** + * @notice Performs an update of the e-mode category borrowable, in the Aave pool configured in this engine instance + * @param updates `EModeCollateralUpdate[]` list of declarative updates containing the new parameters * More information on the documentation of the struct. */ - function updateAssetsEMode(AssetEModeUpdate[] calldata updates) external; + function updateEModeBorrowables(EModeBorrowableUpdate[] memory updates) external; function DEFAULT_INTEREST_RATE_STRATEGY() external view returns (address); diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index ee92da30..ea3d8901 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -11,13 +11,22 @@ library EModeEngine { using PercentageMath for uint256; using SafeCast for uint256; - function executeAssetsEModeUpdate( + function executeEModeCollateralUpdate( IEngine.EngineConstants calldata engineConstants, - IEngine.AssetEModeUpdate[] memory updates + IEngine.EModeCollateralUpdate[] memory updates ) external { require(updates.length != 0, 'AT_LEAST_ONE_UPDATE_REQUIRED'); - _configAssetsEMode(engineConstants.poolConfigurator, updates); + _configEModeCollateral(engineConstants.poolConfigurator, updates); + } + + function executeEModeBorrowableUpdate( + IEngine.EngineConstants calldata engineConstants, + IEngine.EModeBorrowableUpdate[] memory updates + ) external { + require(updates.length != 0, 'AT_LEAST_ONE_UPDATE_REQUIRED'); + + _configEModeBorrowable(engineConstants.poolConfigurator, updates); } function executeEModeCategoriesUpdate( @@ -29,18 +38,29 @@ library EModeEngine { _configEModeCategories(engineConstants.poolConfigurator, engineConstants.pool, updates); } - function _configAssetsEMode( + function _configEModeCollateral( IPoolConfigurator poolConfigurator, - IEngine.AssetEModeUpdate[] memory updates + IEngine.EModeCollateralUpdate[] memory updates ) internal { for (uint256 i = 0; i < updates.length; i++) { - if (updates[i].eModeCategory != 0 && updates[i].eModeCategory != EngineFlags.KEEP_CURRENT) { poolConfigurator.setAssetCollateralInEMode( updates[i].asset, updates[i].eModeCategory, - true + updates[i].enabled + ); + } + } + + function _configEModeBorrowable( + IPoolConfigurator poolConfigurator, + IEngine.EModeBorrowableUpdate[] memory updates + ) internal { + for (uint256 i = 0; i < updates.length; i++) { + poolConfigurator.setAssetBorrowableInEMode( + updates[i].asset, + updates[i].eModeCategory, + updates[i].enabled ); - } } } diff --git a/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol index ad3277e1..29d98807 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/ListingEngine.sol @@ -67,16 +67,6 @@ library ListingEngine { repacked.collateralsUpdates ) ); - - // For an asset listing we only update the e-mode category id for the asset and do not make changes - // to the e-mode category configuration - engineLibraries.eModeEngine.functionDelegateCall( - abi.encodeWithSelector( - EModeEngine.executeAssetsEModeUpdate.selector, - engineConstants, - repacked.assetsEModeUpdates - ) - ); } function _repackListing( @@ -90,9 +80,6 @@ library ListingEngine { IEngine.PriceFeedUpdate[] memory priceFeedsUpdates = new IEngine.PriceFeedUpdate[]( listings.length ); - IEngine.AssetEModeUpdate[] memory assetsEModeUpdates = new IEngine.AssetEModeUpdate[]( - listings.length - ); IEngine.CapsUpdate[] memory capsUpdates = new IEngine.CapsUpdate[](listings.length); IEngine.Basic[] memory basics = new IEngine.Basic[](listings.length); @@ -141,10 +128,6 @@ library ListingEngine { variableRateSlope1: listings[i].base.rateStrategyParams.variableRateSlope1.toUint32(), variableRateSlope2: listings[i].base.rateStrategyParams.variableRateSlope2.toUint32() }); - assetsEModeUpdates[i] = IEngine.AssetEModeUpdate({ - asset: listings[i].base.asset, - eModeCategory: listings[i].base.eModeCategory - }); } return @@ -154,7 +137,6 @@ library ListingEngine { borrowsUpdates, collateralsUpdates, priceFeedsUpdates, - assetsEModeUpdates, capsUpdates, rates ); diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol index 5e2d45ac..4e047fff 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol @@ -15,10 +15,19 @@ contract AaveV3MockAssetEModeUpdate is AaveV3Payload { ASSET_ADDRESS = assetAddress; } - function assetsEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { - IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](1); + function eModeCollateralUpdates() + public + view + override + returns (IEngine.EModeCollateralUpdate[] memory) + { + IEngine.EModeCollateralUpdate[] memory eModeUpdate = new IEngine.EModeCollateralUpdate[](1); - eModeUpdate[0] = IEngine.AssetEModeUpdate({asset: ASSET_ADDRESS, eModeCategory: 1}); + eModeUpdate[0] = IEngine.EModeCollateralUpdate({ + asset: ASSET_ADDRESS, + eModeCategory: 1, + enabled: true + }); return eModeUpdate; } diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol index 5028a481..9d28030a 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol @@ -46,8 +46,7 @@ contract AaveV3MockListing is AaveV3Payload { supplyCap: 85_000, borrowCap: 60_000, debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 + liqProtocolFee: 10_00 }); return listings; diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol index 01fbbf91..4b7d6383 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol @@ -58,8 +58,7 @@ contract AaveV3MockListingCustom is AaveV3Payload { supplyCap: 85_000, borrowCap: 60_000, debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 + liqProtocolFee: 10_00 }), IEngine.TokenImplementations({aToken: A_TOKEN_IMPL, vToken: V_TOKEN_IMPL}) ); diff --git a/tests/mocks/AaveV3TestListing.sol b/tests/mocks/AaveV3TestListing.sol index d5f6b30c..65dc9ccb 100644 --- a/tests/mocks/AaveV3TestListing.sol +++ b/tests/mocks/AaveV3TestListing.sol @@ -83,8 +83,7 @@ contract AaveV3TestListing is AaveV3Payload { supplyCap: 0, borrowCap: 0, debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 + liqProtocolFee: 10_00 }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, @@ -109,8 +108,7 @@ contract AaveV3TestListing is AaveV3Payload { supplyCap: 0, borrowCap: 0, debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 + liqProtocolFee: 10_00 }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, @@ -135,8 +133,7 @@ contract AaveV3TestListing is AaveV3Payload { supplyCap: 0, borrowCap: 0, debtCeiling: 0, - liqProtocolFee: 10_00, - eModeCategory: 0 + liqProtocolFee: 10_00 }), IEngine.TokenImplementations({ aToken: ATOKEN_IMPLEMENTATION, From b24f5e75ca8faf18fb327849ddcc4debf4d68573 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 18:14:17 +0200 Subject: [PATCH 42/88] fix: refactor testbase --- .../libraries/EModeEngine.sol | 20 ++++----- .../configuration/EModeConfiguration.sol | 18 +++----- .../protocol/libraries/logic/GenericLogic.sol | 5 ++- .../libraries/logic/LiquidationLogic.sol | 7 +++- .../libraries/logic/ValidationLogic.sol | 10 ++++- .../PoolConfigurator.eMode.sol | 25 +++++------ tests/utils/ProtocolV3TestBase.sol | 41 ++++++++----------- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index ea3d8901..a279cd35 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -43,11 +43,11 @@ library EModeEngine { IEngine.EModeCollateralUpdate[] memory updates ) internal { for (uint256 i = 0; i < updates.length; i++) { - poolConfigurator.setAssetCollateralInEMode( - updates[i].asset, - updates[i].eModeCategory, - updates[i].enabled - ); + poolConfigurator.setAssetCollateralInEMode( + updates[i].asset, + updates[i].eModeCategory, + updates[i].enabled + ); } } @@ -56,11 +56,11 @@ library EModeEngine { IEngine.EModeBorrowableUpdate[] memory updates ) internal { for (uint256 i = 0; i < updates.length; i++) { - poolConfigurator.setAssetBorrowableInEMode( - updates[i].asset, - updates[i].eModeCategory, - updates[i].enabled - ); + poolConfigurator.setAssetBorrowableInEMode( + updates[i].asset, + updates[i].eModeCategory, + updates[i].enabled + ); } } diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index 80702c14..c4d69ca6 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -35,17 +35,14 @@ library EModeConfiguration { /** * @notice Validates if a reserve can be used as collaterl in a selected eMode - * @param self The configuration object + * @param mask The collateral mask * @param reserveIndex The index of the reserve in the bitmap * @return True if the reserve is collateral */ - function isCollateralAsset( - DataTypes.EModeCategory storage self, - uint256 reserveIndex - ) internal view returns (bool) { + function isCollateralAsset(uint128 mask, uint256 reserveIndex) internal pure returns (bool) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (self.collateralMask >> reserveIndex) & 1 != 0; + return (mask >> reserveIndex) & 1 != 0; } } @@ -73,17 +70,14 @@ library EModeConfiguration { /** * @notice Validates if a reserve can be borrowed in a selected eMode - * @param self The configuration object + * @param mask The borrowable mask * @param reserveIndex The index of the reserve in the bitmap * @return True if the reserve is borrowable */ - function isBorrowable( - DataTypes.EModeCategory storage self, - uint256 reserveIndex - ) internal view returns (bool) { + function isBorrowableAsset(uint128 mask, uint256 reserveIndex) internal pure returns (bool) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (self.borrowableMask >> reserveIndex) & 1 != 0; + return (mask >> reserveIndex) & 1 != 0; } } } diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 96f8b015..c4b2dce7 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -120,7 +120,10 @@ library GenericLogic { vars.isInEModeCategory = params.userEModeCategory != 0 && - eModeCategories[params.userEModeCategory].isCollateralAsset(vars.i); + EModeConfiguration.isCollateralAsset( + eModeCategories[params.userEModeCategory].collateralMask, + vars.i + ); if (vars.ltv != 0) { vars.avgLtv += diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index e7469e2b..049252f7 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -383,7 +383,12 @@ library LiquidationLogic { address debtPriceSource = params.debtAsset; if (params.userEModeCategory != 0) { - if (eModeCategories[params.userEModeCategory].isCollateralAsset(collateralReserve.id)) { + if ( + EModeConfiguration.isCollateralAsset( + eModeCategories[params.userEModeCategory].collateralMask, + collateralReserve.id + ) + ) { liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; } } diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 060d28d5..cd9274c6 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -210,7 +210,10 @@ library ValidationLogic { if (params.userEModeCategory != 0) { require( - eModeCategories[params.userEModeCategory].isBorrowable(reservesData[params.asset].id), + EModeConfiguration.isBorrowableAsset( + eModeCategories[params.userEModeCategory].borrowableMask, + reservesData[params.asset].id + ), Errors.NOT_BORROWABLE_IN_EMODE ); } @@ -570,7 +573,10 @@ library ValidationLogic { unchecked { for (uint256 i = 0; i < reservesCount; i++) { if (userConfig.isBorrowing(i)) { - require(eModeCategory.isBorrowable(i), Errors.NOT_BORROWABLE_IN_EMODE); + require( + EModeConfiguration.isBorrowableAsset(eModeCategory.borrowableMask, i), + Errors.NOT_BORROWABLE_IN_EMODE + ); } } } diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index ba65d340..fd914229 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -26,9 +26,6 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool allowed); event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable); - // EModeConfiguration only works with storage, so definint a temp placeholder for assertions - DataTypes.EModeCategory internal tempConfig; - function setUp() public { initTestEnvironment(); } @@ -150,11 +147,11 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetCollateralInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, input.id, true); - tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(tempConfig.isCollateralAsset(reserveData.id), true); + assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveData.id), true); } function test_addAnotherAssetCollateralInEMode() public { @@ -163,15 +160,15 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, input.id, true); - tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( tokenList.usdx ); DataTypes.ReserveDataLegacy memory reserveDataWBTC = contracts.poolProxy.getReserveData( tokenList.wbtc ); - assertEq(tempConfig.isCollateralAsset(reserveDataUSDX.id), true); - assertEq(tempConfig.isCollateralAsset(reserveDataWBTC.id), true); + assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveDataUSDX.id), true); + assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveDataWBTC.id), true); } function test_removeCollateralFromEmode() public { @@ -183,11 +180,11 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, prevCt.id, false); - tempConfig = contracts.poolProxy.getEModeCategoryData(prevCt.id); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(prevCt.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(tempConfig.isCollateralAsset(reserveData.id), false); + assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveData.id), false); } function test_setAssetBorrowableInEMode() public { @@ -197,11 +194,11 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, true); - tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(tempConfig.isBorrowable(reserveData.id), true); + assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveData.id), true); } function test_removeBorrowableFromEmode() public { @@ -211,10 +208,10 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, false); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, false); - tempConfig = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(tempConfig.isBorrowable(reserveData.id), false); + assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveData.id), false); } } diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 7bfd123f..cdbef24b 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -146,37 +146,32 @@ contract ProtocolV3TestBase is DiffUtils { ReserveConfig[] memory configs = _getReservesConfigs(pool); if (reserveConfigs) _writeReserveConfigs(path, configs, pool); if (strategyConfigs) _writeStrategyConfigs(path, configs); - if (eModeConigs) _writeEModeConfigs(path, configs, pool); + if (eModeConigs) _writeEModeConfigs(path, pool); if (poolConfigs) _writePoolConfiguration(path, pool); return configs; } - function _writeEModeConfigs( - string memory path, - ReserveConfig[] memory configs, - IPool pool - ) internal virtual { + function _writeEModeConfigs(string memory path, IPool pool) internal virtual { // keys for json stringification string memory eModesKey = 'emodes'; string memory content = '{}'; - - uint256[] memory usedCategories = new uint256[](configs.length); - // for (uint256 i = 0; i < configs.length; i++) { - // if (!_isInUint256Array(usedCategories, configs[i].eModeCategory)) { - // usedCategories[i] = configs[i].eModeCategory; - // DataTypes.EModeCategory memory category = pool.getEModeCategoryData( - // uint8(configs[i].eModeCategory) - // ); - // string memory key = vm.toString(configs[i].eModeCategory); - // vm.serializeUint(key, 'eModeCategory', configs[i].eModeCategory); - // vm.serializeString(key, 'label', category.label); - // vm.serializeUint(key, 'ltv', category.ltv); - // vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); - // string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); - // content = vm.serializeString(eModesKey, key, object); - // } - // } + uint8 emptyCounter = 0; + for (uint8 i = 0; i < 256; i++) { + DataTypes.EModeCategory memory category = pool.getEModeCategoryData(i); + if (category.liquidationThreshold == 0) { + if (++emptyCounter > 2) break; + } else { + string memory key = vm.toString(i); + vm.serializeUint(key, 'eModeCategory', i); + vm.serializeString(key, 'label', category.label); + vm.serializeUint(key, 'ltv', category.ltv); + vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); + string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); + content = vm.serializeString(eModesKey, key, object); + emptyCounter = 0; + } + } string memory output = vm.serializeString('root', 'eModes', content); vm.writeJson(output, path); } From 045e6918ab182a167c1e9c7fd8a4ce9396ae4e4d Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 27 Aug 2024 22:46:03 +0200 Subject: [PATCH 43/88] tests: improve tests --- tests/protocol/pool/Pool.EMode.sol | 77 +++++++++++++++++-- .../PoolConfigurator.eMode.sol | 17 ++++ .../PoolConfigurator.reserveRiskConfig.t.sol | 14 ++-- 3 files changed, 94 insertions(+), 14 deletions(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 6650c3c7..5e991aea 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -34,6 +34,14 @@ contract PoolEModeTests is TestnetProcedures { pool = PoolInstance(report.poolProxy); } + function test_setUserEMode_shouldRevertForNonExistingEmode() public { + vm.prank(alice); + vm.expectRevert(bytes(Errors.INCONSISTENT_EMODE_CATEGORY)); + pool.setUserEMode(1); + + assertEq(pool.getUserEMode(alice), 0); + } + function test_getUserEMode_shouldReflectEMode() public { vm.startPrank(poolAdmin); EModeCategoryInput memory ct1 = _genCategoryOne(); @@ -76,6 +84,27 @@ contract PoolEModeTests is TestnetProcedures { assertEq(assetBaseLT, baseLT); } + function test_getUserAccountData_shouldReflectMixedCollateral() public { + vm.startPrank(poolAdmin); + EModeCategoryInput memory ct1 = _genCategoryOne(); + contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct1.id, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(ct1.id); + // supply some dust so the eMode asset is the only collateral + _mintTestnetToken(tokenList.usdx, alice, 1e6); + _supplyToPool(tokenList.usdx, alice, 1e6); + // supply some non eMode asset + _mintTestnetToken(tokenList.wbtc, alice, 1e8); + _supplyToPool(tokenList.wbtc, alice, 1e8); + + (, , , uint256 realLT, uint256 realLTV, ) = contracts.poolProxy.getUserAccountData(alice); + assertLt(realLT, ct1.lt); + assertLt(realLTV, ct1.ltv); + } + function test_setUserEMode_shouldAllowSwitchingIfNoBorrows(uint8 eMode) public { uint256 AVAILABLE_EMODES = 2; EModeCategoryInput memory ct1 = _genCategoryOne(); @@ -83,10 +112,8 @@ contract PoolEModeTests is TestnetProcedures { vm.startPrank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct1.id, ct1.ltv, ct1.lt, ct1.lb, ct1.label); contracts.poolConfiguratorProxy.setEModeCategory(ct2.id, ct2.ltv, ct2.lt, ct2.lb, ct2.label); - contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct1.id, true); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.weth, ct1.id, true); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, ct2.id, true); - contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, ct2.id, true); vm.stopPrank(); eMode = uint8(bound(eMode, 0, AVAILABLE_EMODES)); @@ -167,6 +194,40 @@ contract PoolEModeTests is TestnetProcedures { pool.setUserEMode(2); } + function test_liquidations_shouldApplyEModeLBForEmodeAssets(uint104 amount) public { + amount = uint104(bound(amount, 1 ether, type(uint104).max)); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(1); + _mintTestnetToken(tokenList.usdx, alice, amount); + _supplyToPool(tokenList.usdx, alice, amount); + (uint256 totalCollateralBase, , , , , ) = contracts.poolProxy.getUserAccountData(alice); + uint256 collateralPrice = contracts.aaveOracle.getAssetPrice(tokenList.usdx); + uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); + uint256 borrowAmount = (totalCollateralBase * 1e8) / debtPrice; + _borrowArbitraryAmount(tokenList.wbtc, alice, borrowAmount); + + address liquidator = address(0x0f0f0f); + _mintTestnetToken(tokenList.wbtc, liquidator, borrowAmount); + vm.startPrank(liquidator); + IERC20(tokenList.wbtc).approve(address(contracts.poolProxy), borrowAmount); + contracts.poolProxy.liquidationCall( + tokenList.usdx, + tokenList.wbtc, + alice, + type(uint256).max, + false + ); + + + // todo: assertions based on bonus + } + function _mintTestnetToken(address erc20, address user, uint256 amount) internal { vm.prank(poolAdmin); TestnetERC20(erc20).mint(user, amount); @@ -184,10 +245,14 @@ contract PoolEModeTests is TestnetProcedures { .poolProxy .getUserAccountData(user); uint256 maxBorrowInBase = (totalCollateralBase * currentLt) / 1e4; - uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); + uint256 debtPrice = contracts.aaveOracle.getAssetPrice(erc20); uint256 borrowAmount = (maxBorrowInBase / debtPrice) * 10 ** TestnetERC20(erc20).decimals(); - _mintTestnetToken(erc20, bob, borrowAmount); // todo: better not bob - _supplyToPool(erc20, bob, borrowAmount); + _borrowArbitraryAmount(erc20, user, borrowAmount); + } + + function _borrowArbitraryAmount(address erc20, address user, uint256 amount) internal { + _mintTestnetToken(erc20, bob, amount); // todo: better not bob + _supplyToPool(erc20, bob, amount); vm.mockCall( address(contracts.aaveOracle), @@ -195,7 +260,7 @@ contract PoolEModeTests is TestnetProcedures { abi.encode(0) ); vm.prank(user); - contracts.poolProxy.borrow(erc20, borrowAmount, 2, 0, user); + contracts.poolProxy.borrow(erc20, amount, 2, 0, user); vm.clearMockedCalls(); } } diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index fd914229..226d125f 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -201,6 +201,23 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveData.id), true); } + function test_addAnotherAssetBorrowableInEMode() public { + EModeCategoryInput memory input = _genCategoryOne(); + test_setAssetBorrowableInEMode(); + + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, input.id, true); + DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + DataTypes.ReserveDataLegacy memory reserveDataWBTC = contracts.poolProxy.getReserveData( + tokenList.wbtc + ); + assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveDataUSDX.id), true); + assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveDataWBTC.id), true); + } + function test_removeBorrowableFromEmode() public { EModeCategoryInput memory input = _genCategoryOne(); test_configureEmodeCategory(); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol index 6f6bd0fd..bcd62e00 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.reserveRiskConfig.t.sol @@ -706,9 +706,7 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { } function test_setLiquidationGracePeriodReserve(uint40 gracePeriod) public { - vm.assume( - gracePeriod <= contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD() && gracePeriod != 0 - ); + gracePeriod = uint40(bound(gracePeriod, 1, contracts.poolConfiguratorProxy.MAX_GRACE_PERIOD())); address asset = tokenList.usdx; @@ -723,19 +721,19 @@ contract PoolConfiguratorReserveRiskConfigs is TestnetProcedures { assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); // reserve unpause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); + contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod); assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); assertTrue(contracts.protocolDataProvider.getPaused(asset)); // reserve pause -> pause, liquidationGracePeriod would not be set - contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod + 1); + contracts.poolConfiguratorProxy.setReservePause(asset, true, gracePeriod); assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); // reserve pause -> unpause, liquidationGracePeriod would be set vm.expectEmit(address(contracts.poolConfiguratorProxy)); - emit LiquidationGracePeriodChanged(asset, until + 1); - contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod + 1); - assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until + 1); + emit LiquidationGracePeriodChanged(asset, until); + contracts.poolConfiguratorProxy.setReservePause(asset, false, gracePeriod); + assertEq(contracts.poolProxy.getLiquidationGracePeriod(asset), until); vm.stopPrank(); } From 92c9b0cd24000a1ac9c176215100ace3c211dc87 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Wed, 28 Aug 2024 17:42:07 +0200 Subject: [PATCH 44/88] fix: push configurator patch --- src/contracts/protocol/pool/PoolConfigurator.sol | 15 +++++++-------- .../pool-configurator/PoolConfigurator.eMode.sol | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index e079dd6e..895375a6 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -398,16 +398,15 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator Errors.INVALID_EMODE_CATEGORY_PARAMS ); + DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + categoryData.ltv = ltv; + categoryData.liquidationThreshold = liquidationThreshold; + categoryData.liquidationBonus = liquidationBonus; + categoryData.label = label; + _pool.configureEModeCategory( categoryId, - DataTypes.EModeCategory({ - ltv: ltv, - liquidationThreshold: liquidationThreshold, - liquidationBonus: liquidationBonus, - label: label, - borrowableMask: 0, - collateralMask: 0 - }) + categoryData ); emit EModeCategoryAdded( categoryId, diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index 226d125f..4bee841a 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -50,6 +50,8 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { function test_updateEModeCategory() public { test_configureEmodeCategory(); EModeCategoryInput memory ct = _genCategoryOne(); + vm.prank(poolAdmin); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, 1, true); DataTypes.EModeCategory memory ogCategory = contracts.poolProxy.getEModeCategoryData(ct.id); EModeCategoryInput memory updatedCategory = EModeCategoryInput( ct.id, From 96160475aa0db77b85eb2cf663b645fb59af368c Mon Sep 17 00:00:00 2001 From: sakulstra Date: Wed, 28 Aug 2024 17:53:19 +0200 Subject: [PATCH 45/88] fix: cleanup logic --- .../libraries/logic/LiquidationLogic.sol | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 049252f7..89dcb30e 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -75,8 +75,6 @@ library LiquidationLogic { uint256 liquidationBonus; uint256 healthFactor; uint256 liquidationProtocolFeeAmount; - address collateralPriceSource; - address debtPriceSource; IAToken collateralAToken; DataTypes.ReserveCache debtReserveCache; } @@ -140,8 +138,6 @@ library LiquidationLogic { ( vars.collateralAToken, - vars.collateralPriceSource, - vars.debtPriceSource, vars.liquidationBonus ) = _getConfigurationData(eModeCategories, collateralReserve, params); @@ -154,8 +150,8 @@ library LiquidationLogic { ) = _calculateAvailableCollateralToLiquidate( collateralReserve, vars.debtReserveCache, - vars.collateralPriceSource, - vars.debtPriceSource, + params.collateralAsset, + params.debtAsset, vars.actualDebtToLiquidate, vars.userCollateralBalance, vars.liquidationBonus, @@ -367,21 +363,15 @@ library LiquidationLogic { * @param collateralReserve The data of the collateral reserve * @param params The additional parameters needed to execute the liquidation function * @return The collateral aToken - * @return The address to use as price source for the collateral - * @return The address to use as price source for the debt * @return The liquidation bonus to apply to the collateral */ function _getConfigurationData( mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, DataTypes.ReserveData storage collateralReserve, DataTypes.ExecuteLiquidationCallParams memory params - ) internal view returns (IAToken, address, address, uint256) { + ) internal view returns (IAToken, uint256) { IAToken collateralAToken = IAToken(collateralReserve.aTokenAddress); uint256 liquidationBonus = collateralReserve.configuration.getLiquidationBonus(); - - address collateralPriceSource = params.collateralAsset; - address debtPriceSource = params.debtAsset; - if (params.userEModeCategory != 0) { if ( EModeConfiguration.isCollateralAsset( @@ -393,7 +383,7 @@ library LiquidationLogic { } } - return (collateralAToken, collateralPriceSource, debtPriceSource, liquidationBonus); + return (collateralAToken, liquidationBonus); } struct AvailableCollateralToLiquidateLocalVars { From 351d3f31e5a2456094f037d5c6f28cf77a5dd6c3 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 29 Aug 2024 08:55:09 +0200 Subject: [PATCH 46/88] Update src/contracts/mocks/helpers/MockReserveConfiguration.sol Co-authored-by: Andrey --- src/contracts/mocks/helpers/MockReserveConfiguration.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/contracts/mocks/helpers/MockReserveConfiguration.sol b/src/contracts/mocks/helpers/MockReserveConfiguration.sol index ff747ee4..c0e17933 100644 --- a/src/contracts/mocks/helpers/MockReserveConfiguration.sol +++ b/src/contracts/mocks/helpers/MockReserveConfiguration.sol @@ -89,11 +89,6 @@ contract MockReserveConfiguration { return configuration.getBorrowCap(); } - // function setEModeCategory(uint256 categoryId) external { - // DataTypes.ReserveConfigurationMap memory config = configuration; - // config.setEModeCategory(categoryId); - // configuration = config; - // } function setFlashLoanEnabled(bool enabled) external { DataTypes.ReserveConfigurationMap memory config = configuration; From 99c3afce4564a561695d98ff33699a9f8731ff32 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 29 Aug 2024 08:56:26 +0200 Subject: [PATCH 47/88] fix: linting --- src/contracts/mocks/helpers/MockReserveConfiguration.sol | 1 - .../protocol/libraries/logic/LiquidationLogic.sol | 9 +++++---- src/contracts/protocol/pool/PoolConfigurator.sol | 5 +---- tests/protocol/pool/Pool.EMode.sol | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/contracts/mocks/helpers/MockReserveConfiguration.sol b/src/contracts/mocks/helpers/MockReserveConfiguration.sol index c0e17933..c5ef954c 100644 --- a/src/contracts/mocks/helpers/MockReserveConfiguration.sol +++ b/src/contracts/mocks/helpers/MockReserveConfiguration.sol @@ -89,7 +89,6 @@ contract MockReserveConfiguration { return configuration.getBorrowCap(); } - function setFlashLoanEnabled(bool enabled) external { DataTypes.ReserveConfigurationMap memory config = configuration; config.setFlashLoanEnabled(enabled); diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 89dcb30e..ee4e9980 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -136,10 +136,11 @@ library LiquidationLogic { }) ); - ( - vars.collateralAToken, - vars.liquidationBonus - ) = _getConfigurationData(eModeCategories, collateralReserve, params); + (vars.collateralAToken, vars.liquidationBonus) = _getConfigurationData( + eModeCategories, + collateralReserve, + params + ); vars.userCollateralBalance = vars.collateralAToken.balanceOf(params.user); diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index 895375a6..639e0bae 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -404,10 +404,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator categoryData.liquidationBonus = liquidationBonus; categoryData.label = label; - _pool.configureEModeCategory( - categoryId, - categoryData - ); + _pool.configureEModeCategory(categoryId, categoryData); emit EModeCategoryAdded( categoryId, ltv, diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 5e991aea..715cbc21 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -224,7 +224,6 @@ contract PoolEModeTests is TestnetProcedures { false ); - // todo: assertions based on bonus } From 93cc1a6cef9b3004e2e24c998d8ff3fb3e64fbda Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 29 Aug 2024 09:09:40 +0200 Subject: [PATCH 48/88] fix: update gas diff --- docs/gas-diff.md | 553 ++++++++++++++++++++++++----------------------- 1 file changed, 285 insertions(+), 268 deletions(-) diff --git a/docs/gas-diff.md b/docs/gas-diff.md index 2f4aa2e7..38a59c4a 100644 --- a/docs/gas-diff.md +++ b/docs/gas-diff.md @@ -1,6 +1,6 @@ ```diff diff --git a/reports/gas.old b/reports/gas.new -index 0dec812..9ce5779 100644 +index 0dec812..fe1d1d0 100644 --- a/reports/gas.old +++ b/reports/gas.new @@ -27,37 +27,37 @@ @@ -10,7 +10,7 @@ index 0dec812..9ce5779 100644 -| convertToAssets | 3348 | 3493 | 3496 | 3496 | 261 | -| convertToShares | 22946 | 22946 | 22946 | 22946 | 1 | -| createStaticATokens | 2375769 | 2375769 | 2375769 | 2375769 | 46 | -+| convertToAssets | 3370 | 3516 | 3518 | 3518 | 261 | ++| convertToAssets | 3370 | 3514 | 3518 | 3518 | 261 | +| convertToShares | 22968 | 22968 | 22968 | 22968 | 1 | +| createStaticATokens | 2375835 | 2375835 | 2375835 | 2375835 | 46 | | decimals | 3154 | 3154 | 3154 | 3154 | 1 | @@ -67,9 +67,9 @@ index 0dec812..9ce5779 100644 -| approve | 29055 | 46249 | 46467 | 46467 | 1806 | -| balanceOf | 541 | 989 | 541 | 2541 | 9310 | -| decimals | 2313 | 2313 | 2313 | 2313 | 636 | -+| approve | 29055 | 46246 | 46467 | 46467 | 1785 | -+| balanceOf | 541 | 989 | 541 | 2541 | 9205 | -+| decimals | 2313 | 2313 | 2313 | 2313 | 632 | ++| approve | 29055 | 46247 | 46467 | 46467 | 1794 | ++| balanceOf | 541 | 989 | 541 | 2541 | 9250 | ++| decimals | 2313 | 2313 | 2313 | 2313 | 641 | | symbol | 1213 | 2250 | 3213 | 3213 | 27 | @@ -120,7 +120,7 @@ index 0dec812..9ce5779 100644 | getStaticAToken | 616 | 616 | 616 | 616 | 52 | | getStaticATokens | 9587 | 9587 | 9587 | 9587 | 2 | -| initialize | 24131 | 24131 | 24131 | 24131 | 624 | -+| initialize | 24131 | 24131 | 24131 | 24131 | 620 | ++| initialize | 24131 | 24131 | 24131 | 24131 | 629 | | src/contracts/extensions/static-a-token/StaticATokenLM.sol:StaticATokenLM contract | | | | | | @@ -130,7 +130,7 @@ index 0dec812..9ce5779 100644 | collectAndUpdateRewards | 32217 | 73291 | 73291 | 114366 | 2 | -| convertToAssets | 2550 | 2695 | 2698 | 2698 | 261 | -| convertToShares | 15648 | 15648 | 15648 | 15648 | 1 | -+| convertToAssets | 2572 | 2718 | 2720 | 2720 | 261 | ++| convertToAssets | 2572 | 2716 | 2720 | 2720 | 261 | +| convertToShares | 15670 | 15670 | 15670 | 15670 | 1 | | decimals | 2359 | 2359 | 2359 | 2359 | 1 | -| deposit | 196987 | 215388 | 218294 | 218294 | 22 | @@ -192,16 +192,16 @@ index 0dec812..9ce5779 100644 -| updateEModeCategories | 11063 | 61143 | 27080 | 128256 | 5 | -| updatePriceFeeds | 39338 | 39338 | 39338 | 39338 | 1 | -| updateRateStrategies | 122092 | 122092 | 122092 | 122092 | 1 | -+| DEFAULT_INTEREST_RATE_STRATEGY | 227 | 227 | 227 | 227 | 5 | -+| listAssets | 1832667 | 1832667 | 1832667 | 1832667 | 1 | -+| listAssetsCustom | 1831924 | 5264742 | 5270515 | 5270515 | 616 | -+| updateAssetsEMode | 92916 | 92916 | 92916 | 92916 | 1 | -+| updateBorrowSide | 20101 | 76458 | 76458 | 132816 | 2 | -+| updateCaps | 59883 | 59883 | 59883 | 59883 | 1 | -+| updateCollateralSide | 8777 | 30499 | 8903 | 62957 | 5 | -+| updateEModeCategories | 10592 | 51848 | 29691 | 104184 | 5 | -+| updatePriceFeeds | 39360 | 39360 | 39360 | 39360 | 1 | -+| updateRateStrategies | 122202 | 122202 | 122202 | 122202 | 1 | ++| DEFAULT_INTEREST_RATE_STRATEGY | 271 | 271 | 271 | 271 | 5 | ++| listAssets | 1824291 | 1824291 | 1824291 | 1824291 | 1 | ++| listAssetsCustom | 1823621 | 5252250 | 5257933 | 5257933 | 625 | ++| updateBorrowSide | 20079 | 76436 | 76436 | 132794 | 2 | ++| updateCaps | 59846 | 59846 | 59846 | 59846 | 1 | ++| updateCollateralSide | 8777 | 30494 | 8903 | 62945 | 5 | ++| updateEModeCategories | 10636 | 53642 | 29735 | 108603 | 5 | ++| updateEModeCollaterals | 92981 | 92981 | 92981 | 92981 | 1 | ++| updatePriceFeeds | 39331 | 39331 | 39331 | 39331 | 1 | ++| updateRateStrategies | 122114 | 122114 | 122114 | 122114 | 1 | | src/contracts/helpers/AaveProtocolDataProvider.sol:AaveProtocolDataProvider contract | | | | | | @@ -211,7 +211,7 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| getATokenTotalSupply | 11863 | 14153 | 11907 | 24953 | 2140 | -| getAllReservesTokens | 16222 | 28423 | 31722 | 39722 | 27 | -+| getATokenTotalSupply | 11863 | 14165 | 11907 | 24975 | 2128 | ++| getATokenTotalSupply | 11863 | 14145 | 11907 | 24975 | 2155 | +| getAllReservesTokens | 16155 | 28653 | 39655 | 39655 | 27 | | getDebtCeiling | 3263 | 3263 | 3263 | 3263 | 4 | -| getDebtCeilingDecimals | 237 | 237 | 237 | 237 | 1 | @@ -222,20 +222,20 @@ index 0dec812..9ce5779 100644 -| getLiquidationProtocolFee | 3174 | 9951 | 5674 | 16674 | 9 | -| getPaused | 3219 | 3325 | 3263 | 5263 | 8383 | +| getInterestRateStrategyAddress | 8563 | 19558 | 8563 | 40063 | 9 | -+| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 9373 | ++| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 8519 | +| getLiquidationProtocolFee | 3285 | 10062 | 5785 | 16785 | 9 | -+| getPaused | 3330 | 3427 | 3374 | 5374 | 9640 | ++| getPaused | 3330 | 3433 | 3374 | 5374 | 8786 | | getReserveCaps | 3286 | 8168 | 3286 | 16786 | 47 | -| getReserveConfigurationData | 3565 | 3773 | 3609 | 17109 | 9714 | -| getReserveEModeCategory | 3199 | 3199 | 3199 | 3199 | 1 | -| getReserveTokensAddresses | 8541 | 14283 | 14585 | 40085 | 9574 | -+| getReserveConfigurationData | 3662 | 3851 | 3706 | 17206 | 10968 | -+| getReserveTokensAddresses | 8541 | 14320 | 14585 | 40085 | 10826 | ++| getReserveConfigurationData | 3662 | 3863 | 3706 | 17206 | 10115 | ++| getReserveTokensAddresses | 8541 | 14298 | 14585 | 40085 | 9972 | | getSiloedBorrowing | 3289 | 3289 | 3289 | 3289 | 1 | -| getTotalDebt | 51955 | 51955 | 51955 | 51955 | 3 | -| getUserReserveData | 18944 | 26800 | 27034 | 43944 | 1302 | +| getTotalDebt | 51890 | 51890 | 51890 | 51890 | 3 | -+| getUserReserveData | 18988 | 26798 | 27013 | 43988 | 1301 | ++| getUserReserveData | 18988 | 26784 | 27013 | 43988 | 1301 | | src/contracts/helpers/L2Encoder.sol:L2Encoder contract | | | | | | @@ -291,36 +291,36 @@ index 0dec812..9ce5779 100644 | POOL | 327 | 327 | 327 | 327 | 151 | -| RESERVE_TREASURY_ADDRESS | 420 | 783 | 420 | 2420 | 9917 | -| UNDERLYING_ASSET_ADDRESS | 442 | 475 | 442 | 2442 | 8251 | -+| RESERVE_TREASURY_ADDRESS | 420 | 742 | 420 | 2420 | 11173 | -+| UNDERLYING_ASSET_ADDRESS | 442 | 471 | 442 | 2442 | 9508 | ++| RESERVE_TREASURY_ADDRESS | 420 | 809 | 420 | 2420 | 10575 | ++| UNDERLYING_ASSET_ADDRESS | 442 | 474 | 442 | 2442 | 8654 | | allowance | 785 | 1554 | 785 | 2785 | 26 | | approve | 24590 | 24590 | 24590 | 24590 | 39 | -| balanceOf | 2744 | 5319 | 4744 | 17744 | 4799 | -| burn | 911 | 35660 | 37180 | 81176 | 2111 | -| decimals | 357 | 403 | 357 | 2357 | 8304 | -+| balanceOf | 2766 | 5342 | 4766 | 17766 | 4796 | -+| burn | 911 | 35659 | 37180 | 81176 | 2110 | -+| decimals | 357 | 397 | 357 | 2357 | 9561 | ++| balanceOf | 2766 | 5311 | 4766 | 17766 | 5052 | ++| burn | 911 | 37674 | 37180 | 81176 | 2366 | ++| decimals | 357 | 401 | 357 | 2357 | 8707 | | decreaseAllowance | 7709 | 7709 | 7709 | 7709 | 1 | -| getIncentivesController | 475 | 475 | 475 | 2475 | 8116 | -+| getIncentivesController | 475 | 475 | 475 | 2475 | 9373 | ++| getIncentivesController | 475 | 475 | 475 | 2475 | 8519 | | getPreviousIndex | 654 | 654 | 654 | 654 | 39 | | getScaledUserBalanceAndSupply | 830 | 2419 | 2830 | 4830 | 39 | -| handleRepayment | 597 | 597 | 597 | 597 | 2599 | -+| handleRepayment | 597 | 597 | 597 | 597 | 2598 | ++| handleRepayment | 597 | 597 | 597 | 597 | 2854 | | increaseAllowance | 7776 | 20601 | 24876 | 24876 | 4 | -| initialize | 146515 | 228079 | 231709 | 321646 | 43251 | -| mint | 940 | 59706 | 64435 | 72198 | 4166 | -+| initialize | 146515 | 231136 | 231709 | 321646 | 44496 | -+| mint | 940 | 60222 | 64435 | 72198 | 4676 | ++| initialize | 146515 | 228395 | 231709 | 321646 | 43669 | ++| mint | 940 | 61265 | 64435 | 72198 | 6214 | | mintToTreasury | 444 | 43943 | 49223 | 66323 | 6 | -| name | 1009 | 1454 | 1326 | 3264 | 8351 | -+| name | 1009 | 1448 | 1326 | 3264 | 9608 | ++| name | 1009 | 1454 | 1561 | 3264 | 8754 | | nonces | 655 | 1988 | 2655 | 2655 | 9 | | permit | 1117 | 33566 | 43549 | 53499 | 16 | | rescueTokens | 12040 | 24418 | 14258 | 46957 | 3 | -| scaledBalanceOf | 691 | 1986 | 2691 | 2691 | 10419 | -+| scaledBalanceOf | 691 | 1933 | 2691 | 2691 | 11720 | ++| scaledBalanceOf | 691 | 1909 | 2691 | 2691 | 13978 | | scaledTotalSupply | 375 | 2181 | 2375 | 2375 | 414 | | setIncentivesController | 11941 | 14316 | 14316 | 16691 | 2 | -| symbol | 1074 | 1515 | 1391 | 3329 | 8333 | @@ -329,12 +329,12 @@ index 0dec812..9ce5779 100644 -| transferFrom | 87624 | 120965 | 130243 | 145830 | 43 | -| transferOnLiquidation | 988 | 30249 | 37526 | 44326 | 1807 | -| transferUnderlyingTo | 802 | 18573 | 16500 | 33639 | 2704 | -+| symbol | 1074 | 1513 | 1391 | 3329 | 9590 | -+| totalSupply | 411 | 4985 | 6479 | 10479 | 5146 | -+| transfer | 580 | 116801 | 122712 | 140404 | 275 | ++| symbol | 1074 | 1514 | 1391 | 3329 | 8736 | ++| totalSupply | 411 | 5166 | 6479 | 10479 | 5941 | ++| transfer | 580 | 117696 | 122712 | 140404 | 275 | +| transferFrom | 87646 | 120962 | 130265 | 145587 | 43 | -+| transferOnLiquidation | 988 | 30267 | 37548 | 44348 | 1806 | -+| transferUnderlyingTo | 802 | 19862 | 16500 | 33639 | 2959 | ++| transferOnLiquidation | 988 | 31171 | 37548 | 44348 | 2062 | ++| transferUnderlyingTo | 802 | 22711 | 16500 | 33639 | 3727 | | src/contracts/instances/L2PoolInstance.sol:L2PoolInstance contract | | | | | | @@ -349,16 +349,16 @@ index 0dec812..9ce5779 100644 -| dropReserve | 6336 | 6631 | 6336 | 82330 | 257 | -| getBorrowLogic | 282 | 282 | 282 | 282 | 1 | +| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 415 | 415 | 415 | 124 | -+| borrow(address,uint256,uint256,uint16,address) | 197850 | 203970 | 203450 | 238567 | 266 | ++| borrow(address,uint256,uint256,uint16,address) | 197850 | 203778 | 203450 | 238567 | 266 | +| borrow(bytes32) | 203449 | 203449 | 203449 | 203449 | 3 | -+| configureEModeCategory | 7310 | 8476 | 7310 | 51792 | 276 | ++| configureEModeCategory | 7310 | 8345 | 7310 | 45792 | 276 | +| dropReserve | 6270 | 6565 | 6270 | 82286 | 257 | +| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | | getBridgeLogic | 346 | 346 | 346 | 346 | 1 | -| getConfiguration | 682 | 728 | 682 | 2682 | 1636 | -| getEModeCategoryData | 6141 | 6141 | 6141 | 6141 | 12 | +| getConfiguration | 704 | 714 | 704 | 2704 | 1462 | -+| getEModeCategoryData | 8379 | 8379 | 8379 | 8379 | 14 | ++| getEModeCategoryData | 8124 | 8302 | 8379 | 8379 | 20 | | getEModeLogic | 279 | 279 | 279 | 279 | 1 | -| getFlashLoanLogic | 348 | 348 | 348 | 348 | 1 | -| getLiquidationGracePeriod | 2659 | 2659 | 2659 | 2659 | 256 | @@ -393,12 +393,12 @@ index 0dec812..9ce5779 100644 +| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 4 | +| initReserve | 6575 | 41039 | 6575 | 167551 | 656 | +| initialize | 45425 | 45425 | 45425 | 45425 | 62 | -+| liquidationCall | 376891 | 376891 | 376891 | 376891 | 1 | ++| liquidationCall | 376728 | 376728 | 376728 | 376728 | 1 | +| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | +| repay(address,uint256,uint256,address) | 164652 | 164652 | 164652 | 164652 | 2 | +| repay(bytes32) | 135733 | 135733 | 135733 | 135733 | 1 | +| repayWithATokens | 138767 | 138767 | 138767 | 138767 | 1 | -+| repayWithPermit | 183077 | 199368 | 206950 | 210170 | 256 | ++| repayWithPermit | 183077 | 198894 | 189516 | 210170 | 256 | +| rescueTokens | 48219 | 48219 | 48219 | 48219 | 256 | | resetIsolationModeTotalDebt | 4276 | 5590 | 6269 | 15276 | 402 | -| setConfiguration | 2178 | 4409 | 2178 | 24334 | 2004 | @@ -409,9 +409,9 @@ index 0dec812..9ce5779 100644 -| setUserUseReserveAsCollateral(bytes32) | 73824 | 73824 | 73824 | 73824 | 1 | -| supply(address,uint256,address,uint16) | 157289 | 207630 | 208589 | 208589 | 284 | +| setConfiguration | 2178 | 4547 | 2178 | 24334 | 1848 | -+| setLiquidationGracePeriod | 6374 | 11387 | 10862 | 17025 | 768 | ++| setLiquidationGracePeriod | 6374 | 11394 | 10862 | 17025 | 768 | +| setReserveInterestRateStrategyAddress | 6416 | 7991 | 6525 | 15813 | 769 | -+| setUserEMode | 19813 | 42071 | 40892 | 87328 | 7 | ++| setUserEMode | 19833 | 42074 | 40892 | 87328 | 7 | +| setUserUseReserveAsCollateral(address,bool) | 53610 | 69578 | 71631 | 102908 | 17 | +| setUserUseReserveAsCollateral(bytes32) | 73781 | 73781 | 73781 | 73781 | 1 | +| supply(address,uint256,address,uint16) | 157311 | 207652 | 208611 | 208611 | 284 | @@ -434,7 +434,7 @@ index 0dec812..9ce5779 100644 |----------------------------------------------------------------------------------------|-----------------|----------|---------|-----------|---------| | Deployment Cost | Deployment Size | | | | | -| 4442338 | 20353 | | | | | -+| 4446007 | 20370 | | | | | ++| 4462068 | 20445 | | | | | | Function Name | min | avg | median | max | # calls | -| MAX_GRACE_PERIOD | 305 | 305 | 305 | 305 | 1792 | -| configureReserveAsCollateral | 12205 | 26298 | 17314 | 95608 | 4169 | @@ -470,38 +470,38 @@ index 0dec812..9ce5779 100644 -| updateFlashloanPremiumTotal | 14136 | 27000 | 32071 | 36971 | 907 | -| updateVariableDebtToken | 14141 | 14597 | 14141 | 131538 | 257 | +| MAX_GRACE_PERIOD | 261 | 261 | 261 | 261 | 1792 | -+| configureReserveAsCollateral | 12283 | 26410 | 17358 | 95708 | 4157 | ++| configureReserveAsCollateral | 12271 | 26312 | 17358 | 95696 | 4184 | +| disableLiquidationGracePeriod | 17259 | 28403 | 39505 | 39505 | 513 | +| dropReserve | 14113 | 14970 | 14113 | 104795 | 261 | +| getConfiguratorLogic | 284 | 284 | 284 | 284 | 1 | +| getPendingLtv | 643 | 643 | 643 | 643 | 771 | -+| initReserves | 17446 | 26379812 | 1659772 | 213979799 | 2666 | -+| initialize | 72581 | 90425 | 90481 | 90481 | 647 | -+| setAssetBorrowableInEMode | 94038 | 94125 | 94126 | 94126 | 517 | -+| setAssetCollateralInEMode | 17518 | 68765 | 77122 | 77123 | 1826 | -+| setBorrowCap | 11219 | 12208 | 11285 | 44241 | 2114 | -+| setBorrowableInIsolation | 10786 | 11126 | 10852 | 43798 | 1860 | -+| setDebtCeiling | 17301 | 39432 | 39860 | 94933 | 2121 | -+| setEModeCategory | 17827 | 70955 | 84268 | 84268 | 1310 | -+| setLiquidationProtocolFee | 11290 | 11499 | 11356 | 44312 | 1855 | ++| initReserves | 17446 | 25802050 | 1659767 | 213970339 | 2675 | ++| initialize | 72581 | 90426 | 90481 | 90481 | 656 | ++| setAssetBorrowableInEMode | 74227 | 94101 | 94126 | 94126 | 1545 | ++| setAssetCollateralInEMode | 17518 | 71246 | 77122 | 77123 | 2597 | ++| setBorrowCap | 11219 | 12197 | 11285 | 44241 | 2141 | ++| setBorrowableInIsolation | 10786 | 11122 | 10852 | 43798 | 1887 | ++| setDebtCeiling | 17301 | 39465 | 39860 | 94933 | 2148 | ++| setEModeCategory | 17827 | 81478 | 88643 | 88643 | 2594 | ++| setLiquidationProtocolFee | 11290 | 11498 | 11356 | 44312 | 1882 | +| setPoolPause(bool) | 17247 | 17670 | 17247 | 90044 | 515 | -+| setPoolPause(bool,uint40) | 17359 | 61722 | 48341 | 107751 | 512 | ++| setPoolPause(bool,uint40) | 17359 | 61500 | 48341 | 107751 | 512 | +| setReserveActive | 14224 | 17128 | 14224 | 91434 | 267 | -+| setReserveBorrowing | 10960 | 17724 | 11182 | 41836 | 2616 | -+| setReserveFactor | 17346 | 40438 | 36925 | 125233 | 2106 | -+| setReserveFlashLoaning | 10959 | 17755 | 11025 | 43991 | 2361 | ++| setReserveBorrowing | 10960 | 17656 | 11182 | 41836 | 2643 | ++| setReserveFactor | 17346 | 40478 | 36925 | 125233 | 2133 | ++| setReserveFlashLoaning | 10959 | 17680 | 11025 | 43991 | 2388 | +| setReserveFreeze | 20602 | 48131 | 53013 | 73219 | 782 | +| setReserveInterestRateData | 17605 | 18272 | 17605 | 103713 | 258 | +| setReserveInterestRateStrategyAddress | 17626 | 34359 | 17626 | 162458 | 300 | +| setReservePause(address,bool) | 17392 | 17575 | 17392 | 41114 | 258 | -+| setReservePause(address,bool,uint40) | 14464 | 39159 | 47072 | 52184 | 3084 | -+| setSiloedBorrowing | 11332 | 11564 | 11398 | 91272 | 1850 | -+| setSupplyCap | 11176 | 12931 | 11242 | 44198 | 2127 | ++| setReservePause(address,bool,uint40) | 14464 | 38788 | 47072 | 49384 | 3084 | ++| setSiloedBorrowing | 11332 | 11562 | 11398 | 91272 | 1877 | ++| setSupplyCap | 11176 | 12919 | 11242 | 44198 | 2154 | +| setUnbackedMintCap | 44233 | 44233 | 44233 | 44233 | 7 | +| updateAToken | 14074 | 14554 | 14074 | 137640 | 257 | +| updateBridgeProtocolFee | 14141 | 49349 | 52058 | 52058 | 14 | -+| updateFlashloanPremiumToProtocol | 10205 | 11353 | 10205 | 37005 | 903 | -+| updateFlashloanPremiumTotal | 14091 | 26958 | 32070 | 36970 | 903 | ++| updateFlashloanPremiumToProtocol | 10205 | 11342 | 10205 | 37005 | 912 | ++| updateFlashloanPremiumTotal | 14091 | 27009 | 32070 | 36970 | 912 | +| updateVariableDebtToken | 14075 | 14531 | 14075 | 131490 | 257 | @@ -515,17 +515,17 @@ index 0dec812..9ce5779 100644 -| BRIDGE_PROTOCOL_FEE | 416 | 2176 | 2416 | 2416 | 25 | -| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1182 | -| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 416 | 415 | 2415 | 1179 | -+| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3058 | ++| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3076 | +| BRIDGE_PROTOCOL_FEE | 350 | 2110 | 2350 | 2350 | 25 | -+| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1174 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1171 | ++| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1192 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1189 | | MAX_NUMBER_RESERVES | 309 | 309 | 309 | 309 | 514 | -| backUnbacked | 98453 | 114633 | 112032 | 133026 | 9 | -| borrow | 46669 | 219345 | 222815 | 262245 | 2435 | -| configureEModeCategory | 7207 | 10703 | 7207 | 49424 | 280 | +| backUnbacked | 98475 | 114655 | 112054 | 133048 | 9 | -+| borrow | 46603 | 220726 | 222483 | 261668 | 2690 | -+| configureEModeCategory | 7332 | 24595 | 8814 | 51814 | 3371 | ++| borrow | 46603 | 224445 | 222483 | 261668 | 3458 | ++| configureEModeCategory | 6014 | 26167 | 25914 | 45814 | 6454 | | deposit | 32854 | 190352 | 208588 | 214736 | 80 | -| dropReserve | 6270 | 7104 | 6270 | 82308 | 262 | -| finalizeTransfer | 20766 | 45533 | 48574 | 88370 | 317 | @@ -533,15 +533,15 @@ index 0dec812..9ce5779 100644 -| flashLoanSimple | 23431 | 343312 | 189538 | 757563 | 11 | -| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | +| dropReserve | 6292 | 7125 | 6292 | 82265 | 262 | -+| finalizeTransfer | 20766 | 45011 | 48574 | 88106 | 317 | -+| flashLoan | 29764 | 82208 | 65635 | 320653 | 267 | ++| finalizeTransfer | 20766 | 45787 | 48574 | 88106 | 317 | ++| flashLoan | 29764 | 84224 | 69664 | 320653 | 267 | +| flashLoanSimple | 23453 | 343384 | 189604 | 757609 | 11 | +| getBorrowLogic | 326 | 326 | 326 | 326 | 1 | | getBridgeLogic | 280 | 280 | 280 | 280 | 1 | -| getConfiguration | 726 | 968 | 726 | 2726 | 53149 | -| getEModeCategoryData | 1908 | 5110 | 6163 | 6163 | 43 | -+| getConfiguration | 748 | 978 | 748 | 2748 | 54971 | -+| getEModeCategoryData | 2146 | 8374 | 8401 | 8401 | 2086 | ++| getConfiguration | 748 | 988 | 748 | 2748 | 52680 | ++| getEModeCategoryData | 2146 | 8240 | 8401 | 8401 | 6311 | | getEModeLogic | 301 | 301 | 301 | 301 | 1 | -| getFlashLoanLogic | 303 | 303 | 303 | 303 | 1 | -| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 2014 | @@ -575,48 +575,49 @@ index 0dec812..9ce5779 100644 -| setUserEMode | 21974 | 41470 | 40194 | 87548 | 10 | -| setUserUseReserveAsCollateral | 53632 | 72191 | 71653 | 103041 | 25 | -| supply | 29467 | 187262 | 208611 | 216374 | 3016 | +-| supplyWithPermit | 113813 | 196609 | 218266 | 257750 | 768 | +-| syncIndexesState | 7251 | 13978 | 7251 | 62644 | 1763 | +-| syncRatesState | 13531 | 16046 | 16072 | 22572 | 1763 | +-| updateBridgeProtocolFee | 6195 | 7025 | 6195 | 23375 | 269 | +-| updateFlashloanPremiums | 1704 | 10703 | 6377 | 21604 | 1432 | +-| withdraw | 39229 | 105506 | 87802 | 177983 | 51 | +| getFlashLoanLogic | 325 | 325 | 325 | 325 | 1 | -+| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 2005 | ++| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 1993 | +| getLiquidationLogic | 303 | 303 | 303 | 303 | 1 | +| getPoolLogic | 302 | 302 | 302 | 302 | 1 | +| getReserveAddressById | 620 | 620 | 620 | 620 | 1 | -+| getReserveData | 4261 | 9945 | 10261 | 24261 | 21550 | ++| getReserveData | 4261 | 11061 | 10261 | 24261 | 22560 | +| getReserveDataExtended | 3438 | 4104 | 3438 | 5438 | 6 | -+| getReserveNormalizedIncome | 871 | 1142 | 871 | 5333 | 10752 | -+| getReserveNormalizedVariableDebt | 828 | 1005 | 828 | 6426 | 7186 | ++| getReserveNormalizedIncome | 871 | 1112 | 871 | 5333 | 12032 | ++| getReserveNormalizedVariableDebt | 828 | 1000 | 828 | 6426 | 7394 | +| getReservesCount | 373 | 373 | 373 | 373 | 2 | -+| getReservesList | 3116 | 12647 | 11116 | 102626 | 1874 | ++| getReservesList | 3116 | 12284 | 11116 | 101829 | 1874 | +| getSupplyLogic | 326 | 326 | 326 | 326 | 1 | -+| getUserAccountData | 17882 | 21571 | 22382 | 28994 | 1804 | -+| getUserConfiguration | 728 | 777 | 728 | 2728 | 1821 | -+| getUserEMode | 659 | 659 | 659 | 659 | 1548 | ++| getUserAccountData | 12238 | 23068 | 22382 | 39507 | 2574 | ++| getUserConfiguration | 728 | 767 | 728 | 2728 | 1821 | ++| getUserEMode | 659 | 660 | 659 | 2659 | 1294 | +| getVirtualUnderlyingBalance | 726 | 726 | 726 | 726 | 2155 | -+| initReserve | 6552 | 179760 | 179592 | 207256 | 44864 | -+| initialize | 45382 | 45482 | 45382 | 66903 | 589 | -+| liquidationCall | 53261 | 227732 | 315362 | 376486 | 3514 | ++| initReserve | 6552 | 179727 | 179592 | 207256 | 44037 | ++| initialize | 45382 | 45480 | 45382 | 66903 | 598 | ++| liquidationCall | 53186 | 239514 | 323748 | 383313 | 3720 | +| mintToTreasury | 77343 | 78738 | 78738 | 80133 | 2 | +| mintUnbacked | 12177 | 118400 | 103526 | 165870 | 17 | +| repay | 33261 | 99436 | 95921 | 164631 | 21 | -+| repayWithATokens | 128164 | 154520 | 155359 | 166023 | 261 | -+| repayWithPermit | 127039 | 165709 | 154132 | 209835 | 768 | ++| repayWithATokens | 128164 | 154206 | 155359 | 166023 | 261 | ++| repayWithPermit | 127039 | 165740 | 154132 | 210104 | 768 | +| rescueTokens | 48176 | 48176 | 48176 | 48176 | 256 | -+| resetIsolationModeTotalDebt | 4298 | 4569 | 4298 | 15298 | 1962 | -+| setConfiguration | 2200 | 17083 | 24200 | 24356 | 66881 | -+| setLiquidationGracePeriod | 6329 | 12432 | 14480 | 16980 | 3485 | ++| resetIsolationModeTotalDebt | 4298 | 4565 | 4298 | 15298 | 1989 | ++| setConfiguration | 2200 | 16938 | 24200 | 24356 | 66324 | ++| setLiquidationGracePeriod | 6329 | 12223 | 12480 | 16980 | 3435 | +| setReserveInterestRateStrategyAddress | 6438 | 7977 | 6547 | 15835 | 813 | -+| setUserEMode | 18886 | 49402 | 40914 | 94583 | 1034 | ++| setUserEMode | 16734 | 48129 | 40914 | 94630 | 2318 | +| setUserUseReserveAsCollateral | 53676 | 72230 | 71697 | 102974 | 25 | -+| supply | 29401 | 190289 | 208545 | 216308 | 3526 | - | supplyWithPermit | 113813 | 196609 | 218266 | 257750 | 768 | --| syncIndexesState | 7251 | 13978 | 7251 | 62644 | 1763 | --| syncRatesState | 13531 | 16046 | 16072 | 22572 | 1763 | --| updateBridgeProtocolFee | 6195 | 7025 | 6195 | 23375 | 269 | --| updateFlashloanPremiums | 1704 | 10703 | 6377 | 21604 | 1432 | --| withdraw | 39229 | 105506 | 87802 | 177983 | 51 | -+| syncIndexesState | 7273 | 14001 | 7273 | 62666 | 1751 | -+| syncRatesState | 13553 | 16068 | 16094 | 22594 | 1751 | ++| supply | 29401 | 195831 | 208545 | 216308 | 5064 | ++| supplyWithPermit | 113813 | 196587 | 218266 | 257750 | 768 | ++| syncIndexesState | 7273 | 14000 | 7273 | 62666 | 1778 | ++| syncRatesState | 13553 | 16069 | 16094 | 22594 | 1778 | +| updateBridgeProtocolFee | 6217 | 7047 | 6217 | 23397 | 269 | -+| updateFlashloanPremiums | 1726 | 10720 | 6399 | 21626 | 1424 | ++| updateFlashloanPremiums | 1726 | 10732 | 6399 | 21626 | 1442 | +| withdraw | 39251 | 105523 | 87824 | 177740 | 51 | @@ -626,32 +627,32 @@ index 0dec812..9ce5779 100644 | 1723145 | 8349 | | | | | | Function Name | min | avg | median | max | # calls | -| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8112 | -+| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 9369 | ++| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8515 | | approveDelegation | 27012 | 27012 | 27012 | 27012 | 1 | -| balanceOf | 681 | 4986 | 4771 | 10365 | 7692 | -+| balanceOf | 681 | 4925 | 4706 | 10300 | 7712 | ++| balanceOf | 681 | 4919 | 4706 | 10300 | 7918 | | borrowAllowance | 831 | 831 | 831 | 831 | 5 | -| burn | 19204 | 26197 | 26204 | 26205 | 3108 | -| decimals | 335 | 335 | 335 | 335 | 8112 | -+| burn | 19204 | 26197 | 26204 | 26205 | 3107 | -+| decimals | 335 | 335 | 335 | 335 | 9369 | ++| burn | 19204 | 26197 | 26204 | 26205 | 3363 | ++| decimals | 335 | 335 | 335 | 335 | 8515 | | delegationWithSig | 1052 | 28689 | 21662 | 55862 | 7 | -| getIncentivesController | 431 | 431 | 431 | 431 | 8112 | -| initialize | 123620 | 207871 | 209041 | 299205 | 43251 | -| mint | 26385 | 62549 | 62585 | 72374 | 2687 | -| name | 1009 | 1421 | 1264 | 3264 | 8202 | -+| getIncentivesController | 431 | 431 | 431 | 431 | 9369 | -+| initialize | 123620 | 206084 | 209041 | 299205 | 44496 | -+| mint | 26385 | 62552 | 62585 | 72374 | 2942 | -+| name | 1009 | 1419 | 1264 | 3264 | 9459 | ++| getIncentivesController | 431 | 431 | 431 | 431 | 8515 | ++| initialize | 123620 | 208766 | 209041 | 299205 | 43669 | ++| mint | 26385 | 62559 | 62585 | 72374 | 3710 | ++| name | 1009 | 1420 | 1326 | 3264 | 8605 | | nonces | 577 | 577 | 577 | 577 | 1 | -| scaledBalanceOf | 691 | 1887 | 2691 | 2691 | 5867 | -| scaledTotalSupply | 419 | 2102 | 2419 | 2419 | 18707 | -| symbol | 1030 | 1440 | 1347 | 3285 | 8195 | -| totalSupply | 4079 | 7582 | 6481 | 19079 | 15 | -+| scaledBalanceOf | 691 | 1829 | 2691 | 2691 | 6656 | -+| scaledTotalSupply | 419 | 2116 | 2419 | 2419 | 19469 | -+| symbol | 1030 | 1440 | 1347 | 3285 | 9452 | ++| scaledBalanceOf | 691 | 1885 | 2691 | 2691 | 7118 | ++| scaledTotalSupply | 419 | 2152 | 2419 | 2419 | 22291 | ++| symbol | 1030 | 1441 | 1347 | 3285 | 8598 | +| totalSupply | 4014 | 7523 | 6416 | 19014 | 15 | @@ -661,7 +662,7 @@ index 0dec812..9ce5779 100644 | BASE_CURRENCY | 293 | 293 | 293 | 293 | 3 | | BASE_CURRENCY_UNIT | 262 | 262 | 262 | 262 | 1 | -| getAssetPrice | 679 | 4746 | 7873 | 7873 | 22337 | -+| getAssetPrice | 0 | 4726 | 7873 | 7873 | 24937 | ++| getAssetPrice | 0 | 4859 | 7873 | 7873 | 29705 | | getAssetsPrices | 2300 | 3404 | 2300 | 5614 | 3 | | getFallbackOracle | 365 | 1031 | 365 | 2365 | 3 | -| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1140 | @@ -674,43 +675,45 @@ index 0dec812..9ce5779 100644 | MAX_OPTIMAL_POINT | 262 | 262 | 262 | 262 | 6918 | | MIN_OPTIMAL_POINT | 261 | 261 | 261 | 261 | 6918 | -| calculateInterestRates | 0 | 4436 | 4271 | 5999 | 16046 | -+| calculateInterestRates | 0 | 4456 | 4271 | 5999 | 16797 | ++| calculateInterestRates | 0 | 4513 | 4271 | 5999 | 19642 | | getBaseVariableBorrowRate | 748 | 776 | 748 | 2748 | 2908 | | getInterestRateData | 1804 | 1804 | 1804 | 1804 | 256 | | getInterestRateDataBps | 987 | 987 | 987 | 987 | 256 | -@@ -507,7 +507,7 @@ +@@ -507,8 +507,8 @@ | getOptimalUsageRatio | 738 | 738 | 738 | 2738 | 2136 | | getVariableRateSlope1 | 778 | 778 | 778 | 778 | 2140 | | getVariableRateSlope2 | 799 | 799 | 799 | 799 | 1368 | -| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29729 | 29075 | 36816 | 2816 | -+| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28290 | 29729 | 29075 | 36804 | 2816 | - | setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | +-| setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | ++| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29728 | 29075 | 36804 | 2816 | ++| setInterestRateParams(address,bytes) | 28612 | 33084 | 29860 | 37156 | 6405 | + | src/contracts/misc/PriceOracleSentinel.sol:PriceOracleSentinel contract | | | | | | @@ -530,26 +530,26 @@ | Deployment Cost | Deployment Size | | | | | | 465623 | 2115 | | | | | | Function Name | min | avg | median | max | # calls | -| ADDRESSES_PROVIDER | 898 | 4368 | 5398 | 5465 | 3190 | -| BRIDGE_PROTOCOL_FEE | 1029 | 5311 | 7529 | 7529 | 23 | -+| ADDRESSES_PROVIDER | 898 | 4371 | 5398 | 5465 | 3182 | ++| ADDRESSES_PROVIDER | 898 | 4364 | 5398 | 5465 | 3200 | +| BRIDGE_PROTOCOL_FEE | 963 | 5245 | 7463 | 7463 | 23 | | DOMAIN_SEPARATOR | 1071 | 4688 | 4156 | 7571 | 5 | -| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 650 | -| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1304 | -| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1039 | 1028 | 7528 | 1301 | -| MAX_GRACE_PERIOD | 5418 | 5418 | 5418 | 5418 | 1792 | -+| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 646 | -+| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1296 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1293 | ++| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 655 | ++| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1314 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1311 | +| MAX_GRACE_PERIOD | 5374 | 5374 | 5374 | 5374 | 1792 | | MAX_NUMBER_RESERVES | 922 | 922 | 922 | 922 | 512 | | POOL | 940 | 940 | 940 | 940 | 151 | -| RESERVE_TREASURY_ADDRESS | 1033 | 1397 | 1033 | 7533 | 9918 | -+| RESERVE_TREASURY_ADDRESS | 1033 | 1356 | 1033 | 7533 | 11174 | ++| RESERVE_TREASURY_ADDRESS | 1033 | 1422 | 1033 | 7533 | 10576 | | REVISION | 874 | 874 | 874 | 874 | 8 | -| UNDERLYING_ASSET_ADDRESS | 1011 | 1050 | 1055 | 3055 | 16363 | -+| UNDERLYING_ASSET_ADDRESS | 1011 | 1047 | 1055 | 3055 | 18877 | ++| UNDERLYING_ASSET_ADDRESS | 1011 | 1049 | 1055 | 3055 | 17169 | | admin | 21390 | 21390 | 21390 | 21390 | 8 | | allowance | 1404 | 3173 | 3404 | 7904 | 26 | | approve | 51293 | 51357 | 51341 | 51653 | 39 | @@ -720,8 +723,8 @@ index 0dec812..9ce5779 100644 -| borrow(address,uint256,uint256,uint16,address) | 74012 | 244274 | 250193 | 289647 | 2700 | -| borrow(bytes32) | 230155 | 230155 | 230155 | 230155 | 3 | +| backUnbacked | 125336 | 140987 | 138939 | 159945 | 9 | -+| balanceOf | 1297 | 5820 | 5382 | 22882 | 12508 | -+| borrow(address,uint256,uint256,uint16,address) | 73946 | 244911 | 249861 | 289070 | 2955 | ++| balanceOf | 1297 | 5802 | 5382 | 22882 | 12970 | ++| borrow(address,uint256,uint256,uint16,address) | 73946 | 247047 | 249861 | 289070 | 3723 | +| borrow(bytes32) | 229802 | 229802 | 229802 | 229802 | 3 | | borrowAllowance | 1450 | 1450 | 1450 | 1450 | 5 | | burn | 28132 | 40754 | 28464 | 65668 | 3 | @@ -734,8 +737,8 @@ index 0dec812..9ce5779 100644 -| configureReserveAsCollateral | 44067 | 64524 | 57732 | 122552 | 2308 | -| decimals | 948 | 982 | 970 | 7470 | 16416 | +| configureEModeCategory | 34733 | 34744 | 34744 | 34755 | 512 | -+| configureReserveAsCollateral | 44111 | 64591 | 57798 | 122652 | 2308 | -+| decimals | 948 | 979 | 970 | 7470 | 18930 | ++| configureReserveAsCollateral | 44111 | 64587 | 57798 | 122640 | 2308 | ++| decimals | 948 | 981 | 970 | 7470 | 17222 | | decreaseAllowance | 34424 | 34424 | 34424 | 34424 | 1 | | delegationWithSig | 29263 | 56402 | 45264 | 84300 | 7 | | deposit | 91067 | 215461 | 232188 | 235808 | 64 | @@ -743,9 +746,9 @@ index 0dec812..9ce5779 100644 -| dropReserve | 32591 | 35715 | 32657 | 105072 | 775 | -| flashLoan | 59293 | 162000 | 126617 | 374226 | 267 | -| flashLoanSimple | 50944 | 311491 | 177238 | 642906 | 11 | -+| disableLiquidationGracePeriod | 43592 | 54914 | 66050 | 66050 | 513 | ++| disableLiquidationGracePeriod | 43592 | 54921 | 66050 | 66050 | 513 | +| dropReserve | 32591 | 35715 | 32613 | 105072 | 775 | -+| flashLoan | 59315 | 165996 | 134021 | 374248 | 267 | ++| flashLoan | 59315 | 170319 | 141410 | 374248 | 267 | +| flashLoanSimple | 50966 | 311558 | 177304 | 642952 | 11 | | getAllUserRewards | 9271 | 9271 | 9271 | 9271 | 1 | | getAssetDecimals | 1275 | 1275 | 1275 | 1275 | 2 | @@ -756,11 +759,11 @@ index 0dec812..9ce5779 100644 | getClaimer | 1244 | 3410 | 1244 | 7744 | 3 | -| getConfiguration | 1298 | 1892 | 1342 | 7842 | 54785 | -| getConfiguratorLogic | 5353 | 5353 | 5353 | 5353 | 1 | -+| getConfiguration | 1320 | 1888 | 1364 | 7864 | 56433 | ++| getConfiguration | 1320 | 1913 | 1364 | 7864 | 54142 | +| getConfiguratorLogic | 5397 | 5397 | 5397 | 5397 | 1 | | getDistributionEnd | 1411 | 1411 | 1411 | 1411 | 1 | -| getEModeCategoryData | 2554 | 6313 | 6815 | 11054 | 55 | -+| getEModeCategoryData | 2798 | 13513 | 13559 | 13559 | 2100 | ++| getEModeCategoryData | 2798 | 13319 | 13559 | 13559 | 6331 | | getEModeLogic | 5392 | 5403 | 5403 | 5414 | 2 | -| getFlashLoanLogic | 5416 | 5438 | 5438 | 5461 | 2 | -| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 16230 | @@ -769,8 +772,8 @@ index 0dec812..9ce5779 100644 -| getPendingLtv | 1215 | 1215 | 1215 | 1215 | 771 | -| getPoolLogic | 5393 | 5404 | 5404 | 5416 | 2 | +| getFlashLoanLogic | 5394 | 5416 | 5416 | 5438 | 2 | -+| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 18744 | -+| getLiquidationGracePeriod | 29229 | 29248 | 29251 | 29251 | 2261 | ++| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 17036 | ++| getLiquidationGracePeriod | 29229 | 29248 | 29251 | 29251 | 2249 | +| getLiquidationLogic | 5416 | 5438 | 5438 | 5461 | 2 | +| getPendingLtv | 1259 | 1259 | 1259 | 1259 | 771 | +| getPoolLogic | 5415 | 5426 | 5426 | 5438 | 2 | @@ -783,12 +786,12 @@ index 0dec812..9ce5779 100644 -| getReservesCount | 1050 | 1050 | 1050 | 1050 | 2 | -| getReservesList | 3792 | 16242 | 16292 | 103281 | 2164 | +| getReserveAddressById | 1236 | 1236 | 1236 | 1236 | 1 | -+| getReserveData | 4911 | 10848 | 10955 | 29455 | 22403 | ++| getReserveData | 4911 | 11914 | 10955 | 29455 | 23413 | +| getReserveDataExtended | 4144 | 4810 | 4144 | 6144 | 6 | -+| getReserveNormalizedIncome | 1443 | 1979 | 1487 | 10449 | 11044 | -+| getReserveNormalizedVariableDebt | 1444 | 1618 | 1444 | 11542 | 7450 | ++| getReserveNormalizedIncome | 1443 | 1927 | 1487 | 10449 | 12324 | ++| getReserveNormalizedVariableDebt | 1444 | 1613 | 1444 | 11542 | 7658 | +| getReservesCount | 986 | 986 | 986 | 986 | 2 | -+| getReservesList | 3747 | 16682 | 16247 | 104040 | 2130 | ++| getReservesList | 3747 | 16360 | 16247 | 103236 | 2130 | | getRewardOracle | 1268 | 1268 | 1268 | 1268 | 1 | | getRewardsByAsset | 2399 | 5698 | 3672 | 10899 | 201 | | getRewardsData | 1610 | 1610 | 1610 | 1610 | 3 | @@ -798,13 +801,13 @@ index 0dec812..9ce5779 100644 +| getSupplyLogic | 5395 | 5417 | 5417 | 5439 | 2 | | getTransferStrategy | 1267 | 1267 | 1267 | 1267 | 1 | -| getUserAccountData | 18764 | 22167 | 23264 | 30029 | 1037 | -+| getUserAccountData | 18522 | 22212 | 23022 | 29634 | 1805 | ++| getUserAccountData | 12878 | 23707 | 23022 | 40147 | 2575 | | getUserAccruedRewards | 2267 | 2267 | 2267 | 2267 | 1 | | getUserAssetIndex | 1634 | 1634 | 1634 | 1634 | 1 | -| getUserConfiguration | 1322 | 1364 | 1322 | 3322 | 1822 | -| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1037 | -+| getUserConfiguration | 1344 | 1393 | 1344 | 3344 | 1821 | -+| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1548 | ++| getUserConfiguration | 1344 | 1383 | 1344 | 3344 | 1821 | ++| getUserEMode | 1275 | 1280 | 1275 | 7775 | 1294 | | getUserRewards | 5237 | 7340 | 7469 | 10837 | 19 | -| getVirtualUnderlyingBalance | 1298 | 1319 | 1320 | 1320 | 2161 | +| getVirtualUnderlyingBalance | 1320 | 1341 | 1342 | 1342 | 2159 | @@ -814,9 +817,9 @@ index 0dec812..9ce5779 100644 -| liquidationCall(address,address,address,uint256,bool) | 80856 | 256275 | 351792 | 404755 | 3491 | -| liquidationCall(bytes32,bytes32) | 404144 | 404144 | 404144 | 404144 | 1 | +| initReserve | 33269 | 33280 | 33280 | 33292 | 1024 | -+| initReserves | 45710 | 33036201 | 1608627 | 216658072 | 2049 | -+| liquidationCall(address,address,address,uint256,bool) | 80856 | 255326 | 342956 | 404416 | 3514 | -+| liquidationCall(bytes32,bytes32) | 403771 | 403771 | 403771 | 403771 | 1 | ++| initReserves | 45710 | 32395912 | 1608692 | 215319236 | 2049 | ++| liquidationCall(address,address,address,uint256,bool) | 80781 | 267131 | 351342 | 411243 | 3720 | ++| liquidationCall(bytes32,bytes32) | 403608 | 403608 | 403608 | 403608 | 1 | | mint | 28161 | 73503 | 91286 | 91766 | 7 | -| mintToTreasury(address[]) | 99333 | 100926 | 100926 | 102519 | 4 | +| mintToTreasury(address[]) | 99355 | 100948 | 100948 | 102541 | 4 | @@ -824,7 +827,7 @@ index 0dec812..9ce5779 100644 -| mintUnbacked | 39431 | 145665 | 130791 | 193135 | 17 | -| name | 1625 | 2063 | 1945 | 8383 | 16555 | +| mintUnbacked | 39386 | 145620 | 130746 | 193090 | 17 | -+| name | 1625 | 2058 | 1945 | 8383 | 19069 | ++| name | 1625 | 2063 | 1945 | 8383 | 17361 | | nonces | 1193 | 2463 | 3271 | 3271 | 10 | | permit | 29304 | 46376 | 37841 | 81937 | 8 | -| repay(address,uint256,uint256,address) | 60448 | 129350 | 167720 | 187144 | 13 | @@ -836,10 +839,10 @@ index 0dec812..9ce5779 100644 -| rescueTokens | 39115 | 70318 | 70428 | 70471 | 515 | +| repay(address,uint256,uint256,address) | 60470 | 129327 | 167677 | 187099 | 13 | +| repay(bytes32) | 157445 | 157445 | 157445 | 157445 | 1 | -+| repayWithATokens(address,uint256,uint256) | 155001 | 181337 | 182208 | 193232 | 261 | ++| repayWithATokens(address,uint256,uint256) | 155001 | 181023 | 182208 | 193232 | 261 | +| repayWithATokens(bytes32) | 160479 | 160479 | 160479 | 160479 | 1 | -+| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155591 | 186031 | 182803 | 218606 | 768 | -+| repayWithPermit(bytes32,bytes32,bytes32) | 190590 | 206885 | 214480 | 217827 | 256 | ++| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155615 | 186074 | 182779 | 218803 | 768 | ++| repayWithPermit(bytes32,bytes32,bytes32) | 190566 | 206430 | 197065 | 217839 | 256 | +| rescueTokens | 39115 | 70340 | 70450 | 70493 | 515 | | resetIsolationModeTotalDebt | 32590 | 32636 | 32612 | 41843 | 514 | -| scaledBalanceOf | 1307 | 3741 | 3307 | 7807 | 16286 | @@ -847,17 +850,17 @@ index 0dec812..9ce5779 100644 -| setAssetEModeCategory | 43877 | 48422 | 43877 | 79556 | 296 | -| setBorrowCap | 43786 | 44743 | 43786 | 70919 | 267 | -| setBorrowableInIsolation | 67706 | 70116 | 70508 | 70508 | 13 | -+| scaledBalanceOf | 1307 | 3711 | 3307 | 7807 | 18376 | -+| scaledTotalSupply | 988 | 5907 | 7532 | 7532 | 19883 | -+| setAssetBorrowableInEMode | 120872 | 120959 | 120960 | 120960 | 517 | -+| setAssetCollateralInEMode | 44125 | 95562 | 103956 | 103956 | 1825 | ++| scaledBalanceOf | 1307 | 3788 | 3307 | 7807 | 21096 | ++| scaledTotalSupply | 988 | 6068 | 7532 | 7532 | 22705 | ++| setAssetBorrowableInEMode | 101049 | 120935 | 120960 | 120960 | 1545 | ++| setAssetCollateralInEMode | 44125 | 98055 | 103956 | 103956 | 2596 | +| setBorrowCap | 43786 | 44744 | 43786 | 70941 | 267 | +| setBorrowableInIsolation | 67684 | 70094 | 70486 | 70486 | 13 | | setConfiguration | 32805 | 32816 | 32816 | 32827 | 512 | -| setDebtCeiling | 43743 | 48112 | 43743 | 121555 | 274 | -| setEModeCategory | 45031 | 53892 | 45031 | 135431 | 295 | +| setDebtCeiling | 43765 | 48137 | 43765 | 121621 | 274 | -+| setEModeCategory | 44872 | 98218 | 111566 | 111662 | 1308 | ++| setEModeCategory | 44872 | 108807 | 116025 | 116037 | 2592 | | setIncentivesController | 38502 | 40869 | 40869 | 43236 | 2 | -| setLiquidationGracePeriod | 32828 | 37932 | 37350 | 43761 | 1536 | -| setLiquidationProtocolFee | 43996 | 60606 | 69878 | 70968 | 8 | @@ -866,10 +869,10 @@ index 0dec812..9ce5779 100644 -| setReserveActive | 40906 | 43807 | 40906 | 118044 | 267 | -| setReserveBorrowing | 43833 | 60242 | 68446 | 68448 | 768 | -| setReserveFactor | 43766 | 44186 | 43766 | 151823 | 258 | -+| setLiquidationGracePeriod | 32805 | 37924 | 37338 | 43761 | 1536 | ++| setLiquidationGracePeriod | 32805 | 37936 | 37338 | 43761 | 1536 | +| setLiquidationProtocolFee | 44018 | 60642 | 69922 | 71012 | 8 | -+| setPoolPause(bool) | 43568 | 43997 | 43568 | 116349 | 515 | -+| setPoolPause(bool,uint40) | 43811 | 88193 | 74821 | 134211 | 512 | ++| setPoolPause(bool) | 43568 | 43997 | 43580 | 116349 | 515 | ++| setPoolPause(bool,uint40) | 43811 | 87972 | 74821 | 134211 | 512 | +| setReserveActive | 40928 | 43831 | 40928 | 118110 | 267 | +| setReserveBorrowing | 43877 | 60301 | 68512 | 68514 | 768 | +| setReserveFactor | 43810 | 44230 | 43810 | 151933 | 258 | @@ -887,33 +890,33 @@ index 0dec812..9ce5779 100644 -| setUserUseReserveAsCollateral(address,bool) | 80336 | 96356 | 93550 | 129754 | 42 | -| setUserUseReserveAsCollateral(bytes32) | 95329 | 95329 | 95329 | 95329 | 1 | +| setReserveFreeze | 47066 | 73158 | 74889 | 99907 | 782 | -+| setReserveInterestRateData | 44370 | 44851 | 44598 | 131179 | 257 | -+| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34612 | 33217 | 42751 | 1538 | ++| setReserveInterestRateData | 44370 | 44856 | 44598 | 131179 | 257 | ++| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34614 | 33217 | 42751 | 1538 | +| setReserveInterestRateStrategyAddress(address,address,bytes) | 44513 | 61386 | 44513 | 190298 | 300 | -+| setReservePause(address,bool) | 43856 | 44188 | 44084 | 67802 | 258 | -+| setReservePause(address,bool,uint40) | 41299 | 65986 | 73906 | 79018 | 3084 | ++| setReservePause(address,bool) | 43856 | 44201 | 44084 | 67802 | 258 | ++| setReservePause(address,bool,uint40) | 41311 | 65613 | 73900 | 76218 | 3084 | +| setSiloedBorrowing | 102085 | 111949 | 115804 | 117960 | 3 | +| setSupplyCap | 43743 | 45756 | 43743 | 70898 | 279 | +| setUnbackedMintCap | 70933 | 70933 | 70933 | 70933 | 7 | -+| setUserEMode | 43191 | 75378 | 67231 | 120900 | 1041 | ++| setUserEMode | 43067 | 74317 | 67231 | 120947 | 2325 | +| setUserUseReserveAsCollateral(address,bool) | 80314 | 96359 | 93573 | 129666 | 42 | +| setUserUseReserveAsCollateral(bytes32) | 95286 | 95286 | 95286 | 95286 | 1 | | setValue | 31574 | 31590 | 31598 | 31598 | 3 | -| supply(address,uint256,address,uint16) | 56664 | 214087 | 231043 | 243594 | 3300 | -+| supply(address,uint256,address,uint16) | 56598 | 215668 | 226285 | 243528 | 3810 | ++| supply(address,uint256,address,uint16) | 56598 | 218710 | 226273 | 243528 | 5348 | | supply(bytes32) | 237010 | 237010 | 237010 | 237010 | 7 | -| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216977 | 242026 | 266578 | 768 | -| supplyWithPermit(bytes32,bytes32,bytes32) | 262532 | 262616 | 262592 | 262736 | 256 | -| symbol | 1646 | 2128 | 1966 | 8448 | 16530 | -+| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216981 | 242026 | 266578 | 768 | -+| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262636 | 262614 | 262758 | 256 | -+| symbol | 1646 | 2123 | 1988 | 8448 | 19044 | ++| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216979 | 242026 | 266578 | 768 | ++| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262631 | 262602 | 262758 | 256 | ++| symbol | 1646 | 2126 | 1966 | 8448 | 17336 | | text | 1789 | 1789 | 1789 | 1789 | 8 | -| totalSupply | 1024 | 8279 | 11570 | 15570 | 4914 | -| transfer | 27662 | 144188 | 149393 | 167373 | 273 | -| transferFrom | 138702 | 138822 | 138822 | 138942 | 2 | -+| totalSupply | 1024 | 8463 | 11592 | 15592 | 5157 | -+| transfer | 27662 | 143606 | 149415 | 167131 | 273 | ++| totalSupply | 1024 | 8842 | 11592 | 15592 | 5952 | ++| transfer | 27662 | 144508 | 149415 | 167131 | 273 | +| transferFrom | 138724 | 138844 | 138844 | 138964 | 2 | | transferOnLiquidation | 28063 | 28063 | 28063 | 28063 | 1 | | transferUnderlyingTo | 27506 | 27506 | 27506 | 27506 | 1 | @@ -961,16 +964,12 @@ index 0dec812..9ce5779 100644 | decimals | 144 | 144 | 144 | 144 | 83 | | description | 170 | 170 | 170 | 170 | 83 | -| latestAnswer | 281 | 1395 | 2281 | 2281 | 24197 | -+| latestAnswer | 281 | 1396 | 2281 | 2281 | 26529 | ++| latestAnswer | 281 | 1462 | 2281 | 2281 | 30556 | | name | 170 | 170 | 170 | 170 | 83 | -@@ -732,10 +733,10 @@ - | src/contracts/mocks/oracle/SequencerOracle.sol:SequencerOracle contract | | | | | | - |-------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 278266 | 1393 | | | | | -+| 278290 | 1393 | | | | | +@@ -735,7 +736,7 @@ + | 278266 | 1393 | | | | | | Function Name | min | avg | median | max | # calls | | latestRoundData | 730 | 1533 | 735 | 4735 | 10 | -| setAnswer | 26207 | 27452 | 26207 | 46119 | 73 | @@ -986,14 +985,14 @@ index 0dec812..9ce5779 100644 -| balanceOf | 651 | 991 | 651 | 2651 | 12549 | -| decimals | 312 | 1481 | 2312 | 2312 | 73384 | -| mint | 36480 | 58491 | 53592 | 70740 | 4133 | -+| approve | 29140 | 46492 | 46588 | 46588 | 5089 | ++| approve | 29140 | 46453 | 46588 | 46588 | 6901 | +| balanceOf | 651 | 991 | 651 | 2651 | 12547 | -+| decimals | 312 | 1441 | 2312 | 2312 | 78660 | -+| mint | 36480 | 59853 | 53592 | 70800 | 4604 | ++| decimals | 312 | 1475 | 2312 | 2312 | 75774 | ++| mint | 36480 | 62216 | 70692 | 70800 | 6416 | | name | 3241 | 3241 | 3241 | 3241 | 2048 | | nonces | 2604 | 2604 | 2604 | 2604 | 1 | -| permit | 76466 | 76512 | 76502 | 76670 | 512 | -+| permit | 76454 | 76517 | 76502 | 76670 | 512 | ++| permit | 76454 | 76514 | 76502 | 76670 | 512 | | symbol | 1328 | 2328 | 2328 | 3328 | 56 | | transfer | 46931 | 51023 | 51707 | 51707 | 7 | | transferOwnership | 28800 | 28800 | 28800 | 28800 | 30 | @@ -1003,11 +1002,12 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | -| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 448 | -| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 689 | -+| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 422 | -+| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 667 | - | percentDiv | 321 | 426 | 432 | 432 | 259 | +-| percentDiv | 321 | 426 | 432 | 432 | 259 | -| percentMul | 338 | 411 | 435 | 435 | 259 | -+| percentMul | 338 | 402 | 435 | 435 | 259 | ++| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 432 | ++| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 661 | ++| percentDiv | 321 | 420 | 432 | 432 | 259 | ++| percentMul | 338 | 405 | 435 | 435 | 259 | | src/contracts/mocks/tests/WadRayMathWrapper.sol:WadRayMathWrapper contract | | | | | | @@ -1016,19 +1016,20 @@ index 0dec812..9ce5779 100644 | Function Name | min | avg | median | max | # calls | | HALF_RAY | 247 | 247 | 247 | 247 | 1 | -| HALF_WAD | 224 | 224 | 224 | 224 | 443 | -+| HALF_WAD | 224 | 224 | 224 | 224 | 433 | ++| HALF_WAD | 224 | 224 | 224 | 224 | 434 | | RAY | 225 | 225 | 225 | 225 | 1 | -| WAD | 180 | 180 | 180 | 180 | 658 | -| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1762 | -+| WAD | 180 | 180 | 180 | 180 | 649 | ++| WAD | 180 | 180 | 180 | 180 | 651 | +| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1765 | | rayDiv | 498 | 498 | 498 | 498 | 4 | | rayMul | 501 | 501 | 501 | 501 | 3 | | rayToWad | 387 | 390 | 387 | 401 | 515 | - | wadDiv | 431 | 524 | 542 | 542 | 260 | +-| wadDiv | 431 | 524 | 542 | 542 | 260 | -| wadMul | 338 | 409 | 435 | 435 | 262 | -| wadToRay | 284 | 355 | 360 | 360 | 485 | -+| wadMul | 338 | 406 | 435 | 435 | 262 | ++| wadDiv | 431 | 523 | 542 | 542 | 260 | ++| wadMul | 338 | 407 | 435 | 435 | 262 | +| wadToRay | 284 | 355 | 360 | 360 | 488 | @@ -1038,28 +1039,28 @@ index 0dec812..9ce5779 100644 | 864174 | 4235 | | | | | | Function Name | min | avg | median | max | # calls | -| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1318 | -+| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1310 | ++| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1328 | | FLASH_BORROWER_ROLE | 317 | 317 | 317 | 317 | 20 | -| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 649 | -+| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 645 | ++| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 654 | | addAssetListingAdmin | 50962 | 50962 | 50962 | 50962 | 3 | | addBridge | 51028 | 51028 | 51028 | 51028 | 14 | | addEmergencyAdmin | 50963 | 50963 | 50963 | 50963 | 3 | | addFlashBorrower | 50984 | 52203 | 50984 | 55863 | 4 | -| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 639 | -+| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 635 | ++| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 644 | | addRiskAdmin | 51028 | 51028 | 51028 | 51028 | 14 | | grantRole | 51480 | 52091 | 51480 | 56370 | 8 | | hasRole | 740 | 2622 | 2740 | 2740 | 17 | -| isAssetListingAdmin | 814 | 2465 | 2814 | 2814 | 3562 | -+| isAssetListingAdmin | 814 | 2466 | 2814 | 2814 | 3554 | ++| isAssetListingAdmin | 814 | 2463 | 2814 | 2814 | 3572 | | isBridge | 2791 | 2791 | 2791 | 2791 | 26 | | isEmergencyAdmin | 747 | 2746 | 2747 | 2747 | 3843 | | isFlashBorrower | 2833 | 2833 | 2833 | 2833 | 268 | -| isPoolAdmin | 757 | 1741 | 757 | 2757 | 45593 | -| isRiskAdmin | 747 | 1420 | 747 | 2747 | 29906 | -+| isPoolAdmin | 757 | 1849 | 2757 | 2757 | 46656 | -+| isRiskAdmin | 747 | 1594 | 747 | 2747 | 30985 | ++| isPoolAdmin | 757 | 1899 | 2757 | 2757 | 50045 | ++| isRiskAdmin | 747 | 1691 | 747 | 2747 | 34338 | | removeAssetListingAdmin | 29054 | 29054 | 29054 | 29054 | 2 | | removeBridge | 29023 | 29023 | 29023 | 29023 | 1 | | removeEmergencyAdmin | 28999 | 28999 | 28999 | 28999 | 1 | @@ -1070,9 +1071,9 @@ index 0dec812..9ce5779 100644 -| getACLAdmin | 480 | 551 | 480 | 2480 | 676 | -| getACLManager | 534 | 1369 | 534 | 2534 | 39760 | -| getAddress | 546 | 549 | 546 | 2546 | 657 | -+| getACLAdmin | 480 | 551 | 480 | 2480 | 672 | -+| getACLManager | 534 | 1497 | 534 | 2534 | 40823 | -+| getAddress | 546 | 549 | 546 | 2546 | 653 | ++| getACLAdmin | 480 | 550 | 480 | 2480 | 681 | ++| getACLManager | 534 | 1563 | 2534 | 2534 | 44212 | ++| getAddress | 546 | 549 | 546 | 2546 | 662 | | getMarketId | 1351 | 1351 | 1351 | 1351 | 6 | -| getPool | 469 | 682 | 469 | 2469 | 43331 | -| getPoolConfigurator | 512 | 774 | 512 | 2512 | 182138 | @@ -1080,12 +1081,12 @@ index 0dec812..9ce5779 100644 -| getPriceOracle | 577 | 2281 | 2577 | 2577 | 7894 | -| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6231 | -| owner | 365 | 365 | 365 | 365 | 653 | -+| getPool | 469 | 660 | 469 | 2469 | 48324 | -+| getPoolConfigurator | 512 | 800 | 512 | 2512 | 186919 | -+| getPoolDataProvider | 489 | 1326 | 489 | 2489 | 2191 | -+| getPriceOracle | 577 | 2188 | 2577 | 2577 | 9964 | -+| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6509 | -+| owner | 365 | 365 | 365 | 365 | 649 | ++| getPool | 469 | 675 | 469 | 2469 | 44963 | ++| getPoolConfigurator | 512 | 832 | 512 | 2512 | 187849 | ++| getPoolDataProvider | 489 | 1323 | 489 | 2489 | 2218 | ++| getPriceOracle | 577 | 2160 | 2577 | 2577 | 12992 | ++| getPriceOracleSentinel | 490 | 2485 | 2490 | 2490 | 7483 | ++| owner | 365 | 365 | 365 | 365 | 658 | | setACLAdmin | 24016 | 45798 | 47621 | 47621 | 24 | | setACLManager | 24059 | 37487 | 39114 | 47664 | 4 | | setAddress | 24625 | 35611 | 31540 | 48640 | 5 | @@ -1104,7 +1105,7 @@ index 0dec812..9ce5779 100644 | getAddressesProviderIdByAddress | 559 | 1225 | 559 | 2559 | 6 | | getAddressesProvidersList | 673 | 3403 | 3292 | 5018 | 5 | -| owner | 331 | 2327 | 2331 | 2331 | 650 | -+| owner | 331 | 2327 | 2331 | 2331 | 646 | ++| owner | 331 | 2327 | 2331 | 2331 | 655 | | registerAddressesProvider | 24444 | 104012 | 119926 | 119926 | 6 | | unregisterAddressesProvider | 26448 | 39029 | 40004 | 49662 | 4 | @@ -1113,7 +1114,7 @@ index 0dec812..9ce5779 100644 | 3183382 | 14716 | | | | | | Function Name | min | avg | median | max | # calls | -| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 653 | -+| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 649 | ++| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 658 | | claimAllRewards | 92349 | 92349 | 92349 | 92349 | 1 | | claimAllRewardsOnBehalf | 94649 | 94649 | 94649 | 94649 | 1 | | claimAllRewardsToSelf | 92147 | 92147 | 92147 | 92147 | 1 | @@ -1123,8 +1124,8 @@ index 0dec812..9ce5779 100644 | getUserRewards | 4600 | 6703 | 6832 | 10200 | 19 | -| handleAction | 732 | 2337 | 2732 | 38089 | 17852 | -| initialize | 26067 | 45246 | 45252 | 53156 | 652 | -+| handleAction | 732 | 2354 | 2732 | 38089 | 18613 | -+| initialize | 26067 | 45246 | 45252 | 53156 | 648 | ++| handleAction | 732 | 2364 | 2732 | 38089 | 21943 | ++| initialize | 26067 | 45246 | 45252 | 53156 | 657 | | setClaimer | 24282 | 24282 | 24282 | 24282 | 4 | | setDistributionEnd | 8888 | 8888 | 8888 | 8888 | 2 | | setEmissionPerSecond | 24335 | 24335 | 24335 | 24335 | 2 | @@ -1133,17 +1134,17 @@ index 0dec812..9ce5779 100644 | 0 | 0 | | | | | | Function Name | min | avg | median | max | # calls | -| initialize | 90684 | 90684 | 90684 | 90684 | 674 | -+| initialize | 90684 | 90684 | 90684 | 90684 | 670 | ++| initialize | 90684 | 90684 | 90684 | 90684 | 679 | | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol:AaveV3GettersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | -| 5190134 | 33125 | | | | | -+| 5144006 | 33345 | | | | | ++| 5145702 | 33451 | | | | | | Function Name | min | avg | median | max | # calls | -| getGettersReportOne | 971 | 971 | 971 | 971 | 672 | -+| getGettersReportOne | 971 | 971 | 971 | 971 | 668 | ++| getGettersReportOne | 971 | 971 | 971 | 971 | 677 | | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol:AaveV3GettersBatchTwo contract | | | | | | @@ -1152,17 +1153,17 @@ index 0dec812..9ce5779 100644 | 1583555 | 11792 | | | | | | Function Name | min | avg | median | max | # calls | -| getGettersReportTwo | 535 | 535 | 535 | 535 | 647 | -+| getGettersReportTwo | 535 | 535 | 535 | 535 | 643 | ++| getGettersReportTwo | 535 | 535 | 535 | 535 | 652 | | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol:AaveV3HelpersBatchOne contract | | | | | | |-----------------------------------------------------------------------------------------------------------|-----------------|------|--------|------|---------| | Deployment Cost | Deployment Size | | | | | -| 7434786 | 35360 | | | | | -+| 7379990 | 35117 | | | | | ++| 7356455 | 35017 | | | | | | Function Name | min | avg | median | max | # calls | -| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 622 | -+| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 618 | ++| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 627 | | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol:AaveV3HelpersBatchTwo contract | | | | | | @@ -1171,35 +1172,42 @@ index 0dec812..9ce5779 100644 | 7169046 | 31590 | | | | | | Function Name | min | avg | median | max | # calls | -| staticATokenReport | 971 | 971 | 971 | 971 | 622 | -+| staticATokenReport | 971 | 971 | 971 | 971 | 618 | ++| staticATokenReport | 971 | 971 | 971 | 971 | 627 | | src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol:AaveV3L2PoolBatch contract | | | | | | |---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | -| 9289812 | 42653 | | | | | -+| 9322069 | 42803 | | | | | ++| 9338136 | 42878 | | | | | | Function Name | min | avg | median | max | # calls | -| getPoolReport | 535 | 535 | 535 | 535 | 672 | -+| getPoolReport | 535 | 535 | 535 | 535 | 668 | ++| getPoolReport | 535 | 535 | 535 | 535 | 677 | | src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol:AaveV3MiscBatch contract | | | | | | -@@ -1103,7 +1104,7 @@ +@@ -1103,13 +1104,13 @@ | Deployment Cost | Deployment Size | | | | | | 1062926 | 7122 | | | | | | Function Name | min | avg | median | max | # calls | -| getMiscReport | 535 | 535 | 535 | 535 | 672 | -+| getMiscReport | 535 | 535 | 535 | 535 | 668 | ++| getMiscReport | 535 | 535 | 535 | 535 | 677 | | src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol:AaveV3ParaswapBatch contract | | | | | | + |-------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| + | Deployment Cost | Deployment Size | | | | | +-| 6476447 | 33699 | | | | | ++| 6475775 | 33699 | | | | | + | Function Name | min | avg | median | max | # calls | + | getParaswapReport | 971 | 971 | 971 | 971 | 30 | + @@ -1119,7 +1120,7 @@ | Deployment Cost | Deployment Size | | | | | | 7573451 | 38861 | | | | | | Function Name | min | avg | median | max | # calls | -| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 672 | -+| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 668 | ++| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 677 | | src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol:AaveV3SetupBatch contract | | | | | | @@ -1210,18 +1218,18 @@ index 0dec812..9ce5779 100644 -| getInitialReport | 554 | 554 | 554 | 554 | 672 | -| setMarketReport | 632455 | 634818 | 632455 | 773435 | 622 | -| setupAaveV3Market | 2709798 | 2710437 | 2709798 | 2736039 | 649 | -+| getInitialReport | 554 | 554 | 554 | 554 | 668 | -+| setMarketReport | 632455 | 634834 | 632455 | 773435 | 618 | -+| setupAaveV3Market | 2709798 | 2710433 | 2709798 | 2735948 | 645 | ++| getInitialReport | 554 | 554 | 554 | 554 | 677 | ++| setMarketReport | 632455 | 634799 | 632455 | 773435 | 627 | ++| setupAaveV3Market | 2709798 | 2710424 | 2709798 | 2735948 | 654 | | src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol:AaveV3TokensBatch contract | | | | | | -@@ -1137,53 +1138,53 @@ +@@ -1137,130 +1138,130 @@ | Deployment Cost | Deployment Size | | | | | | 4294582 | 20766 | | | | | | Function Name | min | avg | median | max | # calls | -| getTokensReport | 535 | 535 | 535 | 535 | 647 | -+| getTokensReport | 535 | 535 | 535 | 535 | 643 | ++| getTokensReport | 535 | 535 | 535 | 535 | 652 | -| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | @@ -1233,160 +1241,166 @@ index 0dec812..9ce5779 100644 +| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | +|------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | -+| 747109 | 3465 | | | | | ++| 790748 | 3668 | | | | | +| Function Name | min | avg | median | max | # calls | -+| execute | 118935 | 118935 | 118935 | 118935 | 1 | ++| execute | 119157 | 119157 | 119157 | 119157 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol:AaveV3MockBorrowUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 783501 | 3634 | | | | | -+| 775935 | 3599 | | | | | ++| 816478 | 3787 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 159425 | 159425 | 159425 | 159425 | 1 | -+| execute | 159601 | 159601 | 159601 | 159601 | 1 | ++| execute | 159566 | 159566 | 159566 | 159566 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol:AaveV3MockBorrowUpdateNoChange contract | | | | | | |--------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 790396 | 3666 | | | | | -+| 782829 | 3631 | | | | | ++| 823384 | 3819 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 47089 | 47089 | 47089 | 47089 | 1 | -+| execute | 47111 | 47111 | 47111 | 47111 | 1 | ++| execute | 47076 | 47076 | 47076 | 47076 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol:AaveV3MockCapUpdate contract | | | | | | |----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 770601 | 3574 | | | | | -+| 763034 | 3539 | | | | | ++| 803217 | 3726 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 86135 | 86135 | 86135 | 86135 | 1 | -+| execute | 86134 | 86134 | 86134 | 86134 | 1 | ++| execute | 86081 | 86081 | 86081 | 86081 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol:AaveV3MockCollateralUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 784137 | 3637 | | | | | -+| 776595 | 3602 | | | | | ++| 817030 | 3790 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89745 | 89745 | 89745 | 89745 | 1 | ++| execute | 89720 | 89720 | 89720 | 89720 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol:AaveV3MockCollateralUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 790576 | 3667 | | | | | -+| 783009 | 3632 | | | | | ++| 823420 | 3820 | | | | | | Function Name | min | avg | median | max | # calls | - | execute | 35916 | 35916 | 35916 | 35916 | 2 | +-| execute | 35916 | 35916 | 35916 | 35916 | 2 | ++| execute | 35903 | 35903 | 35903 | 35903 | 2 | + -@@ -1191,15 +1192,15 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateCorrectBonus contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 784137 | 3637 | | | | | -+| 776595 | 3602 | | | | | ++| 817030 | 3790 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89745 | 89745 | 89745 | 89745 | 1 | ++| execute | 89720 | 89720 | 89720 | 89720 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateWrongBonus contract | | | | | | |--------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 785049 | 3641 | | | | | -+| 777483 | 3606 | | | | | ++| 817894 | 3794 | | | | | | Function Name | min | avg | median | max | # calls | - | execute | 35332 | 35332 | 35332 | 35332 | 1 | +-| execute | 35332 | 35332 | 35332 | 35332 | 1 | ++| execute | 35294 | 35294 | 35294 | 35294 | 1 | + -@@ -1207,59 +1208,59 @@ | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdate contract | | | | | | |------------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 756400 | 3425 | | | | | -+| 745395 | 3374 | | | | | ++| 785793 | 3562 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 155461 | 155461 | 155461 | 155461 | 2 | -+| execute | 131198 | 131198 | 131198 | 131198 | 2 | ++| execute | 135648 | 135648 | 135648 | 135648 | 2 | | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdateEdgeBonus contract | | | | | | |---------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 757072 | 3428 | | | | | -+| 746007 | 3377 | | | | | ++| 786441 | 3565 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 53964 | 53964 | 53964 | 53964 | 1 | -+| execute | 56384 | 56384 | 56384 | 56384 | 1 | ++| execute | 56434 | 56434 | 56434 | 56434 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol:AaveV3MockEModeCategoryUpdateNoChange contract | | | | | | |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 770849 | 3492 | | | | | -+| 759832 | 3441 | | | | | ++| 800206 | 3629 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 38497 | 38497 | 38497 | 38497 | 2 | -+| execute | 37835 | 37835 | 37835 | 37835 | 2 | ++| execute | 37910 | 37910 | 37910 | 37910 | 2 | | tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol:AaveV3MockListing contract | | | | | | |------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | -| 853685 | 4030 | | | | | -+| 849574 | 4011 | | | | | ++| 882403 | 4162 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 1836009 | 1836009 | 1836009 | 1836009 | 1 | -+| execute | 1823723 | 1823723 | 1823723 | 1823723 | 1 | - | newListings | 2820 | 2820 | 2820 | 2820 | 4 | +-| newListings | 2820 | 2820 | 2820 | 2820 | 4 | ++| execute | 1815216 | 1815216 | 1815216 | 1815216 | 1 | ++| newListings | 2729 | 2729 | 2729 | 2729 | 4 | | tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol:AaveV3MockListingCustom contract | | | | | | |------------------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | -| 918454 | 4491 | | | | | -+| 914350 | 4472 | | | | | ++| 946992 | 4623 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 1835953 | 1835953 | 1835953 | 1835953 | 1 | -+| execute | 1823667 | 1823667 | 1823667 | 1823667 | 1 | - | newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | +-| newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | ++| execute | 1815233 | 1815233 | 1815233 | 1815233 | 1 | ++| newListingsCustom | 3226 | 3226 | 3226 | 3226 | 4 | | tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol:AaveV3MockPriceFeedUpdate contract | | | | | | |----------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 774000 | 3660 | | | | | -+| 769896 | 3641 | | | | | ++| 806996 | 3812 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 65371 | 65371 | 65371 | 65371 | 1 | -+| execute | 65393 | 65393 | 65393 | 65393 | 1 | ++| execute | 65395 | 65395 | 65395 | 65395 | 1 | | tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol:AaveV3MockRatesUpdate contract | | | | | | |--------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 772773 | 3584 | | | | | -+| 768681 | 3565 | | | | | ++| 809091 | 3753 | | | | | | Function Name | min | avg | median | max | # calls | -| execute | 148663 | 148663 | 148663 | 148663 | 1 | -+| execute | 148773 | 148773 | 148773 | 148773 | 1 | - | rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | +-| rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | ++| execute | 148672 | 148672 | 148672 | 148672 | 1 | ++| rateStrategiesUpdates | 1162 | 1162 | 1162 | 1162 | 4 | -@@ -1273,15 +1274,15 @@ + | tests/harness/VariableDebtToken.sol:VariableDebtTokenHarness contract | | | | | | +@@ -1273,17 +1274,17 @@ | UNDERLYING_ASSET_ADDRESS | 376 | 1200 | 376 | 2376 | 4354 | | allowance | 909 | 909 | 909 | 909 | 1 | | approve | 22107 | 22107 | 22107 | 22107 | 1 | -| approveDelegation | 48608 | 48637 | 48632 | 48680 | 256 | -| burn | 52036 | 52064 | 52060 | 52108 | 512 | -+| approveDelegation | 48608 | 48638 | 48632 | 48680 | 256 | -+| burn | 52036 | 52063 | 52060 | 52108 | 512 | ++| approveDelegation | 48608 | 48634 | 48632 | 48680 | 256 | ++| burn | 52036 | 52065 | 52060 | 52108 | 512 | | decimals | 335 | 335 | 335 | 335 | 3330 | | decreaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | | getIncentivesController | 431 | 431 | 431 | 431 | 3330 | @@ -1394,25 +1408,28 @@ index 0dec812..9ce5779 100644 -| initialize | 29524 | 148072 | 179097 | 270713 | 2048 | -| mint | 86763 | 88040 | 86799 | 91824 | 1024 | -| name | 1009 | 1332 | 1264 | 1796 | 3330 | -+| initialize | 29500 | 146691 | 179067 | 270797 | 2048 | ++| initialize | 29318 | 147436 | 179085 | 270653 | 2048 | +| mint | 86763 | 88039 | 86799 | 91824 | 1024 | -+| name | 1009 | 1328 | 1264 | 1796 | 3330 | ++| name | 1009 | 1329 | 1264 | 1796 | 3330 | | scaledBalanceOf | 691 | 691 | 691 | 691 | 1024 | - | symbol | 1030 | 1351 | 1285 | 1817 | 3330 | +-| symbol | 1030 | 1351 | 1285 | 1817 | 3330 | ++| symbol | 1030 | 1354 | 1285 | 1817 | 3330 | | transfer | 22150 | 22150 | 22150 | 22150 | 1 | + | transferFrom | 22377 | 22377 | 22377 | 22377 | 1 | + @@ -1291,11 +1292,11 @@ | tests/mocks/AaveV3TestListing.sol:AaveV3TestListing contract | | | | | | |--------------------------------------------------------------|-----------------|---------|---------|---------|---------| | Deployment Cost | Deployment Size | | | | | -| 3392063 | 13846 | | | | | -+| 3391415 | 13843 | | | | | ++| 3416267 | 13958 | | | | | | Function Name | min | avg | median | max | # calls | -| USDX_ADDRESS | 294 | 294 | 294 | 294 | 617 | -| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 617 | -| execute | 5227666 | 5230040 | 5230240 | 5230240 | 619 | -+| USDX_ADDRESS | 294 | 294 | 294 | 294 | 613 | -+| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 613 | -+| execute | 5190851 | 5193099 | 5193290 | 5193290 | 615 | ++| USDX_ADDRESS | 272 | 272 | 272 | 272 | 622 | ++| WBTC_ADDRESS | 228 | 228 | 228 | 228 | 622 | ++| execute | 5177782 | 5180033 | 5180221 | 5180221 | 624 | | tests/mocks/AugustusRegistryMock.sol:AugustusRegistryMock contract | | | | | | @@ -1421,5 +1438,5 @@ index 0dec812..9ce5779 100644 -Ran 56 test suites in 75.93s (123.90s CPU time): 694 tests passed, 0 failed, 0 skipped (694 total tests) -+Ran 57 test suites in 74.55s (146.31s CPU time): 690 tests passed, 0 failed, 0 skipped (690 total tests) ++Ran 57 test suites in 75.90s (200.04s CPU time): 699 tests passed, 0 failed, 0 skipped (699 total tests) ``` From 8edfae9e7794ba0a767326fe68387f3c03b9c8a1 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 29 Aug 2024 17:15:10 +0200 Subject: [PATCH 49/88] Update tests/protocol/pool/Pool.EMode.sol Co-authored-by: Andrey --- tests/protocol/pool/Pool.EMode.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 715cbc21..687fe226 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -39,7 +39,6 @@ contract PoolEModeTests is TestnetProcedures { vm.expectRevert(bytes(Errors.INCONSISTENT_EMODE_CATEGORY)); pool.setUserEMode(1); - assertEq(pool.getUserEMode(alice), 0); } function test_getUserEMode_shouldReflectEMode() public { From 10b46b82f0da4d1d9a948632a5e29a7895e4b645 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 30 Aug 2024 11:58:34 +0300 Subject: [PATCH 50/88] fix lint --- tests/protocol/pool/Pool.EMode.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 687fe226..1604e701 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -38,7 +38,6 @@ contract PoolEModeTests is TestnetProcedures { vm.prank(alice); vm.expectRevert(bytes(Errors.INCONSISTENT_EMODE_CATEGORY)); pool.setUserEMode(1); - } function test_getUserEMode_shouldReflectEMode() public { From 3b5dc5ec7c611162c6de79dc0fc9a82132d66cf4 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 30 Aug 2024 13:45:57 +0300 Subject: [PATCH 51/88] remove unused stableDebtToken field from the MarketReport struct --- src/deployments/interfaces/IMarketReportTypes.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/deployments/interfaces/IMarketReportTypes.sol b/src/deployments/interfaces/IMarketReportTypes.sol index e0ebedd4..96446aeb 100644 --- a/src/deployments/interfaces/IMarketReportTypes.sol +++ b/src/deployments/interfaces/IMarketReportTypes.sol @@ -79,7 +79,6 @@ struct MarketReport { address l2Encoder; address aToken; address variableDebtToken; - address stableDebtToken; address emissionManager; address rewardsControllerImplementation; address rewardsControllerProxy; From ee386026248fbb822c1d2d3d630c075f9fe0ad3e Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 30 Aug 2024 14:07:28 +0300 Subject: [PATCH 52/88] oppimisation of if condition in calculateAvailableBorrows --- src/contracts/protocol/libraries/logic/GenericLogic.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 254e24ae..b47f8f98 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -199,7 +199,7 @@ library GenericLogic { ) internal pure returns (uint256) { uint256 availableBorrowsInBaseCurrency = totalCollateralInBaseCurrency.percentMul(ltv); - if (availableBorrowsInBaseCurrency < totalDebtInBaseCurrency) { + if (availableBorrowsInBaseCurrency <= totalDebtInBaseCurrency) { return 0; } From 90814152beda70b91b6a513a88a0f41bdf4decb4 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 30 Aug 2024 13:24:59 +0200 Subject: [PATCH 53/88] fix: remove unncessary import --- src/contracts/protocol/libraries/logic/EModeLogic.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/EModeLogic.sol b/src/contracts/protocol/libraries/logic/EModeLogic.sol index b3ee42a3..5a431f9b 100644 --- a/src/contracts/protocol/libraries/logic/EModeLogic.sol +++ b/src/contracts/protocol/libraries/logic/EModeLogic.sol @@ -5,7 +5,6 @@ import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC2 import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; import {UserConfiguration} from '../configuration/UserConfiguration.sol'; -import {EModeConfiguration} from '../configuration/EModeConfiguration.sol'; import {WadRayMath} from '../math/WadRayMath.sol'; import {PercentageMath} from '../math/PercentageMath.sol'; import {DataTypes} from '../types/DataTypes.sol'; @@ -22,7 +21,6 @@ library EModeLogic { using ReserveLogic for DataTypes.ReserveData; using GPv2SafeERC20 for IERC20; using UserConfiguration for DataTypes.UserConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; using WadRayMath for uint256; using PercentageMath for uint256; From 58971e5d8c6b16751564823d607294a2a81659c2 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 30 Aug 2024 13:38:32 +0200 Subject: [PATCH 54/88] fix: add deprecated note --- src/contracts/protocol/libraries/types/DataTypes.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 8dd9d48e..cb694456 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -93,7 +93,7 @@ library DataTypes { //bit 80-115: borrow cap in whole tokens, borrowCap == 0 => no cap //bit 116-151: supply cap in whole tokens, supplyCap == 0 => no cap //bit 152-167: liquidation protocol fee - //bit 168-175: eMode category + //bit 168-175: DEPRECATED: eMode category //bit 176-211: unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled //bit 212-251: debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals //bit 252: virtual accounting is enabled for the reserve From c21fc46033abb853a9cac406d71117d1a84917ca Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 30 Aug 2024 13:45:52 +0200 Subject: [PATCH 55/88] fix: remove unnecessary using --- src/contracts/protocol/libraries/logic/GenericLogic.sol | 1 - src/contracts/protocol/libraries/logic/LiquidationLogic.sol | 1 - src/contracts/protocol/libraries/logic/ValidationLogic.sol | 1 - 3 files changed, 3 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 3cc24229..86d0bb10 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -24,7 +24,6 @@ library GenericLogic { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using UserConfiguration for DataTypes.UserConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; struct CalculateUserAccountDataVars { uint256 assetPrice; diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index ee4e9980..44234381 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -30,7 +30,6 @@ library LiquidationLogic { using ReserveLogic for DataTypes.ReserveData; using UserConfiguration for DataTypes.UserConfigurationMap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; using GPv2SafeERC20 for IERC20; // See `IPool` for descriptions diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 9be76791..bb024c0d 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -36,7 +36,6 @@ library ValidationLogic { using GPv2SafeERC20 for IERC20; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using UserConfiguration for DataTypes.UserConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; using Address for address; // Factor to apply to "only-variable-debt" liquidity rate to get threshold for rebalancing, expressed in bps From 2a2d1852b86793530eebd5dab59a0f9c08031bd7 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 30 Aug 2024 15:37:42 +0300 Subject: [PATCH 56/88] remove unused deprecatedd events: StableDebtTokenUpgraded and ReserveStableRateBorrowing --- .../interfaces/IPoolConfigurator.sol | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 2465e8cb..f123b69a 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -61,14 +61,6 @@ interface IPoolConfigurator { uint256 liquidationBonus ); - /** - * @dev Emitted when stable rate borrowing is enabled or disabled on a reserve - * @notice deprecated in v3.2.0 - * @param asset The address of the underlying asset of the reserve - * @param enabled True if stable rate borrowing is enabled, false otherwise - */ - event ReserveStableRateBorrowing(address indexed asset, bool enabled); - /** * @dev Emitted when a reserve is activated or deactivated * @param asset The address of the underlying asset of the reserve @@ -214,19 +206,6 @@ interface IPoolConfigurator { address indexed implementation ); - /** - * @dev Emitted when the implementation of a stable debt token is upgraded. - * @notice deprecated in v3.2.0 - * @param asset The address of the underlying asset of the reserve - * @param proxy The stable debt token proxy address - * @param implementation The new aToken implementation - */ - event StableDebtTokenUpgraded( - address indexed asset, - address indexed proxy, - address indexed implementation - ); - /** * @dev Emitted when the implementation of a variable debt token is upgraded. * @param asset The address of the underlying asset of the reserve From c2d4ba12175152d39e5ca18bf3ed33b90e8154dc Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Fri, 30 Aug 2024 15:53:01 +0300 Subject: [PATCH 57/88] removal of the borrowRate prameter on borrowETH and repayETH methods of the WrappedTokenGatewayV3 --- .../helpers/WrappedTokenGatewayV3.sol | 22 ++----------------- .../interfaces/IWrappedTokenGatewayV3.sol | 14 ++---------- tests/helpers/WrappedTokenGateway.t.sol | 20 ++++------------- 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/contracts/helpers/WrappedTokenGatewayV3.sol b/src/contracts/helpers/WrappedTokenGatewayV3.sol index 305003a5..56725d5e 100644 --- a/src/contracts/helpers/WrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/WrappedTokenGatewayV3.sol @@ -72,16 +72,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything * @param onBehalfOf the address for which msg.sender is repaying */ - function repayETH( - address, - uint256 amount, - uint256 rateMode, - address onBehalfOf - ) external payable override { - require( - rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), - 'INVALID_INTEREST_RATE_MODE_SELECTED' - ); + function repayETH(address, uint256 amount, address onBehalfOf) external payable override { uint256 paybackAmount = IERC20((POOL.getReserveData(address(WETH))).variableDebtTokenAddress) .balanceOf(onBehalfOf); @@ -106,16 +97,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param amount the amount of ETH to borrow * @param referralCode integrators are assigned a referral code and can potentially receive rewards */ - function borrowETH( - address, - uint256 amount, - uint256 rateMode, - uint16 referralCode - ) external override { - require( - rateMode == uint256(DataTypes.InterestRateMode.VARIABLE), - 'INVALID_INTEREST_RATE_MODE_SELECTED' - ); + function borrowETH(address, uint256 amount, uint16 referralCode) external override { POOL.borrow( address(WETH), amount, diff --git a/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol b/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol index 38f4cadb..ae8f5980 100644 --- a/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol +++ b/src/contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol @@ -6,19 +6,9 @@ interface IWrappedTokenGatewayV3 { function withdrawETH(address pool, uint256 amount, address onBehalfOf) external; - function repayETH( - address pool, - uint256 amount, - uint256 rateMode, - address onBehalfOf - ) external payable; + function repayETH(address pool, uint256 amount, address onBehalfOf) external payable; - function borrowETH( - address pool, - uint256 amount, - uint256 interestRateMode, - uint16 referralCode - ) external; + function borrowETH(address pool, uint256 amount, uint16 referralCode) external; function withdrawETHWithPermit( address pool, diff --git a/tests/helpers/WrappedTokenGateway.t.sol b/tests/helpers/WrappedTokenGateway.t.sol index 35b854b4..a311dd73 100644 --- a/tests/helpers/WrappedTokenGateway.t.sol +++ b/tests/helpers/WrappedTokenGateway.t.sol @@ -300,7 +300,6 @@ contract WrappedTokenGatewayTests is TestnetProcedures { wrappedTokenGatewayV3.repayETH{value: partialRepayment}( report.poolProxy, partialRepayment, - 2, bob ); @@ -313,12 +312,7 @@ contract WrappedTokenGatewayTests is TestnetProcedures { vm.expectEmit(address(contracts.poolProxy)); emit Repay(tokenList.weth, bob, address(wrappedTokenGatewayV3), partialRepayment, false); // Full repayment - wrappedTokenGatewayV3.repayETH{value: partialRepayment}( - report.poolProxy, - type(uint).max, - 2, - bob - ); + wrappedTokenGatewayV3.repayETH{value: partialRepayment}(report.poolProxy, type(uint).max, bob); assertEq(wEthVariableDebtToken.balanceOf(bob), 0, 'The users debt should be 0'); @@ -375,7 +369,6 @@ contract WrappedTokenGatewayTests is TestnetProcedures { wrappedTokenGatewayV3.repayETH{value: partialRepayment + 1}( report.poolProxy, partialRepayment, - 2, bob ); @@ -388,12 +381,7 @@ contract WrappedTokenGatewayTests is TestnetProcedures { vm.expectEmit(address(contracts.poolProxy)); emit Repay(tokenList.weth, bob, address(wrappedTokenGatewayV3), partialRepayment, false); // Full repayment - wrappedTokenGatewayV3.repayETH{value: partialRepayment}( - report.poolProxy, - type(uint).max, - 2, - bob - ); + wrappedTokenGatewayV3.repayETH{value: partialRepayment}(report.poolProxy, type(uint).max, bob); } function test_borrowDelegateApprove_repay() public { @@ -405,7 +393,7 @@ contract WrappedTokenGatewayTests is TestnetProcedures { wEthVariableDebtToken.approveDelegation(address(wrappedTokenGatewayV3), borrowSize); - wrappedTokenGatewayV3.borrowETH(address(contracts.poolProxy), borrowSize, 2, 0); + wrappedTokenGatewayV3.borrowETH(address(contracts.poolProxy), borrowSize, 0); assertEq( wEthVariableDebtToken.balanceOf(alice), @@ -414,7 +402,7 @@ contract WrappedTokenGatewayTests is TestnetProcedures { ); // Full repayment - wrappedTokenGatewayV3.repayETH{value: borrowSize}(report.poolProxy, type(uint).max, 2, alice); + wrappedTokenGatewayV3.repayETH{value: borrowSize}(report.poolProxy, type(uint).max, alice); vm.stopPrank(); assertEq(wEthVariableDebtToken.balanceOf(alice), 0, 'The users debt should be 0'); From 6954d197eaaba881380eb06f4dda967d6cb8beb8 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sat, 31 Aug 2024 21:16:59 +0200 Subject: [PATCH 58/88] fix: cleanup test base --- tests/protocol/pool/Pool.EMode.sol | 2 -- tests/utils/ProtocolV3TestBase.sol | 35 +++++++----------------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 1604e701..c9069f89 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -26,8 +26,6 @@ contract PoolEModeTests is TestnetProcedures { IPool internal pool; - // @notice number of eModes that are created per default - function setUp() public virtual { initTestEnvironment(false); diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index cdbef24b..bb69b96a 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -801,33 +801,6 @@ contract ProtocolV3TestBase is DiffUtils { ); } - function _validateAssetsOnEmodeCategory( - uint256 category, - ReserveConfig[] memory assetsConfigs, - string[] memory expectedAssets - ) internal pure { - string[] memory assetsInCategory = new string[](assetsConfigs.length); - - uint256 countCategory; - // for (uint256 i = 0; i < assetsConfigs.length; i++) { - // if (assetsConfigs[i].eModeCategory == category) { - // assetsInCategory[countCategory] = assetsConfigs[i].symbol; - // require( - // keccak256(bytes(assetsInCategory[countCategory])) == - // keccak256(bytes(expectedAssets[countCategory])), - // '_getAssetOnEmodeCategory(): INCONSISTENT_ASSETS' - // ); - // countCategory++; - // if (countCategory > expectedAssets.length) { - // revert('_getAssetOnEmodeCategory(): MORE_ASSETS_IN_CATEGORY_THAN_EXPECTED'); - // } - // } - // } - if (countCategory < expectedAssets.length) { - revert('_getAssetOnEmodeCategory(): LESS_ASSETS_IN_CATEGORY_THAN_EXPECTED'); - } - } - function _validateEmodeCategory( IPoolAddressesProvider addressesProvider, uint256 category, @@ -853,6 +826,14 @@ contract ProtocolV3TestBase is DiffUtils { currentCategoryData.liquidationBonus == expectedCategoryData.liquidationBonus, '_validateEmodeCategory(): INVALID_LB' ); + require( + currentCategoryData.collateralMask == expectedCategoryData.collateralMask, + '_validateEmodeCategory(): INVALID_LB' + ); + require( + currentCategoryData.borrowableMask == expectedCategoryData.borrowableMask, + '_validateEmodeCategory(): INVALID_LB' + ); } /** From 726069fdf69e2c7a316cb31304696acef121a3bd Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sat, 31 Aug 2024 21:26:22 +0200 Subject: [PATCH 59/88] refactor: remove unnecessary _getConfigurationData --- .../libraries/logic/LiquidationLogic.sol | 46 +++++-------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 44234381..3d02366f 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -135,11 +135,18 @@ library LiquidationLogic { }) ); - (vars.collateralAToken, vars.liquidationBonus) = _getConfigurationData( - eModeCategories, - collateralReserve, - params - ); + vars.collateralAToken = IAToken(collateralReserve.aTokenAddress); + if ( + params.userEModeCategory != 0 && + EModeConfiguration.isCollateralAsset( + eModeCategories[params.userEModeCategory].collateralMask, + collateralReserve.id + ) + ) { + vars.liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; + } else { + vars.liquidationBonus = collateralReserve.configuration.getLiquidationBonus(); + } vars.userCollateralBalance = vars.collateralAToken.balanceOf(params.user); @@ -357,35 +364,6 @@ library LiquidationLogic { return (userVariableDebt, actualDebtToLiquidate); } - /** - * @notice Returns the configuration data for the debt and the collateral reserves. - * @param eModeCategories The configuration of all the efficiency mode categories - * @param collateralReserve The data of the collateral reserve - * @param params The additional parameters needed to execute the liquidation function - * @return The collateral aToken - * @return The liquidation bonus to apply to the collateral - */ - function _getConfigurationData( - mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - DataTypes.ReserveData storage collateralReserve, - DataTypes.ExecuteLiquidationCallParams memory params - ) internal view returns (IAToken, uint256) { - IAToken collateralAToken = IAToken(collateralReserve.aTokenAddress); - uint256 liquidationBonus = collateralReserve.configuration.getLiquidationBonus(); - if (params.userEModeCategory != 0) { - if ( - EModeConfiguration.isCollateralAsset( - eModeCategories[params.userEModeCategory].collateralMask, - collateralReserve.id - ) - ) { - liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; - } - } - - return (collateralAToken, liquidationBonus); - } - struct AvailableCollateralToLiquidateLocalVars { uint256 collateralPrice; uint256 debtAssetPrice; From e129ac9989e6e574e83e4691211e6fc0daa09f3f Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sat, 31 Aug 2024 21:30:49 +0200 Subject: [PATCH 60/88] fix: add notice about hole --- .../protocol/libraries/configuration/ReserveConfiguration.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol index b5d0f0c2..43987f47 100644 --- a/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/ReserveConfiguration.sol @@ -25,6 +25,7 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SUPPLY_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant LIQUIDATION_PROTOCOL_FEE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore + //@notice there is an unoccupied hole of 8 bits from 168 to 176 left from pre 3.2 eModeCategory uint256 internal constant UNBACKED_MINT_CAP_MASK = 0xFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant DEBT_CEILING_MASK = 0xF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant VIRTUAL_ACC_ACTIVE_MASK = 0xEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore @@ -44,6 +45,7 @@ library ReserveConfiguration { uint256 internal constant BORROW_CAP_START_BIT_POSITION = 80; uint256 internal constant SUPPLY_CAP_START_BIT_POSITION = 116; uint256 internal constant LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION = 152; + //@notice there is an unoccupied hole of 8 bits from 168 to 176 left from pre 3.2 eModeCategory uint256 internal constant UNBACKED_MINT_CAP_START_BIT_POSITION = 176; uint256 internal constant DEBT_CEILING_START_BIT_POSITION = 212; uint256 internal constant VIRTUAL_ACC_START_BIT_POSITION = 252; From 3716b69acd6f664b6d54e1d3c993bbdf8db5ea4b Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sat, 31 Aug 2024 21:33:22 +0200 Subject: [PATCH 61/88] fix: rename params as they are not masks themselfes --- .../configuration/EModeConfiguration.sol | 8 ++-- .../protocol/libraries/logic/GenericLogic.sol | 2 +- .../libraries/logic/LiquidationLogic.sol | 2 +- .../libraries/logic/ValidationLogic.sol | 4 +- .../protocol/libraries/types/DataTypes.sol | 4 +- .../PoolConfigurator.eMode.sol | 42 +++++++++++++------ tests/utils/ProtocolV3TestBase.sol | 4 +- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index c4d69ca6..9aeb3985 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -26,9 +26,9 @@ library EModeConfiguration { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); uint128 bit = uint128(1 << reserveIndex); if (collateral) { - self.collateralMask |= bit; + self.isCollateralBitmap |= bit; } else { - self.collateralMask &= ~bit; + self.isCollateralBitmap &= ~bit; } } } @@ -61,9 +61,9 @@ library EModeConfiguration { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); uint128 bit = uint128(1 << reserveIndex); if (borrowable) { - self.borrowableMask |= bit; + self.isBorrowableBitmap |= bit; } else { - self.borrowableMask &= ~bit; + self.isBorrowableBitmap &= ~bit; } } } diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 86d0bb10..e90168a8 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -120,7 +120,7 @@ library GenericLogic { vars.isInEModeCategory = params.userEModeCategory != 0 && EModeConfiguration.isCollateralAsset( - eModeCategories[params.userEModeCategory].collateralMask, + eModeCategories[params.userEModeCategory].isCollateralBitmap, vars.i ); diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index 3d02366f..d85dd94d 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -139,7 +139,7 @@ library LiquidationLogic { if ( params.userEModeCategory != 0 && EModeConfiguration.isCollateralAsset( - eModeCategories[params.userEModeCategory].collateralMask, + eModeCategories[params.userEModeCategory].isCollateralBitmap, collateralReserve.id ) ) { diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index bb024c0d..70e77547 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -210,7 +210,7 @@ library ValidationLogic { if (params.userEModeCategory != 0) { require( EModeConfiguration.isBorrowableAsset( - eModeCategories[params.userEModeCategory].borrowableMask, + eModeCategories[params.userEModeCategory].isBorrowableBitmap, reservesData[params.asset].id ), Errors.NOT_BORROWABLE_IN_EMODE @@ -573,7 +573,7 @@ library ValidationLogic { for (uint256 i = 0; i < reservesCount; i++) { if (userConfig.isBorrowing(i)) { require( - EModeConfiguration.isBorrowableAsset(eModeCategory.borrowableMask, i), + EModeConfiguration.isBorrowableAsset(eModeCategory.isBorrowableBitmap, i), Errors.NOT_BORROWABLE_IN_EMODE ); } diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index cb694456..398e7695 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -116,9 +116,9 @@ library DataTypes { uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; - uint128 collateralMask; + uint128 isCollateralBitmap; string label; - uint128 borrowableMask; + uint128 isBorrowableBitmap; } enum InterestRateMode { diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index 4bee841a..6efddcb9 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -43,8 +43,8 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(emodeConfig.liquidationThreshold, ct.lt); assertEq(emodeConfig.liquidationBonus, ct.lb); assertEq(emodeConfig.label, ct.label); - assertEq(emodeConfig.collateralMask, 0); - assertEq(emodeConfig.borrowableMask, 0); + assertEq(emodeConfig.isCollateralBitmap, 0); + assertEq(emodeConfig.isBorrowableBitmap, 0); } function test_updateEModeCategory() public { @@ -85,8 +85,8 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { assertEq(emodeConfig.liquidationThreshold, updatedCategory.lt); assertEq(emodeConfig.liquidationBonus, updatedCategory.lb); assertEq(emodeConfig.label, updatedCategory.label); - assertEq(emodeConfig.collateralMask, ogCategory.collateralMask); - assertEq(emodeConfig.borrowableMask, ogCategory.borrowableMask); + assertEq(emodeConfig.isCollateralBitmap, ogCategory.isCollateralBitmap); + assertEq(emodeConfig.isBorrowableBitmap, ogCategory.isBorrowableBitmap); } function test_reverts_setEmodeCategory_zero_ltv() public { @@ -153,7 +153,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveData.id), true); + assertEq(EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveData.id), true); } function test_addAnotherAssetCollateralInEMode() public { @@ -169,8 +169,14 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveDataWBTC = contracts.poolProxy.getReserveData( tokenList.wbtc ); - assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveDataUSDX.id), true); - assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveDataWBTC.id), true); + assertEq( + EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveDataUSDX.id), + true + ); + assertEq( + EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveDataWBTC.id), + true + ); } function test_removeCollateralFromEmode() public { @@ -186,7 +192,10 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isCollateralAsset(config.collateralMask, reserveData.id), false); + assertEq( + EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveData.id), + false + ); } function test_setAssetBorrowableInEMode() public { @@ -200,7 +209,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveData.id), true); + assertEq(EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveData.id), true); } function test_addAnotherAssetBorrowableInEMode() public { @@ -216,8 +225,14 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveDataWBTC = contracts.poolProxy.getReserveData( tokenList.wbtc ); - assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveDataUSDX.id), true); - assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveDataWBTC.id), true); + assertEq( + EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveDataUSDX.id), + true + ); + assertEq( + EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveDataWBTC.id), + true + ); } function test_removeBorrowableFromEmode() public { @@ -231,6 +246,9 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isBorrowableAsset(config.borrowableMask, reserveData.id), false); + assertEq( + EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveData.id), + false + ); } } diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index bb69b96a..eba3c7ac 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -827,11 +827,11 @@ contract ProtocolV3TestBase is DiffUtils { '_validateEmodeCategory(): INVALID_LB' ); require( - currentCategoryData.collateralMask == expectedCategoryData.collateralMask, + currentCategoryData.isCollateralBitmap == expectedCategoryData.isCollateralBitmap, '_validateEmodeCategory(): INVALID_LB' ); require( - currentCategoryData.borrowableMask == expectedCategoryData.borrowableMask, + currentCategoryData.isBorrowableBitmap == expectedCategoryData.isBorrowableBitmap, '_validateEmodeCategory(): INVALID_LB' ); } From 304348d928e38edfb45860f40c7c09254f3ee533 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sat, 31 Aug 2024 22:00:17 +0200 Subject: [PATCH 62/88] fix: patch test --- .../v3-config-engine/AaveV3ConfigEngineTest.t.sol | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index 9ab6d7ec..4a5bd84e 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -18,13 +18,14 @@ import {AaveV3MockEModeCategoryUpdateNoChange} from './mocks/AaveV3MockEModeCate import {AaveV3MockAssetEModeUpdate} from './mocks/AaveV3MockAssetEModeUpdate.sol'; import {ATokenInstance} from '../../../src/contracts/instances/ATokenInstance.sol'; +import {EModeConfiguration} from '../../../src/contracts/protocol/libraries/configuration/EModeConfiguration.sol'; import {VariableDebtTokenInstance} from '../../../src/contracts/instances/VariableDebtTokenInstance.sol'; import {TestnetProcedures, AaveV3ConfigEngine} from '../../utils/TestnetProcedures.sol'; import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; import {MockAggregator} from '../../../src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol'; import {IPool, IPoolAddressesProvider} from '../../utils/ProtocolV3TestBase.sol'; import {DataTypes} from '../../../src/contracts/protocol/libraries/types/DataTypes.sol'; -import {ProtocolV3TestBase, IDefaultInterestRateStrategyV2, ReserveConfig, ReserveTokens, DataTypes as DataTypeOld} from '../../utils/ProtocolV3TestBase.sol'; +import {ProtocolV3TestBase, IDefaultInterestRateStrategyV2, ReserveConfig, ReserveTokens} from '../../utils/ProtocolV3TestBase.sol'; contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { using stdStorage for StdStorage; @@ -536,7 +537,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineEModeCategoryUpdate', 'postTestEngineEModeCategoryUpdate'); - DataTypeOld.EModeCategory memory prevEmodeCategoryData; + DataTypes.EModeCategory memory prevEmodeCategoryData; prevEmodeCategoryData.ltv = 97_40; prevEmodeCategoryData.liquidationThreshold = 97_60; prevEmodeCategoryData.liquidationBonus = 101_50; // 100_00 + 1_50 @@ -613,7 +614,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineEModeCategoryNoChange', 'postTestEngineEModeCategoryNoChange'); - DataTypeOld.EModeCategory memory prevEmodeCategoryData; + DataTypes.EModeCategory memory prevEmodeCategoryData; prevEmodeCategoryData.ltv = eModeCategoryDataBefore.ltv; prevEmodeCategoryData.liquidationThreshold = eModeCategoryDataBefore.liquidationThreshold; prevEmodeCategoryData.liquidationBonus = eModeCategoryDataBefore.liquidationBonus; @@ -655,6 +656,8 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); - // assertEq(contracts.protocolDataProvider.getReserveEModeCategory(asset), 1); + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData(asset); + DataTypes.EModeCategory memory eMode = contracts.poolProxy.getEModeCategoryData(1); + EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveData.id); } } From be906917d540c0a16681c95ed4b332faf6742b38 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sun, 1 Sep 2024 11:02:54 +0200 Subject: [PATCH 63/88] feat: allow asset to be borrowable in eMode, while being non borrowable --- .../libraries/logic/ValidationLogic.sol | 12 ++++++- tests/protocol/pool/Pool.EMode.sol | 36 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 70e77547..436926f8 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -152,7 +152,17 @@ library ValidationLogic { require(vars.isActive, Errors.RESERVE_INACTIVE); require(!vars.isPaused, Errors.RESERVE_PAUSED); require(!vars.isFrozen, Errors.RESERVE_FROZEN); - require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); + if (params.userEModeCategory != 0) { + require( + EModeConfiguration.isBorrowableAsset( + eModeCategories[params.userEModeCategory].isBorrowableBitmap, + reservesData[params.asset].id + ), + Errors.NOT_BORROWABLE_IN_EMODE + ); + } else { + require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); + } require( !params.reserveCache.reserveConfiguration.getIsVirtualAccActive() || IERC20(params.reserveCache.aTokenAddress).totalSupply() >= params.amount, diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index c9069f89..bb90716b 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -190,6 +190,42 @@ contract PoolEModeTests is TestnetProcedures { pool.setUserEMode(2); } + function test_liquidations_shouldAllowLiquidatingAssetThatIsBorrowableInEmodeOnly( + uint104 amount + ) external { + amount = uint104(bound(amount, 1 ether, type(uint104).max)); + vm.startPrank(poolAdmin); + contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); + contracts.poolConfiguratorProxy.setReserveBorrowing(tokenList.wbtc, false); + contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); + vm.stopPrank(); + + vm.prank(alice); + pool.setUserEMode(1); + _mintTestnetToken(tokenList.usdx, alice, amount); + _supplyToPool(tokenList.usdx, alice, amount); + (uint256 totalCollateralBase, , , , , ) = contracts.poolProxy.getUserAccountData(alice); + uint256 collateralPrice = contracts.aaveOracle.getAssetPrice(tokenList.usdx); + uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); + uint256 borrowAmount = (totalCollateralBase * 1e8) / debtPrice; + _borrowArbitraryAmount(tokenList.wbtc, alice, borrowAmount); + + address liquidator = address(0x0f0f0f); + _mintTestnetToken(tokenList.wbtc, liquidator, borrowAmount); + vm.startPrank(liquidator); + IERC20(tokenList.wbtc).approve(address(contracts.poolProxy), borrowAmount); + contracts.poolProxy.liquidationCall( + tokenList.usdx, + tokenList.wbtc, + alice, + type(uint256).max, + false + ); + + // TODO: assumptions about lb + } + function test_liquidations_shouldApplyEModeLBForEmodeAssets(uint104 amount) public { amount = uint104(bound(amount, 1 ether, type(uint104).max)); vm.startPrank(poolAdmin); From a8690a4b46bde3854355f4f1d11ef2e50bac98e5 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sun, 1 Sep 2024 14:54:15 +0200 Subject: [PATCH 64/88] fix: improve tests --- tests/protocol/pool/Pool.EMode.sol | 44 ++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index bb90716b..892d00bd 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -12,6 +12,7 @@ import {PoolInstance} from '../../../src/contracts/instances/PoolInstance.sol'; import {Errors} from '../../../src/contracts/protocol/libraries/helpers/Errors.sol'; import {ReserveConfiguration} from '../../../src/contracts/protocol/pool/PoolConfigurator.sol'; import {WadRayMath} from '../../../src/contracts/protocol/libraries/math/WadRayMath.sol'; +import {PercentageMath} from '../../../src/contracts/protocol/libraries/math/PercentageMath.sol'; import {IAaveOracle} from '../../../src/contracts/interfaces/IAaveOracle.sol'; import {TestnetProcedures} from '../../utils/TestnetProcedures.sol'; import {TestnetERC20} from '../../../src/contracts/mocks/testnet-helpers/TestnetERC20.sol'; @@ -21,6 +22,7 @@ contract PoolEModeTests is TestnetProcedures { using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using WadRayMath for uint256; + using PercentageMath for uint256; event UserEModeSet(address indexed user, uint8 categoryId); @@ -191,11 +193,18 @@ contract PoolEModeTests is TestnetProcedures { } function test_liquidations_shouldAllowLiquidatingAssetThatIsBorrowableInEmodeOnly( - uint104 amount - ) external { - amount = uint104(bound(amount, 1 ether, type(uint104).max)); + uint256 amount + ) public { + amount = bound(amount, 1 ether, type(uint104).max); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + uint16 liquidationBonus = 10050; + contracts.poolConfiguratorProxy.setEModeCategory( + 1, + 9000, + 9200, + liquidationBonus, + 'usdx eMode low' + ); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); contracts.poolConfiguratorProxy.setReserveBorrowing(tokenList.wbtc, false); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); @@ -223,13 +232,25 @@ contract PoolEModeTests is TestnetProcedures { false ); - // TODO: assumptions about lb + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + uint256 bonus = amount - amount.percentDiv(liquidationBonus); + uint256 protocolFee = bonus.percentMul(reserveData.configuration.getLiquidationProtocolFee()); + assertEq(IERC20(tokenList.usdx).balanceOf(liquidator), amount - protocolFee); } - function test_liquidations_shouldApplyEModeLBForEmodeAssets(uint104 amount) public { - amount = uint104(bound(amount, 1 ether, type(uint104).max)); + function test_liquidations_shouldApplyEModeLBForEmodeAssets(uint256 amount) public { + amount = bound(amount, 1 ether, type(uint104).max); vm.startPrank(poolAdmin); - contracts.poolConfiguratorProxy.setEModeCategory(1, 9000, 9200, 10050, 'usdx eMode low'); + uint16 liquidationBonus = 10050; + contracts.poolConfiguratorProxy.setEModeCategory( + 1, + 9000, + 9200, + liquidationBonus, + 'usdx eMode low' + ); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, 1, true); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, 1, true); vm.stopPrank(); @@ -256,7 +277,12 @@ contract PoolEModeTests is TestnetProcedures { false ); - // todo: assertions based on bonus + DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( + tokenList.usdx + ); + uint256 bonus = amount - amount.percentDiv(liquidationBonus); + uint256 protocolFee = bonus.percentMul(reserveData.configuration.getLiquidationProtocolFee()); + assertEq(IERC20(tokenList.usdx).balanceOf(liquidator), amount - protocolFee); } function _mintTestnetToken(address erc20, address user, uint256 amount) internal { From c5af437eb05b963f923c0885cbe39e6f0df1ed23 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 2 Sep 2024 11:57:52 +0200 Subject: [PATCH 65/88] revert: add back the requirement on borrowable outside eMode --- .../libraries/logic/ValidationLogic.sol | 12 +------ tests/protocol/pool/Pool.EMode.sol | 31 +++---------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 436926f8..70e77547 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -152,17 +152,7 @@ library ValidationLogic { require(vars.isActive, Errors.RESERVE_INACTIVE); require(!vars.isPaused, Errors.RESERVE_PAUSED); require(!vars.isFrozen, Errors.RESERVE_FROZEN); - if (params.userEModeCategory != 0) { - require( - EModeConfiguration.isBorrowableAsset( - eModeCategories[params.userEModeCategory].isBorrowableBitmap, - reservesData[params.asset].id - ), - Errors.NOT_BORROWABLE_IN_EMODE - ); - } else { - require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); - } + require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); require( !params.reserveCache.reserveConfiguration.getIsVirtualAccActive() || IERC20(params.reserveCache.aTokenAddress).totalSupply() >= params.amount, diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index 892d00bd..fff94431 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -192,9 +192,7 @@ contract PoolEModeTests is TestnetProcedures { pool.setUserEMode(2); } - function test_liquidations_shouldAllowLiquidatingAssetThatIsBorrowableInEmodeOnly( - uint256 amount - ) public { + function test_borrowing_shouldRevert_ifNonBorrowableOutsideEmode(uint256 amount) public { amount = bound(amount, 1 ether, type(uint104).max); vm.startPrank(poolAdmin); uint16 liquidationBonus = 10050; @@ -214,30 +212,10 @@ contract PoolEModeTests is TestnetProcedures { pool.setUserEMode(1); _mintTestnetToken(tokenList.usdx, alice, amount); _supplyToPool(tokenList.usdx, alice, amount); - (uint256 totalCollateralBase, , , , , ) = contracts.poolProxy.getUserAccountData(alice); - uint256 collateralPrice = contracts.aaveOracle.getAssetPrice(tokenList.usdx); - uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); - uint256 borrowAmount = (totalCollateralBase * 1e8) / debtPrice; - _borrowArbitraryAmount(tokenList.wbtc, alice, borrowAmount); - - address liquidator = address(0x0f0f0f); - _mintTestnetToken(tokenList.wbtc, liquidator, borrowAmount); - vm.startPrank(liquidator); - IERC20(tokenList.wbtc).approve(address(contracts.poolProxy), borrowAmount); - contracts.poolProxy.liquidationCall( - tokenList.usdx, - tokenList.wbtc, - alice, - type(uint256).max, - false - ); - DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( - tokenList.usdx - ); - uint256 bonus = amount - amount.percentDiv(liquidationBonus); - uint256 protocolFee = bonus.percentMul(reserveData.configuration.getLiquidationProtocolFee()); - assertEq(IERC20(tokenList.usdx).balanceOf(liquidator), amount - protocolFee); + vm.prank(alice); + vm.expectRevert(bytes(Errors.BORROWING_NOT_ENABLED)); + contracts.poolProxy.borrow(tokenList.wbtc, 1, 2, 0, alice); } function test_liquidations_shouldApplyEModeLBForEmodeAssets(uint256 amount) public { @@ -260,7 +238,6 @@ contract PoolEModeTests is TestnetProcedures { _mintTestnetToken(tokenList.usdx, alice, amount); _supplyToPool(tokenList.usdx, alice, amount); (uint256 totalCollateralBase, , , , , ) = contracts.poolProxy.getUserAccountData(alice); - uint256 collateralPrice = contracts.aaveOracle.getAssetPrice(tokenList.usdx); uint256 debtPrice = contracts.aaveOracle.getAssetPrice(tokenList.wbtc); uint256 borrowAmount = (totalCollateralBase * 1e8) / debtPrice; _borrowArbitraryAmount(tokenList.wbtc, alice, borrowAmount); From 01c349037aded0d670b4bbea422fc13bcdee37e3 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 2 Sep 2024 16:28:59 +0200 Subject: [PATCH 66/88] fix: rename mask to bitmap --- .../libraries/configuration/EModeConfiguration.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index 9aeb3985..88bf8f22 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -35,14 +35,14 @@ library EModeConfiguration { /** * @notice Validates if a reserve can be used as collaterl in a selected eMode - * @param mask The collateral mask + * @param bitmap The collateral bitmap * @param reserveIndex The index of the reserve in the bitmap * @return True if the reserve is collateral */ - function isCollateralAsset(uint128 mask, uint256 reserveIndex) internal pure returns (bool) { + function isCollateralAsset(uint128 bitmap, uint256 reserveIndex) internal pure returns (bool) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (mask >> reserveIndex) & 1 != 0; + return (bitmap >> reserveIndex) & 1 != 0; } } @@ -70,14 +70,14 @@ library EModeConfiguration { /** * @notice Validates if a reserve can be borrowed in a selected eMode - * @param mask The borrowable mask + * @param bitmap The borrowable bitmap * @param reserveIndex The index of the reserve in the bitmap * @return True if the reserve is borrowable */ - function isBorrowableAsset(uint128 mask, uint256 reserveIndex) internal pure returns (bool) { + function isBorrowableAsset(uint128 bitmap, uint256 reserveIndex) internal pure returns (bool) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (mask >> reserveIndex) & 1 != 0; + return (bitmap >> reserveIndex) & 1 != 0; } } } From a3bd352d53f5ee8189c9b26a36989a45702c0b00 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 2 Sep 2024 16:47:28 +0200 Subject: [PATCH 67/88] Update src/contracts/helpers/UiPoolDataProviderV3.sol Co-authored-by: pavelvm5 <56404416+pavelvm5@users.noreply.github.com> --- src/contracts/helpers/UiPoolDataProviderV3.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index da693e1c..83c1a1fd 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -197,7 +197,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { ++missCounter; } // assumes there will never be a gap > 2 when setting eModes - if (++missCounter > 2) break; + if (missCounter > 1) break; } Emode[] memory categories = new Emode[](eModesFound); for (uint8 i = 0; i < eModesFound; i++) { From 03e8225fc392d87b234d17c2febf16634213caa4 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 2 Sep 2024 17:01:33 +0200 Subject: [PATCH 68/88] fix: improve docs --- .../interfaces/IPoolConfigurator.sol | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index b89d52dd..91451155 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -150,23 +150,23 @@ interface IPoolConfigurator { ); /** - * @dev Emitted when the asset of category of an asset in eMode is changed. + * @dev Emitted when an collateral configuration of an asset in an eMode is changed. * @param asset The address of the underlying asset of the reserve - * @param categoryId The old eMode asset category - * @param allowed True if the asset was added to the eMode + * @param categoryId The eMode category + * @param collateral True if the asset was enabled as collateral in the eMode, false otherwise. */ - event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool allowed); + event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool collateral); /** - * @dev Emitted when the borrowability of an asset in an eMode changed. + * @dev Emitted when the borrowable configuration of an asset in an eMode changed. * @param asset The address of the underlying asset of the reserve - * @param categoryId The eMode asset category - * @param borrowable True if the asset is borrowable + * @param categoryId The eMode category + * @param borrowable True if the asset was enabled as borrowable in the eMode, false otherwise. */ event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable); /** - * @dev Emitted when a new eMode category is added. + * @dev Emitted when a new eMode category is added or an existing category is altered. * @param categoryId The new eMode category id * @param ltv The ltv for the asset category in eMode * @param liquidationThreshold The liquidationThreshold for the asset category in eMode @@ -458,28 +458,24 @@ interface IPoolConfigurator { function setUnbackedMintCap(address asset, uint256 newUnbackedMintCap) external; /** - * @notice Allows an asset to be borrowed in the specified eMode. - * - eMode.borrowable always has less priotiry then reserve.eMode + * @notice Enables/disables an asset to be borrowable in a selected eMode. + * - eMode.borrowable always has less priority then reserve.borrowable * @param asset The address of the underlying asset of the reserve - * @param categoryId The category id - * @param borrowable True if the asset should be borrowable + * @param categoryId The eMode categoryId + * @param borrowable True if the asset should be borrowable in the given eMode category, false otherwise. */ function setAssetBorrowableInEMode(address asset, uint8 categoryId, bool borrowable) external; /** - * @notice Assign an asset to an efficiency mode (eMode) category. + * @notice Enables/disables an asset to be collateral in a selected eMode. * @param asset The address of the underlying asset of the reserve - * @param categoryId The new category id of the asset - * @param allowed If the asset should be allowed + * @param categoryId The eMode categoryId + * @param collateral True if the asset should be collateral in the given eMode category, false otherwise. */ - function setAssetCollateralInEMode(address asset, uint8 categoryId, bool allowed) external; + function setAssetCollateralInEMode(address asset, uint8 categoryId, bool collateral) external; /** - * @notice Adds a new efficiency mode (eMode) category. - * @dev If zero is provided as oracle address, the default asset oracles will be used to compute the overall debt and - * overcollateralization of the users using this category. - * @dev The new ltv and liquidation threshold must be greater than the base - * ltvs and liquidation thresholds of all assets within the eMode category + * @notice Adds a new efficiency mode (eMode) category or alters a existing one. * @param categoryId The id of the category to be configured * @param ltv The ltv associated with the category * @param liquidationThreshold The liquidation threshold associated with the category From a4849111a0ce57e3af1ca5cd9a9b8c6a8cdad1e0 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 3 Sep 2024 11:35:56 +0200 Subject: [PATCH 69/88] fix: fix grammar --- src/contracts/interfaces/IPoolConfigurator.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 91451155..476bd72d 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -153,7 +153,7 @@ interface IPoolConfigurator { * @dev Emitted when an collateral configuration of an asset in an eMode is changed. * @param asset The address of the underlying asset of the reserve * @param categoryId The eMode category - * @param collateral True if the asset was enabled as collateral in the eMode, false otherwise. + * @param collateral True if the asset is enabled as collateral in the eMode, false otherwise. */ event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool collateral); @@ -161,7 +161,7 @@ interface IPoolConfigurator { * @dev Emitted when the borrowable configuration of an asset in an eMode changed. * @param asset The address of the underlying asset of the reserve * @param categoryId The eMode category - * @param borrowable True if the asset was enabled as borrowable in the eMode, false otherwise. + * @param borrowable True if the asset is enabled as borrowable in the eMode, false otherwise. */ event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable); From 6424af86bdfb49ab51b3f64329cc0b24a668a94b Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 11 Sep 2024 13:42:05 +0200 Subject: [PATCH 70/88] refactor: engine refactor (#44) * refactor: engine refactor * fix: lint --- .../v3-config-engine/AaveV3ConfigEngine.sol | 15 +----- .../v3-config-engine/AaveV3Payload.sol | 28 ++-------- .../v3-config-engine/IAaveV3ConfigEngine.sol | 34 +++---------- .../libraries/EModeEngine.sol | 51 +++++++------------ .../AaveV3ConfigEngineTest.t.sol | 22 +++++++- .../mocks/AaveV3MockAssetEModeUpdate.sol | 28 ++++++---- 6 files changed, 71 insertions(+), 107 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol index 0331bfbd..ed817352 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol @@ -187,21 +187,10 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { } /// @inheritdoc IAaveV3ConfigEngine - function updateEModeCollaterals(EModeCollateralUpdate[] calldata updates) external { + function updateAssetEMode(AssetEModeUpdate[] calldata updates) external { EMODE_ENGINE.functionDelegateCall( abi.encodeWithSelector( - EModeEngine.executeEModeCollateralUpdate.selector, - _getEngineConstants(), - updates - ) - ); - } - - /// @inheritdoc IAaveV3ConfigEngine - function updateEModeBorrowables(EModeBorrowableUpdate[] calldata updates) external { - EMODE_ENGINE.functionDelegateCall( - abi.encodeWithSelector( - EModeEngine.executeEModeBorrowableUpdate.selector, + EModeEngine.executeAssetEModeUpdate.selector, _getEngineConstants(), updates ) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol index bdaa17c6..8618056f 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol @@ -49,8 +49,7 @@ abstract contract AaveV3Payload { IEngine.BorrowUpdate[] memory borrows = borrowsUpdates(); IEngine.RateStrategyUpdate[] memory rates = rateStrategiesUpdates(); IEngine.PriceFeedUpdate[] memory priceFeeds = priceFeedsUpdates(); - IEngine.EModeCollateralUpdate[] memory eModeCollaterals = eModeCollateralUpdates(); - IEngine.EModeBorrowableUpdate[] memory eModeBorrowables = eModeBorrowableUpdates(); + IEngine.AssetEModeUpdate[] memory assetEModes = assetEModeUpdates(); IEngine.CapsUpdate[] memory caps = capsUpdates(); if (eModeCategories.length != 0) { @@ -99,15 +98,9 @@ abstract contract AaveV3Payload { ); } - if (eModeCollaterals.length != 0) { + if (assetEModes.length != 0) { address(CONFIG_ENGINE).functionDelegateCall( - abi.encodeWithSelector(CONFIG_ENGINE.updateEModeCollaterals.selector, eModeCollaterals) - ); - } - - if (eModeBorrowables.length != 0) { - address(CONFIG_ENGINE).functionDelegateCall( - abi.encodeWithSelector(CONFIG_ENGINE.updateEModeBorrowables.selector, eModeBorrowables) + abi.encodeWithSelector(CONFIG_ENGINE.updateAssetEMode.selector, assetEModes) ); } @@ -159,20 +152,7 @@ abstract contract AaveV3Payload { {} /// @dev to be defined in the child with a list of assets for which eMode collateral to update - function eModeCollateralUpdates() - public - view - virtual - returns (IEngine.EModeCollateralUpdate[] memory) - {} - - /// @dev to be defined in the child with a list of assets for which eMode borrowable to update - function eModeBorrowableUpdates() - public - view - virtual - returns (IEngine.EModeBorrowableUpdate[] memory) - {} + function assetEModeUpdates() public view virtual returns (IEngine.AssetEModeUpdate[] memory) {} /// @dev to be defined in the child with a list of set of parameters of rate strategies function rateStrategiesUpdates() diff --git a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index d716cf9a..6c743d30 100644 --- a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -190,27 +190,15 @@ interface IAaveV3ConfigEngine { * EModeCollateralUpdate({ * asset: AaveV3EthereumAssets.rETH_UNDERLYING, * eModeCategory: 1, // ETH correlated - * enabled: true, + * borrowable: EngineFlags.ENABLED, + * collateral: EngineFlags.KEEP_CURRENT, * }) */ - struct EModeCollateralUpdate { + struct AssetEModeUpdate { address asset; uint8 eModeCategory; - bool enabled; - } - - /** - * @dev Example (mock): - * EModeBorrowableUpdate({ - * asset: AaveV3EthereumAssets.rETH_UNDERLYING, - * eModeCategory: 1, // ETH correlated - * enabled: true, - * }) - */ - struct EModeBorrowableUpdate { - address asset; - uint8 eModeCategory; - bool enabled; + uint256 borrowable; + uint256 collateral; } /** @@ -315,18 +303,12 @@ interface IAaveV3ConfigEngine { function updateEModeCategories(EModeCategoryUpdate[] memory updates) external; /** - * @notice Performs an update of the e-mode category collateral, in the Aave pool configured in this engine instance - * @param updates `EModeCollateralUpdate[]` list of declarative updates containing the new parameters - * More information on the documentation of the struct. - */ - function updateEModeCollaterals(EModeCollateralUpdate[] memory updates) external; - - /** - * @notice Performs an update of the e-mode category borrowable, in the Aave pool configured in this engine instance + * @notice Performs an update of the e-mode category. + * Sets a specified asset collateral and/or borrowable, in the Aave pool configured in this engine instance * @param updates `EModeCollateralUpdate[]` list of declarative updates containing the new parameters * More information on the documentation of the struct. */ - function updateEModeBorrowables(EModeBorrowableUpdate[] memory updates) external; + function updateAssetEMode(AssetEModeUpdate[] memory updates) external; function DEFAULT_INTEREST_RATE_STRATEGY() external view returns (address); diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index a279cd35..f0894198 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -11,22 +11,13 @@ library EModeEngine { using PercentageMath for uint256; using SafeCast for uint256; - function executeEModeCollateralUpdate( + function executeAssetEModeUpdate( IEngine.EngineConstants calldata engineConstants, - IEngine.EModeCollateralUpdate[] memory updates + IEngine.AssetEModeUpdate[] memory updates ) external { require(updates.length != 0, 'AT_LEAST_ONE_UPDATE_REQUIRED'); - _configEModeCollateral(engineConstants.poolConfigurator, updates); - } - - function executeEModeBorrowableUpdate( - IEngine.EngineConstants calldata engineConstants, - IEngine.EModeBorrowableUpdate[] memory updates - ) external { - require(updates.length != 0, 'AT_LEAST_ONE_UPDATE_REQUIRED'); - - _configEModeBorrowable(engineConstants.poolConfigurator, updates); + _configAssetEMode(engineConstants.poolConfigurator, updates); } function executeEModeCategoriesUpdate( @@ -38,29 +29,25 @@ library EModeEngine { _configEModeCategories(engineConstants.poolConfigurator, engineConstants.pool, updates); } - function _configEModeCollateral( - IPoolConfigurator poolConfigurator, - IEngine.EModeCollateralUpdate[] memory updates - ) internal { - for (uint256 i = 0; i < updates.length; i++) { - poolConfigurator.setAssetCollateralInEMode( - updates[i].asset, - updates[i].eModeCategory, - updates[i].enabled - ); - } - } - - function _configEModeBorrowable( + function _configAssetEMode( IPoolConfigurator poolConfigurator, - IEngine.EModeBorrowableUpdate[] memory updates + IEngine.AssetEModeUpdate[] memory updates ) internal { for (uint256 i = 0; i < updates.length; i++) { - poolConfigurator.setAssetBorrowableInEMode( - updates[i].asset, - updates[i].eModeCategory, - updates[i].enabled - ); + if (updates[i].collateral != EngineFlags.KEEP_CURRENT) { + poolConfigurator.setAssetCollateralInEMode( + updates[i].asset, + updates[i].eModeCategory, + EngineFlags.toBool(updates[i].collateral) + ); + } + if (updates[i].borrowable != EngineFlags.KEEP_CURRENT) { + poolConfigurator.setAssetBorrowableInEMode( + updates[i].asset, + updates[i].eModeCategory, + EngineFlags.toBool(updates[i].borrowable) + ); + } } } diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index 4a5bd84e..62a3a1d8 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -629,11 +629,16 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { function testAssetEModeUpdates() public { address asset = tokenList.usdx; + address asset2 = tokenList.wbtc; AaveV3MockEModeCategoryUpdate payloadToAddEMode = new AaveV3MockEModeCategoryUpdate( configEngine ); - AaveV3MockAssetEModeUpdate payload = new AaveV3MockAssetEModeUpdate(asset, configEngine); + AaveV3MockAssetEModeUpdate payload = new AaveV3MockAssetEModeUpdate( + asset, + asset2, + configEngine + ); vm.startPrank(roleList.marketOwner); contracts.aclManager.addPoolAdmin(address(payload)); @@ -658,6 +663,19 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData(asset); DataTypes.EModeCategory memory eMode = contracts.poolProxy.getEModeCategoryData(1); - EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveData.id); + assertEq(EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveData.id), false); + assertEq(EModeConfiguration.isCollateralAsset(eMode.isBorrowableBitmap, reserveData.id), true); + + DataTypes.ReserveDataLegacy memory reserveDataAsset2 = contracts.poolProxy.getReserveData( + asset2 + ); + assertEq( + EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveDataAsset2.id), + true + ); + assertEq( + EModeConfiguration.isCollateralAsset(eMode.isBorrowableBitmap, reserveDataAsset2.id), + false + ); } } diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol index 4e047fff..9a36644e 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol @@ -10,23 +10,31 @@ import '../../../../src/contracts/extensions/v3-config-engine/AaveV3Payload.sol' */ contract AaveV3MockAssetEModeUpdate is AaveV3Payload { address public immutable ASSET_ADDRESS; + address public immutable ASSET_2_ADDRESS; - constructor(address assetAddress, address customEngine) AaveV3Payload(IEngine(customEngine)) { + constructor( + address assetAddress, + address asset2Address, + address customEngine + ) AaveV3Payload(IEngine(customEngine)) { ASSET_ADDRESS = assetAddress; + ASSET_2_ADDRESS = asset2Address; } - function eModeCollateralUpdates() - public - view - override - returns (IEngine.EModeCollateralUpdate[] memory) - { - IEngine.EModeCollateralUpdate[] memory eModeUpdate = new IEngine.EModeCollateralUpdate[](1); + function assetEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { + IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](2); - eModeUpdate[0] = IEngine.EModeCollateralUpdate({ + eModeUpdate[0] = IEngine.AssetEModeUpdate({ asset: ASSET_ADDRESS, eModeCategory: 1, - enabled: true + collateral: EngineFlags.DISABLED, + borrowable: EngineFlags.ENABLED + }); + eModeUpdate[1] = IEngine.AssetEModeUpdate({ + asset: ASSET_2_ADDRESS, + eModeCategory: 1, + collateral: EngineFlags.ENABLED, + borrowable: EngineFlags.KEEP_CURRENT }); return eModeUpdate; From 9a72720ad12ff38e3c957cbef3e1e1a05ffb2095 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sun, 8 Sep 2024 12:09:36 +0200 Subject: [PATCH 71/88] fix: oxorio #5 unused local variable --- src/contracts/protocol/libraries/logic/GenericLogic.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index e90168a8..637475b3 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -40,7 +40,6 @@ library GenericLogic { uint256 avgLiquidationThreshold; uint256 eModeLtv; uint256 eModeLiqThreshold; - uint256 eModeAssetCategory; address currentReserveAddress; bool hasZeroLtvCollateral; bool isInEModeCategory; From 477d9edd80adf50b13a1b476dcc543e4233ab9ad Mon Sep 17 00:00:00 2001 From: sakulstra Date: Sun, 8 Sep 2024 12:13:36 +0200 Subject: [PATCH 72/88] fix: oxorio #4 - unnecessary casts --- src/contracts/helpers/UiPoolDataProviderV3.sol | 2 +- src/contracts/protocol/pool/PoolConfigurator.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index 83c1a1fd..ddc7eb20 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -188,7 +188,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { uint8 eModesFound = 0; uint8 missCounter = 0; for (uint8 i = 1; i < 256; i++) { - DataTypes.EModeCategory memory category = pool.getEModeCategoryData(uint8(i)); + DataTypes.EModeCategory memory category = pool.getEModeCategoryData(i); if (category.liquidationThreshold != 0) { tempCategories[eModesFound] = Emode({eMode: category, id: i}); ++eModesFound; diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index 255ccfd4..60f9d53a 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -424,7 +424,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); categoryData.setCollateral(reserveData.id, allowed); _pool.configureEModeCategory(categoryId, categoryData); - emit AssetCollateralInEModeChanged(asset, uint8(categoryId), allowed); + emit AssetCollateralInEModeChanged(asset, categoryId, allowed); } /// @inheritdoc IPoolConfigurator From 78406a1360b9d7d05980dad54b392b7b15456c2f Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 9 Sep 2024 15:37:21 +0200 Subject: [PATCH 73/88] fix: oxorio #7 - align comment with code --- src/contracts/helpers/UiPoolDataProviderV3.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index ddc7eb20..418e77fd 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -197,7 +197,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { ++missCounter; } // assumes there will never be a gap > 2 when setting eModes - if (missCounter > 1) break; + if (missCounter > 2) break; } Emode[] memory categories = new Emode[](eModesFound); for (uint8 i = 0; i < eModesFound; i++) { From 27418752340b4b78729761aea72f29c09b9b265b Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 9 Sep 2024 21:50:17 +0200 Subject: [PATCH 74/88] fix: oxorio #6 - ensure asset exists --- src/contracts/protocol/pool/PoolConfigurator.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index 60f9d53a..a2429891 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -422,6 +422,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ) external override onlyRiskOrPoolAdmins { DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); categoryData.setCollateral(reserveData.id, allowed); _pool.configureEModeCategory(categoryId, categoryData); emit AssetCollateralInEModeChanged(asset, categoryId, allowed); @@ -435,6 +436,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator ) external override onlyRiskOrPoolAdmins { DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); categoryData.setBorrowable(reserveData.id, borrowable); _pool.configureEModeCategory(categoryId, categoryData); emit AssetBorrowableInEModeChanged(asset, categoryId, borrowable); From 4fcf2d6da1aca25168ae35c18bfbf10a988f7047 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 12 Sep 2024 11:37:47 +0200 Subject: [PATCH 75/88] fix: enigma #4 - misc (#48) --- src/contracts/interfaces/IPool.sol | 2 +- src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol index fd10f4bd..811c3488 100644 --- a/src/contracts/interfaces/IPool.sol +++ b/src/contracts/interfaces/IPool.sol @@ -292,7 +292,7 @@ interface IPool { /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned - * - E.g. User repays 100 USDC, burning 100 variabledebt tokens of the `onBehalfOf` address + * - E.g. User repays 100 USDC, burning 100 variable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` diff --git a/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol index 2d39226d..c6b08dcc 100644 --- a/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol +++ b/src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol @@ -40,7 +40,7 @@ library ConfiguratorLogic { ); /** - * @notice Initialize a reserve by creating and initializing aToken, stable debt token and variable debt token + * @notice Initialize a reserve by creating and initializing aToken and variable debt token * @dev Emits the `ReserveInitialized` event * @param pool The Pool in which the reserve will be initialized * @param input The needed parameters for the initialization From dbdb73962f5546d066d75f1950b781a74303be46 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 12 Sep 2024 11:38:00 +0200 Subject: [PATCH 76/88] fix: enigma #1 (issue #3) - remove unnecessary allocation (#47) --- .../interfaces/IUiIncentiveDataProviderV3.sol | 2 -- .../interfaces/IUiPoolDataProviderV3.sol | 22 ------------------- 2 files changed, 24 deletions(-) diff --git a/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol index 910c662b..3402953f 100644 --- a/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiIncentiveDataProviderV3.sol @@ -8,7 +8,6 @@ interface IUiIncentiveDataProviderV3 { address underlyingAsset; IncentiveData aIncentiveData; IncentiveData vIncentiveData; - IncentiveData sIncentiveData; } struct IncentiveData { @@ -35,7 +34,6 @@ interface IUiIncentiveDataProviderV3 { address underlyingAsset; UserIncentiveData aTokenIncentivesUserData; UserIncentiveData vTokenIncentivesUserData; - UserIncentiveData sTokenIncentivesUserData; } struct UserIncentiveData { diff --git a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index f104d047..ba7e58d7 100644 --- a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -5,16 +5,6 @@ import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.so import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; interface IUiPoolDataProviderV3 { - struct InterestRates { - uint256 variableRateSlope1; - uint256 variableRateSlope2; - uint256 stableRateSlope1; - uint256 stableRateSlope2; - uint256 baseStableBorrowRate; - uint256 baseVariableBorrowRate; - uint256 optimalUsageRatio; - } - struct AggregatedReserveData { address underlyingAsset; string name; @@ -26,7 +16,6 @@ interface IUiPoolDataProviderV3 { uint256 reserveFactor; bool usageAsCollateralEnabled; bool borrowingEnabled; - bool stableBorrowRateEnabled; bool isActive; bool isFrozen; // base data @@ -34,25 +23,17 @@ interface IUiPoolDataProviderV3 { uint128 variableBorrowIndex; uint128 liquidityRate; uint128 variableBorrowRate; - uint128 stableBorrowRate; uint40 lastUpdateTimestamp; address aTokenAddress; - address stableDebtTokenAddress; address variableDebtTokenAddress; address interestRateStrategyAddress; // uint256 availableLiquidity; - uint256 totalPrincipalStableDebt; - uint256 averageStableRate; - uint256 stableDebtLastUpdateTimestamp; uint256 totalScaledVariableDebt; uint256 priceInMarketReferenceCurrency; address priceOracle; uint256 variableRateSlope1; uint256 variableRateSlope2; - uint256 stableRateSlope1; - uint256 stableRateSlope2; - uint256 baseStableBorrowRate; uint256 baseVariableBorrowRate; uint256 optimalUsageRatio; // v3 only @@ -77,10 +58,7 @@ interface IUiPoolDataProviderV3 { address underlyingAsset; uint256 scaledATokenBalance; bool usageAsCollateralEnabledOnUser; - uint256 stableBorrowRate; uint256 scaledVariableDebt; - uint256 principalStableDebt; - uint256 stableBorrowLastUpdateTimestamp; } struct BaseCurrencyInfo { From 740d0a8163197a4948c959078258c12254207bef Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 12 Sep 2024 11:39:37 +0200 Subject: [PATCH 77/88] fix: add getEModes to interface (#46) fix: add inheritdoc --- src/contracts/helpers/UiPoolDataProviderV3.sol | 1 + src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index 418e77fd..ac83745c 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -182,6 +182,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { return (reservesData, baseCurrencyInfo); } + /// @inheritdoc IUiPoolDataProviderV3 function getEModes(IPoolAddressesProvider provider) external view returns (Emode[] memory) { IPool pool = IPool(provider.getPool()); Emode[] memory tempCategories = new Emode[](256); diff --git a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol index ba7e58d7..3280d75b 100644 --- a/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol +++ b/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol @@ -85,4 +85,11 @@ interface IUiPoolDataProviderV3 { IPoolAddressesProvider provider, address user ) external view returns (UserReserveData[] memory, uint8); + + /** + * @dev Iterates the eModes mapping and returns all eModes found + * @notice The method assumes for id gaps <= 2 within the eMode definitions + * @return an array of eModes that were found in the eMode mapping + */ + function getEModes(IPoolAddressesProvider provider) external view returns (Emode[] memory); } From 5dc61d1e6015780e31a9fa2cdb762a5ffe2782d8 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 16 Sep 2024 14:00:18 +0200 Subject: [PATCH 78/88] fix: add deprecated to interface (#53) --- src/contracts/interfaces/IPoolConfigurator.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/interfaces/IPoolConfigurator.sol b/src/contracts/interfaces/IPoolConfigurator.sol index 476bd72d..977d316e 100644 --- a/src/contracts/interfaces/IPoolConfigurator.sol +++ b/src/contracts/interfaces/IPoolConfigurator.sol @@ -171,7 +171,7 @@ interface IPoolConfigurator { * @param ltv The ltv for the asset category in eMode * @param liquidationThreshold The liquidationThreshold for the asset category in eMode * @param liquidationBonus The liquidationBonus for the asset category in eMode - * @param oracle The optional address of the price oracle specific for this category + * @param oracle DEPRECATED in v3.2.0 * @param label A human readable identifier for the category */ event EModeCategoryAdded( From 47e89db38ae5d61bc83a22c5f8edb10fa3fb226d Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 17 Sep 2024 20:05:11 +0200 Subject: [PATCH 79/88] fix: skip if eMode is the same (#54) * fix: skip if eMode is the same * fix: add a test --- src/contracts/protocol/libraries/logic/EModeLogic.sol | 2 ++ tests/protocol/pool/Pool.EMode.sol | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/contracts/protocol/libraries/logic/EModeLogic.sol b/src/contracts/protocol/libraries/logic/EModeLogic.sol index 5a431f9b..647fc7e7 100644 --- a/src/contracts/protocol/libraries/logic/EModeLogic.sol +++ b/src/contracts/protocol/libraries/logic/EModeLogic.sol @@ -46,6 +46,8 @@ library EModeLogic { DataTypes.UserConfigurationMap storage userConfig, DataTypes.ExecuteSetUserEModeParams memory params ) external { + if (usersEModeCategory[msg.sender] == params.categoryId) return; + ValidationLogic.validateSetUserEMode( eModeCategories, userConfig, diff --git a/tests/protocol/pool/Pool.EMode.sol b/tests/protocol/pool/Pool.EMode.sol index fff94431..24c621e9 100644 --- a/tests/protocol/pool/Pool.EMode.sol +++ b/tests/protocol/pool/Pool.EMode.sol @@ -55,6 +55,15 @@ contract PoolEModeTests is TestnetProcedures { assertEq(pool.getUserEMode(alice), ct1.id); } + function test_reenterSameEmode_shouldSucceed() public { + test_getUserEMode_shouldReflectEMode(); + + assertEq(pool.getUserEMode(alice), 1); + vm.prank(alice); + pool.setUserEMode(1); + assertEq(pool.getUserEMode(alice), 1); + } + function test_getUserAccountData_shouldReflectEmodeParams() public { vm.startPrank(poolAdmin); EModeCategoryInput memory ct1 = _genCategoryOne(); From dd0bbecb90a53628fe15c076217eac3a7275182f Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 17 Sep 2024 20:07:17 +0200 Subject: [PATCH 80/88] refactor: add independent getters and setters for better backwards compatibility (#57) --- .../libraries/EModeEngine.sol | 10 +-- .../helpers/UiPoolDataProviderV3.sol | 16 ++++- src/contracts/interfaces/IPool.sol | 56 ++++++++++++++- .../configuration/EModeConfiguration.sol | 68 ++++++------------- .../protocol/libraries/logic/GenericLogic.sol | 4 +- .../libraries/logic/LiquidationLogic.sol | 4 +- .../libraries/logic/ValidationLogic.sol | 6 +- .../protocol/libraries/types/DataTypes.sol | 28 +++++++- src/contracts/protocol/pool/Pool.sol | 66 ++++++++++++++++-- .../protocol/pool/PoolConfigurator.sol | 23 ++++--- .../AaveV3ConfigEngineTest.t.sol | 15 ++-- tests/protocol/pool/Pool.Liquidations.t.sol | 6 +- tests/protocol/pool/Pool.t.sol | 2 +- .../PoolConfigurator.eMode.sol | 63 +++++++++++------ tests/utils/ProtocolV3TestBase.sol | 34 +++++----- 15 files changed, 272 insertions(+), 129 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index f0894198..fd9c95e9 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -70,28 +70,28 @@ library EModeEngine { keccak256(abi.encode(EngineFlags.KEEP_CURRENT_STRING)); if (notAllKeepCurrent && atLeastOneKeepCurrent) { - DataTypes.EModeCategory memory configuration = pool.getEModeCategoryData( + DataTypes.CollateralConfig memory cfg = pool.getEModeCategoryCollateralConfig( updates[i].eModeCategory ); if (updates[i].ltv == EngineFlags.KEEP_CURRENT) { - updates[i].ltv = configuration.ltv; + updates[i].ltv = cfg.ltv; } if (updates[i].liqThreshold == EngineFlags.KEEP_CURRENT) { - updates[i].liqThreshold = configuration.liquidationThreshold; + updates[i].liqThreshold = cfg.liquidationThreshold; } if (updates[i].liqBonus == EngineFlags.KEEP_CURRENT) { // Subtracting 100_00 to be consistent with the engine as 100_00 gets added while setting the liqBonus - updates[i].liqBonus = configuration.liquidationBonus - 100_00; + updates[i].liqBonus = cfg.liquidationBonus - 100_00; } if ( keccak256(abi.encode(updates[i].label)) == keccak256(abi.encode(EngineFlags.KEEP_CURRENT_STRING)) ) { - updates[i].label = configuration.label; + updates[i].label = pool.getEModeCategoryLabel(updates[i].eModeCategory); } } diff --git a/src/contracts/helpers/UiPoolDataProviderV3.sol b/src/contracts/helpers/UiPoolDataProviderV3.sol index ac83745c..b079d2dd 100644 --- a/src/contracts/helpers/UiPoolDataProviderV3.sol +++ b/src/contracts/helpers/UiPoolDataProviderV3.sol @@ -189,9 +189,19 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { uint8 eModesFound = 0; uint8 missCounter = 0; for (uint8 i = 1; i < 256; i++) { - DataTypes.EModeCategory memory category = pool.getEModeCategoryData(i); - if (category.liquidationThreshold != 0) { - tempCategories[eModesFound] = Emode({eMode: category, id: i}); + DataTypes.CollateralConfig memory cfg = pool.getEModeCategoryCollateralConfig(i); + if (cfg.liquidationThreshold != 0) { + tempCategories[eModesFound] = Emode({ + eMode: DataTypes.EModeCategory({ + ltv: cfg.ltv, + liquidationThreshold: cfg.liquidationThreshold, + liquidationBonus: cfg.liquidationBonus, + label: pool.getEModeCategoryLabel(i), + collateralBitmap: pool.getEModeCategoryCollateralBitmap(i), + borrowableBitmap: pool.getEModeCategoryBorrowableBitmap(i) + }), + id: i + }); ++eModesFound; missCounter = 0; } else { diff --git a/src/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol index 811c3488..2d25a9ce 100644 --- a/src/contracts/interfaces/IPool.sol +++ b/src/contracts/interfaces/IPool.sol @@ -642,20 +642,70 @@ interface IPool { ) external; /** - * @notice Configures a new category for the eMode. + * @notice Configures a new or alters an existing collateral configuration of an eMode. * @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category. * The category 0 is reserved as it's the default for volatile assets * @param id The id of the category * @param config The configuration of the category */ - function configureEModeCategory(uint8 id, DataTypes.EModeCategory memory config) external; + function configureEModeCategory( + uint8 id, + DataTypes.EModeCategoryBaseConfiguration memory config + ) external; + + /** + * @notice Replaces the current eMode collateralBitmap. + * @param id The id of the category + * @param collateralBitmap The collateralBitmap of the category + */ + function configureEModeCategoryCollateralBitmap(uint8 id, uint128 collateralBitmap) external; + + /** + * @notice Replaces the current eMode borrowableBitmap. + * @param id The id of the category + * @param borrowableBitmap The borrowableBitmap of the category + */ + function configureEModeCategoryBorrowableBitmap(uint8 id, uint128 borrowableBitmap) external; /** * @notice Returns the data of an eMode category + * @dev DEPRECATED use independent getters instead * @param id The id of the category * @return The configuration data of the category */ - function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategory memory); + function getEModeCategoryData( + uint8 id + ) external view returns (DataTypes.EModeCategoryLegacy memory); + + /** + * @notice Returns the label of an eMode category + * @param id The id of the category + * @return The label of the category + */ + function getEModeCategoryLabel(uint8 id) external view returns (string memory); + + /** + * @notice Returns the collateral config of an eMode category + * @param id The id of the category + * @return The ltv,lt,lb of the category + */ + function getEModeCategoryCollateralConfig( + uint8 id + ) external view returns (DataTypes.CollateralConfig memory); + + /** + * @notice Returns the collateralBitmap of an eMode category + * @param id The id of the category + * @return The collateralBitmap of the category + */ + function getEModeCategoryCollateralBitmap(uint8 id) external view returns (uint128); + + /** + * @notice Returns the borrowableBitmap of an eMode category + * @param id The id of the category + * @return The borrowableBitmap of the category + */ + function getEModeCategoryBorrowableBitmap(uint8 id) external view returns (uint128); /** * @notice Allows a user to use the protocol in eMode diff --git a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol index 88bf8f22..3bb69ef0 100644 --- a/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol +++ b/src/contracts/protocol/libraries/configuration/EModeConfiguration.sol @@ -12,69 +12,39 @@ import {ReserveConfiguration} from './ReserveConfiguration.sol'; */ library EModeConfiguration { /** - * @notice Sets if the asset is collateral in the given eMode - * @param self The configuration object + * @notice Sets a bit in a given bitmap that represents the reserve index range + * @dev The supplied bitmap is supposed to be a uint128 in which each bit represents a reserve + * @param bitmap The bitmap * @param reserveIndex The index of the reserve in the bitmap - * @param collateral True if the asset should be collateral, false otherwise + * @param enabled True if the reserveIndex should be enabled on the bitmap, false otherwise + * @return The altered bitmap */ - function setCollateral( - DataTypes.EModeCategory memory self, + function setReserveBitmapBit( + uint128 bitmap, uint256 reserveIndex, - bool collateral - ) internal pure { + bool enabled + ) internal pure returns (uint128) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); uint128 bit = uint128(1 << reserveIndex); - if (collateral) { - self.isCollateralBitmap |= bit; + if (enabled) { + return bitmap | bit; } else { - self.isCollateralBitmap &= ~bit; + return bitmap & ~bit; } } } /** - * @notice Validates if a reserve can be used as collaterl in a selected eMode - * @param bitmap The collateral bitmap + * @notice Validates if a reserveIndex is flagged as enabled on a given bitmap + * @param bitmap The bitmap * @param reserveIndex The index of the reserve in the bitmap - * @return True if the reserve is collateral + * @return True if the reserveindex is flagged true */ - function isCollateralAsset(uint128 bitmap, uint256 reserveIndex) internal pure returns (bool) { - unchecked { - require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - return (bitmap >> reserveIndex) & 1 != 0; - } - } - - /** - * @notice Sets if the asset is borrowable in the given eMode - * @param self The configuration object - * @param reserveIndex The index of the reserve in the bitmap - * @param borrowable True if the asset should be borrowable, false otherwise - */ - function setBorrowable( - DataTypes.EModeCategory memory self, - uint256 reserveIndex, - bool borrowable - ) internal pure { - unchecked { - require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); - uint128 bit = uint128(1 << reserveIndex); - if (borrowable) { - self.isBorrowableBitmap |= bit; - } else { - self.isBorrowableBitmap &= ~bit; - } - } - } - - /** - * @notice Validates if a reserve can be borrowed in a selected eMode - * @param bitmap The borrowable bitmap - * @param reserveIndex The index of the reserve in the bitmap - * @return True if the reserve is borrowable - */ - function isBorrowableAsset(uint128 bitmap, uint256 reserveIndex) internal pure returns (bool) { + function isReserveEnabledOnBitmap( + uint128 bitmap, + uint256 reserveIndex + ) internal pure returns (bool) { unchecked { require(reserveIndex < ReserveConfiguration.MAX_RESERVES_COUNT, Errors.INVALID_RESERVE_INDEX); return (bitmap >> reserveIndex) & 1 != 0; diff --git a/src/contracts/protocol/libraries/logic/GenericLogic.sol b/src/contracts/protocol/libraries/logic/GenericLogic.sol index 637475b3..cd5b83c6 100644 --- a/src/contracts/protocol/libraries/logic/GenericLogic.sol +++ b/src/contracts/protocol/libraries/logic/GenericLogic.sol @@ -118,8 +118,8 @@ library GenericLogic { vars.isInEModeCategory = params.userEModeCategory != 0 && - EModeConfiguration.isCollateralAsset( - eModeCategories[params.userEModeCategory].isCollateralBitmap, + EModeConfiguration.isReserveEnabledOnBitmap( + eModeCategories[params.userEModeCategory].collateralBitmap, vars.i ); diff --git a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol index d85dd94d..8f4c35f6 100644 --- a/src/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -138,8 +138,8 @@ library LiquidationLogic { vars.collateralAToken = IAToken(collateralReserve.aTokenAddress); if ( params.userEModeCategory != 0 && - EModeConfiguration.isCollateralAsset( - eModeCategories[params.userEModeCategory].isCollateralBitmap, + EModeConfiguration.isReserveEnabledOnBitmap( + eModeCategories[params.userEModeCategory].collateralBitmap, collateralReserve.id ) ) { diff --git a/src/contracts/protocol/libraries/logic/ValidationLogic.sol b/src/contracts/protocol/libraries/logic/ValidationLogic.sol index 70e77547..e08a30e8 100644 --- a/src/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/src/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -209,8 +209,8 @@ library ValidationLogic { if (params.userEModeCategory != 0) { require( - EModeConfiguration.isBorrowableAsset( - eModeCategories[params.userEModeCategory].isBorrowableBitmap, + EModeConfiguration.isReserveEnabledOnBitmap( + eModeCategories[params.userEModeCategory].borrowableBitmap, reservesData[params.asset].id ), Errors.NOT_BORROWABLE_IN_EMODE @@ -573,7 +573,7 @@ library ValidationLogic { for (uint256 i = 0; i < reservesCount; i++) { if (userConfig.isBorrowing(i)) { require( - EModeConfiguration.isBorrowableAsset(eModeCategory.isBorrowableBitmap, i), + EModeConfiguration.isReserveEnabledOnBitmap(eModeCategory.borrowableBitmap, i), Errors.NOT_BORROWABLE_IN_EMODE ); } diff --git a/src/contracts/protocol/libraries/types/DataTypes.sol b/src/contracts/protocol/libraries/types/DataTypes.sol index 398e7695..13c12c99 100644 --- a/src/contracts/protocol/libraries/types/DataTypes.sol +++ b/src/contracts/protocol/libraries/types/DataTypes.sol @@ -111,14 +111,38 @@ library DataTypes { uint256 data; } + // DEPRECATED: kept for backwards compatibility, might be removed in a future version + struct EModeCategoryLegacy { + // each eMode category has a custom ltv and liquidation threshold + uint16 ltv; + uint16 liquidationThreshold; + uint16 liquidationBonus; + // DEPRECATED + address priceSource; + string label; + } + + struct CollateralConfig { + uint16 ltv; + uint16 liquidationThreshold; + uint16 liquidationBonus; + } + + struct EModeCategoryBaseConfiguration { + uint16 ltv; + uint16 liquidationThreshold; + uint16 liquidationBonus; + string label; + } + struct EModeCategory { // each eMode category has a custom ltv and liquidation threshold uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; - uint128 isCollateralBitmap; + uint128 collateralBitmap; string label; - uint128 isBorrowableBitmap; + uint128 borrowableBitmap; } enum InterestRateMode { diff --git a/src/contracts/protocol/pool/Pool.sol b/src/contracts/protocol/pool/Pool.sol index 170a762c..f4a9812e 100644 --- a/src/contracts/protocol/pool/Pool.sol +++ b/src/contracts/protocol/pool/Pool.sol @@ -686,18 +686,76 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool { /// @inheritdoc IPool function configureEModeCategory( uint8 id, - DataTypes.EModeCategory memory category + DataTypes.EModeCategoryBaseConfiguration memory category ) external virtual override onlyPoolConfigurator { // category 0 is reserved for volatile heterogeneous assets and it's always disabled require(id != 0, Errors.EMODE_CATEGORY_RESERVED); - _eModeCategories[id] = category; + _eModeCategories[id].ltv = category.ltv; + _eModeCategories[id].liquidationThreshold = category.liquidationThreshold; + _eModeCategories[id].liquidationBonus = category.liquidationBonus; + _eModeCategories[id].label = category.label; + } + + /// @inheritdoc IPool + function configureEModeCategoryCollateralBitmap( + uint8 id, + uint128 collateralBitmap + ) external virtual override onlyPoolConfigurator { + // category 0 is reserved for volatile heterogeneous assets and it's always disabled + require(id != 0, Errors.EMODE_CATEGORY_RESERVED); + _eModeCategories[id].collateralBitmap = collateralBitmap; + } + + /// @inheritdoc IPool + function configureEModeCategoryBorrowableBitmap( + uint8 id, + uint128 borrowableBitmap + ) external virtual override onlyPoolConfigurator { + // category 0 is reserved for volatile heterogeneous assets and it's always disabled + require(id != 0, Errors.EMODE_CATEGORY_RESERVED); + _eModeCategories[id].borrowableBitmap = borrowableBitmap; } /// @inheritdoc IPool function getEModeCategoryData( uint8 id - ) external view virtual override returns (DataTypes.EModeCategory memory) { - return _eModeCategories[id]; + ) external view virtual override returns (DataTypes.EModeCategoryLegacy memory) { + DataTypes.EModeCategory memory category = _eModeCategories[id]; + return + DataTypes.EModeCategoryLegacy({ + ltv: category.ltv, + liquidationThreshold: category.liquidationThreshold, + liquidationBonus: category.liquidationBonus, + priceSource: address(0), + label: category.label + }); + } + + /// @inheritdoc IPool + function getEModeCategoryCollateralConfig( + uint8 id + ) external view returns (DataTypes.CollateralConfig memory) { + return + DataTypes.CollateralConfig({ + ltv: _eModeCategories[id].ltv, + liquidationThreshold: _eModeCategories[id].liquidationThreshold, + liquidationBonus: _eModeCategories[id].liquidationBonus + }); + } + + /// @inheritdoc IPool + function getEModeCategoryLabel(uint8 id) external view returns (string memory) { + return _eModeCategories[id].label; + } + + /// @inheritdoc IPool + function getEModeCategoryCollateralBitmap(uint8 id) external view returns (uint128) { + return _eModeCategories[id].collateralBitmap; + } + + /// @inheritdoc IPool + function getEModeCategoryBorrowableBitmap(uint8 id) external view returns (uint128) { + return _eModeCategories[id].borrowableBitmap; } /// @inheritdoc IPool diff --git a/src/contracts/protocol/pool/PoolConfigurator.sol b/src/contracts/protocol/pool/PoolConfigurator.sol index a2429891..778ee79b 100644 --- a/src/contracts/protocol/pool/PoolConfigurator.sol +++ b/src/contracts/protocol/pool/PoolConfigurator.sol @@ -26,7 +26,6 @@ import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20De abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; IPoolAddressesProvider internal _addressesProvider; IPool internal _pool; @@ -397,7 +396,7 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator Errors.INVALID_EMODE_CATEGORY_PARAMS ); - DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + DataTypes.EModeCategoryBaseConfiguration memory categoryData; categoryData.ltv = ltv; categoryData.liquidationThreshold = liquidationThreshold; categoryData.liquidationBonus = liquidationBonus; @@ -420,11 +419,15 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator uint8 categoryId, bool allowed ) external override onlyRiskOrPoolAdmins { - DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + uint128 collateralBitmap = _pool.getEModeCategoryCollateralBitmap(categoryId); DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); - categoryData.setCollateral(reserveData.id, allowed); - _pool.configureEModeCategory(categoryId, categoryData); + collateralBitmap = EModeConfiguration.setReserveBitmapBit( + collateralBitmap, + reserveData.id, + allowed + ); + _pool.configureEModeCategoryCollateralBitmap(categoryId, collateralBitmap); emit AssetCollateralInEModeChanged(asset, categoryId, allowed); } @@ -434,11 +437,15 @@ abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator uint8 categoryId, bool borrowable ) external override onlyRiskOrPoolAdmins { - DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(categoryId); + uint128 borrowableBitmap = _pool.getEModeCategoryBorrowableBitmap(categoryId); DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); - categoryData.setBorrowable(reserveData.id, borrowable); - _pool.configureEModeCategory(categoryId, categoryData); + borrowableBitmap = EModeConfiguration.setReserveBitmapBit( + borrowableBitmap, + reserveData.id, + borrowable + ); + _pool.configureEModeCategoryBorrowableBitmap(categoryId, borrowableBitmap); emit AssetBorrowableInEModeChanged(asset, categoryId, borrowable); } diff --git a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol index 62a3a1d8..196122fb 100644 --- a/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol +++ b/tests/extensions/v3-config-engine/AaveV3ConfigEngineTest.t.sol @@ -568,7 +568,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { configEngine ); - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts + DataTypes.EModeCategoryLegacy memory eModeCategoryDataBefore = contracts .poolProxy .getEModeCategoryData(1); @@ -593,7 +593,7 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { configEngine ); - DataTypes.EModeCategory memory eModeCategoryDataBefore = contracts + DataTypes.EModeCategoryLegacy memory eModeCategoryDataBefore = contracts .poolProxy .getEModeCategoryData(1); @@ -662,19 +662,20 @@ contract AaveV3ConfigEngineTest is TestnetProcedures, ProtocolV3TestBase { diffReports('preTestEngineAssetEModeUpdate', 'postTestEngineAssetEModeUpdate'); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData(asset); - DataTypes.EModeCategory memory eMode = contracts.poolProxy.getEModeCategoryData(1); - assertEq(EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveData.id), false); - assertEq(EModeConfiguration.isCollateralAsset(eMode.isBorrowableBitmap, reserveData.id), true); + uint128 collateralBitmap = contracts.poolProxy.getEModeCategoryCollateralBitmap(1); + uint128 borrowableBitmap = contracts.poolProxy.getEModeCategoryBorrowableBitmap(1); + assertEq(EModeConfiguration.isReserveEnabledOnBitmap(collateralBitmap, reserveData.id), false); + assertEq(EModeConfiguration.isReserveEnabledOnBitmap(borrowableBitmap, reserveData.id), true); DataTypes.ReserveDataLegacy memory reserveDataAsset2 = contracts.poolProxy.getReserveData( asset2 ); assertEq( - EModeConfiguration.isCollateralAsset(eMode.isCollateralBitmap, reserveDataAsset2.id), + EModeConfiguration.isReserveEnabledOnBitmap(collateralBitmap, reserveDataAsset2.id), true ); assertEq( - EModeConfiguration.isCollateralAsset(eMode.isBorrowableBitmap, reserveDataAsset2.id), + EModeConfiguration.isReserveEnabledOnBitmap(borrowableBitmap, reserveDataAsset2.id), false ); } diff --git a/tests/protocol/pool/Pool.Liquidations.t.sol b/tests/protocol/pool/Pool.Liquidations.t.sol index 9e32f271..66dfc23e 100644 --- a/tests/protocol/pool/Pool.Liquidations.t.sol +++ b/tests/protocol/pool/Pool.Liquidations.t.sol @@ -1009,8 +1009,10 @@ contract PoolLiquidationTests is TestnetProcedures { ) internal view returns (uint256, address, address) { uint256 id = contracts.poolProxy.getUserEMode(user); if (id != 0) { - DataTypes.EModeCategory memory cat = contracts.poolProxy.getEModeCategoryData(uint8(id)); - return (cat.liquidationBonus, collateralAsset, debtAsset); + DataTypes.CollateralConfig memory cfg = contracts.poolProxy.getEModeCategoryCollateralConfig( + uint8(id) + ); + return (cfg.liquidationBonus, collateralAsset, debtAsset); } else { DataTypes.ReserveConfigurationMap memory conf = contracts.poolProxy.getConfiguration( debtAsset diff --git a/tests/protocol/pool/Pool.t.sol b/tests/protocol/pool/Pool.t.sol index 5b8907d5..6aec766a 100644 --- a/tests/protocol/pool/Pool.t.sol +++ b/tests/protocol/pool/Pool.t.sol @@ -239,7 +239,7 @@ contract PoolTests is TestnetProcedures { DataTypes.ReserveConfigurationMap memory configuration; - DataTypes.EModeCategory memory category; + DataTypes.EModeCategoryBaseConfiguration memory category; vm.expectRevert(bytes(Errors.CALLER_NOT_POOL_CONFIGURATOR)); pool.initReserve(address(0), address(0), address(0), address(0)); diff --git a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol index 6efddcb9..b15dfc4a 100644 --- a/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol +++ b/tests/protocol/pool/pool-configurator/PoolConfigurator.eMode.sol @@ -12,7 +12,6 @@ import {TestnetProcedures} from '../../../utils/TestnetProcedures.sol'; contract PoolConfiguratorEModeConfigTests is TestnetProcedures { using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - using EModeConfiguration for DataTypes.EModeCategory; event EModeCategoryAdded( uint8 indexed categoryId, @@ -38,13 +37,13 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setEModeCategory(ct.id, ct.ltv, ct.lt, ct.lb, ct.label); - DataTypes.EModeCategory memory emodeConfig = contracts.poolProxy.getEModeCategoryData(ct.id); + DataTypes.EModeCategory memory emodeConfig = _getFullEMode(ct.id); assertEq(emodeConfig.ltv, ct.ltv); assertEq(emodeConfig.liquidationThreshold, ct.lt); assertEq(emodeConfig.liquidationBonus, ct.lb); assertEq(emodeConfig.label, ct.label); - assertEq(emodeConfig.isCollateralBitmap, 0); - assertEq(emodeConfig.isBorrowableBitmap, 0); + assertEq(emodeConfig.collateralBitmap, 0); + assertEq(emodeConfig.borrowableBitmap, 0); } function test_updateEModeCategory() public { @@ -52,7 +51,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { EModeCategoryInput memory ct = _genCategoryOne(); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, 1, true); - DataTypes.EModeCategory memory ogCategory = contracts.poolProxy.getEModeCategoryData(ct.id); + DataTypes.EModeCategory memory ogCategory = _getFullEMode(ct.id); EModeCategoryInput memory updatedCategory = EModeCategoryInput( ct.id, 90_00, @@ -80,13 +79,13 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { updatedCategory.label ); - DataTypes.EModeCategory memory emodeConfig = contracts.poolProxy.getEModeCategoryData(ct.id); + DataTypes.EModeCategory memory emodeConfig = _getFullEMode(ct.id); assertEq(emodeConfig.ltv, updatedCategory.ltv); assertEq(emodeConfig.liquidationThreshold, updatedCategory.lt); assertEq(emodeConfig.liquidationBonus, updatedCategory.lb); assertEq(emodeConfig.label, updatedCategory.label); - assertEq(emodeConfig.isCollateralBitmap, ogCategory.isCollateralBitmap); - assertEq(emodeConfig.isBorrowableBitmap, ogCategory.isBorrowableBitmap); + assertEq(emodeConfig.collateralBitmap, ogCategory.collateralBitmap); + assertEq(emodeConfig.borrowableBitmap, ogCategory.borrowableBitmap); } function test_reverts_setEmodeCategory_zero_ltv() public { @@ -149,11 +148,14 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetCollateralInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, input.id, true); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = _getFullEMode(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveData.id), true); + assertEq( + EModeConfiguration.isReserveEnabledOnBitmap(config.collateralBitmap, reserveData.id), + true + ); } function test_addAnotherAssetCollateralInEMode() public { @@ -162,7 +164,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.wbtc, input.id, true); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = _getFullEMode(input.id); DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( tokenList.usdx ); @@ -170,11 +172,11 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { tokenList.wbtc ); assertEq( - EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveDataUSDX.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.collateralBitmap, reserveDataUSDX.id), true ); assertEq( - EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveDataWBTC.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.collateralBitmap, reserveDataWBTC.id), true ); } @@ -188,12 +190,12 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetCollateralInEMode(tokenList.usdx, prevCt.id, false); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(prevCt.id); + DataTypes.EModeCategory memory config = _getFullEMode(prevCt.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); assertEq( - EModeConfiguration.isCollateralAsset(config.isCollateralBitmap, reserveData.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.collateralBitmap, reserveData.id), false ); } @@ -205,11 +207,14 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, true); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, true); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = _getFullEMode(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); - assertEq(EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveData.id), true); + assertEq( + EModeConfiguration.isReserveEnabledOnBitmap(config.borrowableBitmap, reserveData.id), + true + ); } function test_addAnotherAssetBorrowableInEMode() public { @@ -218,7 +223,7 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.wbtc, input.id, true); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = _getFullEMode(input.id); DataTypes.ReserveDataLegacy memory reserveDataUSDX = contracts.poolProxy.getReserveData( tokenList.usdx ); @@ -226,11 +231,11 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { tokenList.wbtc ); assertEq( - EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveDataUSDX.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.borrowableBitmap, reserveDataUSDX.id), true ); assertEq( - EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveDataWBTC.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.borrowableBitmap, reserveDataWBTC.id), true ); } @@ -242,13 +247,27 @@ contract PoolConfiguratorEModeConfigTests is TestnetProcedures { emit AssetBorrowableInEModeChanged(tokenList.usdx, input.id, false); vm.prank(poolAdmin); contracts.poolConfiguratorProxy.setAssetBorrowableInEMode(tokenList.usdx, input.id, false); - DataTypes.EModeCategory memory config = contracts.poolProxy.getEModeCategoryData(input.id); + DataTypes.EModeCategory memory config = _getFullEMode(input.id); DataTypes.ReserveDataLegacy memory reserveData = contracts.poolProxy.getReserveData( tokenList.usdx ); assertEq( - EModeConfiguration.isBorrowableAsset(config.isBorrowableBitmap, reserveData.id), + EModeConfiguration.isReserveEnabledOnBitmap(config.borrowableBitmap, reserveData.id), false ); } + + function _getFullEMode(uint8 eMode) internal view returns (DataTypes.EModeCategory memory) { + DataTypes.EModeCategory memory eModeCategory; + DataTypes.CollateralConfig memory cfg = contracts.poolProxy.getEModeCategoryCollateralConfig( + eMode + ); + eModeCategory.ltv = cfg.ltv; + eModeCategory.liquidationThreshold = cfg.liquidationThreshold; + eModeCategory.liquidationBonus = cfg.liquidationBonus; + (eModeCategory.label) = contracts.poolProxy.getEModeCategoryLabel(eMode); + (eModeCategory.collateralBitmap) = contracts.poolProxy.getEModeCategoryCollateralBitmap(eMode); + (eModeCategory.borrowableBitmap) = contracts.poolProxy.getEModeCategoryBorrowableBitmap(eMode); + return eModeCategory; + } } diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index eba3c7ac..122c7c23 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -158,16 +158,18 @@ contract ProtocolV3TestBase is DiffUtils { string memory content = '{}'; uint8 emptyCounter = 0; for (uint8 i = 0; i < 256; i++) { - DataTypes.EModeCategory memory category = pool.getEModeCategoryData(i); - if (category.liquidationThreshold == 0) { + DataTypes.CollateralConfig memory cfg = pool.getEModeCategoryCollateralConfig(i); + if (cfg.liquidationThreshold == 0) { if (++emptyCounter > 2) break; } else { string memory key = vm.toString(i); vm.serializeUint(key, 'eModeCategory', i); - vm.serializeString(key, 'label', category.label); - vm.serializeUint(key, 'ltv', category.ltv); - vm.serializeUint(key, 'liquidationThreshold', category.liquidationThreshold); - string memory object = vm.serializeUint(key, 'liquidationBonus', category.liquidationBonus); + vm.serializeString(key, 'label', pool.getEModeCategoryLabel(i)); + vm.serializeUint(key, 'ltv', cfg.ltv); + vm.serializeUint(key, 'collateralBitmap', pool.getEModeCategoryCollateralBitmap(i)); + vm.serializeUint(key, 'borrowableBitmap', pool.getEModeCategoryBorrowableBitmap(i)); + vm.serializeUint(key, 'liquidationThreshold', cfg.liquidationThreshold); + string memory object = vm.serializeUint(key, 'liquidationBonus', cfg.liquidationBonus); content = vm.serializeString(eModesKey, key, object); emptyCounter = 0; } @@ -807,31 +809,31 @@ contract ProtocolV3TestBase is DiffUtils { DataTypes.EModeCategory memory expectedCategoryData ) internal view { address poolAddress = addressesProvider.getPool(); - DataTypes.EModeCategory memory currentCategoryData = IPool(poolAddress).getEModeCategoryData( + DataTypes.CollateralConfig memory cfg = IPool(poolAddress).getEModeCategoryCollateralConfig( uint8(category) ); require( - keccak256(bytes(currentCategoryData.label)) == keccak256(bytes(expectedCategoryData.label)), + keccak256(bytes(IPool(poolAddress).getEModeCategoryLabel(uint8(category)))) == + keccak256(bytes(expectedCategoryData.label)), '_validateEmodeCategory(): INVALID_LABEL' ); + require(cfg.ltv == expectedCategoryData.ltv, '_validateEmodeCategory(): INVALID_LTV'); require( - currentCategoryData.ltv == expectedCategoryData.ltv, - '_validateEmodeCategory(): INVALID_LTV' - ); - require( - currentCategoryData.liquidationThreshold == expectedCategoryData.liquidationThreshold, + cfg.liquidationThreshold == expectedCategoryData.liquidationThreshold, '_validateEmodeCategory(): INVALID_LT' ); require( - currentCategoryData.liquidationBonus == expectedCategoryData.liquidationBonus, + cfg.liquidationBonus == expectedCategoryData.liquidationBonus, '_validateEmodeCategory(): INVALID_LB' ); require( - currentCategoryData.isCollateralBitmap == expectedCategoryData.isCollateralBitmap, + IPool(poolAddress).getEModeCategoryCollateralBitmap(uint8(category)) == + expectedCategoryData.collateralBitmap, '_validateEmodeCategory(): INVALID_LB' ); require( - currentCategoryData.isBorrowableBitmap == expectedCategoryData.isBorrowableBitmap, + IPool(poolAddress).getEModeCategoryBorrowableBitmap(uint8(category)) == + expectedCategoryData.borrowableBitmap, '_validateEmodeCategory(): INVALID_LB' ); } From a1240df950887de5f5b8e333504b879a6b1ef6f4 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 19 Sep 2024 13:33:02 +0200 Subject: [PATCH 81/88] fix: typo fixes (#59) * fix: add comments * Update src/contracts/interfaces/IPool.sol --- .../extensions/v3-config-engine/IAaveV3ConfigEngine.sol | 2 +- src/contracts/interfaces/IPool.sol | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index 6c743d30..cf745de6 100644 --- a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -187,7 +187,7 @@ interface IAaveV3ConfigEngine { /** * @dev Example (mock): - * EModeCollateralUpdate({ + * AssetEModeUpdate({ * asset: AaveV3EthereumAssets.rETH_UNDERLYING, * eModeCategory: 1, // ETH correlated * borrowable: EngineFlags.ENABLED, diff --git a/src/contracts/interfaces/IPool.sol b/src/contracts/interfaces/IPool.sol index 2d25a9ce..01e1bcaf 100644 --- a/src/contracts/interfaces/IPool.sol +++ b/src/contracts/interfaces/IPool.sol @@ -470,6 +470,7 @@ interface IPool { /** * @notice Drop a reserve * @dev Only callable by the PoolConfigurator contract + * @dev Does not reset eMode flags, which must be considered when reusing the same reserve id for a different reserve. * @param asset The address of the underlying asset of the reserve */ function dropReserve(address asset) external; From ea1032452431a8cf27ee519784cd0f2983e3fa3d Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 19 Sep 2024 13:33:50 +0200 Subject: [PATCH 82/88] docs: migration guide (#52) --- Makefile | 4 +- changelog/3.2.md | 102 +++ changelog/3.2_3.1_gas-diff.md | 255 ++++++ docs/gas-diff.md | 1442 --------------------------------- foundry.toml | 41 +- 5 files changed, 382 insertions(+), 1462 deletions(-) create mode 100644 changelog/3.2.md create mode 100644 changelog/3.2_3.1_gas-diff.md delete mode 100644 docs/gas-diff.md diff --git a/Makefile b/Makefile index f46c33c3..e6a424d8 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,6 @@ coverage :; forge coverage --report lcov && \ download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address} git-diff : @mkdir -p diffs - @printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --diff-algorithm=patience --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md + @npx prettier --parser markdown ${before} ${after} --write + @printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md +git-word-diff :; git diff --no-index --word-diff -- ${before} ${after} | tail +6 | sed 's/\[-/\~~/g;s/-]/\~~ /g;' | sed 's/{+/\**/g;s/+}/\**/g;' > diffs/${out}.md diff --git a/changelog/3.2.md b/changelog/3.2.md new file mode 100644 index 00000000..fe50aea5 --- /dev/null +++ b/changelog/3.2.md @@ -0,0 +1,102 @@ +# Aave 3.2 + +Aave 3.2 focuses on two main areas of the aave protocol: + +- the final deprecation of stable borrowing +- improvements on the eModes + +## Stable Rate offboarding + +While previous upgrades allowed graceful offboarding of stable borrowing, now with no stable borrow positions being left the protcol can remove all the now obsolete stable rate related logic. + +### Migration guide + +The upgrade is 100% backwards compatible. +There are no changes to any methods, nor are there changes to emitted events. +Parameters emitted in events that relate to stable rate are nulled. + +## Emodes: Removal of the eMode oracle + +The eMode oracle has never been used and it's usefulnes is debatable. +Therefore to allow for storage optimization within the eMode configuration and reduce unnecessary code paths - the eMode oracle was removed. + +#### Indexers + +For backwards compatibility the existing `EModeCategoryAdded` will be emitted, but with `oracle` being nullified. + +## Emodes: Liquid eModes + +The new Liquid eMode feature of Aave v3.2 removes the previous constraint: **an asset listed on Aave can be eligible for different eModes, and then it only depends on the user to choose which eMode he wants to enter to.** + +For example, with liquid eModes, a possible configuration not doable before would be: + +- eMode 1, with wstETH, weETH and WETH. +- eMode 2, with wstETH and WETH. +- eMode 3, with weETH and WETH. +- eMode 4, with WETH and GHO. + +So then, user A holding the wstETH and weETH collaterals, could borrow WETH at high LTV. +User B holding only wstETH could borrow WETH at high (but different) LTV. +User C holding only weETH could similarly borrow WETH at a different LTV than the previous two eModes. +User D could have a position with WETH collateral and GHO borrowings. + +This doesn’t stop there, as more sophisticated configuration strategies could be adopted, like: + +- eMode for only WETH and stablecoins. +- eMode for onboarding less mature LSTs, without requiring them being together with all major LSTs. + +**For extra configuration flexibility, liquid eModes also allow now to flag an asset as only borrowable, only collateral, or both, in the context of an eMode.** +For example, in a hypothetic eMode with only wstETH and WETH, the normal configuration would be wstETH as only collateral and WETH as only borrowable, fully focusing on the wstETH leverage use-case. + +### BREAKING CHANGES + +- DataTypes.EModeCategory will return the same data as now, but is flagged deprecated and will be removed at a later point. + +- the new version of `PoolDataProvider` no longer exposes `PoolDataProvider.getReserveEModeCategory(address asset)` as there no longer is a `1:1` relation between assets and eModes. +- `reserveConfig.getEModeCategory()` will return the current eMode, but will no longer be updated and is flagged deprecated. + +### Migration guide + +For existing users, the upgrade is 100% backwards compatible and no migration or similar is required. +Entering and leaving an eMode still works via `setUserEMode(categoryId)` and `getUserEMode(address user)` like in previous versions of the protocol. + +#### Indexers + +As collateral/borrowable flags are newly introduced, two new events are being emitted: + +- `event AssetCollateralInEModeChanged(address indexed asset, uint8 categoryId, bool collateral);` +- `event AssetBorrowableInEModeChanged(address indexed asset, uint8 categoryId, bool borrowable);` + +#### Getters + +In aave 3.1 all eMode parameters were exposed via a single `getEModeCategoryData` getter. +When checking existing integrations, we noticed that in most cases this approach is suboptimal, given that users only rely on a subset of the data. +Therefore in addition to the **deprecated** `getEModeCategoryData` getter there are now independent getters for the respective values: + +- `getEModeCategoryCollateralConfig(categoryId)`, returning the eMode ltv,lt,lb +- `getEModeCategoryLabel(categoryId)`, returning the eMode label +- `getEModeCategoryCollateralBitmap(categoryId)`, returning the collateral bitmap +- `getEModeCategoryBorrowableBitmap(categoryId)`, returning the borrowable bitmap + +#### Identifying eModes for an asset + +In the previous version of the eModes feature it was possible to query a reserve configration to receive it's unique eMode. +The relevant bits on the reseve configuration have been nullified. + +To identify eModes of a selected asset, there is currently multiple options: + +- onchain one can iterate trough eModes and select the "correct one" based on your application specific needs. + +```sol +for (uint8 i = 1; i < 256; i++) { + DataTypes.CollateralConfig memory cfg = pool.getEModeCategoryCollateralConfig(i); + // check if it is an active eMode + if (cfg.liquidationThreshold != 0) { + // check if it's an eMode you are interested in + EModeConfiguration.isCollateralAsset(pool.getEModeCategoryCollateralBitmap(i), someReserveIndex); + EModeConfiguration.isBorrowableAsset(pool.getEModeCategoryBorrowableBitmap(i), someReserveIndex); + } +} +``` + +- an offchain system could listen to `AssetCollateralInEModeChanged` & `AssetBorrowableInEModeChanged` events and feed the onchain contract with an appropriate categoryId diff --git a/changelog/3.2_3.1_gas-diff.md b/changelog/3.2_3.1_gas-diff.md new file mode 100644 index 00000000..59555afb --- /dev/null +++ b/changelog/3.2_3.1_gas-diff.md @@ -0,0 +1,255 @@ +```diff +diff --git a/reports/gas.old b/reports/gas.new +index 27edd2c..d023564 100644 +--- a/reports/gas.old ++++ b/reports/gas.new +@@ -1,28 +1,27 @@ + | Deployment Cost | Deployment Size | | | | | + | 465623 | 2115 | | | | | + | Function Name | min | avg | median | max | # calls | +-| ADDRESSES_PROVIDER | 898 | 3118 | 965 | 5465 | 2960 | ++| ADDRESSES_PROVIDER | 898 | 4362 | 5398 | 5465 | 3204 | +-| DOMAIN_SEPARATOR | 1071 | 3102 | 3071 | 7571 | 260 | ++| DOMAIN_SEPARATOR | 1071 | 4688 | 4156 | 7571 | 5 | +-| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 711 | ++| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 657 | +-| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2032 | 3002 | 7524 | 1426 | ++| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1318 | +-| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1095 | 1099 | 1095 | 7595 | 1423 | ++| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1051 | 1075 | 1073 | 7573 | 1315 | +-| MAX_GRACE_PERIOD | 5418 | 5418 | 5418 | 5418 | 1792 | ++| MAX_GRACE_PERIOD | 5374 | 5374 | 5374 | 5374 | 1792 | +-| MAX_NUMBER_RESERVES | 922 | 922 | 922 | 922 | 1 | ++| MAX_NUMBER_RESERVES | 900 | 900 | 900 | 900 | 512 | +-| MAX_STABLE_RATE_BORROW_SIZE_PERCENT | 1001 | 1001 | 1001 | 1001 | 1 | +-| POOL | 940 | 2117 | 940 | 5440 | 107 | ++| POOL | 940 | 940 | 940 | 940 | 151 | +-| RESERVE_TREASURY_ADDRESS | 1033 | 3279 | 3033 | 7533 | 2582 | ++| RESERVE_TREASURY_ADDRESS | 1033 | 1399 | 1033 | 7533 | 11254 | +-| UNDERLYING_ASSET_ADDRESS | 1011 | 1245 | 1011 | 3055 | 875 | ++| UNDERLYING_ASSET_ADDRESS | 1011 | 1048 | 1055 | 3055 | 18525 | +-| approve | 51281 | 51337 | 51305 | 51653 | 3093 | ++| approve | 51293 | 51357 | 51341 | 51653 | 39 | +-| backUnbacked | 139070 | 153427 | 150732 | 173679 | 9 | ++| backUnbacked | 125314 | 140965 | 138917 | 159923 | 9 | +-| balanceOf | 1033 | 3698 | 3360 | 22860 | 26304 | ++| balanceOf | 1297 | 5838 | 5387 | 22882 | 13022 | +-| borrow(address,uint256,uint256,uint16,address) | 85039 | 259204 | 263334 | 310883 | 2928 | ++| borrow(address,uint256,uint256,uint16,address) | 74012 | 236273 | 249909 | 289117 | 3979 | +-| borrow(bytes32) | 243318 | 243318 | 243318 | 243318 | 3 | ++| borrow(bytes32) | 229784 | 229784 | 229784 | 229784 | 3 | +-| borrowAllowance | 1398 | 1424 | 1424 | 1450 | 10 | ++| borrowAllowance | 1450 | 1450 | 1450 | 1450 | 5 | +-| configureEModeCategory | 34510 | 34532 | 34532 | 34555 | 512 | ++| configureEModeCategory | 34265 | 34276 | 34276 | 34287 | 512 | +-| configureReserveAsCollateral | 44067 | 64132 | 72201 | 122702 | 778 | ++| configureReserveAsCollateral | 44089 | 64560 | 57776 | 122574 | 2308 | +-| decimals | 948 | 1020 | 970 | 7470 | 801 | ++| decimals | 948 | 980 | 970 | 7470 | 18578 | + | decreaseAllowance | 34424 | 34424 | 34424 | 34424 | 1 | +-| delegationWithSig | 29263 | 56423 | 45286 | 84345 | 14 | ++| delegationWithSig | 29263 | 56402 | 45264 | 84300 | 7 | +-| deposit | 185121 | 234784 | 238060 | 247660 | 4362 | ++| deposit | 91045 | 215439 | 232166 | 235786 | 64 | +-| disableLiquidationGracePeriod | 43659 | 55023 | 66191 | 66191 | 513 | ++| disableLiquidationGracePeriod | 43570 | 54942 | 66117 | 66117 | 513 | +-| dropReserve | 32591 | 35807 | 32679 | 114160 | 775 | ++| dropReserve | 32635 | 35738 | 32657 | 105160 | 775 | +-| flashLoan | 59460 | 177954 | 155739 | 374408 | 266 | ++| flashLoan | 59293 | 166429 | 135219 | 374226 | 267 | +-| flashLoanSimple | 50968 | 322401 | 191286 | 664969 | 11 | ++| flashLoanSimple | 50944 | 311942 | 179440 | 642995 | 11 | +-| getAssetIndex | 3098 | 10053 | 9606 | 16527 | 9694 | ++| getAssetIndex | 3708 | 11517 | 14698 | 21619 | 90 | +-| getAverageStableRate | 5340 | 5340 | 5340 | 5340 | 1 | +-| getBorrowLogic | 5417 | 5428 | 5428 | 5439 | 2 | ++| getBorrowLogic | 5395 | 5417 | 5417 | 5439 | 2 | +-| getClaimer | 1244 | 7718 | 7744 | 7744 | 514 | ++| getClaimer | 1244 | 3410 | 1244 | 7744 | 3 | +-| getConfiguration | 1298 | 1981 | 1320 | 7820 | 32304 | ++| getConfiguration | 1342 | 1917 | 1364 | 7864 | 56492 | +-| getConfiguratorLogic | 5353 | 5353 | 5353 | 5353 | 1 | ++| getConfiguratorLogic | 5397 | 5397 | 5397 | 5397 | 1 | + | getDistributionEnd | 1411 | 1411 | 1411 | 1411 | 1 | +-| getEModeCategoryData | 2532 | 6296 | 6793 | 11032 | 55 | ++| getEModeCategoryData | 13446 | 13446 | 13446 | 13446 | 3 | +-| getEModeLogic | 5392 | 5403 | 5403 | 5414 | 2 | ++| getEModeLogic | 5392 | 5425 | 5425 | 5459 | 2 | +-| getFlashLoanLogic | 5394 | 5405 | 5405 | 5416 | 2 | ++| getFlashLoanLogic | 5416 | 5438 | 5438 | 5461 | 2 | +-| getIncentivesController | 1044 | 1082 | 1067 | 7588 | 787 | ++| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 18392 | +-| getLiquidationGracePeriod | 29229 | 29229 | 29229 | 29229 | 2258 | ++| getLiquidationGracePeriod | 29185 | 29204 | 29207 | 29207 | 2270 | +-| getLiquidationLogic | 5439 | 5439 | 5439 | 5439 | 2 | ++| getLiquidationLogic | 5439 | 5450 | 5450 | 5461 | 2 | +-| getPendingLtv | 1215 | 1215 | 1215 | 1215 | 771 | ++| getPendingLtv | 1259 | 1259 | 1259 | 1259 | 771 | +-| getPoolLogic | 5416 | 5438 | 5438 | 5460 | 2 | ++| getPoolLogic | 5393 | 5415 | 5415 | 5438 | 2 | ++| getEModeCategoryBorrowableBitmap | 1287 | 7705 | 7787 | 7787 | 1827 | ++| getEModeCategoryCollateralBitmap | 1297 | 7732 | 7797 | 7797 | 2624 | ++| getEModeCategoryCollateralConfig | 1511 | 2351 | 1511 | 8011 | 110 | ++| getEModeCategoryLabel | 1954 | 2271 | 2212 | 3954 | 25 | + | getPreviousIndex | 1270 | 1270 | 1270 | 1270 | 39 | + | getReserveAddressById | 1281 | 1281 | 1281 | 1281 | 1 | +-| getReserveData | 5007 | 7533 | 5029 | 29529 | 11478 | ++| getReserveData | 4889 | 12060 | 10933 | 29433 | 24876 | +-| getReserveDataExtended | 4122 | 16316 | 4122 | 28622 | 1547 | ++| getReserveDataExtended | 4186 | 4852 | 4186 | 6186 | 6 | +-| getReserveNormalizedIncome | 0 | 3480 | 1465 | 10427 | 28339 | ++| getReserveNormalizedIncome | 1443 | 1928 | 1487 | 10449 | 12324 | +-| getReserveNormalizedVariableDebt | 1487 | 1681 | 1509 | 11607 | 7456 | ++| getReserveNormalizedVariableDebt | 1465 | 1675 | 1509 | 11607 | 7709 | +-| getReservesCount | 1028 | 1028 | 1028 | 1028 | 1 | ++| getReservesCount | 1006 | 1006 | 1006 | 1006 | 2 | +-| getReservesList | 3804 | 14119 | 16304 | 16304 | 1632 | ++| getReservesList | 3814 | 14280 | 11814 | 104107 | 4195 | +-| getRewardsByAsset | 2399 | 10619 | 10899 | 10899 | 2419 | ++| getRewardsByAsset | 2399 | 5698 | 3672 | 10899 | 201 | +-| getScaledUserBalanceAndSupply | 1449 | 5068 | 3449 | 9949 | 21 | ++| getScaledUserBalanceAndSupply | 1449 | 4192 | 3449 | 9949 | 39 | +-| getSupplyData | 941 | 4320 | 5441 | 5441 | 24634 | +-| getSupplyLogic | 5395 | 5406 | 5406 | 5417 | 2 | ++| getSupplyLogic | 5395 | 5427 | 5427 | 5459 | 2 | +-| getTotalSupplyAndAvgRate | 5467 | 5467 | 5467 | 5467 | 1 | +-| getTotalSupplyLastUpdated | 5380 | 5380 | 5380 | 5380 | 1 | +-| getUserAccountData | 20331 | 23740 | 24831 | 33184 | 1037 | ++| getUserAccountData | 12857 | 22690 | 23001 | 38126 | 2575 | +-| getUserConfiguration | 1322 | 1379 | 1322 | 3322 | 1822 | +-| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1036 | +-| getUserLastUpdated | 1063 | 1066 | 1063 | 5563 | 1303 | +-| getUserRewards | 7469 | 8705 | 8749 | 17526 | 267 | +-| getUserStableRate | 1053 | 1056 | 1053 | 5553 | 1303 | +-| getVirtualUnderlyingBalance | 1298 | 1298 | 1298 | 1298 | 2161 | ++| getUserConfiguration | 1322 | 1367 | 1322 | 3322 | 1821 | ++| getUserEMode | 1253 | 1253 | 1253 | 1253 | 1296 | ++| getUserRewards | 5237 | 7340 | 7469 | 10837 | 19 | ++| getVirtualUnderlyingBalance | 1276 | 1276 | 1276 | 1343 | 2159 | +-| initReserve | 33566 | 33566 | 33566 | 33566 | 1024 | ++| initReserve | 33292 | 33324 | 33324 | 33356 | 1024 | +-| initReserves | 43976 | 1109034 | 67095 | 266376563 | 777 | ++| initReserves | 45710 | 32954623 | 1608767 | 216346556 | 2049 | +-| liquidationCall(address,address,address,uint256,bool) | 93735 | 277164 | 373019 | 436593 | 3511 | ++| liquidationCall(address,address,address,uint256,bool) | 80781 | 265740 | 351321 | 411059 | 3772 | +-| liquidationCall(bytes32,bytes32) | 436101 | 436101 | 436101 | 436101 | 1 | ++| liquidationCall(bytes32,bytes32) | 403478 | 403478 | 403478 | 403478 | 1 | +-| mintToTreasury(address[]) | 99379 | 100961 | 100961 | 102543 | 4 | ++| mintToTreasury(address[]) | 99355 | 100937 | 100937 | 102519 | 4 | +-| mintUnbacked | 39431 | 157624 | 142643 | 206928 | 17 | +-| name | 1883 | 2336 | 1883 | 8383 | 1130 | +-| nonces | 1193 | 3233 | 3271 | 3271 | 266 | ++| mintUnbacked | 39409 | 145643 | 130769 | 193113 | 17 | ++| name | 1625 | 2060 | 1945 | 8383 | 18717 | ++| nonces | 1193 | 2463 | 3271 | 3271 | 10 | +-| principalBalanceOf | 1054 | 1058 | 1054 | 5554 | 1304 | +-| rebalanceStableBorrowRate(address,address) | 66731 | 77785 | 76855 | 90701 | 4 | +-| rebalanceStableBorrowRate(bytes32) | 88567 | 88567 | 88567 | 88567 | 1 | +-| repay(address,uint256,uint256,address) | 72862 | 145786 | 183147 | 202671 | 12 | +-| repay(bytes32) | 171079 | 171079 | 171079 | 171079 | 1 | ++| repay(address,uint256,uint256,address) | 60515 | 129404 | 167787 | 187188 | 13 | +-| repayWithATokens(address,uint256,uint256) | 169667 | 197449 | 198790 | 209791 | 261 | ++| repayWithATokens(address,uint256,uint256) | 155169 | 181413 | 182340 | 193364 | 261 | +-| repayWithATokens(bytes32) | 174264 | 174264 | 174264 | 174264 | 1 | +-| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 172046 | 202393 | 206845 | 235069 | 768 | ++| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155747 | 185446 | 182899 | 218983 | 768 | +-| repayWithPermit(bytes32,bytes32,bytes32) | 206026 | 223388 | 232772 | 234406 | 256 | ++| repayWithPermit(bytes32,bytes32,bytes32) | 187610 | 205991 | 197025 | 217816 | 256 | +-| rescueTokens | 39115 | 70330 | 70428 | 70493 | 515 | ++| repay(bytes32) | 157379 | 157379 | 157379 | 157379 | 1 | ++| repayWithATokens(bytes32) | 160457 | 160457 | 160457 | 160457 | 1 | ++| rescueTokens | 39115 | 70351 | 70450 | 70515 | 515 | +-| scaledBalanceOf | 1307 | 3892 | 3307 | 7807 | 17058 | +-| scaledTotalSupply | 988 | 6174 | 7532 | 7532 | 24923 | +-| setAssetEModeCategory | 43877 | 48416 | 43877 | 79492 | 296 | +-| setBorrowCap | 43786 | 44831 | 43786 | 70877 | 268 | +-| setBorrowableInIsolation | 67664 | 70079 | 70466 | 70466 | 13 | +-| setConfiguration | 32805 | 32816 | 32816 | 32827 | 512 | +-| setDebtCeiling | 43831 | 48208 | 43831 | 121793 | 274 | +-| setEModeCategory | 45031 | 53891 | 45031 | 135403 | 295 | ++| scaledBalanceOf | 1307 | 3796 | 3307 | 7807 | 21200 | ++| scaledTotalSupply | 988 | 6101 | 7532 | 7532 | 23280 | ++| setAssetBorrowableInEMode | 94407 | 111508 | 111507 | 124758 | 1801 | ++| setAssetCollateralInEMode | 44103 | 99490 | 107690 | 107690 | 2853 | ++| setBorrowCap | 43764 | 44722 | 43764 | 70919 | 267 | ++| setBorrowableInIsolation | 67662 | 70075 | 70464 | 70464 | 13 | ++| setConfiguration | 32783 | 32794 | 32794 | 32805 | 512 | ++| setDebtCeiling | 43743 | 48113 | 43743 | 121555 | 274 | ++| setEModeCategory | 44850 | 102968 | 108880 | 108892 | 2849 | +-| setLiquidationGracePeriod | 32857 | 37965 | 37379 | 43790 | 1536 | +-| setLiquidationProtocolFee | 43996 | 60580 | 69836 | 70926 | 8 | +-| setPoolPause(bool) | 41133 | 43634 | 43639 | 43645 | 512 | +-| setPoolPause(bool,uint40) | 43789 | 88304 | 105603 | 134276 | 515 | +-| setReserveActive | 40884 | 44328 | 40884 | 118172 | 269 | +-| setReserveBorrowing | 43811 | 44179 | 43811 | 68496 | 260 | +-| setReserveFactor | 43744 | 44228 | 43744 | 168324 | 258 | +-| setReserveFlashLoaning | 68469 | 69188 | 68471 | 70625 | 3 | +-| setReserveFreeze | 47022 | 73134 | 74781 | 99799 | 784 | +-| setReserveInterestRateData | 44304 | 44449 | 44532 | 44532 | 256 | +-| setReserveInterestRateStrategyAddress(address,address) | 32846 | 34595 | 33195 | 42729 | 1538 | +-| setReserveInterestRateStrategyAddress(address,address,bytes) | 44536 | 46606 | 44536 | 204894 | 260 | +-| setReservePause(address,bool) | 43900 | 57019 | 69938 | 69938 | 513 | +-| setReservePause(address,bool,uint40) | 41267 | 65950 | 73872 | 78984 | 3086 | +-| setReserveStableRateBorrowing | 43878 | 55083 | 43878 | 70726 | 447 | +-| setSiloedBorrowing | 110540 | 120362 | 124195 | 126351 | 3 | +-| setSupplyCap | 43766 | 57641 | 70845 | 70881 | 528 | +-| setUnbackedMintCap | 70847 | 70847 | 70847 | 70847 | 7 | +-| setUserEMode | 48307 | 69273 | 66533 | 124479 | 17 | +-| setUserUseReserveAsCollateral(address,bool) | 91258 | 106982 | 102533 | 146832 | 42 | +-| setUserUseReserveAsCollateral(bytes32) | 104249 | 104249 | 104249 | 104249 | 1 | ++| setLiquidationGracePeriod | 32850 | 37953 | 37372 | 43783 | 1536 | ++| setLiquidationProtocolFee | 43996 | 60620 | 69900 | 70990 | 8 | ++| setPoolPause(bool) | 43546 | 43975 | 43558 | 116350 | 515 | ++| setPoolPause(bool,uint40) | 43789 | 88446 | 74811 | 134413 | 512 | ++| setReserveActive | 40906 | 43807 | 40906 | 118044 | 267 | ++| setReserveBorrowing | 43855 | 62331 | 68490 | 68492 | 1024 | ++| setReserveFactor | 43788 | 44208 | 43788 | 151867 | 258 | ++| setReserveFlashLoaning | 68489 | 68494 | 68491 | 70645 | 513 | ++| setReserveFreeze | 47044 | 73136 | 74867 | 99885 | 782 | ++| setReserveInterestRateData | 44360 | 44843 | 44576 | 131113 | 257 | ++| setReserveInterestRateStrategyAddress(address,address) | 32846 | 34588 | 33195 | 42729 | 1538 | ++| setReserveInterestRateStrategyAddress(address,address,bytes) | 44491 | 61354 | 44491 | 190210 | 300 | ++| setReservePause(address,bool) | 43834 | 44174 | 44062 | 67780 | 258 | ++| setReservePause(address,bool,uint40) | 41289 | 65779 | 73951 | 76263 | 3084 | ++| setSiloedBorrowing | 102106 | 111970 | 115825 | 117981 | 3 | ++| setSupplyCap | 43721 | 45734 | 43721 | 70876 | 279 | ++| setUnbackedMintCap | 70911 | 70911 | 70911 | 70911 | 7 | ++| setUserEMode | 40484 | 73767 | 67458 | 121154 | 2583 | ++| setUserUseReserveAsCollateral(address,bool) | 80336 | 96351 | 93552 | 129626 | 42 | ++| setUserUseReserveAsCollateral(bytes32) | 95351 | 95351 | 95351 | 95351 | 1 | +-| supply(address,uint256,address,uint16) | 67576 | 224075 | 242895 | 255446 | 3134 | ++| supply(address,uint256,address,uint16) | 56642 | 219107 | 226317 | 243572 | 5603 | +-| supply(bytes32) | 248862 | 248862 | 248862 | 248862 | 7 | ++| supply(bytes32) | 236988 | 236988 | 236988 | 236988 | 7 | +-| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 154205 | 228834 | 253878 | 278406 | 768 | ++| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216981 | 242026 | 266578 | 768 | +-| supplyWithPermit(bytes32,bytes32,bytes32) | 274396 | 274465 | 274438 | 274588 | 256 | ++| supplyWithPermit(bytes32,bytes32,bytes32) | 262610 | 262681 | 262658 | 262802 | 256 | +-| swapBorrowRateMode(address,uint256) | 71875 | 82362 | 72110 | 108180 | 7 | +-| swapBorrowRateMode(bytes32) | 110034 | 110034 | 110034 | 110034 | 1 | +-| symbol | 1690 | 2535 | 1904 | 8448 | 1098 | ++| symbol | 1646 | 2124 | 2010 | 8448 | 18692 | +-| totalSupply | 907 | 8067 | 11570 | 15570 | 5078 | ++| totalSupply | 1024 | 8836 | 11592 | 15592 | 5958 | +-| transfer | 27662 | 142942 | 149371 | 177944 | 273 | ++| transfer | 27662 | 143985 | 149393 | 167091 | 273 | +-| transferFrom | 138680 | 138800 | 138800 | 138920 | 2 | ++| transferFrom | 138702 | 138822 | 138822 | 138942 | 2 | +-| updateAToken | 41834 | 42242 | 41834 | 146921 | 257 | +-| updateBridgeProtocolFee | 32528 | 33708 | 32595 | 78343 | 526 | +-| updateFlashloanPremiumToProtocol | 40448 | 40537 | 40448 | 63402 | 258 | +-| updateFlashloanPremiumTotal | 40447 | 40536 | 40447 | 63412 | 258 | +-| updateFlashloanPremiums | 32898 | 32909 | 32909 | 32920 | 512 | +-| updateStableDebtToken | 41688 | 42073 | 41688 | 140830 | 257 | +-| updateVariableDebtToken | 41710 | 42095 | 41710 | 140832 | 257 | ++| updateAToken | 41767 | 42175 | 41767 | 146804 | 257 | ++| updateBridgeProtocolFee | 32528 | 33697 | 32573 | 78365 | 526 | ++| updateFlashloanPremiumToProtocol | 40448 | 40537 | 40448 | 63357 | 258 | ++| updateFlashloanPremiumTotal | 40402 | 40491 | 40402 | 63322 | 258 | ++| updateFlashloanPremiums | 32853 | 32864 | 32864 | 32875 | 512 | ++| updateVariableDebtToken | 41622 | 42007 | 41622 | 140688 | 257 | +-| withdraw(address,uint256,address) | 77252 | 147744 | 154662 | 224961 | 23 | ++| withdraw(address,uint256,address) | 66318 | 134721 | 141942 | 204789 | 23 | +-| withdraw(bytes32) | 150631 | 157711 | 157711 | 164791 | 2 | ++| withdraw(bytes32) | 138760 | 145839 | 145839 | 152919 | 2 | +``` diff --git a/docs/gas-diff.md b/docs/gas-diff.md deleted file mode 100644 index 38a59c4a..00000000 --- a/docs/gas-diff.md +++ /dev/null @@ -1,1442 +0,0 @@ -```diff -diff --git a/reports/gas.old b/reports/gas.new -index 0dec812..fe1d1d0 100644 ---- a/reports/gas.old -+++ b/reports/gas.new -@@ -27,37 +27,37 @@ - | claimRewardsOnBehalf | 41981 | 41981 | 41981 | 41981 | 1 | - | claimRewardsToSelf | 61212 | 143791 | 147239 | 188315 | 8 | - | collectAndUpdateRewards | 60947 | 102021 | 102021 | 143096 | 2 | --| convertToAssets | 3348 | 3493 | 3496 | 3496 | 261 | --| convertToShares | 22946 | 22946 | 22946 | 22946 | 1 | --| createStaticATokens | 2375769 | 2375769 | 2375769 | 2375769 | 46 | -+| convertToAssets | 3370 | 3514 | 3518 | 3518 | 261 | -+| convertToShares | 22968 | 22968 | 22968 | 22968 | 1 | -+| createStaticATokens | 2375835 | 2375835 | 2375835 | 2375835 | 46 | - | decimals | 3154 | 3154 | 3154 | 3154 | 1 | --| deposit | 216564 | 235000 | 237907 | 237919 | 22 | -+| deposit | 216608 | 235044 | 237951 | 237963 | 22 | - | getClaimableRewards | 7438 | 9046 | 7653 | 12042 | 17 | - | getStaticAToken | 1414 | 1414 | 1414 | 1414 | 52 | - | getStaticATokens | 16900 | 16900 | 16900 | 16900 | 2 | - | getTotalClaimableRewards | 8608 | 10621 | 10429 | 14208 | 9 | - | getUnclaimedRewards | 1590 | 1590 | 1590 | 1590 | 2 | --| maxDeposit | 33171 | 37914 | 33690 | 44759 | 5 | --| maxMint | 9226 | 57576 | 57765 | 57765 | 257 | --| maxRedeem | 10705 | 13359 | 14138 | 14600 | 18 | --| maxWithdraw | 14471 | 15471 | 15471 | 16471 | 2 | --| metaDeposit | 285952 | 343531 | 354571 | 390070 | 3 | --| metaWithdraw | 211664 | 211664 | 211664 | 211664 | 1 | --| mint | 76230 | 188856 | 188856 | 301483 | 2 | -+| maxDeposit | 33193 | 37936 | 33712 | 44781 | 5 | -+| maxMint | 9248 | 57620 | 57809 | 57809 | 257 | -+| maxRedeem | 10727 | 13402 | 14182 | 14644 | 18 | -+| maxWithdraw | 14537 | 15537 | 15537 | 16537 | 2 | -+| metaDeposit | 285996 | 343575 | 354615 | 390114 | 3 | -+| metaWithdraw | 211708 | 211708 | 211708 | 211708 | 1 | -+| mint | 76274 | 188911 | 188911 | 301549 | 2 | - | name | 10556 | 10556 | 10556 | 10556 | 1 | - | nonces | 3433 | 7147 | 9933 | 9933 | 7 | - | permit | 31503 | 58858 | 60440 | 84631 | 3 | --| previewDeposit | 3445 | 10445 | 10945 | 16445 | 4 | --| previewMint | 3687 | 3687 | 3687 | 3687 | 1 | --| previewRedeem | 3539 | 3539 | 3539 | 3539 | 3 | --| previewWithdraw | 3662 | 3662 | 3662 | 3662 | 1 | --| rate | 3037 | 3037 | 3037 | 3037 | 1 | --| redeem(uint256,address,address) | 76729 | 231188 | 257218 | 318137 | 9 | --| redeem(uint256,address,address,bool) | 181326 | 181326 | 181326 | 181326 | 1 | -+| previewDeposit | 3467 | 10467 | 10967 | 16467 | 4 | -+| previewMint | 3709 | 3709 | 3709 | 3709 | 1 | -+| previewRedeem | 3561 | 3561 | 3561 | 3561 | 3 | -+| previewWithdraw | 3684 | 3684 | 3684 | 3684 | 1 | -+| rate | 3059 | 3059 | 3059 | 3059 | 1 | -+| redeem(uint256,address,address) | 76773 | 231269 | 257306 | 318225 | 9 | -+| redeem(uint256,address,address,bool) | 181370 | 181370 | 181370 | 181370 | 1 | - | refreshRewardTokens | 128879 | 128879 | 128879 | 128879 | 33 | - | symbol | 4143 | 4143 | 4143 | 4143 | 1 | - | transfer | 101595 | 101595 | 101595 | 101595 | 1 | --| withdraw | 239849 | 239849 | 239849 | 239849 | 1 | -+| withdraw | 239959 | 239959 | 239959 | 239959 | 1 | - - - | src/contracts/dependencies/weth/WETH9.sol:WETH9 contract | | | | | | -@@ -66,9 +66,9 @@ - | 546391 | 2423 | | | | | - | Function Name | min | avg | median | max | # calls | - | allowance | 803 | 803 | 803 | 803 | 20 | --| approve | 29055 | 46249 | 46467 | 46467 | 1806 | --| balanceOf | 541 | 989 | 541 | 2541 | 9310 | --| decimals | 2313 | 2313 | 2313 | 2313 | 636 | -+| approve | 29055 | 46247 | 46467 | 46467 | 1794 | -+| balanceOf | 541 | 989 | 541 | 2541 | 9250 | -+| decimals | 2313 | 2313 | 2313 | 2313 | 641 | - | symbol | 1213 | 2250 | 3213 | 3213 | 27 | - - -@@ -91,7 +91,7 @@ - | 2050064 | 10159 | | | | | - | Function Name | min | avg | median | max | # calls | - | owner | 386 | 386 | 386 | 386 | 1 | --| swapAndDeposit | 352192 | 443390 | 475524 | 502455 | 3 | -+| swapAndDeposit | 352280 | 443455 | 475577 | 502508 | 3 | - - - | src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol:ParaSwapRepayAdapter contract | | | | | | -@@ -101,7 +101,7 @@ - | Function Name | min | avg | median | max | # calls | - | owner | 408 | 408 | 408 | 408 | 1 | - | rescueTokens | 36133 | 36133 | 36133 | 36133 | 1 | --| swapAndRepay | 405121 | 515303 | 535881 | 584329 | 4 | -+| swapAndRepay | 404879 | 515029 | 535596 | 584044 | 4 | - - - | src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol:ParaSwapWithdrawSwapAdapter contract | | | | | | -@@ -110,7 +110,7 @@ - | 1757703 | 8731 | | | | | - | Function Name | min | avg | median | max | # calls | - | owner | 408 | 408 | 408 | 408 | 1 | --| withdrawAndSwap | 352139 | 378370 | 371176 | 411796 | 3 | -+| withdrawAndSwap | 352227 | 378435 | 371229 | 411849 | 3 | - - - | src/contracts/extensions/static-a-token/StataOracle.sol:StataOracle contract | | | | | | -@@ -118,8 +118,8 @@ - | Deployment Cost | Deployment Size | | | | | - | 349225 | 1737 | | | | | - | Function Name | min | avg | median | max | # calls | --| getAssetPrice | 14792 | 14877 | 14792 | 36792 | 257 | --| getAssetsPrices | 87496 | 87496 | 87496 | 87496 | 1 | -+| getAssetPrice | 14814 | 14899 | 14814 | 36814 | 257 | -+| getAssetsPrices | 87562 | 87562 | 87562 | 87562 | 1 | - - - | src/contracts/extensions/static-a-token/StaticATokenFactory.sol:StaticATokenFactory contract | | | | | | -@@ -128,10 +128,10 @@ - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | - | STATIC_A_TOKEN_IMPL | 228 | 228 | 228 | 228 | 1 | --| createStaticATokens | 2345990 | 2345990 | 2345990 | 2345990 | 46 | -+| createStaticATokens | 2346056 | 2346056 | 2346056 | 2346056 | 46 | - | getStaticAToken | 616 | 616 | 616 | 616 | 52 | - | getStaticATokens | 9587 | 9587 | 9587 | 9587 | 2 | --| initialize | 24131 | 24131 | 24131 | 24131 | 624 | -+| initialize | 24131 | 24131 | 24131 | 24131 | 629 | - - - | src/contracts/extensions/static-a-token/StaticATokenLM.sol:StaticATokenLM contract | | | | | | -@@ -153,35 +153,35 @@ - | claimRewardsOnBehalf | 12204 | 12204 | 12204 | 12204 | 1 | - | claimRewardsToSelf | 32183 | 127811 | 128173 | 179199 | 8 | - | collectAndUpdateRewards | 32217 | 73291 | 73291 | 114366 | 2 | --| convertToAssets | 2550 | 2695 | 2698 | 2698 | 261 | --| convertToShares | 15648 | 15648 | 15648 | 15648 | 1 | -+| convertToAssets | 2572 | 2716 | 2720 | 2720 | 261 | -+| convertToShares | 15670 | 15670 | 15670 | 15670 | 1 | - | decimals | 2359 | 2359 | 2359 | 2359 | 1 | --| deposit | 196987 | 215388 | 218294 | 218294 | 22 | -+| deposit | 197031 | 215432 | 218338 | 218338 | 22 | - | getClaimableRewards | 6637 | 8244 | 6852 | 11241 | 17 | - | getTotalClaimableRewards | 7810 | 9823 | 9631 | 13410 | 9 | - | getUnclaimedRewards | 789 | 789 | 789 | 789 | 2 | - | initialize | 25757 | 181941 | 180780 | 187780 | 139 | --| maxDeposit | 25873 | 30616 | 26392 | 37461 | 5 | --| maxMint | 8428 | 50303 | 50467 | 50467 | 257 | --| maxRedeem | 9907 | 12561 | 13340 | 13802 | 18 | --| maxWithdraw | 13673 | 14673 | 14673 | 15673 | 2 | --| metaDeposit | 272703 | 338943 | 347430 | 396697 | 3 | --| metaWithdraw | 180770 | 180770 | 180770 | 180770 | 1 | --| mint | 47284 | 169867 | 169867 | 292450 | 2 | -+| maxDeposit | 25895 | 30638 | 26414 | 37483 | 5 | -+| maxMint | 8450 | 50347 | 50511 | 50511 | 257 | -+| maxRedeem | 9929 | 12604 | 13384 | 13846 | 18 | -+| maxWithdraw | 13739 | 14739 | 14739 | 15739 | 2 | -+| metaDeposit | 272747 | 338987 | 347474 | 396741 | 3 | -+| metaWithdraw | 180814 | 180814 | 180814 | 180814 | 1 | -+| mint | 47328 | 169922 | 169922 | 292516 | 2 | - | name | 3255 | 3255 | 3255 | 3255 | 1 | - | nonces | 2635 | 2635 | 2635 | 2635 | 7 | - | permit | 834 | 28265 | 29975 | 53987 | 3 | --| previewDeposit | 2647 | 9647 | 10147 | 15647 | 4 | --| previewMint | 2889 | 2889 | 2889 | 2889 | 1 | --| previewRedeem | 2741 | 2741 | 2741 | 2741 | 3 | --| previewWithdraw | 2864 | 2864 | 2864 | 2864 | 1 | --| rate | 2242 | 2242 | 2242 | 2242 | 1 | --| redeem(uint256,address,address) | 47400 | 211478 | 237511 | 293630 | 9 | --| redeem(uint256,address,address,bool) | 166282 | 166282 | 166282 | 166282 | 1 | -+| previewDeposit | 2669 | 9669 | 10169 | 15669 | 4 | -+| previewMint | 2911 | 2911 | 2911 | 2911 | 1 | -+| previewRedeem | 2763 | 2763 | 2763 | 2763 | 3 | -+| previewWithdraw | 2886 | 2886 | 2886 | 2886 | 1 | -+| rate | 2264 | 2264 | 2264 | 2264 | 1 | -+| redeem(uint256,address,address) | 47444 | 211559 | 237599 | 293718 | 9 | -+| redeem(uint256,address,address,bool) | 166326 | 166326 | 166326 | 166326 | 1 | - | refreshRewardTokens | 100523 | 100523 | 100523 | 100523 | 33 | - | symbol | 3342 | 3342 | 3342 | 3342 | 1 | - | transfer | 72662 | 72662 | 72662 | 72662 | 1 | --| withdraw | 224942 | 224942 | 224942 | 224942 | 1 | -+| withdraw | 225052 | 225052 | 225052 | 225052 | 1 | - - - | src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol:AaveV3ConfigEngine contract | | | | | | -@@ -189,16 +189,16 @@ - | Deployment Cost | Deployment Size | | | | | - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | --| DEFAULT_INTEREST_RATE_STRATEGY | 337 | 337 | 337 | 337 | 5 | --| listAssets | 1844953 | 1844953 | 1844953 | 1844953 | 1 | --| listAssetsCustom | 1844210 | 5301679 | 5307465 | 5307465 | 620 | --| updateAssetsEMode | 68531 | 68531 | 68531 | 68531 | 1 | --| updateBorrowSide | 20079 | 76359 | 76359 | 132640 | 2 | --| updateCaps | 59884 | 59884 | 59884 | 59884 | 1 | --| updateCollateralSide | 8777 | 30468 | 8903 | 62879 | 5 | --| updateEModeCategories | 11063 | 61143 | 27080 | 128256 | 5 | --| updatePriceFeeds | 39338 | 39338 | 39338 | 39338 | 1 | --| updateRateStrategies | 122092 | 122092 | 122092 | 122092 | 1 | -+| DEFAULT_INTEREST_RATE_STRATEGY | 271 | 271 | 271 | 271 | 5 | -+| listAssets | 1824291 | 1824291 | 1824291 | 1824291 | 1 | -+| listAssetsCustom | 1823621 | 5252250 | 5257933 | 5257933 | 625 | -+| updateBorrowSide | 20079 | 76436 | 76436 | 132794 | 2 | -+| updateCaps | 59846 | 59846 | 59846 | 59846 | 1 | -+| updateCollateralSide | 8777 | 30494 | 8903 | 62945 | 5 | -+| updateEModeCategories | 10636 | 53642 | 29735 | 108603 | 5 | -+| updateEModeCollaterals | 92981 | 92981 | 92981 | 92981 | 1 | -+| updatePriceFeeds | 39331 | 39331 | 39331 | 39331 | 1 | -+| updateRateStrategies | 122114 | 122114 | 122114 | 122114 | 1 | - - - | src/contracts/helpers/AaveProtocolDataProvider.sol:AaveProtocolDataProvider contract | | | | | | -@@ -206,22 +206,21 @@ - | Deployment Cost | Deployment Size | | | | | - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | --| getATokenTotalSupply | 11863 | 14153 | 11907 | 24953 | 2140 | --| getAllReservesTokens | 16222 | 28423 | 31722 | 39722 | 27 | -+| getATokenTotalSupply | 11863 | 14145 | 11907 | 24975 | 2155 | -+| getAllReservesTokens | 16155 | 28653 | 39655 | 39655 | 27 | - | getDebtCeiling | 3263 | 3263 | 3263 | 3263 | 4 | --| getDebtCeilingDecimals | 237 | 237 | 237 | 237 | 1 | -+| getDebtCeilingDecimals | 215 | 215 | 215 | 215 | 1 | - | getFlashLoanEnabled | 3236 | 4236 | 4236 | 5236 | 512 | --| getInterestRateStrategyAddress | 8453 | 19448 | 8453 | 39953 | 9 | --| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 8116 | --| getLiquidationProtocolFee | 3174 | 9951 | 5674 | 16674 | 9 | --| getPaused | 3219 | 3325 | 3263 | 5263 | 8383 | -+| getInterestRateStrategyAddress | 8563 | 19558 | 8563 | 40063 | 9 | -+| getIsVirtualAccActive | 3242 | 3285 | 3286 | 3286 | 8519 | -+| getLiquidationProtocolFee | 3285 | 10062 | 5785 | 16785 | 9 | -+| getPaused | 3330 | 3433 | 3374 | 5374 | 8786 | - | getReserveCaps | 3286 | 8168 | 3286 | 16786 | 47 | --| getReserveConfigurationData | 3565 | 3773 | 3609 | 17109 | 9714 | --| getReserveEModeCategory | 3199 | 3199 | 3199 | 3199 | 1 | --| getReserveTokensAddresses | 8541 | 14283 | 14585 | 40085 | 9574 | -+| getReserveConfigurationData | 3662 | 3863 | 3706 | 17206 | 10115 | -+| getReserveTokensAddresses | 8541 | 14298 | 14585 | 40085 | 9972 | - | getSiloedBorrowing | 3289 | 3289 | 3289 | 3289 | 1 | --| getTotalDebt | 51955 | 51955 | 51955 | 51955 | 3 | --| getUserReserveData | 18944 | 26800 | 27034 | 43944 | 1302 | -+| getTotalDebt | 51890 | 51890 | 51890 | 51890 | 3 | -+| getUserReserveData | 18988 | 26784 | 27013 | 43988 | 1301 | - - - | src/contracts/helpers/L2Encoder.sol:L2Encoder contract | | | | | | -@@ -229,15 +228,15 @@ - | Deployment Cost | Deployment Size | | | | | - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | --| encodeBorrowParams | 7859 | 7859 | 7859 | 7859 | 3 | --| encodeLiquidationCall | 19245 | 19245 | 19245 | 19245 | 1 | --| encodeRepayParams | 7742 | 7742 | 7742 | 7742 | 1 | --| encodeRepayWithATokensParams | 7770 | 7770 | 7770 | 7770 | 1 | --| encodeRepayWithPermitParams | 10231 | 10231 | 10231 | 10231 | 256 | --| encodeSetUserUseReserveAsCollateral | 7679 | 7679 | 7679 | 7679 | 1 | --| encodeSupplyParams | 34785 | 34785 | 34785 | 34785 | 7 | --| encodeSupplyWithPermitParams | 35144 | 35144 | 35144 | 35144 | 256 | --| encodeWithdrawParams | 7625 | 7659 | 7659 | 7693 | 2 | -+| encodeBorrowParams | 7881 | 7881 | 7881 | 7881 | 3 | -+| encodeLiquidationCall | 19289 | 19289 | 19289 | 19289 | 1 | -+| encodeRepayParams | 7764 | 7764 | 7764 | 7764 | 1 | -+| encodeRepayWithATokensParams | 7792 | 7792 | 7792 | 7792 | 1 | -+| encodeRepayWithPermitParams | 10253 | 10253 | 10253 | 10253 | 256 | -+| encodeSetUserUseReserveAsCollateral | 7701 | 7701 | 7701 | 7701 | 1 | -+| encodeSupplyParams | 34807 | 34807 | 34807 | 34807 | 7 | -+| encodeSupplyWithPermitParams | 35166 | 35166 | 35166 | 35166 | 256 | -+| encodeWithdrawParams | 7647 | 7681 | 7681 | 7715 | 2 | - - - | src/contracts/helpers/WrappedTokenGatewayV3.sol:WrappedTokenGatewayV3 contract | | | | | | -@@ -245,16 +244,16 @@ - | Deployment Cost | Deployment Size | | | | | - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | --| borrowETH | 253365 | 253365 | 253365 | 253365 | 1 | -+| borrowETH | 253033 | 253033 | 253033 | 253033 | 1 | - | depositETH | 240170 | 240170 | 240170 | 240170 | 8 | - | emergencyEtherTransfer | 33801 | 33801 | 33801 | 33801 | 1 | - | emergencyTokenTransfer | 52810 | 52810 | 52810 | 52810 | 1 | - | getWETHAddress | 245 | 245 | 245 | 245 | 1 | - | owner | 308 | 308 | 308 | 308 | 1 | - | receive | 21206 | 21206 | 21206 | 21206 | 1 | --| repayETH | 175754 | 179762 | 177644 | 187475 | 5 | --| withdrawETH | 231257 | 235319 | 235319 | 239381 | 2 | --| withdrawETHWithPermit | 275525 | 278408 | 278408 | 281291 | 2 | -+| repayETH | 175668 | 179676 | 177558 | 187389 | 5 | -+| withdrawETH | 231328 | 235398 | 235398 | 239469 | 2 | -+| withdrawETHWithPermit | 275613 | 278496 | 278496 | 281379 | 2 | - - - | src/contracts/instances/ATokenInstance.sol:ATokenInstance contract | | | | | | -@@ -264,35 +263,35 @@ - | Function Name | min | avg | median | max | # calls | - | DOMAIN_SEPARATOR | 458 | 2275 | 2458 | 3543 | 5 | - | POOL | 327 | 327 | 327 | 327 | 151 | --| RESERVE_TREASURY_ADDRESS | 420 | 783 | 420 | 2420 | 9917 | --| UNDERLYING_ASSET_ADDRESS | 442 | 475 | 442 | 2442 | 8251 | -+| RESERVE_TREASURY_ADDRESS | 420 | 809 | 420 | 2420 | 10575 | -+| UNDERLYING_ASSET_ADDRESS | 442 | 474 | 442 | 2442 | 8654 | - | allowance | 785 | 1554 | 785 | 2785 | 26 | - | approve | 24590 | 24590 | 24590 | 24590 | 39 | --| balanceOf | 2744 | 5319 | 4744 | 17744 | 4799 | --| burn | 911 | 35660 | 37180 | 81176 | 2111 | --| decimals | 357 | 403 | 357 | 2357 | 8304 | -+| balanceOf | 2766 | 5311 | 4766 | 17766 | 5052 | -+| burn | 911 | 37674 | 37180 | 81176 | 2366 | -+| decimals | 357 | 401 | 357 | 2357 | 8707 | - | decreaseAllowance | 7709 | 7709 | 7709 | 7709 | 1 | --| getIncentivesController | 475 | 475 | 475 | 2475 | 8116 | -+| getIncentivesController | 475 | 475 | 475 | 2475 | 8519 | - | getPreviousIndex | 654 | 654 | 654 | 654 | 39 | - | getScaledUserBalanceAndSupply | 830 | 2419 | 2830 | 4830 | 39 | --| handleRepayment | 597 | 597 | 597 | 597 | 2599 | -+| handleRepayment | 597 | 597 | 597 | 597 | 2854 | - | increaseAllowance | 7776 | 20601 | 24876 | 24876 | 4 | --| initialize | 146515 | 228079 | 231709 | 321646 | 43251 | --| mint | 940 | 59706 | 64435 | 72198 | 4166 | -+| initialize | 146515 | 228395 | 231709 | 321646 | 43669 | -+| mint | 940 | 61265 | 64435 | 72198 | 6214 | - | mintToTreasury | 444 | 43943 | 49223 | 66323 | 6 | --| name | 1009 | 1454 | 1326 | 3264 | 8351 | -+| name | 1009 | 1454 | 1561 | 3264 | 8754 | - | nonces | 655 | 1988 | 2655 | 2655 | 9 | - | permit | 1117 | 33566 | 43549 | 53499 | 16 | - | rescueTokens | 12040 | 24418 | 14258 | 46957 | 3 | --| scaledBalanceOf | 691 | 1986 | 2691 | 2691 | 10419 | -+| scaledBalanceOf | 691 | 1909 | 2691 | 2691 | 13978 | - | scaledTotalSupply | 375 | 2181 | 2375 | 2375 | 414 | - | setIncentivesController | 11941 | 14316 | 14316 | 16691 | 2 | --| symbol | 1074 | 1515 | 1391 | 3329 | 8333 | --| totalSupply | 411 | 4892 | 6457 | 10457 | 4903 | --| transfer | 580 | 117377 | 122690 | 140646 | 275 | --| transferFrom | 87624 | 120965 | 130243 | 145830 | 43 | --| transferOnLiquidation | 988 | 30249 | 37526 | 44326 | 1807 | --| transferUnderlyingTo | 802 | 18573 | 16500 | 33639 | 2704 | -+| symbol | 1074 | 1514 | 1391 | 3329 | 8736 | -+| totalSupply | 411 | 5166 | 6479 | 10479 | 5941 | -+| transfer | 580 | 117696 | 122712 | 140404 | 275 | -+| transferFrom | 87646 | 120962 | 130265 | 145587 | 43 | -+| transferOnLiquidation | 988 | 31171 | 37548 | 44348 | 2062 | -+| transferUnderlyingTo | 802 | 22711 | 16500 | 33639 | 3727 | - - - | src/contracts/instances/L2PoolInstance.sol:L2PoolInstance contract | | | | | | -@@ -302,154 +301,155 @@ - | Function Name | min | avg | median | max | # calls | - | ADDRESSES_PROVIDER | 352 | 352 | 352 | 352 | 126 | - | FLASHLOAN_PREMIUM_TOTAL | 389 | 1389 | 1389 | 2389 | 124 | --| FLASHLOAN_PREMIUM_TO_PROTOCOL | 482 | 482 | 482 | 482 | 124 | --| borrow(address,uint256,uint256,uint16,address) | 198181 | 204033 | 203781 | 238990 | 266 | --| borrow(bytes32) | 203802 | 203802 | 203802 | 203802 | 3 | --| configureEModeCategory | 7230 | 8196 | 7230 | 49447 | 262 | --| dropReserve | 6336 | 6631 | 6336 | 82330 | 257 | --| getBorrowLogic | 282 | 282 | 282 | 282 | 1 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 415 | 415 | 415 | 124 | -+| borrow(address,uint256,uint256,uint16,address) | 197850 | 203778 | 203450 | 238567 | 266 | -+| borrow(bytes32) | 203449 | 203449 | 203449 | 203449 | 3 | -+| configureEModeCategory | 7310 | 8345 | 7310 | 45792 | 276 | -+| dropReserve | 6270 | 6565 | 6270 | 82286 | 257 | -+| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | - | getBridgeLogic | 346 | 346 | 346 | 346 | 1 | --| getConfiguration | 682 | 728 | 682 | 2682 | 1636 | --| getEModeCategoryData | 6141 | 6141 | 6141 | 6141 | 12 | -+| getConfiguration | 704 | 714 | 704 | 2704 | 1462 | -+| getEModeCategoryData | 8124 | 8302 | 8379 | 8379 | 20 | - | getEModeLogic | 279 | 279 | 279 | 279 | 1 | --| getFlashLoanLogic | 348 | 348 | 348 | 348 | 1 | --| getLiquidationGracePeriod | 2659 | 2659 | 2659 | 2659 | 256 | --| getLiquidationLogic | 326 | 326 | 326 | 326 | 1 | --| getPoolLogic | 303 | 303 | 303 | 303 | 1 | --| getReserveData | 4195 | 11606 | 6195 | 24195 | 839 | --| getReserveNormalizedIncome | 892 | 893 | 892 | 1354 | 292 | --| getReserveNormalizedVariableDebt | 849 | 868 | 849 | 2849 | 264 | --| getReservesList | 11117 | 11117 | 11117 | 11117 | 262 | --| getSupplyLogic | 368 | 368 | 368 | 368 | 1 | --| getUserAccountData | 22727 | 22727 | 22727 | 22727 | 1 | --| getVirtualUnderlyingBalance | 682 | 682 | 682 | 682 | 4 | --| initReserve | 6553 | 41017 | 6553 | 167529 | 656 | --| initialize | 45403 | 45403 | 45403 | 45403 | 62 | --| liquidationCall | 377264 | 377264 | 377264 | 377264 | 1 | --| mintToTreasury | 77299 | 78694 | 78694 | 80089 | 2 | --| repay(address,uint256,uint256,address) | 164697 | 164697 | 164697 | 164697 | 2 | --| repay(bytes32) | 135689 | 135689 | 135689 | 135689 | 1 | --| repayWithATokens | 138810 | 138810 | 138810 | 138810 | 1 | --| repayWithPermit | 183122 | 199089 | 206994 | 210215 | 256 | --| rescueTokens | 48197 | 48197 | 48197 | 48197 | 256 | -+| getFlashLoanLogic | 281 | 281 | 281 | 281 | 1 | -+| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 256 | -+| getLiquidationLogic | 348 | 348 | 348 | 348 | 1 | -+| getPoolLogic | 325 | 325 | 325 | 325 | 1 | -+| getReserveData | 4217 | 11834 | 6217 | 24217 | 853 | -+| getReserveNormalizedIncome | 827 | 828 | 827 | 1289 | 292 | -+| getReserveNormalizedVariableDebt | 871 | 890 | 871 | 2871 | 264 | -+| getReservesList | 11139 | 11139 | 11139 | 11139 | 256 | -+| getSupplyLogic | 282 | 282 | 282 | 282 | 1 | -+| getUserAccountData | 22396 | 22396 | 22396 | 22396 | 1 | -+| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 4 | -+| initReserve | 6575 | 41039 | 6575 | 167551 | 656 | -+| initialize | 45425 | 45425 | 45425 | 45425 | 62 | -+| liquidationCall | 376728 | 376728 | 376728 | 376728 | 1 | -+| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | -+| repay(address,uint256,uint256,address) | 164652 | 164652 | 164652 | 164652 | 2 | -+| repay(bytes32) | 135733 | 135733 | 135733 | 135733 | 1 | -+| repayWithATokens | 138767 | 138767 | 138767 | 138767 | 1 | -+| repayWithPermit | 183077 | 198894 | 189516 | 210170 | 256 | -+| rescueTokens | 48219 | 48219 | 48219 | 48219 | 256 | - | resetIsolationModeTotalDebt | 4276 | 5590 | 6269 | 15276 | 402 | --| setConfiguration | 2178 | 4409 | 2178 | 24334 | 2004 | --| setLiquidationGracePeriod | 6352 | 11369 | 10840 | 17003 | 768 | --| setReserveInterestRateStrategyAddress | 6394 | 7969 | 6503 | 15791 | 769 | --| setUserEMode | 22040 | 42082 | 40260 | 87614 | 7 | --| setUserUseReserveAsCollateral(address,bool) | 53653 | 69628 | 71674 | 103062 | 17 | --| setUserUseReserveAsCollateral(bytes32) | 73824 | 73824 | 73824 | 73824 | 1 | --| supply(address,uint256,address,uint16) | 157289 | 207630 | 208589 | 208589 | 284 | -+| setConfiguration | 2178 | 4547 | 2178 | 24334 | 1848 | -+| setLiquidationGracePeriod | 6374 | 11394 | 10862 | 17025 | 768 | -+| setReserveInterestRateStrategyAddress | 6416 | 7991 | 6525 | 15813 | 769 | -+| setUserEMode | 19833 | 42074 | 40892 | 87328 | 7 | -+| setUserUseReserveAsCollateral(address,bool) | 53610 | 69578 | 71631 | 102908 | 17 | -+| setUserUseReserveAsCollateral(bytes32) | 73781 | 73781 | 73781 | 73781 | 1 | -+| supply(address,uint256,address,uint16) | 157311 | 207652 | 208611 | 208611 | 284 | - | supply(bytes32) | 210669 | 210669 | 210669 | 210669 | 7 | --| supplyWithPermit | 259858 | 259858 | 259858 | 259858 | 256 | --| syncIndexesState | 7317 | 13950 | 7317 | 27217 | 144 | --| syncRatesState | 16050 | 16050 | 16050 | 16050 | 144 | --| updateBridgeProtocolFee | 6240 | 6240 | 6240 | 6240 | 256 | --| updateFlashloanPremiums | 1749 | 8143 | 6422 | 21649 | 380 | --| withdraw | 126597 | 129039 | 129039 | 131482 | 2 | -+| supplyWithPermit | 259880 | 259880 | 259880 | 259880 | 256 | -+| syncIndexesState | 7251 | 13884 | 7251 | 27151 | 144 | -+| syncRatesState | 16072 | 16072 | 16072 | 16072 | 144 | -+| updateBridgeProtocolFee | 6262 | 6262 | 6262 | 6262 | 256 | -+| updateFlashloanPremiums | 1771 | 8165 | 6444 | 21671 | 380 | -+| withdraw | 126619 | 129061 | 129061 | 131504 | 2 | - - - | src/contracts/instances/PoolConfiguratorInstance.sol:PoolConfiguratorInstance contract | | | | | | - |----------------------------------------------------------------------------------------|-----------------|----------|---------|-----------|---------| - | Deployment Cost | Deployment Size | | | | | --| 4442338 | 20353 | | | | | -+| 4462068 | 20445 | | | | | - | Function Name | min | avg | median | max | # calls | --| MAX_GRACE_PERIOD | 305 | 305 | 305 | 305 | 1792 | --| configureReserveAsCollateral | 12205 | 26298 | 17314 | 95608 | 4169 | --| disableLiquidationGracePeriod | 17326 | 28493 | 39617 | 39617 | 513 | --| dropReserve | 14069 | 14927 | 14069 | 104794 | 261 | --| getConfiguratorLogic | 240 | 240 | 240 | 240 | 1 | --| getPendingLtv | 599 | 599 | 599 | 599 | 771 | --| initReserves | 17491 | 25585884 | 1659867 | 216850380 | 2670 | --| initialize | 72581 | 90426 | 90481 | 90481 | 651 | --| setAssetEModeCategory | 11337 | 12907 | 11403 | 52868 | 2156 | --| setBorrowCap | 11197 | 12183 | 11263 | 44219 | 2126 | --| setBorrowableInIsolation | 10808 | 11146 | 10874 | 43820 | 1872 | --| setDebtCeiling | 17279 | 39386 | 39794 | 94867 | 2133 | --| setEModeCategory | 17852 | 27224 | 17852 | 107759 | 297 | --| setLiquidationProtocolFee | 11246 | 11455 | 11312 | 44268 | 1867 | --| setPoolPause(bool) | 17312 | 17735 | 17312 | 90088 | 515 | --| setPoolPause(bool,uint40) | 17337 | 61920 | 48309 | 107843 | 512 | --| setReserveActive | 14202 | 17104 | 14202 | 91368 | 267 | --| setReserveBorrowing | 10894 | 17630 | 11116 | 41770 | 2628 | --| setReserveFactor | 17302 | 40360 | 36815 | 125123 | 2118 | --| setReserveFlashLoaning | 10959 | 17722 | 11025 | 43991 | 2373 | --| setReserveFreeze | 20558 | 48100 | 52947 | 73153 | 783 | --| setReserveInterestRateData | 17561 | 18227 | 17561 | 103603 | 258 | --| setReserveInterestRateStrategyAddress | 17671 | 34391 | 17671 | 162415 | 300 | --| setReservePause(address,bool) | 17348 | 17531 | 17348 | 41048 | 258 | --| setReservePause(address,bool,uint40) | 14442 | 39080 | 47073 | 52185 | 3084 | --| setSiloedBorrowing | 11266 | 11497 | 11332 | 91271 | 1862 | --| setSupplyCap | 11199 | 12951 | 11265 | 44221 | 2139 | --| setUnbackedMintCap | 44189 | 44189 | 44189 | 44189 | 7 | --| updateAToken | 14141 | 14621 | 14141 | 137683 | 257 | --| updateBridgeProtocolFee | 14119 | 49368 | 52080 | 52080 | 14 | --| updateFlashloanPremiumToProtocol | 10139 | 11301 | 10139 | 36939 | 907 | --| updateFlashloanPremiumTotal | 14136 | 27000 | 32071 | 36971 | 907 | --| updateVariableDebtToken | 14141 | 14597 | 14141 | 131538 | 257 | -+| MAX_GRACE_PERIOD | 261 | 261 | 261 | 261 | 1792 | -+| configureReserveAsCollateral | 12271 | 26312 | 17358 | 95696 | 4184 | -+| disableLiquidationGracePeriod | 17259 | 28403 | 39505 | 39505 | 513 | -+| dropReserve | 14113 | 14970 | 14113 | 104795 | 261 | -+| getConfiguratorLogic | 284 | 284 | 284 | 284 | 1 | -+| getPendingLtv | 643 | 643 | 643 | 643 | 771 | -+| initReserves | 17446 | 25802050 | 1659767 | 213970339 | 2675 | -+| initialize | 72581 | 90426 | 90481 | 90481 | 656 | -+| setAssetBorrowableInEMode | 74227 | 94101 | 94126 | 94126 | 1545 | -+| setAssetCollateralInEMode | 17518 | 71246 | 77122 | 77123 | 2597 | -+| setBorrowCap | 11219 | 12197 | 11285 | 44241 | 2141 | -+| setBorrowableInIsolation | 10786 | 11122 | 10852 | 43798 | 1887 | -+| setDebtCeiling | 17301 | 39465 | 39860 | 94933 | 2148 | -+| setEModeCategory | 17827 | 81478 | 88643 | 88643 | 2594 | -+| setLiquidationProtocolFee | 11290 | 11498 | 11356 | 44312 | 1882 | -+| setPoolPause(bool) | 17247 | 17670 | 17247 | 90044 | 515 | -+| setPoolPause(bool,uint40) | 17359 | 61500 | 48341 | 107751 | 512 | -+| setReserveActive | 14224 | 17128 | 14224 | 91434 | 267 | -+| setReserveBorrowing | 10960 | 17656 | 11182 | 41836 | 2643 | -+| setReserveFactor | 17346 | 40478 | 36925 | 125233 | 2133 | -+| setReserveFlashLoaning | 10959 | 17680 | 11025 | 43991 | 2388 | -+| setReserveFreeze | 20602 | 48131 | 53013 | 73219 | 782 | -+| setReserveInterestRateData | 17605 | 18272 | 17605 | 103713 | 258 | -+| setReserveInterestRateStrategyAddress | 17626 | 34359 | 17626 | 162458 | 300 | -+| setReservePause(address,bool) | 17392 | 17575 | 17392 | 41114 | 258 | -+| setReservePause(address,bool,uint40) | 14464 | 38788 | 47072 | 49384 | 3084 | -+| setSiloedBorrowing | 11332 | 11562 | 11398 | 91272 | 1877 | -+| setSupplyCap | 11176 | 12919 | 11242 | 44198 | 2154 | -+| setUnbackedMintCap | 44233 | 44233 | 44233 | 44233 | 7 | -+| updateAToken | 14074 | 14554 | 14074 | 137640 | 257 | -+| updateBridgeProtocolFee | 14141 | 49349 | 52058 | 52058 | 14 | -+| updateFlashloanPremiumToProtocol | 10205 | 11342 | 10205 | 37005 | 912 | -+| updateFlashloanPremiumTotal | 14091 | 27009 | 32070 | 36970 | 912 | -+| updateVariableDebtToken | 14075 | 14531 | 14075 | 131490 | 257 | - - - | src/contracts/instances/PoolInstance.sol:PoolInstance contract | | | | | | - |----------------------------------------------------------------|-----------------|--------|--------|--------|---------| - | Deployment Cost | Deployment Size | | | | | --| 4668760 | 21651 | | | | | -+| 4697379 | 21784 | | | | | - | Function Name | min | avg | median | max | # calls | --| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3066 | --| BRIDGE_PROTOCOL_FEE | 416 | 2176 | 2416 | 2416 | 25 | --| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1182 | --| FLASHLOAN_PREMIUM_TO_PROTOCOL | 415 | 416 | 415 | 2415 | 1179 | -+| ADDRESSES_PROVIDER | 285 | 285 | 285 | 285 | 3076 | -+| BRIDGE_PROTOCOL_FEE | 350 | 2110 | 2350 | 2350 | 25 | -+| FLASHLOAN_PREMIUM_TOTAL | 411 | 1414 | 2411 | 2411 | 1192 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 437 | 438 | 437 | 2437 | 1189 | - | MAX_NUMBER_RESERVES | 309 | 309 | 309 | 309 | 514 | --| backUnbacked | 98453 | 114633 | 112032 | 133026 | 9 | --| borrow | 46669 | 219345 | 222815 | 262245 | 2435 | --| configureEModeCategory | 7207 | 10703 | 7207 | 49424 | 280 | -+| backUnbacked | 98475 | 114655 | 112054 | 133048 | 9 | -+| borrow | 46603 | 224445 | 222483 | 261668 | 3458 | -+| configureEModeCategory | 6014 | 26167 | 25914 | 45814 | 6454 | - | deposit | 32854 | 190352 | 208588 | 214736 | 80 | --| dropReserve | 6270 | 7104 | 6270 | 82308 | 262 | --| finalizeTransfer | 20766 | 45533 | 48574 | 88370 | 317 | --| flashLoan | 29742 | 80321 | 61019 | 320939 | 267 | --| flashLoanSimple | 23431 | 343312 | 189538 | 757563 | 11 | --| getBorrowLogic | 304 | 304 | 304 | 304 | 1 | -+| dropReserve | 6292 | 7125 | 6292 | 82265 | 262 | -+| finalizeTransfer | 20766 | 45787 | 48574 | 88106 | 317 | -+| flashLoan | 29764 | 84224 | 69664 | 320653 | 267 | -+| flashLoanSimple | 23453 | 343384 | 189604 | 757609 | 11 | -+| getBorrowLogic | 326 | 326 | 326 | 326 | 1 | - | getBridgeLogic | 280 | 280 | 280 | 280 | 1 | --| getConfiguration | 726 | 968 | 726 | 2726 | 53149 | --| getEModeCategoryData | 1908 | 5110 | 6163 | 6163 | 43 | -+| getConfiguration | 748 | 988 | 748 | 2748 | 52680 | -+| getEModeCategoryData | 2146 | 8240 | 8401 | 8401 | 6311 | - | getEModeLogic | 301 | 301 | 301 | 301 | 1 | --| getFlashLoanLogic | 303 | 303 | 303 | 303 | 1 | --| getLiquidationGracePeriod | 2681 | 2681 | 2681 | 2681 | 2014 | --| getLiquidationLogic | 281 | 281 | 281 | 281 | 1 | --| getPoolLogic | 280 | 280 | 280 | 280 | 1 | --| getReserveAddressById | 665 | 665 | 665 | 665 | 1 | --| getReserveData | 4239 | 8268 | 6239 | 24239 | 18252 | --| getReserveDataExtended | 3416 | 4082 | 3416 | 5416 | 6 | --| getReserveNormalizedIncome | 849 | 1126 | 849 | 5311 | 10501 | --| getReserveNormalizedVariableDebt | 893 | 1071 | 893 | 6491 | 7171 | --| getReservesCount | 437 | 437 | 437 | 437 | 2 | --| getReservesList | 3161 | 12139 | 11161 | 101874 | 1902 | --| getSupplyLogic | 304 | 304 | 304 | 304 | 1 | --| getUserAccountData | 18124 | 21525 | 22624 | 29389 | 1036 | --| getUserConfiguration | 706 | 748 | 706 | 2706 | 1822 | --| getUserEMode | 659 | 659 | 659 | 659 | 1037 | --| getVirtualUnderlyingBalance | 704 | 704 | 704 | 704 | 2157 | --| initReserve | 6597 | 179856 | 179637 | 207301 | 43619 | --| initialize | 45447 | 45546 | 45447 | 66968 | 593 | --| liquidationCall | 53261 | 228680 | 324198 | 376813 | 3491 | --| mintToTreasury | 77321 | 78716 | 78716 | 80111 | 2 | --| mintUnbacked | 12222 | 118445 | 103571 | 165915 | 17 | --| repay | 33239 | 99467 | 95964 | 164674 | 21 | --| repayWithATokens | 128274 | 154025 | 155469 | 166111 | 261 | --| repayWithPermit | 127104 | 165503 | 154197 | 209900 | 768 | --| rescueTokens | 48154 | 48154 | 48154 | 48154 | 256 | --| resetIsolationModeTotalDebt | 4298 | 4568 | 4298 | 15298 | 1974 | --| setConfiguration | 2200 | 16547 | 24200 | 24356 | 67500 | --| setLiquidationGracePeriod | 6374 | 12458 | 14525 | 17025 | 3476 | --| setReserveInterestRateStrategyAddress | 6416 | 7955 | 6525 | 15813 | 813 | --| setUserEMode | 21974 | 41470 | 40194 | 87548 | 10 | --| setUserUseReserveAsCollateral | 53632 | 72191 | 71653 | 103041 | 25 | --| supply | 29467 | 187262 | 208611 | 216374 | 3016 | --| supplyWithPermit | 113813 | 196609 | 218266 | 257750 | 768 | --| syncIndexesState | 7251 | 13978 | 7251 | 62644 | 1763 | --| syncRatesState | 13531 | 16046 | 16072 | 22572 | 1763 | --| updateBridgeProtocolFee | 6195 | 7025 | 6195 | 23375 | 269 | --| updateFlashloanPremiums | 1704 | 10703 | 6377 | 21604 | 1432 | --| withdraw | 39229 | 105506 | 87802 | 177983 | 51 | -+| getFlashLoanLogic | 325 | 325 | 325 | 325 | 1 | -+| getLiquidationGracePeriod | 2703 | 2703 | 2703 | 2703 | 1993 | -+| getLiquidationLogic | 303 | 303 | 303 | 303 | 1 | -+| getPoolLogic | 302 | 302 | 302 | 302 | 1 | -+| getReserveAddressById | 620 | 620 | 620 | 620 | 1 | -+| getReserveData | 4261 | 11061 | 10261 | 24261 | 22560 | -+| getReserveDataExtended | 3438 | 4104 | 3438 | 5438 | 6 | -+| getReserveNormalizedIncome | 871 | 1112 | 871 | 5333 | 12032 | -+| getReserveNormalizedVariableDebt | 828 | 1000 | 828 | 6426 | 7394 | -+| getReservesCount | 373 | 373 | 373 | 373 | 2 | -+| getReservesList | 3116 | 12284 | 11116 | 101829 | 1874 | -+| getSupplyLogic | 326 | 326 | 326 | 326 | 1 | -+| getUserAccountData | 12238 | 23068 | 22382 | 39507 | 2574 | -+| getUserConfiguration | 728 | 767 | 728 | 2728 | 1821 | -+| getUserEMode | 659 | 660 | 659 | 2659 | 1294 | -+| getVirtualUnderlyingBalance | 726 | 726 | 726 | 726 | 2155 | -+| initReserve | 6552 | 179727 | 179592 | 207256 | 44037 | -+| initialize | 45382 | 45480 | 45382 | 66903 | 598 | -+| liquidationCall | 53186 | 239514 | 323748 | 383313 | 3720 | -+| mintToTreasury | 77343 | 78738 | 78738 | 80133 | 2 | -+| mintUnbacked | 12177 | 118400 | 103526 | 165870 | 17 | -+| repay | 33261 | 99436 | 95921 | 164631 | 21 | -+| repayWithATokens | 128164 | 154206 | 155359 | 166023 | 261 | -+| repayWithPermit | 127039 | 165740 | 154132 | 210104 | 768 | -+| rescueTokens | 48176 | 48176 | 48176 | 48176 | 256 | -+| resetIsolationModeTotalDebt | 4298 | 4565 | 4298 | 15298 | 1989 | -+| setConfiguration | 2200 | 16938 | 24200 | 24356 | 66324 | -+| setLiquidationGracePeriod | 6329 | 12223 | 12480 | 16980 | 3435 | -+| setReserveInterestRateStrategyAddress | 6438 | 7977 | 6547 | 15835 | 813 | -+| setUserEMode | 16734 | 48129 | 40914 | 94630 | 2318 | -+| setUserUseReserveAsCollateral | 53676 | 72230 | 71697 | 102974 | 25 | -+| supply | 29401 | 195831 | 208545 | 216308 | 5064 | -+| supplyWithPermit | 113813 | 196587 | 218266 | 257750 | 768 | -+| syncIndexesState | 7273 | 14000 | 7273 | 62666 | 1778 | -+| syncRatesState | 13553 | 16069 | 16094 | 22594 | 1778 | -+| updateBridgeProtocolFee | 6217 | 7047 | 6217 | 23397 | 269 | -+| updateFlashloanPremiums | 1726 | 10732 | 6399 | 21626 | 1442 | -+| withdraw | 39251 | 105523 | 87824 | 177740 | 51 | - - - | src/contracts/instances/VariableDebtTokenInstance.sol:VariableDebtTokenInstance contract | | | | | | -@@ -457,22 +457,22 @@ - | Deployment Cost | Deployment Size | | | | | - | 1723145 | 8349 | | | | | - | Function Name | min | avg | median | max | # calls | --| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8112 | -+| UNDERLYING_ASSET_ADDRESS | 398 | 398 | 398 | 398 | 8515 | - | approveDelegation | 27012 | 27012 | 27012 | 27012 | 1 | --| balanceOf | 681 | 4986 | 4771 | 10365 | 7692 | -+| balanceOf | 681 | 4919 | 4706 | 10300 | 7918 | - | borrowAllowance | 831 | 831 | 831 | 831 | 5 | --| burn | 19204 | 26197 | 26204 | 26205 | 3108 | --| decimals | 335 | 335 | 335 | 335 | 8112 | -+| burn | 19204 | 26197 | 26204 | 26205 | 3363 | -+| decimals | 335 | 335 | 335 | 335 | 8515 | - | delegationWithSig | 1052 | 28689 | 21662 | 55862 | 7 | --| getIncentivesController | 431 | 431 | 431 | 431 | 8112 | --| initialize | 123620 | 207871 | 209041 | 299205 | 43251 | --| mint | 26385 | 62549 | 62585 | 72374 | 2687 | --| name | 1009 | 1421 | 1264 | 3264 | 8202 | -+| getIncentivesController | 431 | 431 | 431 | 431 | 8515 | -+| initialize | 123620 | 208766 | 209041 | 299205 | 43669 | -+| mint | 26385 | 62559 | 62585 | 72374 | 3710 | -+| name | 1009 | 1420 | 1326 | 3264 | 8605 | - | nonces | 577 | 577 | 577 | 577 | 1 | --| scaledBalanceOf | 691 | 1887 | 2691 | 2691 | 5867 | --| scaledTotalSupply | 419 | 2102 | 2419 | 2419 | 18707 | --| symbol | 1030 | 1440 | 1347 | 3285 | 8195 | --| totalSupply | 4079 | 7582 | 6481 | 19079 | 15 | -+| scaledBalanceOf | 691 | 1885 | 2691 | 2691 | 7118 | -+| scaledTotalSupply | 419 | 2152 | 2419 | 2419 | 22291 | -+| symbol | 1030 | 1441 | 1347 | 3285 | 8598 | -+| totalSupply | 4014 | 7523 | 6416 | 19014 | 15 | - - - | src/contracts/misc/AaveOracle.sol:AaveOracle contract | | | | | | -@@ -482,10 +482,10 @@ - | Function Name | min | avg | median | max | # calls | - | BASE_CURRENCY | 293 | 293 | 293 | 293 | 3 | - | BASE_CURRENCY_UNIT | 262 | 262 | 262 | 262 | 1 | --| getAssetPrice | 679 | 4746 | 7873 | 7873 | 22337 | -+| getAssetPrice | 0 | 4859 | 7873 | 7873 | 29705 | - | getAssetsPrices | 2300 | 3404 | 2300 | 5614 | 3 | - | getFallbackOracle | 365 | 1031 | 365 | 2365 | 3 | --| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1140 | -+| getSourceOfAsset | 553 | 635 | 553 | 2553 | 1139 | - | setAssetSources | 37348 | 52896 | 61947 | 62187 | 9 | - | setFallbackOracle | 59544 | 59544 | 59544 | 59544 | 4 | - -@@ -499,7 +499,7 @@ - | MAX_BORROW_RATE | 240 | 240 | 240 | 240 | 5382 | - | MAX_OPTIMAL_POINT | 262 | 262 | 262 | 262 | 6918 | - | MIN_OPTIMAL_POINT | 261 | 261 | 261 | 261 | 6918 | --| calculateInterestRates | 0 | 4436 | 4271 | 5999 | 16046 | -+| calculateInterestRates | 0 | 4513 | 4271 | 5999 | 19642 | - | getBaseVariableBorrowRate | 748 | 776 | 748 | 2748 | 2908 | - | getInterestRateData | 1804 | 1804 | 1804 | 1804 | 256 | - | getInterestRateDataBps | 987 | 987 | 987 | 987 | 256 | -@@ -507,8 +507,8 @@ - | getOptimalUsageRatio | 738 | 738 | 738 | 2738 | 2136 | - | getVariableRateSlope1 | 778 | 778 | 778 | 778 | 2140 | - | getVariableRateSlope2 | 799 | 799 | 799 | 799 | 1368 | --| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29729 | 29075 | 36816 | 2816 | --| setInterestRateParams(address,bytes) | 28624 | 33084 | 29860 | 37156 | 6405 | -+| setInterestRateParams(address,(uint16,uint32,uint32,uint32)) | 28278 | 29728 | 29075 | 36804 | 2816 | -+| setInterestRateParams(address,bytes) | 28612 | 33084 | 29860 | 37156 | 6405 | - - - | src/contracts/misc/PriceOracleSentinel.sol:PriceOracleSentinel contract | | | | | | -@@ -530,26 +530,26 @@ - | Deployment Cost | Deployment Size | | | | | - | 465623 | 2115 | | | | | - | Function Name | min | avg | median | max | # calls | --| ADDRESSES_PROVIDER | 898 | 4368 | 5398 | 5465 | 3190 | --| BRIDGE_PROTOCOL_FEE | 1029 | 5311 | 7529 | 7529 | 23 | -+| ADDRESSES_PROVIDER | 898 | 4364 | 5398 | 5465 | 3200 | -+| BRIDGE_PROTOCOL_FEE | 963 | 5245 | 7463 | 7463 | 23 | - | DOMAIN_SEPARATOR | 1071 | 4688 | 4156 | 7571 | 5 | --| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 650 | --| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1304 | --| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1039 | 1028 | 7528 | 1301 | --| MAX_GRACE_PERIOD | 5418 | 5418 | 5418 | 5418 | 1792 | -+| EMISSION_MANAGER | 940 | 940 | 940 | 940 | 655 | -+| FLASHLOAN_PREMIUM_TOTAL | 1002 | 2033 | 3002 | 7524 | 1314 | -+| FLASHLOAN_PREMIUM_TO_PROTOCOL | 1028 | 1052 | 1050 | 7550 | 1311 | -+| MAX_GRACE_PERIOD | 5374 | 5374 | 5374 | 5374 | 1792 | - | MAX_NUMBER_RESERVES | 922 | 922 | 922 | 922 | 512 | - | POOL | 940 | 940 | 940 | 940 | 151 | --| RESERVE_TREASURY_ADDRESS | 1033 | 1397 | 1033 | 7533 | 9918 | -+| RESERVE_TREASURY_ADDRESS | 1033 | 1422 | 1033 | 7533 | 10576 | - | REVISION | 874 | 874 | 874 | 874 | 8 | --| UNDERLYING_ASSET_ADDRESS | 1011 | 1050 | 1055 | 3055 | 16363 | -+| UNDERLYING_ASSET_ADDRESS | 1011 | 1049 | 1055 | 3055 | 17169 | - | admin | 21390 | 21390 | 21390 | 21390 | 8 | - | allowance | 1404 | 3173 | 3404 | 7904 | 26 | - | approve | 51293 | 51357 | 51341 | 51653 | 39 | - | approveDelegation | 53760 | 53760 | 53760 | 53760 | 1 | --| backUnbacked | 125314 | 140965 | 138917 | 159923 | 9 | --| balanceOf | 1297 | 5849 | 5387 | 22860 | 12491 | --| borrow(address,uint256,uint256,uint16,address) | 74012 | 244274 | 250193 | 289647 | 2700 | --| borrow(bytes32) | 230155 | 230155 | 230155 | 230155 | 3 | -+| backUnbacked | 125336 | 140987 | 138939 | 159945 | 9 | -+| balanceOf | 1297 | 5802 | 5382 | 22882 | 12970 | -+| borrow(address,uint256,uint256,uint16,address) | 73946 | 247047 | 249861 | 289070 | 3723 | -+| borrow(bytes32) | 229802 | 229802 | 229802 | 229802 | 3 | - | borrowAllowance | 1450 | 1450 | 1450 | 1450 | 5 | - | burn | 28132 | 40754 | 28464 | 65668 | 3 | - | claimAllRewards | 119578 | 119578 | 119578 | 119578 | 1 | -@@ -558,128 +558,129 @@ - | claimRewards | 28668 | 77756 | 84171 | 114016 | 4 | - | claimRewardsOnBehalf | 116579 | 116579 | 116579 | 116579 | 1 | - | claimRewardsToSelf | 113333 | 113333 | 113333 | 113333 | 1 | --| configureEModeCategory | 34496 | 34507 | 34507 | 34519 | 512 | --| configureReserveAsCollateral | 44067 | 64524 | 57732 | 122552 | 2308 | --| decimals | 948 | 982 | 970 | 7470 | 16416 | -+| configureEModeCategory | 34733 | 34744 | 34744 | 34755 | 512 | -+| configureReserveAsCollateral | 44111 | 64587 | 57798 | 122640 | 2308 | -+| decimals | 948 | 981 | 970 | 7470 | 17222 | - | decreaseAllowance | 34424 | 34424 | 34424 | 34424 | 1 | - | delegationWithSig | 29263 | 56402 | 45264 | 84300 | 7 | - | deposit | 91067 | 215461 | 232188 | 235808 | 64 | --| disableLiquidationGracePeriod | 43659 | 55004 | 66162 | 66162 | 513 | --| dropReserve | 32591 | 35715 | 32657 | 105072 | 775 | --| flashLoan | 59293 | 162000 | 126617 | 374226 | 267 | --| flashLoanSimple | 50944 | 311491 | 177238 | 642906 | 11 | -+| disableLiquidationGracePeriod | 43592 | 54921 | 66050 | 66050 | 513 | -+| dropReserve | 32591 | 35715 | 32613 | 105072 | 775 | -+| flashLoan | 59315 | 170319 | 141410 | 374248 | 267 | -+| flashLoanSimple | 50966 | 311558 | 177304 | 642952 | 11 | - | getAllUserRewards | 9271 | 9271 | 9271 | 9271 | 1 | - | getAssetDecimals | 1275 | 1275 | 1275 | 1275 | 2 | - | getAssetIndex | 3708 | 11517 | 14698 | 21619 | 90 | --| getBorrowLogic | 5395 | 5406 | 5406 | 5417 | 2 | -+| getBorrowLogic | 5417 | 5428 | 5428 | 5439 | 2 | - | getBridgeLogic | 5393 | 5426 | 5426 | 5459 | 2 | - | getClaimer | 1244 | 3410 | 1244 | 7744 | 3 | --| getConfiguration | 1298 | 1892 | 1342 | 7842 | 54785 | --| getConfiguratorLogic | 5353 | 5353 | 5353 | 5353 | 1 | -+| getConfiguration | 1320 | 1913 | 1364 | 7864 | 54142 | -+| getConfiguratorLogic | 5397 | 5397 | 5397 | 5397 | 1 | - | getDistributionEnd | 1411 | 1411 | 1411 | 1411 | 1 | --| getEModeCategoryData | 2554 | 6313 | 6815 | 11054 | 55 | -+| getEModeCategoryData | 2798 | 13319 | 13559 | 13559 | 6331 | - | getEModeLogic | 5392 | 5403 | 5403 | 5414 | 2 | --| getFlashLoanLogic | 5416 | 5438 | 5438 | 5461 | 2 | --| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 16230 | --| getLiquidationGracePeriod | 29207 | 29226 | 29229 | 29229 | 2270 | --| getLiquidationLogic | 5394 | 5416 | 5416 | 5439 | 2 | --| getPendingLtv | 1215 | 1215 | 1215 | 1215 | 771 | --| getPoolLogic | 5393 | 5404 | 5404 | 5416 | 2 | -+| getFlashLoanLogic | 5394 | 5416 | 5416 | 5438 | 2 | -+| getIncentivesController | 1044 | 1066 | 1088 | 7588 | 17036 | -+| getLiquidationGracePeriod | 29229 | 29248 | 29251 | 29251 | 2249 | -+| getLiquidationLogic | 5416 | 5438 | 5438 | 5461 | 2 | -+| getPendingLtv | 1259 | 1259 | 1259 | 1259 | 771 | -+| getPoolLogic | 5415 | 5426 | 5426 | 5438 | 2 | - | getPreviousIndex | 1270 | 1270 | 1270 | 1270 | 39 | --| getReserveAddressById | 1281 | 1281 | 1281 | 1281 | 1 | --| getReserveData | 4889 | 9269 | 6933 | 29433 | 19091 | --| getReserveDataExtended | 4122 | 4788 | 4122 | 6122 | 6 | --| getReserveNormalizedIncome | 1465 | 1970 | 1465 | 10427 | 10793 | --| getReserveNormalizedVariableDebt | 1465 | 1681 | 1509 | 11607 | 7435 | --| getReservesCount | 1050 | 1050 | 1050 | 1050 | 2 | --| getReservesList | 3792 | 16242 | 16292 | 103281 | 2164 | -+| getReserveAddressById | 1236 | 1236 | 1236 | 1236 | 1 | -+| getReserveData | 4911 | 11914 | 10955 | 29455 | 23413 | -+| getReserveDataExtended | 4144 | 4810 | 4144 | 6144 | 6 | -+| getReserveNormalizedIncome | 1443 | 1927 | 1487 | 10449 | 12324 | -+| getReserveNormalizedVariableDebt | 1444 | 1613 | 1444 | 11542 | 7658 | -+| getReservesCount | 986 | 986 | 986 | 986 | 2 | -+| getReservesList | 3747 | 16360 | 16247 | 103236 | 2130 | - | getRewardOracle | 1268 | 1268 | 1268 | 1268 | 1 | - | getRewardsByAsset | 2399 | 5698 | 3672 | 10899 | 201 | - | getRewardsData | 1610 | 1610 | 1610 | 1610 | 3 | - | getRewardsList | 1736 | 1736 | 1736 | 1736 | 30 | - | getScaledUserBalanceAndSupply | 1449 | 4192 | 3449 | 9949 | 39 | --| getSupplyLogic | 5417 | 5449 | 5449 | 5481 | 2 | -+| getSupplyLogic | 5395 | 5417 | 5417 | 5439 | 2 | - | getTransferStrategy | 1267 | 1267 | 1267 | 1267 | 1 | --| getUserAccountData | 18764 | 22167 | 23264 | 30029 | 1037 | -+| getUserAccountData | 12878 | 23707 | 23022 | 40147 | 2575 | - | getUserAccruedRewards | 2267 | 2267 | 2267 | 2267 | 1 | - | getUserAssetIndex | 1634 | 1634 | 1634 | 1634 | 1 | --| getUserConfiguration | 1322 | 1364 | 1322 | 3322 | 1822 | --| getUserEMode | 1275 | 1275 | 1275 | 1275 | 1037 | -+| getUserConfiguration | 1344 | 1383 | 1344 | 3344 | 1821 | -+| getUserEMode | 1275 | 1280 | 1275 | 7775 | 1294 | - | getUserRewards | 5237 | 7340 | 7469 | 10837 | 19 | --| getVirtualUnderlyingBalance | 1298 | 1319 | 1320 | 1320 | 2161 | -+| getVirtualUnderlyingBalance | 1320 | 1341 | 1342 | 1342 | 2159 | - | increaseAllowance | 34491 | 47316 | 51591 | 51591 | 4 | --| initReserve | 33270 | 33292 | 33292 | 33314 | 1024 | --| initReserves | 45755 | 32070878 | 1608802 | 218102716 | 2049 | --| liquidationCall(address,address,address,uint256,bool) | 80856 | 256275 | 351792 | 404755 | 3491 | --| liquidationCall(bytes32,bytes32) | 404144 | 404144 | 404144 | 404144 | 1 | -+| initReserve | 33269 | 33280 | 33280 | 33292 | 1024 | -+| initReserves | 45710 | 32395912 | 1608692 | 215319236 | 2049 | -+| liquidationCall(address,address,address,uint256,bool) | 80781 | 267131 | 351342 | 411243 | 3720 | -+| liquidationCall(bytes32,bytes32) | 403608 | 403608 | 403608 | 403608 | 1 | - | mint | 28161 | 73503 | 91286 | 91766 | 7 | --| mintToTreasury(address[]) | 99333 | 100926 | 100926 | 102519 | 4 | -+| mintToTreasury(address[]) | 99355 | 100948 | 100948 | 102541 | 4 | - | mintToTreasury(uint256,uint256) | 26988 | 59951 | 59951 | 92915 | 2 | --| mintUnbacked | 39431 | 145665 | 130791 | 193135 | 17 | --| name | 1625 | 2063 | 1945 | 8383 | 16555 | -+| mintUnbacked | 39386 | 145620 | 130746 | 193090 | 17 | -+| name | 1625 | 2063 | 1945 | 8383 | 17361 | - | nonces | 1193 | 2463 | 3271 | 3271 | 10 | - | permit | 29304 | 46376 | 37841 | 81937 | 8 | --| repay(address,uint256,uint256,address) | 60448 | 129350 | 167720 | 187144 | 13 | --| repay(bytes32) | 157401 | 157401 | 157401 | 157401 | 1 | --| repayWithATokens(address,uint256,uint256) | 155111 | 180842 | 182318 | 193320 | 261 | --| repayWithATokens(bytes32) | 160522 | 160522 | 160522 | 160522 | 1 | --| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155668 | 185855 | 182856 | 218694 | 768 | --| repayWithPermit(bytes32,bytes32,bytes32) | 190465 | 206566 | 214543 | 217860 | 256 | --| rescueTokens | 39115 | 70318 | 70428 | 70471 | 515 | -+| repay(address,uint256,uint256,address) | 60470 | 129327 | 167677 | 187099 | 13 | -+| repay(bytes32) | 157445 | 157445 | 157445 | 157445 | 1 | -+| repayWithATokens(address,uint256,uint256) | 155001 | 181023 | 182208 | 193232 | 261 | -+| repayWithATokens(bytes32) | 160479 | 160479 | 160479 | 160479 | 1 | -+| repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32) | 155615 | 186074 | 182779 | 218803 | 768 | -+| repayWithPermit(bytes32,bytes32,bytes32) | 190566 | 206430 | 197065 | 217839 | 256 | -+| rescueTokens | 39115 | 70340 | 70450 | 70493 | 515 | - | resetIsolationModeTotalDebt | 32590 | 32636 | 32612 | 41843 | 514 | --| scaledBalanceOf | 1307 | 3741 | 3307 | 7807 | 16286 | --| scaledTotalSupply | 988 | 5835 | 7532 | 7532 | 19121 | --| setAssetEModeCategory | 43877 | 48422 | 43877 | 79556 | 296 | --| setBorrowCap | 43786 | 44743 | 43786 | 70919 | 267 | --| setBorrowableInIsolation | 67706 | 70116 | 70508 | 70508 | 13 | -+| scaledBalanceOf | 1307 | 3788 | 3307 | 7807 | 21096 | -+| scaledTotalSupply | 988 | 6068 | 7532 | 7532 | 22705 | -+| setAssetBorrowableInEMode | 101049 | 120935 | 120960 | 120960 | 1545 | -+| setAssetCollateralInEMode | 44125 | 98055 | 103956 | 103956 | 2596 | -+| setBorrowCap | 43786 | 44744 | 43786 | 70941 | 267 | -+| setBorrowableInIsolation | 67684 | 70094 | 70486 | 70486 | 13 | - | setConfiguration | 32805 | 32816 | 32816 | 32827 | 512 | --| setDebtCeiling | 43743 | 48112 | 43743 | 121555 | 274 | --| setEModeCategory | 45031 | 53892 | 45031 | 135431 | 295 | -+| setDebtCeiling | 43765 | 48137 | 43765 | 121621 | 274 | -+| setEModeCategory | 44872 | 108807 | 116025 | 116037 | 2592 | - | setIncentivesController | 38502 | 40869 | 40869 | 43236 | 2 | --| setLiquidationGracePeriod | 32828 | 37932 | 37350 | 43761 | 1536 | --| setLiquidationProtocolFee | 43996 | 60606 | 69878 | 70968 | 8 | --| setPoolPause(bool) | 43633 | 44062 | 43633 | 116393 | 515 | --| setPoolPause(bool,uint40) | 43789 | 88393 | 74789 | 134303 | 512 | --| setReserveActive | 40906 | 43807 | 40906 | 118044 | 267 | --| setReserveBorrowing | 43833 | 60242 | 68446 | 68448 | 768 | --| setReserveFactor | 43766 | 44186 | 43766 | 151823 | 258 | -+| setLiquidationGracePeriod | 32805 | 37936 | 37338 | 43761 | 1536 | -+| setLiquidationProtocolFee | 44018 | 60642 | 69922 | 71012 | 8 | -+| setPoolPause(bool) | 43568 | 43997 | 43580 | 116349 | 515 | -+| setPoolPause(bool,uint40) | 43811 | 87972 | 74821 | 134211 | 512 | -+| setReserveActive | 40928 | 43831 | 40928 | 118110 | 267 | -+| setReserveBorrowing | 43877 | 60301 | 68512 | 68514 | 768 | -+| setReserveFactor | 43810 | 44230 | 43810 | 151933 | 258 | - | setReserveFlashLoaning | 68511 | 68516 | 68513 | 70667 | 513 | --| setReserveFreeze | 47022 | 73129 | 74823 | 99841 | 783 | --| setReserveInterestRateData | 44326 | 44812 | 44554 | 131069 | 257 | --| setReserveInterestRateStrategyAddress(address,address) | 32846 | 34588 | 33195 | 42729 | 1538 | --| setReserveInterestRateStrategyAddress(address,address,bytes) | 44558 | 61418 | 44558 | 190255 | 300 | --| setReservePause(address,bool) | 43812 | 44147 | 44040 | 67736 | 258 | --| setReservePause(address,bool,uint40) | 41277 | 65905 | 73907 | 79019 | 3084 | --| setSiloedBorrowing | 102106 | 111956 | 115803 | 117959 | 3 | --| setSupplyCap | 43788 | 45799 | 43788 | 70921 | 279 | --| setUnbackedMintCap | 70889 | 70889 | 70889 | 70889 | 7 | --| setUserEMode | 48307 | 68041 | 66511 | 113935 | 17 | --| setUserUseReserveAsCollateral(address,bool) | 80336 | 96356 | 93550 | 129754 | 42 | --| setUserUseReserveAsCollateral(bytes32) | 95329 | 95329 | 95329 | 95329 | 1 | -+| setReserveFreeze | 47066 | 73158 | 74889 | 99907 | 782 | -+| setReserveInterestRateData | 44370 | 44856 | 44598 | 131179 | 257 | -+| setReserveInterestRateStrategyAddress(address,address) | 32868 | 34614 | 33217 | 42751 | 1538 | -+| setReserveInterestRateStrategyAddress(address,address,bytes) | 44513 | 61386 | 44513 | 190298 | 300 | -+| setReservePause(address,bool) | 43856 | 44201 | 44084 | 67802 | 258 | -+| setReservePause(address,bool,uint40) | 41311 | 65613 | 73900 | 76218 | 3084 | -+| setSiloedBorrowing | 102085 | 111949 | 115804 | 117960 | 3 | -+| setSupplyCap | 43743 | 45756 | 43743 | 70898 | 279 | -+| setUnbackedMintCap | 70933 | 70933 | 70933 | 70933 | 7 | -+| setUserEMode | 43067 | 74317 | 67231 | 120947 | 2325 | -+| setUserUseReserveAsCollateral(address,bool) | 80314 | 96359 | 93573 | 129666 | 42 | -+| setUserUseReserveAsCollateral(bytes32) | 95286 | 95286 | 95286 | 95286 | 1 | - | setValue | 31574 | 31590 | 31598 | 31598 | 3 | --| supply(address,uint256,address,uint16) | 56664 | 214087 | 231043 | 243594 | 3300 | -+| supply(address,uint256,address,uint16) | 56598 | 218710 | 226273 | 243528 | 5348 | - | supply(bytes32) | 237010 | 237010 | 237010 | 237010 | 7 | --| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216977 | 242026 | 266578 | 768 | --| supplyWithPermit(bytes32,bytes32,bytes32) | 262532 | 262616 | 262592 | 262736 | 256 | --| symbol | 1646 | 2128 | 1966 | 8448 | 16530 | -+| supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32) | 142365 | 216979 | 242026 | 266578 | 768 | -+| supplyWithPermit(bytes32,bytes32,bytes32) | 262566 | 262631 | 262602 | 262758 | 256 | -+| symbol | 1646 | 2126 | 1966 | 8448 | 17336 | - | text | 1789 | 1789 | 1789 | 1789 | 8 | --| totalSupply | 1024 | 8279 | 11570 | 15570 | 4914 | --| transfer | 27662 | 144188 | 149393 | 167373 | 273 | --| transferFrom | 138702 | 138822 | 138822 | 138942 | 2 | -+| totalSupply | 1024 | 8842 | 11592 | 15592 | 5952 | -+| transfer | 27662 | 144508 | 149415 | 167131 | 273 | -+| transferFrom | 138724 | 138844 | 138844 | 138964 | 2 | - | transferOnLiquidation | 28063 | 28063 | 28063 | 28063 | 1 | - | transferUnderlyingTo | 27506 | 27506 | 27506 | 27506 | 1 | --| updateAToken | 41856 | 42264 | 41856 | 146869 | 257 | --| updateBridgeProtocolFee | 32528 | 33698 | 32573 | 78409 | 526 | --| updateFlashloanPremiumToProtocol | 40448 | 40536 | 40448 | 63268 | 258 | --| updateFlashloanPremiumTotal | 40469 | 40558 | 40469 | 63300 | 258 | --| updateFlashloanPremiums | 32853 | 32875 | 32875 | 32898 | 512 | --| updateVariableDebtToken | 41710 | 42095 | 41710 | 140758 | 257 | -+| updateAToken | 41789 | 42197 | 41789 | 146826 | 257 | -+| updateBridgeProtocolFee | 32550 | 33719 | 32595 | 78387 | 526 | -+| updateFlashloanPremiumToProtocol | 40470 | 40559 | 40470 | 63334 | 258 | -+| updateFlashloanPremiumTotal | 40424 | 40513 | 40424 | 63299 | 258 | -+| updateFlashloanPremiums | 32875 | 32897 | 32897 | 32920 | 512 | -+| updateVariableDebtToken | 41644 | 42029 | 41644 | 140710 | 257 | - | upgradeTo | 26855 | 28742 | 28742 | 30629 | 2 | - | upgradeToAndCall | 28758 | 152638 | 187413 | 187413 | 8 | - | value | 931 | 931 | 931 | 931 | 11 | - | values | 1213 | 1213 | 1213 | 1213 | 16 | --| withdraw(address,uint256,address) | 66340 | 134756 | 141964 | 205094 | 23 | --| withdraw(bytes32) | 138782 | 145861 | 145861 | 152941 | 2 | -+| withdraw(address,uint256,address) | 66362 | 134766 | 141986 | 204851 | 23 | -+| withdraw(bytes32) | 138804 | 145883 | 145883 | 152963 | 2 | - - - | src/contracts/mocks/flashloan/MockFlashLoanReceiver.sol:MockFlashLoanReceiver contract | | | | | | -@@ -703,9 +704,9 @@ - | src/contracts/mocks/helpers/MockPool.sol:MockPoolInherited contract | | | | | | - |---------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 4732690 | 21870 | | | | | -+| 4761368 | 22003 | | | | | - | Function Name | min | avg | median | max | # calls | --| initialize | 28462 | 28462 | 28462 | 28462 | 2 | -+| initialize | 28397 | 28397 | 28397 | 28397 | 2 | - - - | src/contracts/mocks/oracle/CLAggregators/MockAggregator.sol:MockAggregator contract | | | | | | -@@ -713,10 +714,10 @@ - | Deployment Cost | Deployment Size | | | | | - | 109507 | 321 | | | | | - | Function Name | min | avg | median | max | # calls | --| _latestAnswer | 317 | 317 | 317 | 317 | 4160 | -+| _latestAnswer | 317 | 317 | 317 | 317 | 4156 | - | decimals | 144 | 144 | 144 | 144 | 83 | - | description | 170 | 170 | 170 | 170 | 83 | --| latestAnswer | 281 | 1395 | 2281 | 2281 | 24197 | -+| latestAnswer | 281 | 1462 | 2281 | 2281 | 30556 | - | name | 170 | 170 | 170 | 170 | 83 | - - -@@ -735,7 +736,7 @@ - | 278266 | 1393 | | | | | - | Function Name | min | avg | median | max | # calls | - | latestRoundData | 730 | 1533 | 735 | 4735 | 10 | --| setAnswer | 26207 | 27452 | 26207 | 46119 | 73 | -+| setAnswer | 26207 | 27469 | 26207 | 46119 | 72 | - - - | src/contracts/mocks/swap/MockParaSwapAugustus.sol:MockParaSwapAugustus contract | | | | | | -@@ -773,13 +774,13 @@ - | Function Name | min | avg | median | max | # calls | - | DOMAIN_SEPARATOR | 2340 | 2340 | 2340 | 2340 | 1 | - | allowance | 836 | 836 | 836 | 836 | 9 | --| approve | 29140 | 46510 | 46588 | 46588 | 4618 | --| balanceOf | 651 | 991 | 651 | 2651 | 12549 | --| decimals | 312 | 1481 | 2312 | 2312 | 73384 | --| mint | 36480 | 58491 | 53592 | 70740 | 4133 | -+| approve | 29140 | 46453 | 46588 | 46588 | 6901 | -+| balanceOf | 651 | 991 | 651 | 2651 | 12547 | -+| decimals | 312 | 1475 | 2312 | 2312 | 75774 | -+| mint | 36480 | 62216 | 70692 | 70800 | 6416 | - | name | 3241 | 3241 | 3241 | 3241 | 2048 | - | nonces | 2604 | 2604 | 2604 | 2604 | 1 | --| permit | 76466 | 76512 | 76502 | 76670 | 512 | -+| permit | 76454 | 76514 | 76502 | 76670 | 512 | - | symbol | 1328 | 2328 | 2328 | 3328 | 56 | - | transfer | 46931 | 51023 | 51707 | 51707 | 7 | - | transferOwnership | 28800 | 28800 | 28800 | 28800 | 30 | -@@ -801,10 +802,10 @@ - | Deployment Cost | Deployment Size | | | | | - | 119707 | 340 | | | | | - | Function Name | min | avg | median | max | # calls | --| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 448 | --| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 689 | --| percentDiv | 321 | 426 | 432 | 432 | 259 | --| percentMul | 338 | 411 | 435 | 435 | 259 | -+| HALF_PERCENTAGE_FACTOR | 147 | 147 | 147 | 147 | 432 | -+| PERCENTAGE_FACTOR | 224 | 224 | 224 | 224 | 661 | -+| percentDiv | 321 | 420 | 432 | 432 | 259 | -+| percentMul | 338 | 405 | 435 | 435 | 259 | - - - | src/contracts/mocks/tests/WadRayMathWrapper.sol:WadRayMathWrapper contract | | | | | | -@@ -813,16 +814,16 @@ - | 233882 | 871 | | | | | - | Function Name | min | avg | median | max | # calls | - | HALF_RAY | 247 | 247 | 247 | 247 | 1 | --| HALF_WAD | 224 | 224 | 224 | 224 | 443 | -+| HALF_WAD | 224 | 224 | 224 | 224 | 434 | - | RAY | 225 | 225 | 225 | 225 | 1 | --| WAD | 180 | 180 | 180 | 180 | 658 | --| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1762 | -+| WAD | 180 | 180 | 180 | 180 | 651 | -+| WAD_RAY_RATIO | 269 | 269 | 269 | 269 | 1765 | - | rayDiv | 498 | 498 | 498 | 498 | 4 | - | rayMul | 501 | 501 | 501 | 501 | 3 | - | rayToWad | 387 | 390 | 387 | 401 | 515 | --| wadDiv | 431 | 524 | 542 | 542 | 260 | --| wadMul | 338 | 409 | 435 | 435 | 262 | --| wadToRay | 284 | 355 | 360 | 360 | 485 | -+| wadDiv | 431 | 523 | 542 | 542 | 260 | -+| wadMul | 338 | 407 | 435 | 435 | 262 | -+| wadToRay | 284 | 355 | 360 | 360 | 488 | - - - | src/contracts/mocks/tokens/MockATokenRepayment.sol:MockATokenRepayment contract | | | | | | -@@ -907,23 +908,23 @@ - | Deployment Cost | Deployment Size | | | | | - | 864174 | 4235 | | | | | - | Function Name | min | avg | median | max | # calls | --| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1318 | -+| DEFAULT_ADMIN_ROLE | 284 | 284 | 284 | 284 | 1328 | - | FLASH_BORROWER_ROLE | 317 | 317 | 317 | 317 | 20 | --| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 649 | -+| POOL_ADMIN_ROLE | 294 | 294 | 294 | 294 | 654 | - | addAssetListingAdmin | 50962 | 50962 | 50962 | 50962 | 3 | - | addBridge | 51028 | 51028 | 51028 | 51028 | 14 | - | addEmergencyAdmin | 50963 | 50963 | 50963 | 50963 | 3 | - | addFlashBorrower | 50984 | 52203 | 50984 | 55863 | 4 | --| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 639 | -+| addPoolAdmin | 50995 | 51006 | 51007 | 51007 | 644 | - | addRiskAdmin | 51028 | 51028 | 51028 | 51028 | 14 | - | grantRole | 51480 | 52091 | 51480 | 56370 | 8 | - | hasRole | 740 | 2622 | 2740 | 2740 | 17 | --| isAssetListingAdmin | 814 | 2465 | 2814 | 2814 | 3562 | -+| isAssetListingAdmin | 814 | 2463 | 2814 | 2814 | 3572 | - | isBridge | 2791 | 2791 | 2791 | 2791 | 26 | - | isEmergencyAdmin | 747 | 2746 | 2747 | 2747 | 3843 | - | isFlashBorrower | 2833 | 2833 | 2833 | 2833 | 268 | --| isPoolAdmin | 757 | 1741 | 757 | 2757 | 45593 | --| isRiskAdmin | 747 | 1420 | 747 | 2747 | 29906 | -+| isPoolAdmin | 757 | 1899 | 2757 | 2757 | 50045 | -+| isRiskAdmin | 747 | 1691 | 747 | 2747 | 34338 | - | removeAssetListingAdmin | 29054 | 29054 | 29054 | 29054 | 2 | - | removeBridge | 29023 | 29023 | 29023 | 29023 | 1 | - | removeEmergencyAdmin | 28999 | 28999 | 28999 | 28999 | 1 | -@@ -938,24 +939,24 @@ - | Deployment Cost | Deployment Size | | | | | - | 1604102 | 8368 | | | | | - | Function Name | min | avg | median | max | # calls | --| getACLAdmin | 480 | 551 | 480 | 2480 | 676 | --| getACLManager | 534 | 1369 | 534 | 2534 | 39760 | --| getAddress | 546 | 549 | 546 | 2546 | 657 | -+| getACLAdmin | 480 | 550 | 480 | 2480 | 681 | -+| getACLManager | 534 | 1563 | 2534 | 2534 | 44212 | -+| getAddress | 546 | 549 | 546 | 2546 | 662 | - | getMarketId | 1351 | 1351 | 1351 | 1351 | 6 | --| getPool | 469 | 682 | 469 | 2469 | 43331 | --| getPoolConfigurator | 512 | 774 | 512 | 2512 | 182138 | --| getPoolDataProvider | 489 | 1325 | 489 | 2489 | 2203 | --| getPriceOracle | 577 | 2281 | 2577 | 2577 | 7894 | --| getPriceOracleSentinel | 490 | 2484 | 2490 | 2490 | 6231 | --| owner | 365 | 365 | 365 | 365 | 653 | -+| getPool | 469 | 675 | 469 | 2469 | 44963 | -+| getPoolConfigurator | 512 | 832 | 512 | 2512 | 187849 | -+| getPoolDataProvider | 489 | 1323 | 489 | 2489 | 2218 | -+| getPriceOracle | 577 | 2160 | 2577 | 2577 | 12992 | -+| getPriceOracleSentinel | 490 | 2485 | 2490 | 2490 | 7483 | -+| owner | 365 | 365 | 365 | 365 | 658 | - | setACLAdmin | 24016 | 45798 | 47621 | 47621 | 24 | - | setACLManager | 24059 | 37487 | 39114 | 47664 | 4 | - | setAddress | 24625 | 35611 | 31540 | 48640 | 5 | - | setAddressAsProxy | 24331 | 228775 | 57063 | 518962 | 5 | - | setMarketId | 24424 | 28561 | 28561 | 32699 | 2 | --| setPoolConfiguratorImpl | 24015 | 292593 | 300665 | 545030 | 4 | -+| setPoolConfiguratorImpl | 24015 | 292580 | 300639 | 545030 | 4 | - | setPoolDataProvider | 24104 | 37532 | 39159 | 47709 | 4 | --| setPoolImpl | 24060 | 279069 | 287138 | 517941 | 4 | -+| setPoolImpl | 24060 | 279024 | 287080 | 517876 | 4 | - | setPriceOracle | 24083 | 37511 | 39138 | 47688 | 4 | - | setPriceOracleSentinel | 24126 | 40946 | 47731 | 47731 | 6 | - -@@ -968,7 +969,7 @@ - | getAddressesProviderAddressById | 522 | 522 | 522 | 522 | 4 | - | getAddressesProviderIdByAddress | 559 | 1225 | 559 | 2559 | 6 | - | getAddressesProvidersList | 673 | 3403 | 3292 | 5018 | 5 | --| owner | 331 | 2327 | 2331 | 2331 | 650 | -+| owner | 331 | 2327 | 2331 | 2331 | 655 | - | registerAddressesProvider | 24444 | 104012 | 119926 | 119926 | 6 | - | unregisterAddressesProvider | 26448 | 39029 | 40004 | 49662 | 4 | - -@@ -996,7 +997,7 @@ - | Deployment Cost | Deployment Size | | | | | - | 3183382 | 14716 | | | | | - | Function Name | min | avg | median | max | # calls | --| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 653 | -+| EMISSION_MANAGER | 327 | 327 | 327 | 327 | 658 | - | claimAllRewards | 92349 | 92349 | 92349 | 92349 | 1 | - | claimAllRewardsOnBehalf | 94649 | 94649 | 94649 | 94649 | 1 | - | claimAllRewardsToSelf | 92147 | 92147 | 92147 | 92147 | 1 | -@@ -1018,8 +1019,8 @@ - | getUserAccruedRewards | 1648 | 1648 | 1648 | 1648 | 1 | - | getUserAssetIndex | 1009 | 1009 | 1009 | 1009 | 1 | - | getUserRewards | 4600 | 6703 | 6832 | 10200 | 19 | --| handleAction | 732 | 2337 | 2732 | 38089 | 17852 | --| initialize | 26067 | 45246 | 45252 | 53156 | 652 | -+| handleAction | 732 | 2364 | 2732 | 38089 | 21943 | -+| initialize | 26067 | 45246 | 45252 | 53156 | 657 | - | setClaimer | 24282 | 24282 | 24282 | 24282 | 4 | - | setDistributionEnd | 8888 | 8888 | 8888 | 8888 | 2 | - | setEmissionPerSecond | 24335 | 24335 | 24335 | 24335 | 2 | -@@ -1055,15 +1056,15 @@ - | Deployment Cost | Deployment Size | | | | | - | 0 | 0 | | | | | - | Function Name | min | avg | median | max | # calls | --| initialize | 90684 | 90684 | 90684 | 90684 | 674 | -+| initialize | 90684 | 90684 | 90684 | 90684 | 679 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchOne.sol:AaveV3GettersBatchOne contract | | | | | | - |-----------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| - | Deployment Cost | Deployment Size | | | | | --| 5190134 | 33125 | | | | | -+| 5145702 | 33451 | | | | | - | Function Name | min | avg | median | max | # calls | --| getGettersReportOne | 971 | 971 | 971 | 971 | 672 | -+| getGettersReportOne | 971 | 971 | 971 | 971 | 677 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3GettersBatchTwo.sol:AaveV3GettersBatchTwo contract | | | | | | -@@ -1071,15 +1072,15 @@ - | Deployment Cost | Deployment Size | | | | | - | 1583555 | 11792 | | | | | - | Function Name | min | avg | median | max | # calls | --| getGettersReportTwo | 535 | 535 | 535 | 535 | 647 | -+| getGettersReportTwo | 535 | 535 | 535 | 535 | 652 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchOne.sol:AaveV3HelpersBatchOne contract | | | | | | - |-----------------------------------------------------------------------------------------------------------|-----------------|------|--------|------|---------| - | Deployment Cost | Deployment Size | | | | | --| 7434786 | 35360 | | | | | -+| 7356455 | 35017 | | | | | - | Function Name | min | avg | median | max | # calls | --| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 622 | -+| getConfigEngineReport | 1696 | 1696 | 1696 | 1696 | 627 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3HelpersBatchTwo.sol:AaveV3HelpersBatchTwo contract | | | | | | -@@ -1087,15 +1088,15 @@ - | Deployment Cost | Deployment Size | | | | | - | 7169046 | 31590 | | | | | - | Function Name | min | avg | median | max | # calls | --| staticATokenReport | 971 | 971 | 971 | 971 | 622 | -+| staticATokenReport | 971 | 971 | 971 | 971 | 627 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3L2PoolBatch.sol:AaveV3L2PoolBatch contract | | | | | | - |---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| - | Deployment Cost | Deployment Size | | | | | --| 9289812 | 42653 | | | | | -+| 9338136 | 42878 | | | | | - | Function Name | min | avg | median | max | # calls | --| getPoolReport | 535 | 535 | 535 | 535 | 672 | -+| getPoolReport | 535 | 535 | 535 | 535 | 677 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3MiscBatch.sol:AaveV3MiscBatch contract | | | | | | -@@ -1103,13 +1104,13 @@ - | Deployment Cost | Deployment Size | | | | | - | 1062926 | 7122 | | | | | - | Function Name | min | avg | median | max | # calls | --| getMiscReport | 535 | 535 | 535 | 535 | 672 | -+| getMiscReport | 535 | 535 | 535 | 535 | 677 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3ParaswapBatch.sol:AaveV3ParaswapBatch contract | | | | | | - |-------------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| - | Deployment Cost | Deployment Size | | | | | --| 6476447 | 33699 | | | | | -+| 6475775 | 33699 | | | | | - | Function Name | min | avg | median | max | # calls | - | getParaswapReport | 971 | 971 | 971 | 971 | 30 | - -@@ -1119,7 +1120,7 @@ - | Deployment Cost | Deployment Size | | | | | - | 7573451 | 38861 | | | | | - | Function Name | min | avg | median | max | # calls | --| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 672 | -+| getPeripheryReport | 1333 | 1333 | 1333 | 1333 | 677 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3SetupBatch.sol:AaveV3SetupBatch contract | | | | | | -@@ -1127,9 +1128,9 @@ - | Deployment Cost | Deployment Size | | | | | - | 5147688 | 28075 | | | | | - | Function Name | min | avg | median | max | # calls | --| getInitialReport | 554 | 554 | 554 | 554 | 672 | --| setMarketReport | 632455 | 634818 | 632455 | 773435 | 622 | --| setupAaveV3Market | 2709798 | 2710437 | 2709798 | 2736039 | 649 | -+| getInitialReport | 554 | 554 | 554 | 554 | 677 | -+| setMarketReport | 632455 | 634799 | 632455 | 773435 | 627 | -+| setupAaveV3Market | 2709798 | 2710424 | 2709798 | 2735948 | 654 | - - - | src/deployments/projects/aave-v3-batched/batches/AaveV3TokensBatch.sol:AaveV3TokensBatch contract | | | | | | -@@ -1137,130 +1138,130 @@ - | Deployment Cost | Deployment Size | | | | | - | 4294582 | 20766 | | | | | - | Function Name | min | avg | median | max | # calls | --| getTokensReport | 535 | 535 | 535 | 535 | 647 | -+| getTokensReport | 535 | 535 | 535 | 535 | 652 | - - --| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | --|------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| --| Deployment Cost | Deployment Size | | | | | --| 751213 | 3484 | | | | | --| Function Name | min | avg | median | max | # calls | --| execute | 94550 | 94550 | 94550 | 94550 | 1 | -+| tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol:AaveV3MockAssetEModeUpdate contract | | | | | | -+|------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| -+| Deployment Cost | Deployment Size | | | | | -+| 790748 | 3668 | | | | | -+| Function Name | min | avg | median | max | # calls | -+| execute | 119157 | 119157 | 119157 | 119157 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdate.sol:AaveV3MockBorrowUpdate contract | | | | | | - |----------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| - | Deployment Cost | Deployment Size | | | | | --| 783501 | 3634 | | | | | -+| 816478 | 3787 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 159425 | 159425 | 159425 | 159425 | 1 | -+| execute | 159566 | 159566 | 159566 | 159566 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockBorrowUpdateNoChange.sol:AaveV3MockBorrowUpdateNoChange contract | | | | | | - |--------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 790396 | 3666 | | | | | -+| 823384 | 3819 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 47089 | 47089 | 47089 | 47089 | 1 | -+| execute | 47076 | 47076 | 47076 | 47076 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockCapUpdate.sol:AaveV3MockCapUpdate contract | | | | | | - |----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 770601 | 3574 | | | | | -+| 803217 | 3726 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 86135 | 86135 | 86135 | 86135 | 1 | -+| execute | 86081 | 86081 | 86081 | 86081 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdate.sol:AaveV3MockCollateralUpdate contract | | | | | | - |------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 784137 | 3637 | | | | | -+| 817030 | 3790 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89720 | 89720 | 89720 | 89720 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateNoChange.sol:AaveV3MockCollateralUpdateNoChange contract | | | | | | - |----------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 790576 | 3667 | | | | | -+| 823420 | 3820 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 35916 | 35916 | 35916 | 35916 | 2 | -+| execute | 35903 | 35903 | 35903 | 35903 | 2 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateCorrectBonus contract | | | | | | - |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 784137 | 3637 | | | | | -+| 817030 | 3790 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 89667 | 89667 | 89667 | 89667 | 1 | -+| execute | 89720 | 89720 | 89720 | 89720 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockCollateralUpdateWrongBonus.sol:AaveV3MockCollateralUpdateWrongBonus contract | | | | | | - |--------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 785049 | 3641 | | | | | -+| 817894 | 3794 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 35332 | 35332 | 35332 | 35332 | 1 | -+| execute | 35294 | 35294 | 35294 | 35294 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdate contract | | | | | | - |------------------------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| - | Deployment Cost | Deployment Size | | | | | --| 756400 | 3425 | | | | | -+| 785793 | 3562 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 155461 | 155461 | 155461 | 155461 | 2 | -+| execute | 135648 | 135648 | 135648 | 135648 | 2 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdate.sol:AaveV3MockEModeCategoryUpdateEdgeBonus contract | | | | | | - |---------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 757072 | 3428 | | | | | -+| 786441 | 3565 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 53964 | 53964 | 53964 | 53964 | 1 | -+| execute | 56434 | 56434 | 56434 | 56434 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockEModeCategoryUpdateNoChange.sol:AaveV3MockEModeCategoryUpdateNoChange contract | | | | | | - |----------------------------------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 770849 | 3492 | | | | | -+| 800206 | 3629 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 38497 | 38497 | 38497 | 38497 | 2 | -+| execute | 37910 | 37910 | 37910 | 37910 | 2 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockListing.sol:AaveV3MockListing contract | | | | | | - |------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| - | Deployment Cost | Deployment Size | | | | | --| 853685 | 4030 | | | | | -+| 882403 | 4162 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 1836009 | 1836009 | 1836009 | 1836009 | 1 | --| newListings | 2820 | 2820 | 2820 | 2820 | 4 | -+| execute | 1815216 | 1815216 | 1815216 | 1815216 | 1 | -+| newListings | 2729 | 2729 | 2729 | 2729 | 4 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockListingCustom.sol:AaveV3MockListingCustom contract | | | | | | - |------------------------------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| - | Deployment Cost | Deployment Size | | | | | --| 918454 | 4491 | | | | | -+| 946992 | 4623 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 1835953 | 1835953 | 1835953 | 1835953 | 1 | --| newListingsCustom | 3295 | 3295 | 3295 | 3295 | 4 | -+| execute | 1815233 | 1815233 | 1815233 | 1815233 | 1 | -+| newListingsCustom | 3226 | 3226 | 3226 | 3226 | 4 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockPriceFeedUpdate.sol:AaveV3MockPriceFeedUpdate contract | | | | | | - |----------------------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| - | Deployment Cost | Deployment Size | | | | | --| 774000 | 3660 | | | | | -+| 806996 | 3812 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 65371 | 65371 | 65371 | 65371 | 1 | -+| execute | 65395 | 65395 | 65395 | 65395 | 1 | - - - | tests/extensions/v3-config-engine/mocks/AaveV3MockRatesUpdate.sol:AaveV3MockRatesUpdate contract | | | | | | - |--------------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| - | Deployment Cost | Deployment Size | | | | | --| 772773 | 3584 | | | | | -+| 809091 | 3753 | | | | | - | Function Name | min | avg | median | max | # calls | --| execute | 148663 | 148663 | 148663 | 148663 | 1 | --| rateStrategiesUpdates | 1184 | 1184 | 1184 | 1184 | 4 | -+| execute | 148672 | 148672 | 148672 | 148672 | 1 | -+| rateStrategiesUpdates | 1162 | 1162 | 1162 | 1162 | 4 | - - - | tests/harness/VariableDebtToken.sol:VariableDebtTokenHarness contract | | | | | | -@@ -1273,17 +1274,17 @@ - | UNDERLYING_ASSET_ADDRESS | 376 | 1200 | 376 | 2376 | 4354 | - | allowance | 909 | 909 | 909 | 909 | 1 | - | approve | 22107 | 22107 | 22107 | 22107 | 1 | --| approveDelegation | 48608 | 48637 | 48632 | 48680 | 256 | --| burn | 52036 | 52064 | 52060 | 52108 | 512 | -+| approveDelegation | 48608 | 48634 | 48632 | 48680 | 256 | -+| burn | 52036 | 52065 | 52060 | 52108 | 512 | - | decimals | 335 | 335 | 335 | 335 | 3330 | - | decreaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | - | getIncentivesController | 431 | 431 | 431 | 431 | 3330 | - | increaseAllowance | 22128 | 22128 | 22128 | 22128 | 1 | --| initialize | 29524 | 148072 | 179097 | 270713 | 2048 | --| mint | 86763 | 88040 | 86799 | 91824 | 1024 | --| name | 1009 | 1332 | 1264 | 1796 | 3330 | -+| initialize | 29318 | 147436 | 179085 | 270653 | 2048 | -+| mint | 86763 | 88039 | 86799 | 91824 | 1024 | -+| name | 1009 | 1329 | 1264 | 1796 | 3330 | - | scaledBalanceOf | 691 | 691 | 691 | 691 | 1024 | --| symbol | 1030 | 1351 | 1285 | 1817 | 3330 | -+| symbol | 1030 | 1354 | 1285 | 1817 | 3330 | - | transfer | 22150 | 22150 | 22150 | 22150 | 1 | - | transferFrom | 22377 | 22377 | 22377 | 22377 | 1 | - -@@ -1291,11 +1292,11 @@ - | tests/mocks/AaveV3TestListing.sol:AaveV3TestListing contract | | | | | | - |--------------------------------------------------------------|-----------------|---------|---------|---------|---------| - | Deployment Cost | Deployment Size | | | | | --| 3392063 | 13846 | | | | | -+| 3416267 | 13958 | | | | | - | Function Name | min | avg | median | max | # calls | --| USDX_ADDRESS | 294 | 294 | 294 | 294 | 617 | --| WBTC_ADDRESS | 250 | 250 | 250 | 250 | 617 | --| execute | 5227666 | 5230040 | 5230240 | 5230240 | 619 | -+| USDX_ADDRESS | 272 | 272 | 272 | 272 | 622 | -+| WBTC_ADDRESS | 228 | 228 | 228 | 228 | 622 | -+| execute | 5177782 | 5180033 | 5180221 | 5180221 | 624 | - - - | tests/mocks/AugustusRegistryMock.sol:AugustusRegistryMock contract | | | | | | -@@ -1332,4 +1333,4 @@ - - - --Ran 56 test suites in 75.93s (123.90s CPU time): 694 tests passed, 0 failed, 0 skipped (694 total tests) -+Ran 57 test suites in 75.90s (200.04s CPU time): 699 tests passed, 0 failed, 0 skipped (699 total tests) -``` diff --git a/foundry.toml b/foundry.toml index 61253e0b..b685047e 100644 --- a/foundry.toml +++ b/foundry.toml @@ -4,14 +4,17 @@ test = 'tests' script = 'scripts' optimizer = true optimizer_runs = 200 -solc='0.8.19' +solc = '0.8.19' evm_version = 'paris' bytecode_hash = 'none' out = 'out' libs = ['lib'] -remappings = [ +remappings = [] +fs_permissions = [ + { access = "write", path = "./reports" }, + { access = "read", path = "./out" }, + { access = "read", path = "./config" }, ] -fs_permissions = [{access = "write", path = "./reports"}, {access = "read", path = "./out" }, {access = "read", path = "./config"}] ffi = true [fuzz] @@ -25,7 +28,7 @@ avalanche = "${RPC_AVALANCHE}" polygon = "${RPC_POLYGON}" arbitrum = "${RPC_ARBITRUM}" fantom = "${RPC_FANTOM}" -scroll= "${RPC_SCROLL}" +scroll = "${RPC_SCROLL}" celo = "${RPC_CELO}" fantom_testnet = "${RPC_FANTOM_TESTNET}" harmony = "${RPC_HARMONY}" @@ -38,19 +41,19 @@ gnosis = "${RPC_GNOSIS}" base = "${RPC_BASE}" [etherscan] -mainnet={key="${ETHERSCAN_API_KEY_MAINNET}",chainId=1} -optimism={key="${ETHERSCAN_API_KEY_OPTIMISM}",chainId=10} -avalanche={key="${ETHERSCAN_API_KEY_AVALANCHE}",chainId=43114} -polygon={key="${ETHERSCAN_API_KEY_POLYGON}",chainId=137} -arbitrum={key="${ETHERSCAN_API_KEY_ARBITRUM}",chainId=42161} -fantom={key="${ETHERSCAN_API_KEY_FANTOM}",chainId=250} -scroll={key="${ETHERSCAN_API_KEY_SCROLL}",chainId=534352, url='https://api.scrollscan.com/api\?'} -celo={key="${ETHERSCAN_API_KEY_CELO}",chainId=42220} -sepolia={key="${ETHERSCAN_API_KEY_MAINNET}",chainId=11155111} -mumbai={key="${ETHERSCAN_API_KEY_POLYGON}",chainId=80001} -amoy={key="${ETHERSCAN_API_KEY_POLYGON}",chainId=80002} -bnb_testnet={key="${ETHERSCAN_API_KEY_BNB}",chainId=97,url='https://api-testnet.bscscan.com/api'} -bnb={key="${ETHERSCAN_API_KEY_BNB}",chainId=56,url='https://api.bscscan.com/api'} -base={key="${ETHERSCAN_API_KEY_BASE}",chain=8453} -gnosis={key="${ETHERSCAN_API_KEY_GNOSIS}",chainId=100} +mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 1 } +optimism = { key = "${ETHERSCAN_API_KEY_OPTIMISM}", chainId = 10 } +avalanche = { key = "${ETHERSCAN_API_KEY_AVALANCHE}", chainId = 43114 } +polygon = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 137 } +arbitrum = { key = "${ETHERSCAN_API_KEY_ARBITRUM}", chainId = 42161 } +fantom = { key = "${ETHERSCAN_API_KEY_FANTOM}", chainId = 250 } +scroll = { key = "${ETHERSCAN_API_KEY_SCROLL}", chainId = 534352, url = 'https://api.scrollscan.com/api\?' } +celo = { key = "${ETHERSCAN_API_KEY_CELO}", chainId = 42220 } +sepolia = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 11155111 } +mumbai = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80001 } +amoy = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80002 } +bnb_testnet = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 97, url = 'https://api-testnet.bscscan.com/api' } +bnb = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 56, url = 'https://api.bscscan.com/api' } +base = { key = "${ETHERSCAN_API_KEY_BASE}", chain = 8453 } +gnosis = { key = "${ETHERSCAN_API_KEY_GNOSIS}", chainId = 100 } # See more config options https://github.com/gakonst/foundry/tree/master/config From f02fcb2d6ac2e08aa6bf6a8a0d38f6786cc1809a Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 19 Sep 2024 18:52:33 +0200 Subject: [PATCH 83/88] refactor(configEngine): rename `asset` to `assets` for consistency with other methods (#26) --- .../extensions/v3-config-engine/AaveV3ConfigEngine.sol | 4 ++-- .../extensions/v3-config-engine/AaveV3Payload.sol | 8 ++++---- .../extensions/v3-config-engine/IAaveV3ConfigEngine.sol | 2 +- .../extensions/v3-config-engine/libraries/EModeEngine.sol | 6 +++--- .../v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol index ed817352..3c9df057 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3ConfigEngine.sol @@ -187,10 +187,10 @@ contract AaveV3ConfigEngine is IAaveV3ConfigEngine { } /// @inheritdoc IAaveV3ConfigEngine - function updateAssetEMode(AssetEModeUpdate[] calldata updates) external { + function updateAssetsEMode(AssetEModeUpdate[] calldata updates) external { EMODE_ENGINE.functionDelegateCall( abi.encodeWithSelector( - EModeEngine.executeAssetEModeUpdate.selector, + EModeEngine.executeAssetsEModeUpdate.selector, _getEngineConstants(), updates ) diff --git a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol index 8618056f..50ecc07a 100644 --- a/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol +++ b/src/contracts/extensions/v3-config-engine/AaveV3Payload.sol @@ -49,7 +49,7 @@ abstract contract AaveV3Payload { IEngine.BorrowUpdate[] memory borrows = borrowsUpdates(); IEngine.RateStrategyUpdate[] memory rates = rateStrategiesUpdates(); IEngine.PriceFeedUpdate[] memory priceFeeds = priceFeedsUpdates(); - IEngine.AssetEModeUpdate[] memory assetEModes = assetEModeUpdates(); + IEngine.AssetEModeUpdate[] memory assetsEModes = assetsEModeUpdates(); IEngine.CapsUpdate[] memory caps = capsUpdates(); if (eModeCategories.length != 0) { @@ -98,9 +98,9 @@ abstract contract AaveV3Payload { ); } - if (assetEModes.length != 0) { + if (assetsEModes.length != 0) { address(CONFIG_ENGINE).functionDelegateCall( - abi.encodeWithSelector(CONFIG_ENGINE.updateAssetEMode.selector, assetEModes) + abi.encodeWithSelector(CONFIG_ENGINE.updateAssetsEMode.selector, assetsEModes) ); } @@ -152,7 +152,7 @@ abstract contract AaveV3Payload { {} /// @dev to be defined in the child with a list of assets for which eMode collateral to update - function assetEModeUpdates() public view virtual returns (IEngine.AssetEModeUpdate[] memory) {} + function assetsEModeUpdates() public view virtual returns (IEngine.AssetEModeUpdate[] memory) {} /// @dev to be defined in the child with a list of set of parameters of rate strategies function rateStrategiesUpdates() diff --git a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol index cf745de6..500d7eb7 100644 --- a/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol +++ b/src/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol @@ -308,7 +308,7 @@ interface IAaveV3ConfigEngine { * @param updates `EModeCollateralUpdate[]` list of declarative updates containing the new parameters * More information on the documentation of the struct. */ - function updateAssetEMode(AssetEModeUpdate[] memory updates) external; + function updateAssetsEMode(AssetEModeUpdate[] calldata updates) external; function DEFAULT_INTEREST_RATE_STRATEGY() external view returns (address); diff --git a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol index fd9c95e9..df2f72ab 100644 --- a/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol +++ b/src/contracts/extensions/v3-config-engine/libraries/EModeEngine.sol @@ -11,13 +11,13 @@ library EModeEngine { using PercentageMath for uint256; using SafeCast for uint256; - function executeAssetEModeUpdate( + function executeAssetsEModeUpdate( IEngine.EngineConstants calldata engineConstants, IEngine.AssetEModeUpdate[] memory updates ) external { require(updates.length != 0, 'AT_LEAST_ONE_UPDATE_REQUIRED'); - _configAssetEMode(engineConstants.poolConfigurator, updates); + _configAssetsEMode(engineConstants.poolConfigurator, updates); } function executeEModeCategoriesUpdate( @@ -29,7 +29,7 @@ library EModeEngine { _configEModeCategories(engineConstants.poolConfigurator, engineConstants.pool, updates); } - function _configAssetEMode( + function _configAssetsEMode( IPoolConfigurator poolConfigurator, IEngine.AssetEModeUpdate[] memory updates ) internal { diff --git a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol index 9a36644e..96220fc0 100644 --- a/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol +++ b/tests/extensions/v3-config-engine/mocks/AaveV3MockAssetEModeUpdate.sol @@ -21,7 +21,7 @@ contract AaveV3MockAssetEModeUpdate is AaveV3Payload { ASSET_2_ADDRESS = asset2Address; } - function assetEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { + function assetsEModeUpdates() public view override returns (IEngine.AssetEModeUpdate[] memory) { IEngine.AssetEModeUpdate[] memory eModeUpdate = new IEngine.AssetEModeUpdate[](2); eModeUpdate[0] = IEngine.AssetEModeUpdate({ From 2d4f5a4b4269a281cadb3486df8166df71b09da6 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 22 Sep 2024 23:02:25 +0200 Subject: [PATCH 84/88] chore: bump revisions (#27) --- src/contracts/instances/PoolConfiguratorInstance.sol | 2 +- src/contracts/instances/PoolInstance.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/instances/PoolConfiguratorInstance.sol b/src/contracts/instances/PoolConfiguratorInstance.sol index fefcc236..7f7294fe 100644 --- a/src/contracts/instances/PoolConfiguratorInstance.sol +++ b/src/contracts/instances/PoolConfiguratorInstance.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import {PoolConfigurator, IPoolAddressesProvider, IPool, VersionedInitializable} from '../protocol/pool/PoolConfigurator.sol'; contract PoolConfiguratorInstance is PoolConfigurator { - uint256 public constant CONFIGURATOR_REVISION = 3; + uint256 public constant CONFIGURATOR_REVISION = 4; /// @inheritdoc VersionedInitializable function getRevision() internal pure virtual override returns (uint256) { diff --git a/src/contracts/instances/PoolInstance.sol b/src/contracts/instances/PoolInstance.sol index 5c0146ca..b032e63e 100644 --- a/src/contracts/instances/PoolInstance.sol +++ b/src/contracts/instances/PoolInstance.sol @@ -6,7 +6,7 @@ import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; import {Errors} from '../protocol/libraries/helpers/Errors.sol'; contract PoolInstance is Pool { - uint256 public constant POOL_REVISION = 4; + uint256 public constant POOL_REVISION = 5; constructor(IPoolAddressesProvider provider) Pool(provider) {} From ea32100e3222361085b3328c10f081a7bdc87d60 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 23 Sep 2024 10:34:03 +0200 Subject: [PATCH 85/88] feat: improve snapshots (#28) --- tests/utils/ProtocolV3TestBase.sol | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 122c7c23..407ab8dc 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -166,8 +166,16 @@ contract ProtocolV3TestBase is DiffUtils { vm.serializeUint(key, 'eModeCategory', i); vm.serializeString(key, 'label', pool.getEModeCategoryLabel(i)); vm.serializeUint(key, 'ltv', cfg.ltv); - vm.serializeUint(key, 'collateralBitmap', pool.getEModeCategoryCollateralBitmap(i)); - vm.serializeUint(key, 'borrowableBitmap', pool.getEModeCategoryBorrowableBitmap(i)); + vm.serializeString( + key, + 'collateralBitmap', + vm.toString(pool.getEModeCategoryCollateralBitmap(i)) + ); + vm.serializeString( + key, + 'borrowableBitmap', + vm.toString(pool.getEModeCategoryBorrowableBitmap(i)) + ); vm.serializeUint(key, 'liquidationThreshold', cfg.liquidationThreshold); string memory object = vm.serializeUint(key, 'liquidationBonus', cfg.liquidationBonus); content = vm.serializeString(eModesKey, key, object); @@ -248,6 +256,7 @@ contract ProtocolV3TestBase is DiffUtils { string memory key = vm.toString(config.underlying); vm.serializeJson(key, '{}'); vm.serializeString(key, 'symbol', config.symbol); + vm.serializeUint(key, 'id', i); vm.serializeUint(key, 'ltv', config.ltv); vm.serializeUint(key, 'liquidationThreshold', config.liquidationThreshold); vm.serializeUint(key, 'liquidationBonus', config.liquidationBonus); @@ -313,13 +322,17 @@ contract ProtocolV3TestBase is DiffUtils { } vm.serializeBool(key, 'virtualAccountingActive', config.virtualAccActive); - vm.serializeUint(key, 'virtualBalance', config.virtualBalance); - vm.serializeUint(key, 'aTokenUnderlyingBalance', config.aTokenUnderlyingBalance); + vm.serializeString(key, 'virtualBalance', vm.toString(config.virtualBalance)); + vm.serializeString( + key, + 'aTokenUnderlyingBalance', + vm.toString(config.aTokenUnderlyingBalance) + ); - string memory out = vm.serializeUint( + string memory out = vm.serializeString( key, 'oracleLatestAnswer', - uint256(oracle.getAssetPrice(config.underlying)) + vm.toString(uint256(oracle.getAssetPrice(config.underlying))) ); content = vm.serializeString(reservesKey, key, out); } From e8d17a5182443093b07d137e685ab3780c647124 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 23 Sep 2024 12:56:06 +0200 Subject: [PATCH 86/88] fix: upgrade aave-cli --- package.json | 2 +- tests/utils/DiffUtils.sol | 2 +- yarn.lock | 1048 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1050 insertions(+), 2 deletions(-) create mode 100644 yarn.lock diff --git a/package.json b/package.json index e2047c8f..7404519d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "prettier-plugin-solidity": "^1.1.1" }, "dependencies": { - "@bgd-labs/aave-cli": "^0.16.4", + "@bgd-labs/aave-cli": "^1.0.0", "catapulta-verify": "^1.1.1" } } diff --git a/tests/utils/DiffUtils.sol b/tests/utils/DiffUtils.sol index 23008fb5..c4fef55d 100644 --- a/tests/utils/DiffUtils.sol +++ b/tests/utils/DiffUtils.sol @@ -22,7 +22,7 @@ contract DiffUtils is Test { string[] memory inputs = new string[](7); inputs[0] = 'npx'; - inputs[1] = '@bgd-labs/aave-cli@^0.16.4'; + inputs[1] = '@bgd-labs/aave-cli@^1.0.0'; inputs[2] = 'diff-snapshots'; inputs[3] = beforePath; inputs[4] = afterPath; diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..ef5133db --- /dev/null +++ b/yarn.lock @@ -0,0 +1,1048 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + +"@assemblyscript/loader@^0.9.4": + version "0.9.4" + resolved "https://registry.yarnpkg.com/@assemblyscript/loader/-/loader-0.9.4.tgz#a483c54c1253656bb33babd464e3154a173e1577" + integrity sha512-HazVq9zwTVwGmqdwYzu7WyQ6FQVZ7SwET0KKQuKm55jD0IfUpZgN0OPIiZG3zV1iSrVYcN0bdwLRXI/VNCYsUA== + +"@bgd-labs/aave-address-book@^3.0.0": + version "3.4.0" + resolved "https://registry.yarnpkg.com/@bgd-labs/aave-address-book/-/aave-address-book-3.4.0.tgz#e139ffbb01eea7b51ea5b162e45a9b28e41d74bc" + integrity sha512-0msSmy6tF///f062FheaafONO2niOeWvD0nychrxMVXojcX+obM7g8Ad0+JjSfxmKoGxAYKGER7zF7WbBEz6nw== + +"@bgd-labs/aave-cli@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@bgd-labs/aave-cli/-/aave-cli-1.0.0.tgz#023cd576a73c229476afb984ba69a3179f80a5d7" + integrity sha512-Xs30iS10iagkLjRgQ1zPlZmJD9SkQMZsrimgzLUTlHan0uAiK45wYwvsX4XTFtvlQ+BCqzbzw/vZb8jMWE2kbw== + dependencies: + "@bgd-labs/aave-address-book" "^3.0.0" + "@bgd-labs/aave-v3-governance-cache" "^1.0.6" + "@bgd-labs/js-utils" "^1.4.2" + "@commander-js/extra-typings" "^11.1.0" + "@inquirer/prompts" "^3.3.2" + chalk "^4.1.2" + commander "^11.1.0" + deepmerge "^4.3.1" + dotenv "^16.4.1" + find-object-paths "^1.1.0" + gray-matter "^4.0.3" + ipfs-unixfs-importer "^15.3.1" + json-bigint "^1.0.0" + object-hash "^3.0.0" + viem "^2.17.11" + zod "^3.23.8" + +"@bgd-labs/aave-v3-governance-cache@^1.0.6": + version "1.0.7" + resolved "https://registry.yarnpkg.com/@bgd-labs/aave-v3-governance-cache/-/aave-v3-governance-cache-1.0.7.tgz#14c7cf32e8d9502c3e8ccf28a980ba662a80ad84" + integrity sha512-0viMU8RdJJZ9+pp+YY5LbQJBekgTzxU45+mFLZt6pwqqzhoX3UzBQtq8RmpOQMyoSq+d+axPBQV1K2Hx6gOybg== + +"@bgd-labs/js-utils@^1.4.2": + version "1.4.2" + resolved "https://registry.yarnpkg.com/@bgd-labs/js-utils/-/js-utils-1.4.2.tgz#dd6d954fdda153d76cbcabaeff9b7e8adcf528b1" + integrity sha512-hKiorNIyEApdH1w7laYQ+sGkrCGZTem9kD5Ud7YP/ZKtkoPx12FcTAp+P+JZ42BerPEqzGLZMDRJDB2ZGKeAJw== + dependencies: + "@supercharge/promise-pool" "^3.1.1" + bs58 "^5.0.0" + gray-matter "^4.0.3" + tsx "^4.7.1" + +"@commander-js/extra-typings@^11.1.0": + version "11.1.0" + resolved "https://registry.yarnpkg.com/@commander-js/extra-typings/-/extra-typings-11.1.0.tgz#dd19fcb8cc6e33ede237fc1b7af96c70833d8f93" + integrity sha512-GuvZ38d23H+7Tz2C9DhzCepivsOsky03s5NI+KCy7ke1FNUvsJ2oO47scQ9YaGGhgjgNW5OYYNSADmbjcSoIhw== + +"@esbuild/aix-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz#51299374de171dbd80bb7d838e1cfce9af36f353" + integrity sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ== + +"@esbuild/android-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz#58565291a1fe548638adb9c584237449e5e14018" + integrity sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw== + +"@esbuild/android-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.23.1.tgz#5eb8c652d4c82a2421e3395b808e6d9c42c862ee" + integrity sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ== + +"@esbuild/android-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.23.1.tgz#ae19d665d2f06f0f48a6ac9a224b3f672e65d517" + integrity sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg== + +"@esbuild/darwin-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz#05b17f91a87e557b468a9c75e9d85ab10c121b16" + integrity sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q== + +"@esbuild/darwin-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz#c58353b982f4e04f0d022284b8ba2733f5ff0931" + integrity sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw== + +"@esbuild/freebsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz#f9220dc65f80f03635e1ef96cfad5da1f446f3bc" + integrity sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA== + +"@esbuild/freebsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz#69bd8511fa013b59f0226d1609ac43f7ce489730" + integrity sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g== + +"@esbuild/linux-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz#8050af6d51ddb388c75653ef9871f5ccd8f12383" + integrity sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g== + +"@esbuild/linux-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz#ecaabd1c23b701070484990db9a82f382f99e771" + integrity sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ== + +"@esbuild/linux-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz#3ed2273214178109741c09bd0687098a0243b333" + integrity sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ== + +"@esbuild/linux-loong64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz#a0fdf440b5485c81b0fbb316b08933d217f5d3ac" + integrity sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw== + +"@esbuild/linux-mips64el@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz#e11a2806346db8375b18f5e104c5a9d4e81807f6" + integrity sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q== + +"@esbuild/linux-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz#06a2744c5eaf562b1a90937855b4d6cf7c75ec96" + integrity sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw== + +"@esbuild/linux-riscv64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz#65b46a2892fc0d1af4ba342af3fe0fa4a8fe08e7" + integrity sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA== + +"@esbuild/linux-s390x@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz#e71ea18c70c3f604e241d16e4e5ab193a9785d6f" + integrity sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw== + +"@esbuild/linux-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz#d47f97391e80690d4dfe811a2e7d6927ad9eed24" + integrity sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ== + +"@esbuild/netbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz#44e743c9778d57a8ace4b72f3c6b839a3b74a653" + integrity sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA== + +"@esbuild/openbsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz#05c5a1faf67b9881834758c69f3e51b7dee015d7" + integrity sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q== + +"@esbuild/openbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz#2e58ae511bacf67d19f9f2dcd9e8c5a93f00c273" + integrity sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA== + +"@esbuild/sunos-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz#adb022b959d18d3389ac70769cef5a03d3abd403" + integrity sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA== + +"@esbuild/win32-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz#84906f50c212b72ec360f48461d43202f4c8b9a2" + integrity sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A== + +"@esbuild/win32-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz#5e3eacc515820ff729e90d0cb463183128e82fac" + integrity sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ== + +"@esbuild/win32-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz#81fd50d11e2c32b2d6241470e3185b70c7b30699" + integrity sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg== + +"@inquirer/checkbox@^1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@inquirer/checkbox/-/checkbox-1.5.2.tgz#043ca370ebbc0b92691c2309bc12e8716ed701c4" + integrity sha512-CifrkgQjDkUkWexmgYYNyB5603HhTHI91vLFeQXh6qrTKiCMVASol01Rs1cv6LP/A2WccZSRlJKZhbaBIs/9ZA== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + ansi-escapes "^4.3.2" + chalk "^4.1.2" + figures "^3.2.0" + +"@inquirer/confirm@^2.0.17": + version "2.0.17" + resolved "https://registry.yarnpkg.com/@inquirer/confirm/-/confirm-2.0.17.tgz#a45eb1b973c51c993a3c093a0114e960b1cf09a4" + integrity sha512-EqzhGryzmGpy2aJf6LxJVhndxYmFs+m8cxXzf8nejb1DE3sabf6mUgBcp4J0jAUEiAcYzqmkqRr7LPFh/WdnXA== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + chalk "^4.1.2" + +"@inquirer/core@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-6.0.0.tgz#d44ccd8ae09a4879a78f09cca35bf1ab894b95f4" + integrity sha512-fKi63Khkisgda3ohnskNf5uZJj+zXOaBvOllHsOkdsXRA/ubQLJQrZchFFi57NKbZzkTunXiBMdvWOv71alonw== + dependencies: + "@inquirer/type" "^1.1.6" + "@types/mute-stream" "^0.0.4" + "@types/node" "^20.10.7" + "@types/wrap-ansi" "^3.0.0" + ansi-escapes "^4.3.2" + chalk "^4.1.2" + cli-spinners "^2.9.2" + cli-width "^4.1.0" + figures "^3.2.0" + mute-stream "^1.0.0" + run-async "^3.0.0" + signal-exit "^4.1.0" + strip-ansi "^6.0.1" + wrap-ansi "^6.2.0" + +"@inquirer/editor@^1.2.15": + version "1.2.15" + resolved "https://registry.yarnpkg.com/@inquirer/editor/-/editor-1.2.15.tgz#28de2dabbcf1e07a37149320093798e3f4856f91" + integrity sha512-gQ77Ls09x5vKLVNMH9q/7xvYPT6sIs5f7URksw+a2iJZ0j48tVS6crLqm2ugG33tgXHIwiEqkytY60Zyh5GkJQ== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + chalk "^4.1.2" + external-editor "^3.1.0" + +"@inquirer/expand@^1.1.16": + version "1.1.16" + resolved "https://registry.yarnpkg.com/@inquirer/expand/-/expand-1.1.16.tgz#63dce81240e5f7b2b1d7942b3e3cae18f4f03d07" + integrity sha512-TGLU9egcuo+s7PxphKUCnJnpCIVY32/EwPCLLuu+gTvYiD8hZgx8Z2niNQD36sa6xcfpdLY6xXDBiL/+g1r2XQ== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + chalk "^4.1.2" + figures "^3.2.0" + +"@inquirer/input@^1.2.16": + version "1.2.16" + resolved "https://registry.yarnpkg.com/@inquirer/input/-/input-1.2.16.tgz#94d8765a47689e799fd55ed0361dedc8f554341b" + integrity sha512-Ou0LaSWvj1ni+egnyQ+NBtfM1885UwhRCMtsRt2bBO47DoC1dwtCa+ZUNgrxlnCHHF0IXsbQHYtIIjFGAavI4g== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + chalk "^4.1.2" + +"@inquirer/password@^1.1.16": + version "1.1.16" + resolved "https://registry.yarnpkg.com/@inquirer/password/-/password-1.1.16.tgz#37ddebbe37c6e76f8ad27d1f726aacdd7c423558" + integrity sha512-aZYZVHLUXZ2gbBot+i+zOJrks1WaiI95lvZCn1sKfcw6MtSSlYC8uDX8sTzQvAsQ8epHoP84UNvAIT0KVGOGqw== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + ansi-escapes "^4.3.2" + chalk "^4.1.2" + +"@inquirer/prompts@^3.3.2": + version "3.3.2" + resolved "https://registry.yarnpkg.com/@inquirer/prompts/-/prompts-3.3.2.tgz#0c3a44bbf7e560439590f2fcb769cd8392b0f555" + integrity sha512-k52mOMRvTUejrqyF1h8Z07chC+sbaoaUYzzr1KrJXyj7yaX7Nrh0a9vktv8TuocRwIJOQMaj5oZEmkspEcJFYQ== + dependencies: + "@inquirer/checkbox" "^1.5.2" + "@inquirer/confirm" "^2.0.17" + "@inquirer/core" "^6.0.0" + "@inquirer/editor" "^1.2.15" + "@inquirer/expand" "^1.1.16" + "@inquirer/input" "^1.2.16" + "@inquirer/password" "^1.1.16" + "@inquirer/rawlist" "^1.2.16" + "@inquirer/select" "^1.3.3" + +"@inquirer/rawlist@^1.2.16": + version "1.2.16" + resolved "https://registry.yarnpkg.com/@inquirer/rawlist/-/rawlist-1.2.16.tgz#ac6cc0bb2a60d51dccdfe2c3ea624185f1fbd5bc" + integrity sha512-pZ6TRg2qMwZAOZAV6TvghCtkr53dGnK29GMNQ3vMZXSNguvGqtOVc4j/h1T8kqGJFagjyfBZhUPGwNS55O5qPQ== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + chalk "^4.1.2" + +"@inquirer/select@^1.3.3": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@inquirer/select/-/select-1.3.3.tgz#7d832ee603c15b706148e47cda29cdf6634cd94b" + integrity sha512-RzlRISXWqIKEf83FDC9ZtJ3JvuK1l7aGpretf41BCWYrvla2wU8W8MTRNMiPrPJ+1SIqrRC1nZdZ60hD9hRXLg== + dependencies: + "@inquirer/core" "^6.0.0" + "@inquirer/type" "^1.1.6" + ansi-escapes "^4.3.2" + chalk "^4.1.2" + figures "^3.2.0" + +"@inquirer/type@^1.1.6": + version "1.5.5" + resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-1.5.5.tgz#303ea04ce7ad2e585b921b662b3be36ef7b4f09b" + integrity sha512-MzICLu4yS7V8AA61sANROZ9vT1H3ooca5dSmI1FjZkzq7o/koMsRfQSzRtFo+F3Ao4Sf1C0bpLKejpKB/+j6MA== + dependencies: + mute-stream "^1.0.0" + +"@ipld/dag-pb@^4.1.2": + version "4.1.2" + resolved "https://registry.yarnpkg.com/@ipld/dag-pb/-/dag-pb-4.1.2.tgz#39db25311aeb2745ec20bfc745d91a577832b6ac" + integrity sha512-BSztO4l3C+ya9HjCaQot26Y4AVsqIKtnn6+23ubc1usucnf6yoTBme18oCCdM6gKBMxuPqju5ye3lh9WEJsdeQ== + dependencies: + multiformats "^13.1.0" + +"@multiformats/murmur3@^2.1.8": + version "2.1.8" + resolved "https://registry.yarnpkg.com/@multiformats/murmur3/-/murmur3-2.1.8.tgz#81c1c15b6391109f3febfca4b3205196615a04e9" + integrity sha512-6vId1C46ra3R1sbJUOFCZnsUIveR9oF20yhPmAFxPm0JfrX3/ZRCgP3YDrBzlGoEppOXnA9czHeYc0T9mB6hbA== + dependencies: + multiformats "^13.0.0" + murmurhash3js-revisited "^3.0.0" + +"@noble/curves@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6" + integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg== + dependencies: + "@noble/hashes" "1.4.0" + +"@noble/curves@^1.4.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b" + integrity sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ== + dependencies: + "@noble/hashes" "1.5.0" + +"@noble/curves@~1.4.0": + version "1.4.2" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9" + integrity sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw== + dependencies: + "@noble/hashes" "1.4.0" + +"@noble/hashes@1.4.0", "@noble/hashes@~1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" + integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== + +"@noble/hashes@1.5.0", "@noble/hashes@^1.4.0", "@noble/hashes@~1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0" + integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA== + +"@scure/base@~1.1.6", "@scure/base@~1.1.8": + version "1.1.9" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.9.tgz#e5e142fbbfe251091f9c5f1dd4c834ac04c3dbd1" + integrity sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg== + +"@scure/bip32@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.4.0.tgz#4e1f1e196abedcef395b33b9674a042524e20d67" + integrity sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg== + dependencies: + "@noble/curves" "~1.4.0" + "@noble/hashes" "~1.4.0" + "@scure/base" "~1.1.6" + +"@scure/bip39@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.4.0.tgz#664d4f851564e2e1d4bffa0339f9546ea55960a6" + integrity sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw== + dependencies: + "@noble/hashes" "~1.5.0" + "@scure/base" "~1.1.8" + +"@solidity-parser/parser@^0.18.0": + version "0.18.0" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.18.0.tgz#8e77a02a09ecce957255a2f48c9a7178ec191908" + integrity sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA== + +"@supercharge/promise-pool@^3.1.1": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-3.2.0.tgz#a6ab4afdf798e453a6bb51c4ae340852e1266af8" + integrity sha512-pj0cAALblTZBPtMltWOlZTQSLT07jIaFNeM8TWoJD1cQMgDB9mcMlVMoetiB35OzNJpqQ2b+QEtwiR9f20mADg== + +"@types/mute-stream@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@types/mute-stream/-/mute-stream-0.0.4.tgz#77208e56a08767af6c5e1237be8888e2f255c478" + integrity sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow== + dependencies: + "@types/node" "*" + +"@types/node@*": + version "22.5.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44" + integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA== + dependencies: + undici-types "~6.19.2" + +"@types/node@^20.10.7": + version "20.16.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.16.5.tgz#d43c7f973b32ffdf9aa7bd4f80e1072310fd7a53" + integrity sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA== + dependencies: + undici-types "~6.19.2" + +"@types/wrap-ansi@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz#18b97a972f94f60a679fd5c796d96421b9abb9fd" + integrity sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g== + +abitype@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.5.tgz#29d0daa3eea867ca90f7e4123144c1d1270774b6" + integrity sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw== + +ansi-escapes@^4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +base-x@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a" + integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw== + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bignumber.js@^9.0.0: + version "9.1.2" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" + integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug== + +bl@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-5.1.0.tgz#183715f678c7188ecef9fe475d90209400624273" + integrity sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ== + dependencies: + buffer "^6.0.3" + inherits "^2.0.4" + readable-stream "^3.4.0" + +bs58@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" + integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== + dependencies: + base-x "^4.0.0" + +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +catapulta-verify@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/catapulta-verify/-/catapulta-verify-1.1.1.tgz#46ac6c9ed50480ef982060147f4ff4a34609efd0" + integrity sha512-VZ9pQpno1bjjZ/+7d1AbPWkOhYcZdNSova5Y1L9jj8ftdimv3JrwDTg9i0fs4I8/A/sRXK7AUb1pmL3016Cykw== + +chalk@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== + +cli-spinners@^2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" + integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== + +cli-width@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-4.1.0.tgz#42daac41d3c254ef38ad8ac037672130173691c5" + integrity sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ== + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +commander@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906" + integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ== + +debug@^4.3.1: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + +deepmerge@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" + integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== + +dotenv@^16.4.1: + version "16.4.5" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" + integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +esbuild@~0.23.0: + version "0.23.1" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.23.1.tgz#40fdc3f9265ec0beae6f59824ade1bd3d3d2dab8" + integrity sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg== + optionalDependencies: + "@esbuild/aix-ppc64" "0.23.1" + "@esbuild/android-arm" "0.23.1" + "@esbuild/android-arm64" "0.23.1" + "@esbuild/android-x64" "0.23.1" + "@esbuild/darwin-arm64" "0.23.1" + "@esbuild/darwin-x64" "0.23.1" + "@esbuild/freebsd-arm64" "0.23.1" + "@esbuild/freebsd-x64" "0.23.1" + "@esbuild/linux-arm" "0.23.1" + "@esbuild/linux-arm64" "0.23.1" + "@esbuild/linux-ia32" "0.23.1" + "@esbuild/linux-loong64" "0.23.1" + "@esbuild/linux-mips64el" "0.23.1" + "@esbuild/linux-ppc64" "0.23.1" + "@esbuild/linux-riscv64" "0.23.1" + "@esbuild/linux-s390x" "0.23.1" + "@esbuild/linux-x64" "0.23.1" + "@esbuild/netbsd-x64" "0.23.1" + "@esbuild/openbsd-arm64" "0.23.1" + "@esbuild/openbsd-x64" "0.23.1" + "@esbuild/sunos-x64" "0.23.1" + "@esbuild/win32-arm64" "0.23.1" + "@esbuild/win32-ia32" "0.23.1" + "@esbuild/win32-x64" "0.23.1" + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + +external-editor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" + integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== + dependencies: + chardet "^0.7.0" + iconv-lite "^0.4.24" + tmp "^0.0.33" + +figures@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" + integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== + dependencies: + escape-string-regexp "^1.0.5" + +find-object-paths@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/find-object-paths/-/find-object-paths-1.1.0.tgz#2d2fe99f24c95e63af4b51377a1ba0510490376c" + integrity sha512-UJvfPQibLUOrXl76PJ49cYbXJPsU1lYX6Pw7mHVW+ahaGx6kVHiozNIQriDc/EOlSvkDa6L9GyTFXPYQsa6sGA== + +fsevents@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +get-tsconfig@^4.7.5: + version "4.8.1" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.8.1.tgz#8995eb391ae6e1638d251118c7b56de7eb425471" + integrity sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg== + dependencies: + resolve-pkg-maps "^1.0.0" + +gray-matter@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.3.tgz#e893c064825de73ea1f5f7d88c7a9f7274288798" + integrity sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q== + dependencies: + js-yaml "^3.13.1" + kind-of "^6.0.2" + section-matter "^1.0.0" + strip-bom-string "^1.0.0" + +hamt-sharding@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/hamt-sharding/-/hamt-sharding-3.0.6.tgz#3643107a3021af66ac95684aec87b196add5ba57" + integrity sha512-nZeamxfymIWLpVcAN0CRrb7uVq3hCOGj9IcL6NMA6VVCVWqj+h9Jo/SmaWuS92AEDf1thmHsM5D5c70hM3j2Tg== + dependencies: + sparse-array "^1.3.1" + uint8arrays "^5.0.1" + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +inherits@^2.0.3, inherits@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +interface-blockstore@^5.3.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/interface-blockstore/-/interface-blockstore-5.3.1.tgz#03f511431be2b8b04a536eaae8effe4565ea6536" + integrity sha512-nhgrQnz6yUQEqxTFLhlOBurQOy5lWlwCpgFmZ3GTObTVTQS9RZjK/JTozY6ty9uz2lZs7VFJSqwjWAltorJ4Vw== + dependencies: + interface-store "^6.0.0" + multiformats "^13.2.3" + +interface-store@^6.0.0: + version "6.0.2" + resolved "https://registry.yarnpkg.com/interface-store/-/interface-store-6.0.2.tgz#1746a1ee07634f7678b3aa778738b79e3f75c909" + integrity sha512-KSFCXtBlNoG0hzwNa0RmhHtrdhzexp+S+UY2s0rWTBJyfdEIgn6i6Zl9otVqrcFYbYrneBT7hbmHQ8gE0C3umA== + +ipfs-unixfs-importer@^15.3.1: + version "15.3.1" + resolved "https://registry.yarnpkg.com/ipfs-unixfs-importer/-/ipfs-unixfs-importer-15.3.1.tgz#93cf3bad77e3fff7ee25b4ba822c1a0d2fd56b6e" + integrity sha512-wHCTBqNsZXLJZ9/GSr7Msb3FDXD5yXF20Y9sKyUbbqNjbvaXs3n3h1+NM/5+WrgESHfwRcJIlJtaOKafL8Ymdg== + dependencies: + "@ipld/dag-pb" "^4.1.2" + "@multiformats/murmur3" "^2.1.8" + hamt-sharding "^3.0.6" + interface-blockstore "^5.3.0" + interface-store "^6.0.0" + ipfs-unixfs "^11.0.0" + it-all "^3.0.6" + it-batch "^3.0.6" + it-first "^3.0.6" + it-parallel-batch "^3.0.6" + multiformats "^13.2.3" + progress-events "^1.0.1" + rabin-wasm "^0.1.5" + uint8arraylist "^2.4.8" + uint8arrays "^5.1.0" + +ipfs-unixfs@^11.0.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/ipfs-unixfs/-/ipfs-unixfs-11.2.0.tgz#a7f3d1f9bce29033f273bda124a0eb8bc0c752f6" + integrity sha512-J8FN1qM5nfrDo8sQKQwfj0+brTg1uBfZK2vY9hxci33lcl3BFrsELS9+1+4q/8tO1ASKfxZO8W3Pi2O4sVX2Lg== + dependencies: + protons-runtime "^5.5.0" + uint8arraylist "^2.4.8" + +is-extendable@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +isows@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061" + integrity sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ== + +it-all@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/it-all/-/it-all-3.0.6.tgz#30a4f922ae9ca0945b0f720d3478ae6f5b6707ab" + integrity sha512-HXZWbxCgQZJfrv5rXvaVeaayXED8nTKx9tj9fpBhmcUJcedVZshMMMqTj0RG2+scGypb9Ut1zd1ifbf3lA8L+Q== + +it-batch@^3.0.0, it-batch@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/it-batch/-/it-batch-3.0.6.tgz#0bcda35bf1c600e821c6d5f4d2446fe85a26ab1d" + integrity sha512-pQAAlSvJ4aV6xM/6LRvkPdKSKXxS4my2fGzNUxJyAQ8ccFdxPmK1bUuF5OoeUDkcdrbs8jtsmc4DypCMrGY6sg== + +it-first@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/it-first/-/it-first-3.0.6.tgz#f532f0f36fe9bf0c291e0162b9d3375d59fe8f05" + integrity sha512-ExIewyK9kXKNAplg2GMeWfgjUcfC1FnUXz/RPfAvIXby+w7U4b3//5Lic0NV03gXT8O/isj5Nmp6KiY0d45pIQ== + +it-parallel-batch@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/it-parallel-batch/-/it-parallel-batch-3.0.6.tgz#61487fdaca03cc34c648b3432f59e82e0c805172" + integrity sha512-3wgiQGvMMHy65OXScrtrtmY+bJSF7P6St1AP+BU+SK83fEr8NNk/MrmJKrtB1+MahYX2a8I+pOGKDj8qVtuV0Q== + dependencies: + it-batch "^3.0.0" + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +json-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" + integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== + dependencies: + bignumber.js "^9.0.0" + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +minimist@^1.2.5: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multiformats@^13.0.0, multiformats@^13.1.0, multiformats@^13.2.3: + version "13.3.0" + resolved "https://registry.yarnpkg.com/multiformats/-/multiformats-13.3.0.tgz#1f5188bc7c4fe08ff829ae1c18dc33409042fb71" + integrity sha512-CBiqvsufgmpo01VT5ze94O+uc+Pbf6f/sThlvWss0sBZmAOu6GQn5usrYV2sf2mr17FWYc0rO8c/CNe2T90QAA== + +murmurhash3js-revisited@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz#6bd36e25de8f73394222adc6e41fa3fac08a5869" + integrity sha512-/sF3ee6zvScXMb1XFJ8gDsSnY+X8PbOyjIuBhtgis10W2Jx4ZjIhikUCIF9c4gpJxVnQIsPAFrSwTCuAjicP6g== + +mute-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-1.0.0.tgz#e31bd9fe62f0aed23520aa4324ea6671531e013e" + integrity sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA== + +node-fetch@^2.6.1: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +object-hash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9" + integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + +prettier-plugin-solidity@^1.1.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.4.1.tgz#8060baf18853a9e34d2e09e47e87b4f19e15afe9" + integrity sha512-Mq8EtfacVZ/0+uDKTtHZGW3Aa7vEbX/BNx63hmVg6YTiTXSiuKP0amj0G6pGwjmLaOfymWh3QgXEZkjQbU8QRg== + dependencies: + "@solidity-parser/parser" "^0.18.0" + semver "^7.5.4" + +prettier@^2.8.3: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== + +progress-events@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/progress-events/-/progress-events-1.0.1.tgz#693b6d4153f08c1418ae3cd5fcad8596c91db7e8" + integrity sha512-MOzLIwhpt64KIVN64h1MwdKWiyKFNc/S6BoYKPIVUHFg0/eIEyBulhWCgn678v/4c0ri3FdGuzXymNCv02MUIw== + +protons-runtime@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-5.5.0.tgz#ea06d9ef843aad77ea5de3e1ebafa81b58c24570" + integrity sha512-EsALjF9QsrEk6gbCx3lmfHxVN0ah7nG3cY7GySD4xf4g8cr7g543zB88Foh897Sr1RQJ9yDCUsoT1i1H/cVUFA== + dependencies: + uint8-varint "^2.0.2" + uint8arraylist "^2.4.3" + uint8arrays "^5.0.1" + +rabin-wasm@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/rabin-wasm/-/rabin-wasm-0.1.5.tgz#5b625ca007d6a2cbc1456c78ae71d550addbc9c9" + integrity sha512-uWgQTo7pim1Rnj5TuWcCewRDTf0PEFTSlaUjWP4eY9EbLV9em08v89oCz/WO+wRxpYuO36XEHp4wgYQnAgOHzA== + dependencies: + "@assemblyscript/loader" "^0.9.4" + bl "^5.0.0" + debug "^4.3.1" + minimist "^1.2.5" + node-fetch "^2.6.1" + readable-stream "^3.6.0" + +readable-stream@^3.4.0, readable-stream@^3.6.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +resolve-pkg-maps@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f" + integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw== + +run-async@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-3.0.0.tgz#42a432f6d76c689522058984384df28be379daad" + integrity sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q== + +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +"safer-buffer@>= 2.1.2 < 3": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +section-matter@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/section-matter/-/section-matter-1.0.0.tgz#e9041953506780ec01d59f292a19c7b850b84167" + integrity sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA== + dependencies: + extend-shallow "^2.0.1" + kind-of "^6.0.0" + +semver@^7.5.4: + version "7.6.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== + +signal-exit@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + +sparse-array@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/sparse-array/-/sparse-array-1.3.2.tgz#0e1a8b71706d356bc916fe754ff496d450ec20b0" + integrity sha512-ZT711fePGn3+kQyLuv1fpd3rNSkNF8vd5Kv2D+qnOANeyKs3fx6bUMGWRPvgTTcYV64QMqZKZwcuaQSP3AZ0tg== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +string-width@^4.1.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom-string/-/strip-bom-string-1.0.0.tgz#e5211e9224369fbb81d633a2f00044dc8cedad92" + integrity sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g== + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +tsx@^4.7.1: + version "4.19.1" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.19.1.tgz#b7bffdf4b565813e4dea14b90872af279cd0090b" + integrity sha512-0flMz1lh74BR4wOvBjuh9olbnwqCPc35OOlfyzHba0Dc+QNUeWX/Gq2YTbnwcWPO3BMd8fkzRVrHcsR+a7z7rA== + dependencies: + esbuild "~0.23.0" + get-tsconfig "^4.7.5" + optionalDependencies: + fsevents "~2.3.3" + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +uint8-varint@^2.0.2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/uint8-varint/-/uint8-varint-2.0.4.tgz#85be52b3849eb30f2c3640a2df8a14364180affb" + integrity sha512-FwpTa7ZGA/f/EssWAb5/YV6pHgVF1fViKdW8cWaEarjB8t7NyofSWBdOTyFPaGuUG4gx3v1O3PQ8etsiOs3lcw== + dependencies: + uint8arraylist "^2.0.0" + uint8arrays "^5.0.0" + +uint8arraylist@^2.0.0, uint8arraylist@^2.4.3, uint8arraylist@^2.4.8: + version "2.4.8" + resolved "https://registry.yarnpkg.com/uint8arraylist/-/uint8arraylist-2.4.8.tgz#5a4d17f4defd77799cb38e93fd5db0f0dceddc12" + integrity sha512-vc1PlGOzglLF0eae1M8mLRTBivsvrGsdmJ5RbK3e+QRvRLOZfZhQROTwH/OfyF3+ZVUg9/8hE8bmKP2CvP9quQ== + dependencies: + uint8arrays "^5.0.1" + +uint8arrays@^5.0.0, uint8arrays@^5.0.1, uint8arrays@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-5.1.0.tgz#14047c9bdf825d025b7391299436e5e50e7270f1" + integrity sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww== + dependencies: + multiformats "^13.0.0" + +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== + +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +viem@^2.17.11: + version "2.21.12" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.21.12.tgz#10c668668b62d276e806fc3261145a9285ae663c" + integrity sha512-yPZulbPdoDnuB8Gm2m+Qc9Mjgl6gC1YgNU6zcO+C8XZNYwaCNE6mokPiy30m8o5I1XkfvMc35jMmtT1zCb8yxA== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.4.0" + "@noble/hashes" "1.4.0" + "@scure/bip32" "1.4.0" + "@scure/bip39" "1.4.0" + abitype "1.0.5" + isows "1.0.4" + webauthn-p256 "0.0.5" + ws "8.17.1" + +webauthn-p256@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/webauthn-p256/-/webauthn-p256-0.0.5.tgz#0baebd2ba8a414b21cc09c0d40f9dd0be96a06bd" + integrity sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg== + dependencies: + "@noble/curves" "^1.4.0" + "@noble/hashes" "^1.4.0" + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +wrap-ansi@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" + integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +ws@8.17.1: + version "8.17.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" + integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== + +zod@^3.23.8: + version "3.23.8" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" + integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== From fd4f0334c85d0670a9750cdc2b6e0ce96cbe346a Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 24 Sep 2024 09:36:40 +0200 Subject: [PATCH 87/88] feat: add updated coverage report (#31) --- Makefile | 44 +- foundry.toml | 2 +- report/cmd_line | 2 +- .../protocol/configuration/index-sort-b.html | 169 -- .../protocol/configuration/index-sort-f.html | 169 -- .../protocol/configuration/index-sort-l.html | 169 -- .../protocol/configuration/index.html | 169 -- .../VersionedInitializable.sol.func-c.html | 91 - .../VersionedInitializable.sol.func.html | 91 - .../libraries/helpers/index-sort-b.html | 124 -- .../libraries/helpers/index-sort-f.html | 124 -- .../libraries/helpers/index-sort-l.html | 124 -- .../protocol/libraries/helpers/index.html | 124 -- .../logic/BorrowLogic.sol.func-c.html | 112 -- .../libraries/logic/BorrowLogic.sol.func.html | 112 -- .../logic/EModeLogic.sol.func-c.html | 105 -- .../libraries/logic/EModeLogic.sol.func.html | 105 -- .../contracts/protocol/pool/index-sort-b.html | 169 -- .../contracts/protocol/pool/index-sort-f.html | 169 -- .../contracts/protocol/pool/index-sort-l.html | 169 -- .../core/contracts/protocol/pool/index.html | 169 -- .../StableDebtToken.sol.func-c.html | 217 --- .../StableDebtToken.sol.func.html | 217 --- .../StableDebtToken.sol.gcov.html | 226 --- .../StableDebtTokenInstance.sol.gcov.html | 131 -- report/coverage.svg | 1 - .../AaveParaSwapFeeClaimer.sol.func-c.html | 37 +- .../AaveParaSwapFeeClaimer.sol.func.html | 37 +- .../AaveParaSwapFeeClaimer.sol.gcov.html | 52 +- .../BaseParaSwapAdapter.sol.func-c.html | 37 +- .../BaseParaSwapAdapter.sol.func.html | 37 +- .../BaseParaSwapAdapter.sol.gcov.html | 82 +- .../BaseParaSwapBuyAdapter.sol.func-c.html} | 34 +- .../BaseParaSwapBuyAdapter.sol.func.html} | 34 +- .../BaseParaSwapBuyAdapter.sol.gcov.html | 151 +- .../BaseParaSwapSellAdapter.sol.func-c.html} | 34 +- .../BaseParaSwapSellAdapter.sol.func.html} | 34 +- .../BaseParaSwapSellAdapter.sol.gcov.html | 103 +- ...raSwapLiquiditySwapAdapter.sol.func-c.html | 37 +- ...ParaSwapLiquiditySwapAdapter.sol.func.html | 37 +- ...ParaSwapLiquiditySwapAdapter.sol.gcov.html | 112 +- .../ParaSwapRepayAdapter.sol.func-c.html | 43 +- .../ParaSwapRepayAdapter.sol.func.html | 43 +- .../ParaSwapRepayAdapter.sol.gcov.html | 268 +-- ...araSwapWithdrawSwapAdapter.sol.func-c.html | 39 +- .../ParaSwapWithdrawSwapAdapter.sol.func.html | 39 +- .../ParaSwapWithdrawSwapAdapter.sol.gcov.html | 58 +- .../paraswap-adapters}/index-sort-b.html | 122 +- .../paraswap-adapters}/index-sort-f.html | 126 +- .../paraswap-adapters}/index-sort-l.html | 144 +- .../paraswap-adapters}/index.html | 122 +- .../ERC20AaveLMUpgradeable.sol.func-c.html | 238 +++ .../ERC20AaveLMUpgradeable.sol.func.html | 238 +++ .../ERC20AaveLMUpgradeable.sol.gcov.html | 391 ++++ ...C4626StataTokenUpgradeable.sol.func-c.html | 217 +++ ...ERC4626StataTokenUpgradeable.sol.func.html | 217 +++ ...ERC4626StataTokenUpgradeable.sol.gcov.html | 376 ++++ .../StataTokenFactory.sol.func-c.html | 119 ++ .../StataTokenFactory.sol.func.html | 119 ++ .../StataTokenFactory.sol.gcov.html | 176 ++ .../StataTokenV2.sol.func-c.html | 161 ++ .../static-a-token/StataTokenV2.sol.func.html | 161 ++ .../static-a-token/StataTokenV2.sol.gcov.html | 206 +++ .../static-a-token/index-sort-b.html | 169 ++ .../static-a-token/index-sort-f.html | 169 ++ .../static-a-token/index-sort-l.html | 169 ++ report/extensions/static-a-token/index.html | 169 ++ report/gcov.css | 76 +- .../L2Encoder.sol.func-c.html | 49 +- .../misc => helpers}/L2Encoder.sol.func.html | 53 +- .../misc => helpers}/L2Encoder.sol.gcov.html | 280 ++- .../WrappedTokenGatewayV3.sol.func-c.html | 48 +- .../WrappedTokenGatewayV3.sol.func.html | 48 +- .../WrappedTokenGatewayV3.sol.gcov.html | 419 ++--- report/helpers/index-sort-b.html | 139 ++ report/helpers/index-sort-f.html | 139 ++ report/helpers/index-sort-l.html | 139 ++ report/helpers/index.html | 139 ++ report/index-sort-b.html | 228 +-- report/index-sort-f.html | 230 +-- report/index-sort-l.html | 222 +-- report/index.html | 228 +-- .../instances/ATokenInstance.sol.func-c.html | 37 +- .../instances/ATokenInstance.sol.func.html | 37 +- .../instances/ATokenInstance.sol.gcov.html | 48 +- .../PoolConfiguratorInstance.sol.func-c.html | 26 +- .../PoolConfiguratorInstance.sol.func.html | 26 +- .../PoolConfiguratorInstance.sol.gcov.html | 32 +- .../instances/PoolInstance.sol.func-c.html | 43 +- .../instances/PoolInstance.sol.func.html | 43 +- .../instances/PoolInstance.sol.gcov.html | 51 +- .../VariableDebtTokenInstance.sol.func-c.html | 105 ++ .../VariableDebtTokenInstance.sol.func.html | 105 ++ .../VariableDebtTokenInstance.sol.gcov.html | 52 +- .../src/core => }/instances/index-sort-b.html | 89 +- .../src/core => }/instances/index-sort-f.html | 97 +- .../src/core => }/instances/index-sort-l.html | 91 +- .../src/core => }/instances/index.html | 89 +- .../misc/AaveOracle.sol.func-c.html | 58 +- .../misc/AaveOracle.sol.func.html | 58 +- .../misc/AaveOracle.sol.gcov.html | 112 +- ...erveInterestRateStrategyV2.sol.func-c.html | 85 +- ...eserveInterestRateStrategyV2.sol.func.html | 85 +- ...eserveInterestRateStrategyV2.sol.gcov.html | 454 +++-- .../PriceOracleSentinel.sol.func-c.html | 51 +- .../PriceOracleSentinel.sol.func.html | 51 +- .../PriceOracleSentinel.sol.gcov.html | 84 +- ...leAdminUpgradeabilityProxy.sol.func-c.html | 48 +- ...ableAdminUpgradeabilityProxy.sol.func.html | 48 +- ...ableAdminUpgradeabilityProxy.sol.gcov.html | 60 +- ...leAdminUpgradeabilityProxy.sol.func-c.html | 35 +- ...ableAdminUpgradeabilityProxy.sol.func.html | 35 +- ...ableAdminUpgradeabilityProxy.sol.gcov.html | 30 +- .../VersionedInitializable.sol.func-c.html | 98 + .../VersionedInitializable.sol.func.html | 98 + .../VersionedInitializable.sol.gcov.html | 50 +- .../aave-upgradeability/index-sort-b.html | 66 +- .../aave-upgradeability/index-sort-f.html | 66 +- .../aave-upgradeability/index-sort-l.html | 66 +- .../aave-upgradeability/index.html | 66 +- .../FlashLoanReceiverBase.sol.func-c.html | 91 + .../base/FlashLoanReceiverBase.sol.func.html | 91 + .../base/FlashLoanReceiverBase.sol.gcov.html} | 72 +- ...ashLoanSimpleReceiverBase.sol.func-c.html} | 30 +- ...FlashLoanSimpleReceiverBase.sol.func.html} | 30 +- ...FlashLoanSimpleReceiverBase.sol.gcov.html} | 67 +- report/misc/flashloan/base/index-sort-b.html | 139 ++ report/misc/flashloan/base/index-sort-f.html | 139 ++ report/misc/flashloan/base/index-sort-l.html | 139 ++ report/misc/flashloan/base/index.html | 139 ++ report/misc/index-sort-b.html | 154 ++ report/misc/index-sort-f.html | 154 ++ report/misc/index-sort-l.html | 154 ++ report/misc/index.html | 154 ++ .../BaseParaSwapBuyAdapter.sol.func-c.html | 91 - .../BaseParaSwapBuyAdapter.sol.func.html | 91 - .../BaseParaSwapSellAdapter.sol.func-c.html | 91 - .../BaseParaSwapSellAdapter.sol.func.html | 91 - .../contracts/libraries/index-sort-b.html | 124 -- .../contracts/libraries/index-sort-f.html | 124 -- .../contracts/libraries/index-sort-l.html | 124 -- .../periphery/contracts/libraries/index.html | 124 -- .../contracts/misc/index-sort-b.html | 124 -- .../contracts/misc/index-sort-f.html | 124 -- .../contracts/misc/index-sort-l.html | 124 -- .../src/periphery/contracts/misc/index.html | 124 -- .../configuration/ACLManager.sol.func-c.html | 63 +- .../configuration/ACLManager.sol.func.html | 51 +- .../configuration/ACLManager.sol.gcov.html | 110 +- .../PoolAddressesProvider.sol.func-c.html | 107 +- .../PoolAddressesProvider.sol.func.html | 77 +- .../PoolAddressesProvider.sol.gcov.html | 188 +- ...lAddressesProviderRegistry.sol.func-c.html | 41 +- ...oolAddressesProviderRegistry.sol.func.html | 41 +- ...oolAddressesProviderRegistry.sol.gcov.html | 94 +- .../configuration}/index-sort-b.html | 84 +- .../configuration}/index-sort-f.html | 84 +- .../configuration}/index-sort-l.html | 78 +- .../configuration}/index.html | 84 +- .../logic/BorrowLogic.sol.func-c.html | 98 + .../libraries/logic/BorrowLogic.sol.func.html | 98 + .../libraries/logic/BorrowLogic.sol.gcov.html | 603 +++--- .../logic/BridgeLogic.sol.func-c.html | 22 +- .../libraries/logic/BridgeLogic.sol.func.html | 22 +- .../libraries/logic/BridgeLogic.sol.gcov.html | 76 +- .../logic/CalldataLogic.sol.func-c.html | 48 +- .../logic/CalldataLogic.sol.func.html | 48 +- .../logic/CalldataLogic.sol.gcov.html | 288 ++- .../logic/ConfiguratorLogic.sol.func-c.html | 53 +- .../logic/ConfiguratorLogic.sol.func.html | 53 +- .../logic/ConfiguratorLogic.sol.gcov.html | 492 +++-- .../logic/EModeLogic.sol.func-c.html} | 30 +- .../libraries/logic/EModeLogic.sol.func.html} | 30 +- .../libraries/logic/EModeLogic.sol.gcov.html | 196 +- .../logic/FlashLoanLogic.sol.func-c.html | 32 +- .../logic/FlashLoanLogic.sol.func.html | 32 +- .../logic/FlashLoanLogic.sol.gcov.html | 549 +++--- .../logic/IsolationModeLogic.sol.func-c.html | 24 +- .../logic/IsolationModeLogic.sol.func.html | 24 +- .../logic/IsolationModeLogic.sol.gcov.html | 38 +- .../logic/LiquidationLogic.sol.func-c.html | 61 +- .../logic/LiquidationLogic.sol.func.html | 61 +- .../logic/LiquidationLogic.sol.gcov.html | 990 +++++----- .../libraries/logic/PoolLogic.sol.func-c.html | 44 +- .../libraries/logic/PoolLogic.sol.func.html | 42 +- .../libraries/logic/PoolLogic.sol.gcov.html | 337 ++-- .../logic/SupplyLogic.sol.func-c.html | 28 +- .../libraries/logic/SupplyLogic.sol.func.html | 28 +- .../libraries/logic/SupplyLogic.sol.gcov.html | 144 +- .../logic/ValidationLogic.sol.func-c.html | 102 +- .../logic/ValidationLogic.sol.func.html | 96 +- .../logic/ValidationLogic.sol.gcov.html | 1288 ++++++------- .../libraries/logic/index-sort-b.html | 132 +- .../libraries/logic/index-sort-f.html | 152 +- .../libraries/logic/index-sort-l.html | 150 +- .../protocol/libraries/logic/index.html | 132 +- .../libraries/math/MathUtils.sol.func-c.html | 26 +- .../libraries/math/MathUtils.sol.func.html | 26 +- .../libraries/math/MathUtils.sol.gcov.html | 62 +- .../math/PercentageMath.sol.func-c.html | 30 +- .../math/PercentageMath.sol.func.html | 30 +- .../math/PercentageMath.sol.gcov.html | 38 +- .../libraries/math/WadRayMath.sol.func-c.html | 44 +- .../libraries/math/WadRayMath.sol.func.html | 36 +- .../libraries/math/WadRayMath.sol.gcov.html | 72 +- .../protocol/libraries/math/index-sort-b.html | 54 +- .../protocol/libraries/math/index-sort-f.html | 54 +- .../protocol/libraries/math/index-sort-l.html | 62 +- .../protocol/libraries/math/index.html | 54 +- .../protocol/pool/L2Pool.sol.func-c.html | 48 +- .../protocol/pool/L2Pool.sol.func.html | 48 +- .../protocol/pool/L2Pool.sol.gcov.html | 116 +- .../protocol/pool/Pool.sol.func-c.html | 308 +-- .../protocol/pool/Pool.sol.func.html | 290 +-- .../protocol/pool/Pool.sol.gcov.html | 1645 +++++++++-------- .../pool/PoolConfigurator.sol.func-c.html | 216 ++- .../pool/PoolConfigurator.sol.func.html | 210 ++- .../pool/PoolConfigurator.sol.gcov.html | 1200 ++++++------ report/protocol/pool/index-sort-b.html | 154 ++ report/protocol/pool/index-sort-f.html | 154 ++ report/protocol/pool/index-sort-l.html | 154 ++ report/protocol/pool/index.html | 154 ++ .../tokenization/AToken.sol.func-c.html | 87 +- .../tokenization/AToken.sol.func.html | 61 +- .../tokenization/AToken.sol.gcov.html | 130 +- .../VariableDebtToken.sol.func-c.html | 53 +- .../VariableDebtToken.sol.func.html | 45 +- .../VariableDebtToken.sol.gcov.html | 84 +- .../base/DebtTokenBase.sol.func-c.html | 53 +- .../base/DebtTokenBase.sol.func.html | 43 +- .../base/DebtTokenBase.sol.gcov.html | 64 +- .../base/EIP712Base.sol.func-c.html | 43 +- .../base/EIP712Base.sol.func.html | 43 +- .../base/EIP712Base.sol.gcov.html | 46 +- .../base/IncentivizedERC20.sol.func-c.html | 117 +- .../base/IncentivizedERC20.sol.func.html | 115 +- .../base/IncentivizedERC20.sol.gcov.html | 415 +++-- .../MintableIncentivizedERC20.sol.func-c.html | 37 +- .../MintableIncentivizedERC20.sol.func.html | 37 +- .../MintableIncentivizedERC20.sol.gcov.html | 54 +- .../ScaledBalanceTokenBase.sol.func-c.html | 47 +- .../base/ScaledBalanceTokenBase.sol.func.html | 43 +- .../base/ScaledBalanceTokenBase.sol.gcov.html | 126 +- .../tokenization/base/index-sort-b.html | 84 +- .../tokenization/base/index-sort-f.html | 86 +- .../tokenization/base/index-sort-l.html | 84 +- .../protocol/tokenization/base/index.html | 84 +- .../tokenization}/index-sort-b.html | 58 +- .../tokenization}/index-sort-f.html | 58 +- .../tokenization}/index-sort-l.html | 58 +- .../misc => protocol/tokenization}/index.html | 58 +- .../rewards/EmissionManager.sol.func-c.html | 64 +- .../rewards/EmissionManager.sol.func.html | 52 +- .../rewards/EmissionManager.sol.gcov.html | 86 +- .../rewards/RewardsController.sol.func-c.html | 94 +- .../rewards/RewardsController.sol.func.html | 72 +- .../rewards/RewardsController.sol.gcov.html | 240 +-- .../RewardsDistributor.sol.func-c.html | 90 +- .../rewards/RewardsDistributor.sol.func.html | 72 +- .../rewards/RewardsDistributor.sol.gcov.html | 322 ++-- .../index.html => rewards/index-sort-b.html} | 78 +- .../contracts => }/rewards/index-sort-f.html | 84 +- .../contracts => }/rewards/index-sort-l.html | 80 +- .../index-sort-b.html => rewards/index.html} | 78 +- ...ullRewardsTransferStrategy.sol.func-c.html | 39 +- .../PullRewardsTransferStrategy.sol.func.html | 39 +- .../PullRewardsTransferStrategy.sol.gcov.html | 42 +- ...takedTokenTransferStrategy.sol.func-c.html | 37 +- .../StakedTokenTransferStrategy.sol.func.html | 37 +- .../StakedTokenTransferStrategy.sol.gcov.html | 64 +- .../TransferStrategyBase.sol.func-c.html | 51 +- .../TransferStrategyBase.sol.func.html | 51 +- .../TransferStrategyBase.sol.gcov.html | 52 +- .../transfer-strategies/index-sort-b.html | 74 +- .../transfer-strategies/index-sort-f.html | 66 +- .../transfer-strategies/index-sort-l.html | 66 +- .../rewards/transfer-strategies/index.html | 74 +- 277 files changed, 17910 insertions(+), 16119 deletions(-) delete mode 100644 report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-b.html delete mode 100644 report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-f.html delete mode 100644 report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-l.html delete mode 100644 report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index.html delete mode 100644 report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func-c.html delete mode 100644 report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func.html delete mode 100644 report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-b.html delete mode 100644 report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-f.html delete mode 100644 report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-l.html delete mode 100644 report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index.html delete mode 100644 report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func-c.html delete mode 100644 report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func.html delete mode 100644 report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func-c.html delete mode 100644 report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func.html delete mode 100644 report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-b.html delete mode 100644 report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-f.html delete mode 100644 report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-l.html delete mode 100644 report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index.html delete mode 100644 report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func-c.html delete mode 100644 report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func.html delete mode 100644 report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.gcov.html delete mode 100644 report/core/instances/src/core/instances/StableDebtTokenInstance.sol.gcov.html delete mode 100644 report/coverage.svg rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/AaveParaSwapFeeClaimer.sol.func-c.html (65%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/AaveParaSwapFeeClaimer.sol.func.html (64%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/AaveParaSwapFeeClaimer.sol.gcov.html (76%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/BaseParaSwapAdapter.sol.func-c.html (66%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/BaseParaSwapAdapter.sol.func.html (66%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/BaseParaSwapAdapter.sol.gcov.html (81%) rename report/{core/instances/src/core/instances/VariableDebtTokenInstance.sol.func-c.html => extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func-c.html} (59%) rename report/{core/instances/src/core/instances/StableDebtTokenInstance.sol.func.html => extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func.html} (59%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/BaseParaSwapBuyAdapter.sol.gcov.html (75%) rename report/{core/instances/src/core/instances/StableDebtTokenInstance.sol.func-c.html => extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func-c.html} (59%) rename report/{core/instances/src/core/instances/VariableDebtTokenInstance.sol.func.html => extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func.html} (59%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/BaseParaSwapSellAdapter.sol.gcov.html (79%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapLiquiditySwapAdapter.sol.func-c.html (64%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapLiquiditySwapAdapter.sol.func.html (64%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapLiquiditySwapAdapter.sol.gcov.html (86%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapRepayAdapter.sol.func-c.html (61%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapRepayAdapter.sol.func.html (61%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapRepayAdapter.sol.gcov.html (80%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapWithdrawSwapAdapter.sol.func-c.html (62%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapWithdrawSwapAdapter.sol.func.html (62%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/ParaSwapWithdrawSwapAdapter.sol.gcov.html (82%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/index-sort-b.html (53%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/index-sort-f.html (53%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/index-sort-l.html (53%) rename report/{periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap => extensions/paraswap-adapters}/index.html (53%) create mode 100644 report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func-c.html create mode 100644 report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func.html create mode 100644 report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.gcov.html create mode 100644 report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func-c.html create mode 100644 report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func.html create mode 100644 report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.gcov.html create mode 100644 report/extensions/static-a-token/StataTokenFactory.sol.func-c.html create mode 100644 report/extensions/static-a-token/StataTokenFactory.sol.func.html create mode 100644 report/extensions/static-a-token/StataTokenFactory.sol.gcov.html create mode 100644 report/extensions/static-a-token/StataTokenV2.sol.func-c.html create mode 100644 report/extensions/static-a-token/StataTokenV2.sol.func.html create mode 100644 report/extensions/static-a-token/StataTokenV2.sol.gcov.html create mode 100644 report/extensions/static-a-token/index-sort-b.html create mode 100644 report/extensions/static-a-token/index-sort-f.html create mode 100644 report/extensions/static-a-token/index-sort-l.html create mode 100644 report/extensions/static-a-token/index.html rename report/{core/contracts/misc/src/core/contracts/misc => helpers}/L2Encoder.sol.func-c.html (67%) rename report/{core/contracts/misc/src/core/contracts/misc => helpers}/L2Encoder.sol.func.html (67%) rename report/{core/contracts/misc/src/core/contracts/misc => helpers}/L2Encoder.sol.gcov.html (77%) rename report/{periphery/contracts/misc/src/periphery/contracts/misc => helpers}/WrappedTokenGatewayV3.sol.func-c.html (66%) rename report/{periphery/contracts/misc/src/periphery/contracts/misc => helpers}/WrappedTokenGatewayV3.sol.func.html (66%) rename report/{periphery/contracts/misc/src/periphery/contracts/misc => helpers}/WrappedTokenGatewayV3.sol.gcov.html (73%) create mode 100644 report/helpers/index-sort-b.html create mode 100644 report/helpers/index-sort-f.html create mode 100644 report/helpers/index-sort-l.html create mode 100644 report/helpers/index.html rename report/{core/instances/src/core => }/instances/ATokenInstance.sol.func-c.html (63%) rename report/{core/instances/src/core => }/instances/ATokenInstance.sol.func.html (63%) rename report/{core/instances/src/core => }/instances/ATokenInstance.sol.gcov.html (79%) rename report/{core/instances/src/core => }/instances/PoolConfiguratorInstance.sol.func-c.html (68%) rename report/{core/instances/src/core => }/instances/PoolConfiguratorInstance.sol.func.html (68%) rename report/{core/instances/src/core => }/instances/PoolConfiguratorInstance.sol.gcov.html (72%) rename report/{core/instances/src/core => }/instances/PoolInstance.sol.func-c.html (64%) rename report/{core/instances/src/core => }/instances/PoolInstance.sol.func.html (64%) rename report/{core/instances/src/core => }/instances/PoolInstance.sol.gcov.html (72%) create mode 100644 report/instances/VariableDebtTokenInstance.sol.func-c.html create mode 100644 report/instances/VariableDebtTokenInstance.sol.func.html rename report/{core/instances/src/core => }/instances/VariableDebtTokenInstance.sol.gcov.html (76%) rename report/{core/instances/src/core => }/instances/index-sort-b.html (58%) rename report/{core/instances/src/core => }/instances/index-sort-f.html (58%) rename report/{core/instances/src/core => }/instances/index-sort-l.html (58%) rename report/{core/instances/src/core => }/instances/index.html (58%) rename report/{core/contracts/misc/src/core/contracts => }/misc/AaveOracle.sol.func-c.html (65%) rename report/{core/contracts/misc/src/core/contracts => }/misc/AaveOracle.sol.func.html (65%) rename report/{core/contracts/misc/src/core/contracts => }/misc/AaveOracle.sol.gcov.html (80%) rename report/{core/contracts/protocol/pool/src/core/contracts/protocol/pool => misc}/DefaultReserveInterestRateStrategyV2.sol.func-c.html (64%) rename report/{core/contracts/protocol/pool/src/core/contracts/protocol/pool => misc}/DefaultReserveInterestRateStrategyV2.sol.func.html (64%) rename report/{core/contracts/protocol/pool/src/core/contracts/protocol/pool => misc}/DefaultReserveInterestRateStrategyV2.sol.gcov.html (70%) rename report/{core/contracts/protocol/configuration/src/core/contracts/protocol/configuration => misc}/PriceOracleSentinel.sol.func-c.html (67%) rename report/{core/contracts/protocol/configuration/src/core/contracts/protocol/configuration => misc}/PriceOracleSentinel.sol.func.html (67%) rename report/{core/contracts/protocol/configuration/src/core/contracts/protocol/configuration => misc}/PriceOracleSentinel.sol.gcov.html (77%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html (63%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html (63%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html (81%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html (60%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html (60%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html (75%) create mode 100644 report/misc/aave-upgradeability/VersionedInitializable.sol.func-c.html create mode 100644 report/misc/aave-upgradeability/VersionedInitializable.sol.func.html rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/VersionedInitializable.sol.gcov.html (83%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/index-sort-b.html (59%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/index-sort-f.html (59%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/index-sort-l.html (59%) rename report/{core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries => misc}/aave-upgradeability/index.html (59%) create mode 100644 report/misc/flashloan/base/FlashLoanReceiverBase.sol.func-c.html create mode 100644 report/misc/flashloan/base/FlashLoanReceiverBase.sol.func.html rename report/{periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.gcov.html => misc/flashloan/base/FlashLoanReceiverBase.sol.gcov.html} (54%) rename report/{periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func-c.html => misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func-c.html} (65%) rename report/{periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func.html => misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func.html} (65%) rename report/{core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.gcov.html => misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.gcov.html} (57%) create mode 100644 report/misc/flashloan/base/index-sort-b.html create mode 100644 report/misc/flashloan/base/index-sort-f.html create mode 100644 report/misc/flashloan/base/index-sort-l.html create mode 100644 report/misc/flashloan/base/index.html create mode 100644 report/misc/index-sort-b.html create mode 100644 report/misc/index-sort-f.html create mode 100644 report/misc/index-sort-l.html create mode 100644 report/misc/index.html delete mode 100644 report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func-c.html delete mode 100644 report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func.html delete mode 100644 report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func-c.html delete mode 100644 report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func.html delete mode 100644 report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-b.html delete mode 100644 report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-f.html delete mode 100644 report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-l.html delete mode 100644 report/periphery/contracts/libraries/src/periphery/contracts/libraries/index.html delete mode 100644 report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-b.html delete mode 100644 report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-f.html delete mode 100644 report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-l.html delete mode 100644 report/periphery/contracts/misc/src/periphery/contracts/misc/index.html rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/ACLManager.sol.func-c.html (75%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/ACLManager.sol.func.html (75%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/ACLManager.sol.gcov.html (75%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProvider.sol.func-c.html (72%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProvider.sol.func.html (72%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProvider.sol.gcov.html (75%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html (69%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html (69%) rename report/{core/contracts/protocol/configuration/src/core/contracts => }/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html (77%) rename report/{core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization => protocol/configuration}/index-sort-b.html (53%) rename report/{core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization => protocol/configuration}/index-sort-f.html (53%) rename report/{core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization => protocol/configuration}/index-sort-l.html (53%) rename report/{core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization => protocol/configuration}/index.html (53%) create mode 100644 report/protocol/libraries/logic/BorrowLogic.sol.func-c.html create mode 100644 report/protocol/libraries/logic/BorrowLogic.sol.func.html rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/BorrowLogic.sol.gcov.html (56%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/BridgeLogic.sol.func-c.html (68%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/BridgeLogic.sol.func.html (68%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/BridgeLogic.sol.gcov.html (87%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/CalldataLogic.sol.func-c.html (65%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/CalldataLogic.sol.func.html (65%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/CalldataLogic.sol.gcov.html (70%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html (58%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ConfiguratorLogic.sol.func.html (58%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html (70%) rename report/{core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func-c.html => protocol/libraries/logic/EModeLogic.sol.func-c.html} (61%) rename report/{core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func.html => protocol/libraries/logic/EModeLogic.sol.func.html} (61%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/EModeLogic.sol.gcov.html (58%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html (64%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/FlashLoanLogic.sol.func.html (64%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html (86%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html (65%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/IsolationModeLogic.sol.func.html (65%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html (85%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/LiquidationLogic.sol.func-c.html (56%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/LiquidationLogic.sol.func.html (56%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/LiquidationLogic.sol.gcov.html (76%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/PoolLogic.sol.func-c.html (66%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/PoolLogic.sol.func.html (66%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/PoolLogic.sol.gcov.html (86%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/SupplyLogic.sol.func-c.html (68%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/SupplyLogic.sol.func.html (68%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/SupplyLogic.sol.gcov.html (88%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ValidationLogic.sol.func-c.html (57%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ValidationLogic.sol.func.html (57%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/ValidationLogic.sol.gcov.html (71%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/index-sort-b.html (60%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/index-sort-f.html (60%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/index-sort-l.html (60%) rename report/{core/contracts/protocol/libraries/logic/src/core/contracts => }/protocol/libraries/logic/index.html (60%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/MathUtils.sol.func-c.html (66%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/MathUtils.sol.func.html (66%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/MathUtils.sol.gcov.html (84%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/PercentageMath.sol.func-c.html (64%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/PercentageMath.sol.func.html (64%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/PercentageMath.sol.gcov.html (84%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/WadRayMath.sol.func-c.html (67%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/WadRayMath.sol.func.html (67%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/WadRayMath.sol.gcov.html (83%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/index-sort-b.html (64%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/index-sort-f.html (64%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/index-sort-l.html (64%) rename report/{core/contracts/protocol/libraries/math/src/core/contracts => }/protocol/libraries/math/index.html (64%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/L2Pool.sol.func-c.html (66%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/L2Pool.sol.func.html (66%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/L2Pool.sol.gcov.html (66%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/Pool.sol.func-c.html (62%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/Pool.sol.func.html (62%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/Pool.sol.gcov.html (83%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/PoolConfigurator.sol.func-c.html (56%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/PoolConfigurator.sol.func.html (56%) rename report/{core/contracts/protocol/pool/src/core/contracts => }/protocol/pool/PoolConfigurator.sol.gcov.html (75%) create mode 100644 report/protocol/pool/index-sort-b.html create mode 100644 report/protocol/pool/index-sort-f.html create mode 100644 report/protocol/pool/index-sort-l.html create mode 100644 report/protocol/pool/index.html rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/AToken.sol.func-c.html (70%) rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/AToken.sol.func.html (70%) rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/AToken.sol.gcov.html (83%) rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/VariableDebtToken.sol.func-c.html (72%) rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/VariableDebtToken.sol.func.html (72%) rename report/{core/contracts/protocol/tokenization/src/core/contracts => }/protocol/tokenization/VariableDebtToken.sol.gcov.html (80%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/DebtTokenBase.sol.func-c.html (66%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/DebtTokenBase.sol.func.html (66%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/DebtTokenBase.sol.gcov.html (83%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/EIP712Base.sol.func-c.html (62%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/EIP712Base.sol.func.html (62%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/EIP712Base.sol.gcov.html (82%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html (57%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/IncentivizedERC20.sol.func.html (57%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html (80%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html (64%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html (64%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html (80%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html (68%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html (69%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html (80%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/index-sort-b.html (62%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/index-sort-f.html (62%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/index-sort-l.html (62%) rename report/{core/contracts/protocol/tokenization/base/src/core/contracts => }/protocol/tokenization/base/index.html (62%) rename report/{core/contracts/misc/src/core/contracts/misc => protocol/tokenization}/index-sort-b.html (59%) rename report/{core/contracts/misc/src/core/contracts/misc => protocol/tokenization}/index-sort-f.html (59%) rename report/{core/contracts/misc/src/core/contracts/misc => protocol/tokenization}/index-sort-l.html (59%) rename report/{core/contracts/misc/src/core/contracts/misc => protocol/tokenization}/index.html (59%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/EmissionManager.sol.func-c.html (68%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/EmissionManager.sol.func.html (68%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/EmissionManager.sol.gcov.html (78%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsController.sol.func-c.html (74%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsController.sol.func.html (74%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsController.sol.gcov.html (82%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsDistributor.sol.func-c.html (73%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsDistributor.sol.func.html (73%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/RewardsDistributor.sol.gcov.html (84%) rename report/{periphery/contracts/rewards/src/periphery/contracts/rewards/index.html => rewards/index-sort-b.html} (57%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/index-sort-f.html (57%) rename report/{periphery/contracts/rewards/src/periphery/contracts => }/rewards/index-sort-l.html (57%) rename report/{periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-b.html => rewards/index.html} (57%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html (64%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html (64%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html (79%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html (67%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html (67%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html (76%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html (57%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/TransferStrategyBase.sol.func.html (57%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html (78%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/index-sort-b.html (60%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/index-sort-f.html (60%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/index-sort-l.html (60%) rename report/{periphery/contracts/rewards/transfer-strategies/src/periphery/contracts => }/rewards/transfer-strategies/index.html (60%) diff --git a/Makefile b/Makefile index d238d12c..8db35cf3 100644 --- a/Makefile +++ b/Makefile @@ -9,32 +9,32 @@ update:; forge update test :; forge test -vvv --no-match-contract DeploymentsGasLimits test-contract :; forge test --match-contract ${filter} -vvv test-watch :; forge test --watch -vvv --no-match-contract DeploymentsGasLimits -coverage :; forge coverage --report lcov && \ - lcov --remove ./lcov.info -o ./lcov.info.p \ - 'scripts/*' \ - 'tests/*' \ - 'src/deployments/*' \ - 'src/periphery/contracts/v3-config-engine/*' \ - 'src/periphery/contracts/treasury/*' \ - 'src/periphery/contracts/dependencies/openzeppelin/ReentrancyGuard.sol' \ - 'src/periphery/contracts/misc/UiIncentiveDataProviderV3.sol' \ - 'src/periphery/contracts/misc/UiPoolDataProviderV3.sol' \ - 'src/periphery/contracts/misc/WalletBalanceProvider.sol' \ - 'src/periphery/contracts/mocks/*' \ - 'src/core/contracts/mocks/*' \ - 'src/core/contracts/dependencies/*' \ - 'src/core/contracts/misc/AaveProtocolDataProvider.sol' \ - 'src/core/contracts/protocol/libraries/configuration/*' \ - 'src/core/contracts/protocol/libraries/logic/GenericLogic.sol' \ - 'src/core/contracts/protocol/libraries/logic/ReserveLogic.sol' \ - && genhtml ./lcov.info.p -o report --branch-coverage \ - && coverage=$$(awk -F '[<>]' '/headerCovTableEntryHi/{print $3}' ./report/index.html | sed 's/[^0-9.]//g' | head -n 1); \ - wget -O ./report/coverage.svg "https://img.shields.io/badge/coverage-$${coverage}%25-brightgreen" +# Coverage +coverage-base :; forge coverage --report lcov --no-match-coverage "(scripts|tests|deployments|mocks)" +coverage-clean :; lcov --rc derive_function_end_line=0 --remove ./lcov.info -o ./lcov.info.p \ + 'src/contracts/extensions/v3-config-engine/*' \ + 'src/contracts/treasury/*' \ + 'src/contracts/dependencies/openzeppelin/ReentrancyGuard.sol' \ + 'src/contracts/helpers/UiIncentiveDataProviderV3.sol' \ + 'src/contracts/helpers/UiPoolDataProviderV3.sol' \ + 'src/contracts/helpers/WalletBalanceProvider.sol' \ + 'src/contracts/dependencies/*' \ + 'src/contracts/helpers/AaveProtocolDataProvider.sol' \ + 'src/contracts/protocol/libraries/configuration/*' \ + 'src/contracts/protocol/libraries/logic/GenericLogic.sol' \ + 'src/contracts/protocol/libraries/logic/ReserveLogic.sol' +coverage-report :; genhtml ./lcov.info.p -o report --branch-coverage --rc derive_function_end_line=0 --parallel +coverage-badge :; coverage=$$(awk -F '[<>]' '/headerCovTableEntryHi/{print $3}' ./report/index.html | sed 's/[^0-9.]//g' | head -n 1); \ + wget -O ./report/coverage.svg "https://img.shields.io/badge/coverage-$${coverage}%25-brightgreen" +coverage : + make coverage-base + make coverage-clean + make coverage-report + make coverage-badge # Utilities download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address} git-diff : @mkdir -p diffs @npx prettier ${before} ${after} --write @printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md - diff --git a/foundry.toml b/foundry.toml index e5ae0500..97da41a2 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,7 +5,7 @@ script = 'scripts' optimizer = true optimizer_runs = 200 solc = '0.8.20' -evm_version = 'paris' +evm_version = 'shanghai' bytecode_hash = 'none' ignored_warnings_from = ["src/periphery/contracts/treasury/RevenueSplitter.sol"] out = 'out' diff --git a/report/cmd_line b/report/cmd_line index 531e7eed..32f76312 100644 --- a/report/cmd_line +++ b/report/cmd_line @@ -1 +1 @@ -genhtml ./lcov.info.p -o report --branch-coverage +genhtml ./lcov.info.p -o report --branch-coverage --rc derive_function_end_line=0 --parallel diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-b.html b/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-b.html deleted file mode 100644 index 54f9b9fb..00000000 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-b.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configurationCoverageTotalHit
Test:lcov.info.pLines:100.0 %111111
Test Date:2024-04-09 14:12:28Functions:100.0 %5555
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
ACLManager.sol -
100.0%
-
100.0 %1919-100.0 %1919
PoolAddressesProvider.sol -
100.0%
-
100.0 %5656-100.0 %2222
PoolAddressesProviderRegistry.sol -
100.0%
-
100.0 %2626-100.0 %77
PriceOracleSentinel.sol -
100.0%
-
100.0 %1010-100.0 %77
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-f.html b/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-f.html deleted file mode 100644 index fc55300b..00000000 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-f.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configurationCoverageTotalHit
Test:lcov.info.pLines:100.0 %111111
Test Date:2024-04-09 14:12:28Functions:100.0 %5555
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
PoolAddressesProviderRegistry.sol -
100.0%
-
100.0 %2626-100.0 %77
PriceOracleSentinel.sol -
100.0%
-
100.0 %1010-100.0 %77
ACLManager.sol -
100.0%
-
100.0 %1919-100.0 %1919
PoolAddressesProvider.sol -
100.0%
-
100.0 %5656-100.0 %2222
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-l.html b/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-l.html deleted file mode 100644 index 0c13c5fc..00000000 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index-sort-l.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configurationCoverageTotalHit
Test:lcov.info.pLines:100.0 %111111
Test Date:2024-04-09 14:12:28Functions:100.0 %5555
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
PriceOracleSentinel.sol -
100.0%
-
100.0 %1010-100.0 %77
ACLManager.sol -
100.0%
-
100.0 %1919-100.0 %1919
PoolAddressesProviderRegistry.sol -
100.0%
-
100.0 %2626-100.0 %77
PoolAddressesProvider.sol -
100.0%
-
100.0 %5656-100.0 %2222
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index.html b/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index.html deleted file mode 100644 index bd9350ec..00000000 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/index.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configurationCoverageTotalHit
Test:lcov.info.pLines:100.0 %111111
Test Date:2024-04-09 14:12:28Functions:100.0 %5555
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
ACLManager.sol -
100.0%
-
100.0 %1919-100.0 %1919
PoolAddressesProvider.sol -
100.0%
-
100.0 %5656-100.0 %2222
PoolAddressesProviderRegistry.sol -
100.0%
-
100.0 %2626-100.0 %77
PriceOracleSentinel.sol -
100.0%
-
100.0 %1010-100.0 %77
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func-c.html b/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func-c.html deleted file mode 100644 index c983b9c9..00000000 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func-c.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - VersionedInitializable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %33
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
VersionedInitializable.isConstructor15381
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func.html b/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func.html deleted file mode 100644 index 971352cb..00000000 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.func.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - VersionedInitializable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %33
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
VersionedInitializable.isConstructor15381
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-b.html b/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-b.html deleted file mode 100644 index 3d12b7bd..00000000 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-b.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpersCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
Helpers.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-f.html b/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-f.html deleted file mode 100644 index 69c76388..00000000 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-f.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpersCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
Helpers.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-l.html b/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-l.html deleted file mode 100644 index d2bec174..00000000 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index-sort-l.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpersCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
Helpers.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index.html b/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index.html deleted file mode 100644 index 985d097b..00000000 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/index.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpersCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
Helpers.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func-c.html b/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func-c.html deleted file mode 100644 index b8d88ccc..00000000 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func-c.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BorrowLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:88.1 %6759
Test Date:2024-04-09 14:12:28Functions:100.0 %44
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BorrowLogic.executeRebalanceStableBorrowRate5
BorrowLogic.executeSwapBorrowRateMode8
BorrowLogic.executeRepay5029
BorrowLogic.executeBorrow9117
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func.html b/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func.html deleted file mode 100644 index 4c169418..00000000 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.func.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BorrowLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:88.1 %6759
Test Date:2024-04-09 14:12:28Functions:100.0 %44
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BorrowLogic.executeBorrow9117
BorrowLogic.executeRebalanceStableBorrowRate5
BorrowLogic.executeRepay5029
BorrowLogic.executeSwapBorrowRateMode8
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func-c.html b/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func-c.html deleted file mode 100644 index 7a6e66bf..00000000 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func-c.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - EModeLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %1212
Test Date:2024-04-09 14:12:28Functions:100.0 %33
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
EModeLogic.getEModeConfiguration10
EModeLogic.executeSetUserEMode17
EModeLogic.isInEModeCategory25421
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func.html b/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func.html deleted file mode 100644 index 0117170a..00000000 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.func.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - EModeLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %1212
Test Date:2024-04-09 14:12:28Functions:100.0 %33
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
EModeLogic.executeSetUserEMode17
EModeLogic.getEModeConfiguration10
EModeLogic.isInEModeCategory25421
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-b.html b/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-b.html deleted file mode 100644 index 4190f8d8..00000000 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-b.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/poolCoverageTotalHit
Test:lcov.info.pLines:98.1 %365358
Test Date:2024-04-09 14:12:28Functions:97.6 %124121
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DefaultReserveInterestRateStrategyV2.sol -
100.0%
-
100.0 %4343-100.0 %1313
L2Pool.sol -
100.0%
-
100.0 %2424-100.0 %1111
Pool.sol -
99.1%99.1%
-
99.1 %108107-98.4 %6160
PoolConfigurator.sol -
96.8%96.8%
-
96.8 %190184-94.9 %3937
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-f.html b/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-f.html deleted file mode 100644 index 33c1c9f7..00000000 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-f.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/poolCoverageTotalHit
Test:lcov.info.pLines:98.1 %365358
Test Date:2024-04-09 14:12:28Functions:97.6 %124121
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
PoolConfigurator.sol -
96.8%96.8%
-
96.8 %190184-94.9 %3937
Pool.sol -
99.1%99.1%
-
99.1 %108107-98.4 %6160
L2Pool.sol -
100.0%
-
100.0 %2424-100.0 %1111
DefaultReserveInterestRateStrategyV2.sol -
100.0%
-
100.0 %4343-100.0 %1313
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-l.html b/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-l.html deleted file mode 100644 index cb465de1..00000000 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index-sort-l.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/poolCoverageTotalHit
Test:lcov.info.pLines:98.1 %365358
Test Date:2024-04-09 14:12:28Functions:97.6 %124121
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
PoolConfigurator.sol -
96.8%96.8%
-
96.8 %190184-94.9 %3937
Pool.sol -
99.1%99.1%
-
99.1 %108107-98.4 %6160
L2Pool.sol -
100.0%
-
100.0 %2424-100.0 %1111
DefaultReserveInterestRateStrategyV2.sol -
100.0%
-
100.0 %4343-100.0 %1313
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index.html b/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index.html deleted file mode 100644 index 01f7d7cf..00000000 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/index.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/poolCoverageTotalHit
Test:lcov.info.pLines:98.1 %365358
Test Date:2024-04-09 14:12:28Functions:97.6 %124121
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DefaultReserveInterestRateStrategyV2.sol -
100.0%
-
100.0 %4343-100.0 %1313
L2Pool.sol -
100.0%
-
100.0 %2424-100.0 %1111
Pool.sol -
99.1%99.1%
-
99.1 %108107-98.4 %6160
PoolConfigurator.sol -
96.8%96.8%
-
96.8 %190184-94.9 %3937
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func-c.html b/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func-c.html deleted file mode 100644 index 9132f3db..00000000 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func-c.html +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - StableDebtToken.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:63.2 %1912
Test Date:2024-04-09 14:12:28Functions:100.0 %1919
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
StableDebtToken.allowance1
StableDebtToken.approve1
StableDebtToken.decreaseAllowance1
StableDebtToken.getTotalSupplyAndAvgRate1
StableDebtToken.getTotalSupplyLastUpdated1
StableDebtToken.increaseAllowance1
StableDebtToken.transfer1
StableDebtToken.transferFrom1
StableDebtToken.burn3
StableDebtToken.mint7
StableDebtToken.getAverageStableRate8
StableDebtToken.totalSupply17
StableDebtToken.UNDERLYING_ASSET_ADDRESS1016
StableDebtToken._EIP712BaseId3474
StableDebtToken.getUserLastUpdated4023
StableDebtToken.getUserStableRate4023
StableDebtToken.principalBalanceOf4024
StableDebtToken.balanceOf34689
StableDebtToken.getSupplyData51684
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func.html b/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func.html deleted file mode 100644 index 4db63dd8..00000000 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.func.html +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - StableDebtToken.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:63.2 %1912
Test Date:2024-04-09 14:12:28Functions:100.0 %1919
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
StableDebtToken.UNDERLYING_ASSET_ADDRESS1016
StableDebtToken._EIP712BaseId3474
StableDebtToken.allowance1
StableDebtToken.approve1
StableDebtToken.balanceOf34689
StableDebtToken.burn3
StableDebtToken.decreaseAllowance1
StableDebtToken.getAverageStableRate8
StableDebtToken.getSupplyData51684
StableDebtToken.getTotalSupplyAndAvgRate1
StableDebtToken.getTotalSupplyLastUpdated1
StableDebtToken.getUserLastUpdated4023
StableDebtToken.getUserStableRate4023
StableDebtToken.increaseAllowance1
StableDebtToken.mint7
StableDebtToken.principalBalanceOf4024
StableDebtToken.totalSupply17
StableDebtToken.transfer1
StableDebtToken.transferFrom1
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.gcov.html b/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.gcov.html deleted file mode 100644 index b19a9048..00000000 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol.gcov.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/StableDebtToken.sol - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - StableDebtToken.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:63.2 %1912
Test Date:2024-04-09 14:12:28Functions:100.0 %1919
Branches:-00
-
- - - - - - - - -

-
             Branch data     Line data    Source code
-
-       1                 :             : // SPDX-License-Identifier: BUSL-1.1
-       2                 :             : pragma solidity ^0.8.10;
-       3                 :             : 
-       4                 :             : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
-       5                 :             : import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol';
-       6                 :             : import {Errors} from '../libraries/helpers/Errors.sol';
-       7                 :             : import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol';
-       8                 :             : import {IInitializableDebtToken} from '../../interfaces/IInitializableDebtToken.sol';
-       9                 :             : import {IStableDebtToken} from '../../interfaces/IStableDebtToken.sol';
-      10                 :             : import {IPool} from '../../interfaces/IPool.sol';
-      11                 :             : import {EIP712Base} from './base/EIP712Base.sol';
-      12                 :             : import {DebtTokenBase} from './base/DebtTokenBase.sol';
-      13                 :             : import {IncentivizedERC20} from './base/IncentivizedERC20.sol';
-      14                 :             : 
-      15                 :             : /**
-      16                 :             :  * @title StableDebtToken
-      17                 :             :  * @author Aave
-      18                 :             :  * @notice Implements a stable debt token to track the borrowing positions of users
-      19                 :             :  * at stable rate mode
-      20                 :             :  * @dev Transfer and approve functionalities are disabled since its a non-transferable token
-      21                 :             :  */
-      22                 :             : abstract contract StableDebtToken is DebtTokenBase, IncentivizedERC20, IStableDebtToken {
-      23                 :             :   /**
-      24                 :             :    * @dev Constructor.
-      25                 :             :    * @param pool The address of the Pool contract
-      26                 :             :    */
-      27                 :             :   constructor(
-      28                 :             :     IPool pool
-      29                 :             :   ) DebtTokenBase() IncentivizedERC20(pool, 'STABLE_DEBT_TOKEN_IMPL', 'STABLE_DEBT_TOKEN_IMPL', 0) {
-      30                 :             :     // Intentionally left blank
-      31                 :             :   }
-      32                 :             : 
-      33                 :             :   /// @inheritdoc IInitializableDebtToken
-      34                 :             :   function initialize(
-      35                 :             :     IPool initializingPool,
-      36                 :             :     address underlyingAsset,
-      37                 :             :     IAaveIncentivesController incentivesController,
-      38                 :             :     uint8 debtTokenDecimals,
-      39                 :             :     string memory debtTokenName,
-      40                 :             :     string memory debtTokenSymbol,
-      41                 :             :     bytes calldata params
-      42                 :             :   ) external virtual;
-      43                 :             : 
-      44                 :             :   /// @inheritdoc IStableDebtToken
-      45                 :           8 :   function getAverageStableRate() external pure virtual override returns (uint256) {
-      46                 :           0 :     return 0;
-      47                 :             :   }
-      48                 :             : 
-      49                 :             :   /// @inheritdoc IStableDebtToken
-      50                 :        4023 :   function getUserLastUpdated(address) external pure virtual override returns (uint40) {
-      51                 :           0 :     return 0;
-      52                 :             :   }
-      53                 :             : 
-      54                 :             :   /// @inheritdoc IStableDebtToken
-      55                 :        4023 :   function getUserStableRate(address) external pure virtual override returns (uint256) {
-      56                 :           0 :     return 0;
-      57                 :             :   }
-      58                 :             : 
-      59                 :             :   /// @inheritdoc IERC20
-      60                 :       34689 :   function balanceOf(address) public pure virtual override returns (uint256) {
-      61                 :           0 :     return 0;
-      62                 :             :   }
-      63                 :             : 
-      64                 :             :   /// @inheritdoc IStableDebtToken
-      65                 :           7 :   function mint(
-      66                 :             :     address,
-      67                 :             :     address,
-      68                 :             :     uint256,
-      69                 :             :     uint256
-      70                 :             :   ) external virtual override onlyPool returns (bool, uint256, uint256) {
-      71                 :          14 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-      72                 :             :   }
-      73                 :             : 
-      74                 :             :   /// @inheritdoc IStableDebtToken
-      75                 :           3 :   function burn(address, uint256) external virtual override onlyPool returns (uint256, uint256) {
-      76                 :           6 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-      77                 :             :   }
-      78                 :             : 
-      79                 :             :   /// @inheritdoc IStableDebtToken
-      80                 :       51684 :   function getSupplyData() external pure override returns (uint256, uint256, uint256, uint40) {
-      81                 :      103368 :     return (0, 0, 0, 0);
-      82                 :             :   }
-      83                 :             : 
-      84                 :             :   /// @inheritdoc IStableDebtToken
-      85                 :           1 :   function getTotalSupplyAndAvgRate() external pure override returns (uint256, uint256) {
-      86                 :           2 :     return (0, 0);
-      87                 :             :   }
-      88                 :             : 
-      89                 :             :   /// @inheritdoc IERC20
-      90                 :          17 :   function totalSupply() public pure virtual override returns (uint256) {
-      91                 :           0 :     return 0;
-      92                 :             :   }
-      93                 :             : 
-      94                 :             :   /// @inheritdoc IStableDebtToken
-      95                 :           1 :   function getTotalSupplyLastUpdated() external pure override returns (uint40) {
-      96                 :           0 :     return 0;
-      97                 :             :   }
-      98                 :             : 
-      99                 :             :   /// @inheritdoc IStableDebtToken
-     100                 :        4024 :   function principalBalanceOf(address) external pure virtual override returns (uint256) {
-     101                 :           0 :     return 0;
-     102                 :             :   }
-     103                 :             : 
-     104                 :             :   /// @inheritdoc IStableDebtToken
-     105                 :        1016 :   function UNDERLYING_ASSET_ADDRESS() external view override returns (address) {
-     106                 :        2032 :     return _underlyingAsset;
-     107                 :             :   }
-     108                 :             : 
-     109                 :             :   /// @inheritdoc EIP712Base
-     110                 :        3474 :   function _EIP712BaseId() internal view override returns (string memory) {
-     111                 :       10422 :     return name();
-     112                 :             :   }
-     113                 :             : 
-     114                 :             :   /**
-     115                 :             :    * @dev Being non transferrable, the debt token does not implement any of the
-     116                 :             :    * standard ERC20 functions for transfer and allowance.
-     117                 :             :    */
-     118                 :           1 :   function transfer(address, uint256) external virtual override returns (bool) {
-     119                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     120                 :             :   }
-     121                 :             : 
-     122                 :           1 :   function allowance(address, address) external view virtual override returns (uint256) {
-     123                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     124                 :             :   }
-     125                 :             : 
-     126                 :           1 :   function approve(address, uint256) external virtual override returns (bool) {
-     127                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     128                 :             :   }
-     129                 :             : 
-     130                 :           1 :   function transferFrom(address, address, uint256) external virtual override returns (bool) {
-     131                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     132                 :             :   }
-     133                 :             : 
-     134                 :           1 :   function increaseAllowance(address, uint256) external virtual override returns (bool) {
-     135                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     136                 :             :   }
-     137                 :             : 
-     138                 :           1 :   function decreaseAllowance(address, uint256) external virtual override returns (bool) {
-     139                 :           2 :     revert(Errors.OPERATION_NOT_SUPPORTED);
-     140                 :             :   }
-     141                 :             : }
-        
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.gcov.html b/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.gcov.html deleted file mode 100644 index f4dc8848..00000000 --- a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.gcov.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - LCOV - lcov.info.p - core/instances/src/core/instances/StableDebtTokenInstance.sol - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - core/instances/src/core/instances - StableDebtTokenInstance.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:88.9 %98
Test Date:2024-04-09 14:12:28Functions:50.0 %21
Branches:-00
-
- - - - - - - - -

-
             Branch data     Line data    Source code
-
-       1                 :             : // SPDX-License-Identifier: MIT
-       2                 :             : pragma solidity ^0.8.0;
-       3                 :             : 
-       4                 :             : import {StableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../contracts/protocol/tokenization/StableDebtToken.sol';
-       5                 :             : 
-       6                 :             : contract StableDebtTokenInstance is StableDebtToken {
-       7                 :             :   uint256 public constant DEBT_TOKEN_REVISION = 1;
-       8                 :             : 
-       9                 :             :   constructor(IPool pool) StableDebtToken(pool) {}
-      10                 :             : 
-      11                 :             :   /// @inheritdoc VersionedInitializable
-      12                 :           0 :   function getRevision() internal pure virtual override returns (uint256) {
-      13                 :           0 :     return DEBT_TOKEN_REVISION;
-      14                 :             :   }
-      15                 :             : 
-      16                 :             :   /// @inheritdoc IInitializableDebtToken
-      17                 :        3476 :   function initialize(
-      18                 :             :     IPool initializingPool,
-      19                 :             :     address underlyingAsset,
-      20                 :             :     IAaveIncentivesController incentivesController,
-      21                 :             :     uint8 debtTokenDecimals,
-      22                 :             :     string memory debtTokenName,
-      23                 :             :     string memory debtTokenSymbol,
-      24                 :             :     bytes calldata params
-      25                 :             :   ) external override initializer {
-      26                 :        6950 :     require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH);
-      27                 :        6948 :     _setName(debtTokenName);
-      28                 :        6948 :     _setSymbol(debtTokenSymbol);
-      29                 :        6948 :     _setDecimals(debtTokenDecimals);
-      30                 :             : 
-      31                 :        6948 :     _underlyingAsset = underlyingAsset;
-      32                 :        6948 :     _incentivesController = incentivesController;
-      33                 :             : 
-      34                 :        6948 :     _domainSeparator = _calculateDomainSeparator();
-      35                 :             : 
-      36                 :        6948 :     emit Initialized(
-      37                 :             :       underlyingAsset,
-      38                 :             :       address(POOL),
-      39                 :             :       address(incentivesController),
-      40                 :             :       debtTokenDecimals,
-      41                 :             :       debtTokenName,
-      42                 :             :       debtTokenSymbol,
-      43                 :             :       params
-      44                 :             :     );
-      45                 :             :   }
-      46                 :             : }
-        
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/coverage.svg b/report/coverage.svg deleted file mode 100644 index 238f1ed5..00000000 --- a/report/coverage.svg +++ /dev/null @@ -1 +0,0 @@ -coverage: 98.3%coverage98.3% \ No newline at end of file diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func-c.html b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func-c.html similarity index 65% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func-c.html rename to report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func-c.html index e6bcdf57..4984f5b9 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func-c.html +++ b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - AaveParaSwapFeeClaimer.sol (source / functions)top level - extensions/paraswap-adapters - AaveParaSwapFeeClaimer.sol (source / functions) Coveragelcov.info.p Lines:100.0 %450.0 %8 4
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
- + + + + + + + + - + @@ -103,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
AaveParaSwapFeeClaimer.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func.html b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func.html similarity index 64% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func.html rename to report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func.html index 57faaedc..3e9f0163 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.func.html +++ b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - AaveParaSwapFeeClaimer.sol (source / functions)top level - extensions/paraswap-adapters - AaveParaSwapFeeClaimer.sol (source / functions) Coveragelcov.info.p Lines:100.0 %450.0 %8 4
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
- + + + + + + + + - + @@ -103,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
AaveParaSwapFeeClaimer.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.gcov.html b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.gcov.html similarity index 76% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.gcov.html rename to report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.gcov.html index ff9ddb78..ff368042 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol.gcov.html +++ b/report/extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/AaveParaSwapFeeClaimer.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/AaveParaSwapFeeClaimer.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - AaveParaSwapFeeClaimer.sol (source / functions)top level - extensions/paraswap-adapters - AaveParaSwapFeeClaimer.sol (source / functions) Coveragelcov.info.p Lines:100.0 %450.0 %8 4
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
@@ -74,7 +74,7 @@ 3 : : pragma solidity ^0.8.0; 4 : : 5 : : import {IFeeClaimer} from './interfaces/IFeeClaimer.sol'; - 6 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; + 6 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 7 : : 8 : : /** 9 : : * @title AaveParaSwapFeeClaimer @@ -87,26 +87,26 @@ 16 : : IFeeClaimer public immutable paraswapFeeClaimer; 17 : : 18 : : constructor(address _aaveCollector, IFeeClaimer _paraswapFeeClaimer) { - 19 : : require(address(_paraswapFeeClaimer) != address(0), 'PARASWAP_FEE_CLAIMER_REQUIRED'); - 20 : : require(_aaveCollector != address(0), 'COLLECTOR_REQUIRED'); - 21 : : aaveCollector = _aaveCollector; - 22 : : paraswapFeeClaimer = _paraswapFeeClaimer; + 19 : 0 : require(address(_paraswapFeeClaimer) != address(0), 'PARASWAP_FEE_CLAIMER_REQUIRED'); + 20 : 0 : require(_aaveCollector != address(0), 'COLLECTOR_REQUIRED'); + 21 : 0 : aaveCollector = _aaveCollector; + 22 : 0 : paraswapFeeClaimer = _paraswapFeeClaimer; 23 : : } 24 : : 25 : : /** 26 : : * @dev returns claimable balance for a specified asset 27 : : * @param asset The asset to fetch claimable balance of 28 : : */ - 29 : 5 : function getClaimable(address asset) public view returns (uint256) { - 30 : 15 : return paraswapFeeClaimer.getBalance(IERC20(asset), address(this)); + 29 : : function getClaimable(address asset) external view returns (uint256) { + 30 : 5 : return paraswapFeeClaimer.getBalance(IERC20(asset), address(this)); 31 : : } 32 : : 33 : : /** 34 : : * @dev returns claimable balances for specified assets 35 : : * @param assets The assets to fetch claimable balances of 36 : : */ - 37 : 1 : function batchGetClaimable(address[] memory assets) public view returns (uint256[] memory) { - 38 : 3 : return paraswapFeeClaimer.batchGetBalance(assets, address(this)); + 37 : : function batchGetClaimable(address[] memory assets) external view returns (uint256[] memory) { + 38 : 1 : return paraswapFeeClaimer.batchGetBalance(assets, address(this)); 39 : : } 40 : : 41 : : /** @@ -114,8 +114,8 @@ 43 : : * @notice will revert when there's nothing to claim 44 : : * @param asset The asset to claim rewards of 45 : : */ - 46 : 1 : function claimToCollector(IERC20 asset) external { - 47 : 2 : paraswapFeeClaimer.withdrawAllERC20(asset, aaveCollector); + 46 : : function claimToCollector(IERC20 asset) external { + 47 : 1 : paraswapFeeClaimer.withdrawAllERC20(asset, aaveCollector); 48 : : } 49 : : 50 : : /** @@ -123,8 +123,8 @@ 52 : : * @notice will revert when there's nothing to claim on a single supplied asset 53 : : * @param assets The assets to claim rewards of 54 : : */ - 55 : 1 : function batchClaimToCollector(address[] memory assets) external { - 56 : 2 : paraswapFeeClaimer.batchWithdrawAllERC20(assets, aaveCollector); + 55 : : function batchClaimToCollector(address[] memory assets) external { + 56 : 1 : paraswapFeeClaimer.batchWithdrawAllERC20(assets, aaveCollector); 57 : : } 58 : : } @@ -134,8 +134,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func-c.html b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func-c.html similarity index 66% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func-c.html rename to report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func-c.html index dcbd91b9..84c9b528 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func-c.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1292.3 %13 12
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + + + + + + + + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
BaseParaSwapAdapter.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func.html b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func.html similarity index 66% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func.html rename to report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func.html index c3716a1f..f53ebc8b 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.func.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1292.3 %13 12
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + + + + + + + + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
BaseParaSwapAdapter.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.gcov.html similarity index 81% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.gcov.html index a3f06783..50495699 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1292.3 %13 12
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
@@ -72,16 +72,16 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; - 5 : : import {FlashLoanSimpleReceiverBase} from 'aave-v3-core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol'; - 6 : : import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; - 7 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; - 8 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 9 : : import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; - 10 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; - 11 : : import {IPriceOracleGetter} from 'aave-v3-core/contracts/interfaces/IPriceOracleGetter.sol'; - 12 : : import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; - 13 : : import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; + 4 : : import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; + 5 : : import {FlashLoanSimpleReceiverBase} from '../../misc/flashloan/base/FlashLoanSimpleReceiverBase.sol'; + 6 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; + 7 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; + 8 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 9 : : import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; + 10 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 11 : : import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; + 12 : : import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; + 13 : : import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; 14 : : 15 : : /** 16 : : * @title BaseParaSwapAdapter @@ -123,7 +123,7 @@ 52 : : constructor( 53 : : IPoolAddressesProvider addressesProvider 54 : : ) FlashLoanSimpleReceiverBase(addressesProvider) { - 55 : : ORACLE = IPriceOracleGetter(addressesProvider.getPriceOracle()); + 55 : 0 : ORACLE = IPriceOracleGetter(addressesProvider.getPriceOracle()); 56 : : } 57 : : 58 : : /** @@ -131,41 +131,41 @@ 60 : : * @param asset address 61 : : * @return eth price for the asset 62 : : */ - 63 : 30 : function _getPrice(address asset) internal view returns (uint256) { - 64 : 90 : return ORACLE.getAssetPrice(asset); + 63 : : function _getPrice(address asset) internal view returns (uint256) { + 64 : 30 : return ORACLE.getAssetPrice(asset); 65 : : } 66 : : 67 : : /** 68 : : * @dev Get the decimals of an asset 69 : : * @return number of decimals of the asset 70 : : */ - 71 : 30 : function _getDecimals(IERC20Detailed asset) internal view returns (uint8) { - 72 : 90 : uint8 decimals = asset.decimals(); + 71 : : function _getDecimals(IERC20Detailed asset) internal view returns (uint8) { + 72 : 30 : uint8 decimals = asset.decimals(); 73 : : // Ensure 10**decimals won't overflow a uint256 - 74 : 60 : require(decimals <= 77, 'TOO_MANY_DECIMALS_ON_TOKEN'); - 75 : 60 : return decimals; + 74 : 30 : require(decimals <= 77, 'TOO_MANY_DECIMALS_ON_TOKEN'); + 75 : 30 : return decimals; 76 : : } 77 : : 78 : : /** 79 : : * @dev Get the aToken associated to the asset 80 : : * @return address of the aToken 81 : : */ - 82 : 21 : function _getReserveData( + 82 : : function _getReserveData( 83 : : address asset 84 : : ) internal view returns (DataTypes.ReserveDataLegacy memory) { - 85 : 63 : return POOL.getReserveData(asset); + 85 : 21 : return POOL.getReserveData(asset); 86 : : } 87 : : - 88 : 20 : function _pullATokenAndWithdraw( + 88 : : function _pullATokenAndWithdraw( 89 : : address reserve, 90 : : address user, 91 : : uint256 amount, 92 : : PermitSignature memory permitSignature 93 : : ) internal { - 94 : 18 : IERC20WithPermit reserveAToken = IERC20WithPermit( + 94 : 6 : IERC20WithPermit reserveAToken = IERC20WithPermit( 95 : : _getReserveData(address(reserve)).aTokenAddress 96 : : ); - 97 : 12 : _pullATokenAndWithdraw(reserve, reserveAToken, user, amount, permitSignature); + 97 : 6 : _pullATokenAndWithdraw(reserve, reserveAToken, user, amount, permitSignature); 98 : : } 99 : : 100 : : /** @@ -184,8 +184,8 @@ 113 : : PermitSignature memory permitSignature 114 : : ) internal { 115 : : // If deadline is set to zero, assume there is no signature for permit - 116 : 28 : if (permitSignature.deadline != 0) { - 117 : 10 : reserveAToken.permit( + 116 : 14 : if (permitSignature.deadline != 0) { + 117 : 5 : reserveAToken.permit( 118 : : user, 119 : : address(this), 120 : : permitSignature.amount, @@ -197,10 +197,10 @@ 126 : : } 127 : : 128 : : // transfer from user to adapter - 129 : 28 : reserveAToken.safeTransferFrom(user, address(this), amount); + 129 : 14 : reserveAToken.safeTransferFrom(user, address(this), amount); 130 : : 131 : : // withdraw reserve - 132 : 28 : require(POOL.withdraw(reserve, amount, address(this)) == amount, 'UNEXPECTED_AMOUNT_WITHDRAWN'); + 132 : 14 : require(POOL.withdraw(reserve, amount, address(this)) == amount, 'UNEXPECTED_AMOUNT_WITHDRAWN'); 133 : : } 134 : : 135 : : /** @@ -208,8 +208,8 @@ 137 : : * - Funds should never remain in this contract more time than during transactions 138 : : * - Only callable by the owner 139 : : */ - 140 : 1 : function rescueTokens(IERC20 token) external onlyOwner { - 141 : 2 : token.safeTransfer(owner(), token.balanceOf(address(this))); + 140 : : function rescueTokens(IERC20 token) external onlyOwner { + 141 : 1 : token.safeTransfer(owner(), token.balanceOf(address(this))); 142 : : } 143 : : } @@ -219,8 +219,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func-c.html b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func-c.html similarity index 59% rename from report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func-c.html rename to report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func-c.html index 34e84f9b..af5a5341 100644 --- a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func-c.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/VariableDebtTokenInstance.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - VariableDebtTokenInstance.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapBuyAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %9882.8 %2924
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 50.0 %0 0
- + - + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
VariableDebtTokenInstance.getRevisionBaseParaSwapBuyAdapter. 0
VariableDebtTokenInstance.initializeBaseParaSwapBuyAdapter._buyOnParaSwap34786
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func.html b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func.html similarity index 59% rename from report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func.html rename to report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func.html index b9085eeb..310f2da3 100644 --- a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/StableDebtTokenInstance.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - StableDebtTokenInstance.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapBuyAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %9882.8 %2924
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 50.0 %0 0
- + - + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
StableDebtTokenInstance.getRevisionBaseParaSwapBuyAdapter. 0
StableDebtTokenInstance.initializeBaseParaSwapBuyAdapter._buyOnParaSwap34766
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.gcov.html similarity index 75% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.gcov.html index 221a762a..5500645a 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapBuyAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapBuyAdapter.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapBuyAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %2482.8 %29 24
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %150.0 %2 1
0 0
@@ -72,11 +72,11 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; - 5 : : import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; - 6 : : import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; - 7 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; - 8 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 4 : : import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; + 5 : : import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; + 6 : : import {PercentageMath} from '../../protocol/libraries/math/PercentageMath.sol'; + 7 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 8 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; 9 : : import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; 10 : : import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; 11 : : import {BaseParaSwapAdapter} from './BaseParaSwapAdapter.sol'; @@ -97,8 +97,8 @@ 26 : : IParaSwapAugustusRegistry augustusRegistry 27 : : ) BaseParaSwapAdapter(addressesProvider) { 28 : : // Do something on Augustus registry to check the right contract was passed - 29 : : require(!augustusRegistry.isValidAugustus(address(0)), 'Not a valid Augustus address'); - 30 : : AUGUSTUS_REGISTRY = augustusRegistry; + 29 : 0 : require(!augustusRegistry.isValidAugustus(address(0)), 'Not a valid Augustus address'); + 30 : 0 : AUGUSTUS_REGISTRY = augustusRegistry; 31 : : } 32 : : 33 : : /** @@ -110,49 +110,49 @@ 39 : : * @param maxAmountToSwap Max amount to be swapped 40 : : * @param amountToReceive Amount to be received from the swap 41 : : * @return amountSold The amount sold during the swap - 42 : : */ - 43 : 6 : function _buyOnParaSwap( - 44 : : uint256 toAmountOffset, - 45 : : bytes memory paraswapData, - 46 : : IERC20Detailed assetToSwapFrom, - 47 : : IERC20Detailed assetToSwapTo, - 48 : : uint256 maxAmountToSwap, - 49 : : uint256 amountToReceive - 50 : : ) internal returns (uint256 amountSold) { - 51 : 18 : (bytes memory buyCalldata, IParaSwapAugustus augustus) = abi.decode( - 52 : : paraswapData, - 53 : : (bytes, IParaSwapAugustus) - 54 : : ); - 55 : : - 56 : 12 : require(AUGUSTUS_REGISTRY.isValidAugustus(address(augustus)), 'INVALID_AUGUSTUS'); - 57 : : - 58 : : { - 59 : 18 : uint256 fromAssetDecimals = _getDecimals(assetToSwapFrom); - 60 : 18 : uint256 toAssetDecimals = _getDecimals(assetToSwapTo); - 61 : : - 62 : 18 : uint256 fromAssetPrice = _getPrice(address(assetToSwapFrom)); - 63 : 18 : uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); - 64 : : - 65 : 18 : uint256 expectedMaxAmountToSwap = amountToReceive - 66 : : .mul(toAssetPrice.mul(10 ** fromAssetDecimals)) - 67 : : .div(fromAssetPrice.mul(10 ** toAssetDecimals)) - 68 : : .percentMul(PercentageMath.PERCENTAGE_FACTOR.add(MAX_SLIPPAGE_PERCENT)); - 69 : : - 70 : 12 : require(maxAmountToSwap <= expectedMaxAmountToSwap, 'maxAmountToSwap exceed max slippage'); - 71 : : } - 72 : : - 73 : 18 : uint256 balanceBeforeAssetFrom = assetToSwapFrom.balanceOf(address(this)); - 74 : 12 : require(balanceBeforeAssetFrom >= maxAmountToSwap, 'INSUFFICIENT_BALANCE_BEFORE_SWAP'); - 75 : 18 : uint256 balanceBeforeAssetTo = assetToSwapTo.balanceOf(address(this)); - 76 : : - 77 : 18 : address tokenTransferProxy = augustus.getTokenTransferProxy(); - 78 : 12 : assetToSwapFrom.safeApprove(tokenTransferProxy, 0); - 79 : 12 : assetToSwapFrom.safeApprove(tokenTransferProxy, maxAmountToSwap); + 42 : : * @return amountBought The amount bought during the swap + 43 : : */ + 44 : : function _buyOnParaSwap( + 45 : : uint256 toAmountOffset, + 46 : : bytes memory paraswapData, + 47 : : IERC20Detailed assetToSwapFrom, + 48 : : IERC20Detailed assetToSwapTo, + 49 : : uint256 maxAmountToSwap, + 50 : : uint256 amountToReceive + 51 : : ) internal returns (uint256 amountSold, uint256 amountBought) { + 52 : 6 : (bytes memory buyCalldata, IParaSwapAugustus augustus) = abi.decode( + 53 : : paraswapData, + 54 : : (bytes, IParaSwapAugustus) + 55 : : ); + 56 : : + 57 : 6 : require(AUGUSTUS_REGISTRY.isValidAugustus(address(augustus)), 'INVALID_AUGUSTUS'); + 58 : : + 59 : : { + 60 : 6 : uint256 fromAssetDecimals = _getDecimals(assetToSwapFrom); + 61 : 6 : uint256 toAssetDecimals = _getDecimals(assetToSwapTo); + 62 : : + 63 : 6 : uint256 fromAssetPrice = _getPrice(address(assetToSwapFrom)); + 64 : 6 : uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); + 65 : : + 66 : 6 : uint256 expectedMaxAmountToSwap = amountToReceive + 67 : : .mul(toAssetPrice.mul(10 ** fromAssetDecimals)) + 68 : : .div(fromAssetPrice.mul(10 ** toAssetDecimals)) + 69 : : .percentMul(PercentageMath.PERCENTAGE_FACTOR.add(MAX_SLIPPAGE_PERCENT)); + 70 : : + 71 : 6 : require(maxAmountToSwap <= expectedMaxAmountToSwap, 'maxAmountToSwap exceed max slippage'); + 72 : : } + 73 : : + 74 : 6 : uint256 balanceBeforeAssetFrom = assetToSwapFrom.balanceOf(address(this)); + 75 : 6 : require(balanceBeforeAssetFrom >= maxAmountToSwap, 'INSUFFICIENT_BALANCE_BEFORE_SWAP'); + 76 : 6 : uint256 balanceBeforeAssetTo = assetToSwapTo.balanceOf(address(this)); + 77 : : + 78 : 6 : address tokenTransferProxy = augustus.getTokenTransferProxy(); + 79 : 6 : assetToSwapFrom.safeApprove(tokenTransferProxy, maxAmountToSwap); 80 : : - 81 : 12 : if (toAmountOffset != 0) { + 81 : 6 : if (toAmountOffset != 0) { 82 : : // Ensure 256 bit (32 bytes) toAmountOffset value is within bounds of the 83 : : // calldata, not overlapping with the first 4 bytes (function selector). - 84 : 2 : require( + 84 : 1 : require( 85 : : toAmountOffset >= 4 && toAmountOffset <= buyCalldata.length.sub(32), 86 : : 'TO_AMOUNT_OFFSET_OUT_OF_RANGE' 87 : : ); @@ -160,27 +160,30 @@ 89 : : // In memory, buyCalldata consists of a 256 bit length field, followed by 90 : : // the actual bytes data, that is why 32 is added to the byte offset. 91 : : assembly { - 92 : : mstore(add(buyCalldata, add(toAmountOffset, 32)), amountToReceive) + 92 : 0 : mstore(add(buyCalldata, add(toAmountOffset, 32)), amountToReceive) 93 : : } 94 : : } - 95 : 15 : (bool success, ) = address(augustus).call(buyCalldata); - 96 : 10 : if (!success) { + 95 : 5 : (bool success, ) = address(augustus).call(buyCalldata); + 96 : 5 : if (!success) { 97 : : // Copy revert reason from call 98 : : assembly { - 99 : : returndatacopy(0, 0, returndatasize()) - 100 : : revert(0, returndatasize()) + 99 : 0 : returndatacopy(0, 0, returndatasize()) + 100 : 0 : revert(0, returndatasize()) 101 : : } 102 : : } 103 : : - 104 : 15 : uint256 balanceAfterAssetFrom = assetToSwapFrom.balanceOf(address(this)); - 105 : 10 : amountSold = balanceBeforeAssetFrom - balanceAfterAssetFrom; - 106 : 10 : require(amountSold <= maxAmountToSwap, 'WRONG_BALANCE_AFTER_SWAP'); - 107 : 15 : uint256 amountReceived = assetToSwapTo.balanceOf(address(this)).sub(balanceBeforeAssetTo); - 108 : 10 : require(amountReceived >= amountToReceive, 'INSUFFICIENT_AMOUNT_RECEIVED'); - 109 : : - 110 : 10 : emit Bought(address(assetToSwapFrom), address(assetToSwapTo), amountSold, amountReceived); - 111 : : } - 112 : : } + 104 : : // Reset allowance + 105 : 5 : assetToSwapFrom.safeApprove(tokenTransferProxy, 0); + 106 : : + 107 : 5 : uint256 balanceAfterAssetFrom = assetToSwapFrom.balanceOf(address(this)); + 108 : 5 : amountSold = balanceBeforeAssetFrom - balanceAfterAssetFrom; + 109 : 5 : require(amountSold <= maxAmountToSwap, 'WRONG_BALANCE_AFTER_SWAP'); + 110 : 5 : amountBought = assetToSwapTo.balanceOf(address(this)).sub(balanceBeforeAssetTo); + 111 : 5 : require(amountBought >= amountToReceive, 'INSUFFICIENT_AMOUNT_RECEIVED'); + 112 : : + 113 : 5 : emit Bought(address(assetToSwapFrom), address(assetToSwapTo), amountSold, amountBought); + 114 : : } + 115 : : } @@ -188,8 +191,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func-c.html b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func-c.html similarity index 59% rename from report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func-c.html rename to report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func-c.html index 405abeaf..c8215b33 100644 --- a/report/core/instances/src/core/instances/StableDebtTokenInstance.sol.func-c.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/StableDebtTokenInstance.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - StableDebtTokenInstance.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapSellAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %9880.8 %2621
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 50.0 %0 0
- + - + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
StableDebtTokenInstance.getRevisionBaseParaSwapSellAdapter. 0
StableDebtTokenInstance.initializeBaseParaSwapSellAdapter._sellOnParaSwap34769
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func.html b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func.html similarity index 59% rename from report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func.html rename to report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func.html index 2b0b5821..0c5f7eb6 100644 --- a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.func.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/VariableDebtTokenInstance.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - VariableDebtTokenInstance.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapSellAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %9880.8 %2621
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 50.0 %0 0
- + - + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
VariableDebtTokenInstance.getRevisionBaseParaSwapSellAdapter. 0
VariableDebtTokenInstance.initializeBaseParaSwapSellAdapter._sellOnParaSwap34789
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.gcov.html similarity index 79% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.gcov.html index 485592d0..98a66965 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/BaseParaSwapSellAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapSellAdapter.sol (source / functions)top level - extensions/paraswap-adapters - BaseParaSwapSellAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %2180.8 %26 21
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %150.0 %2 1
0 0
@@ -72,11 +72,11 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; - 5 : : import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; - 6 : : import {PercentageMath} from 'aave-v3-core/contracts/protocol/libraries/math/PercentageMath.sol'; - 7 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; - 8 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 4 : : import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; + 5 : : import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; + 6 : : import {PercentageMath} from '../../protocol/libraries/math/PercentageMath.sol'; + 7 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 8 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; 9 : : import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; 10 : : import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; 11 : : import {BaseParaSwapAdapter} from './BaseParaSwapAdapter.sol'; @@ -98,8 +98,8 @@ 27 : : IParaSwapAugustusRegistry augustusRegistry 28 : : ) BaseParaSwapAdapter(addressesProvider) { 29 : : // Do something on Augustus registry to check the right contract was passed - 30 : : require(!augustusRegistry.isValidAugustus(address(0))); - 31 : : AUGUSTUS_REGISTRY = augustusRegistry; + 30 : 0 : require(!augustusRegistry.isValidAugustus(address(0))); + 31 : 0 : AUGUSTUS_REGISTRY = augustusRegistry; 32 : : } 33 : : 34 : : /** @@ -113,7 +113,7 @@ 42 : : * @param minAmountToReceive Minimum amount to be received from the swap 43 : : * @return amountReceived The amount received from the swap 44 : : */ - 45 : 9 : function _sellOnParaSwap( + 45 : : function _sellOnParaSwap( 46 : : uint256 fromAmountOffset, 47 : : bytes memory swapCalldata, 48 : : IParaSwapAugustus augustus, @@ -122,35 +122,35 @@ 51 : : uint256 amountToSwap, 52 : : uint256 minAmountToReceive 53 : : ) internal returns (uint256 amountReceived) { - 54 : 18 : require(AUGUSTUS_REGISTRY.isValidAugustus(address(augustus)), 'INVALID_AUGUSTUS'); + 54 : 9 : require(AUGUSTUS_REGISTRY.isValidAugustus(address(augustus)), 'INVALID_AUGUSTUS'); 55 : : 56 : : { - 57 : 27 : uint256 fromAssetDecimals = _getDecimals(assetToSwapFrom); - 58 : 27 : uint256 toAssetDecimals = _getDecimals(assetToSwapTo); + 57 : 9 : uint256 fromAssetDecimals = _getDecimals(assetToSwapFrom); + 58 : 9 : uint256 toAssetDecimals = _getDecimals(assetToSwapTo); 59 : : - 60 : 27 : uint256 fromAssetPrice = _getPrice(address(assetToSwapFrom)); - 61 : 27 : uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); + 60 : 9 : uint256 fromAssetPrice = _getPrice(address(assetToSwapFrom)); + 61 : 9 : uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); 62 : : - 63 : 27 : uint256 expectedMinAmountOut = amountToSwap + 63 : 9 : uint256 expectedMinAmountOut = amountToSwap 64 : : .mul(fromAssetPrice.mul(10 ** toAssetDecimals)) 65 : : .div(toAssetPrice.mul(10 ** fromAssetDecimals)) 66 : : .percentMul(PercentageMath.PERCENTAGE_FACTOR - MAX_SLIPPAGE_PERCENT); 67 : : - 68 : 18 : require(expectedMinAmountOut <= minAmountToReceive, 'MIN_AMOUNT_EXCEEDS_MAX_SLIPPAGE'); + 68 : 9 : require(expectedMinAmountOut <= minAmountToReceive, 'MIN_AMOUNT_EXCEEDS_MAX_SLIPPAGE'); 69 : : } 70 : : - 71 : 27 : uint256 balanceBeforeAssetFrom = assetToSwapFrom.balanceOf(address(this)); - 72 : 18 : require(balanceBeforeAssetFrom >= amountToSwap, 'INSUFFICIENT_BALANCE_BEFORE_SWAP'); - 73 : 27 : uint256 balanceBeforeAssetTo = assetToSwapTo.balanceOf(address(this)); + 71 : 9 : uint256 balanceBeforeAssetFrom = assetToSwapFrom.balanceOf(address(this)); + 72 : 9 : require(balanceBeforeAssetFrom >= amountToSwap, 'INSUFFICIENT_BALANCE_BEFORE_SWAP'); + 73 : 9 : uint256 balanceBeforeAssetTo = assetToSwapTo.balanceOf(address(this)); 74 : : - 75 : 27 : address tokenTransferProxy = augustus.getTokenTransferProxy(); - 76 : 18 : assetToSwapFrom.safeApprove(tokenTransferProxy, 0); - 77 : 18 : assetToSwapFrom.safeApprove(tokenTransferProxy, amountToSwap); + 75 : 9 : address tokenTransferProxy = augustus.getTokenTransferProxy(); + 76 : 9 : assetToSwapFrom.safeApprove(tokenTransferProxy, 0); + 77 : 9 : assetToSwapFrom.safeApprove(tokenTransferProxy, amountToSwap); 78 : : - 79 : 18 : if (fromAmountOffset != 0) { + 79 : 9 : if (fromAmountOffset != 0) { 80 : : // Ensure 256 bit (32 bytes) fromAmount value is within bounds of the 81 : : // calldata, not overlapping with the first 4 bytes (function selector). - 82 : 6 : require( + 82 : 3 : require( 83 : : fromAmountOffset >= 4 && fromAmountOffset <= swapCalldata.length.sub(32), 84 : : 'FROM_AMOUNT_OFFSET_OUT_OF_RANGE' 85 : : ); @@ -158,27 +158,28 @@ 87 : : // In memory, swapCalldata consists of a 256 bit length field, followed by 88 : : // the actual bytes data, that is why 32 is added to the byte offset. 89 : : assembly { - 90 : : mstore(add(swapCalldata, add(fromAmountOffset, 32)), amountToSwap) + 90 : 0 : mstore(add(swapCalldata, add(fromAmountOffset, 32)), amountToSwap) 91 : : } 92 : : } - 93 : 18 : (bool success, ) = address(augustus).call(swapCalldata); - 94 : 12 : if (!success) { + 93 : 6 : (bool success, ) = address(augustus).call(swapCalldata); + 94 : 6 : if (!success) { 95 : : // Copy revert reason from call 96 : : assembly { - 97 : : returndatacopy(0, 0, returndatasize()) - 98 : : revert(0, returndatasize()) + 97 : 0 : returndatacopy(0, 0, returndatasize()) + 98 : 0 : revert(0, returndatasize()) 99 : : } 100 : : } - 101 : 12 : require( - 102 : : assetToSwapFrom.balanceOf(address(this)) == balanceBeforeAssetFrom - amountToSwap, - 103 : : 'WRONG_BALANCE_AFTER_SWAP' - 104 : : ); - 105 : 12 : amountReceived = assetToSwapTo.balanceOf(address(this)).sub(balanceBeforeAssetTo); - 106 : 12 : require(amountReceived >= minAmountToReceive, 'INSUFFICIENT_AMOUNT_RECEIVED'); - 107 : : - 108 : 12 : emit Swapped(address(assetToSwapFrom), address(assetToSwapTo), amountToSwap, amountReceived); - 109 : : } - 110 : : } + 101 : : + 102 : 6 : require( + 103 : : assetToSwapFrom.balanceOf(address(this)) == balanceBeforeAssetFrom - amountToSwap, + 104 : : 'WRONG_BALANCE_AFTER_SWAP' + 105 : : ); + 106 : 6 : amountReceived = assetToSwapTo.balanceOf(address(this)).sub(balanceBeforeAssetTo); + 107 : 6 : require(amountReceived >= minAmountToReceive, 'INSUFFICIENT_AMOUNT_RECEIVED'); + 108 : : + 109 : 6 : emit Swapped(address(assetToSwapFrom), address(assetToSwapTo), amountToSwap, amountReceived); + 110 : : } + 111 : : } @@ -186,8 +187,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func-c.html b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func-c.html similarity index 64% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func-c.html rename to report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func-c.html index 8a0f181f..399ff583 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func-c.html +++ b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapLiquiditySwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapLiquiditySwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %3497.1 %35 34
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %375.0 %4 3
0 0
- + + + + + + + + - + @@ -96,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ParaSwapLiquiditySwapAdapter.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func.html b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func.html similarity index 64% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func.html rename to report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func.html index 1bcf5d38..e628152b 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.func.html +++ b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapLiquiditySwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapLiquiditySwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %3497.1 %35 34
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %375.0 %4 3
0 0
- + + + + + + + + - + @@ -96,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ParaSwapLiquiditySwapAdapter.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.gcov.html similarity index 86% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.gcov.html index 63a5e17b..7f70f051 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapLiquiditySwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapLiquiditySwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %3497.1 %35 34
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %375.0 %4 3
0 0
@@ -72,11 +72,11 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 5 : : import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; - 6 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; - 7 : : import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; - 8 : : import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; + 4 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 5 : : import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; + 6 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 7 : : import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; + 8 : : import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; 9 : : import {BaseParaSwapSellAdapter} from './BaseParaSwapSellAdapter.sol'; 10 : : import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; 11 : : import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; @@ -96,7 +96,7 @@ 25 : : IParaSwapAugustusRegistry augustusRegistry, 26 : : address owner 27 : : ) BaseParaSwapSellAdapter(addressesProvider, augustusRegistry) { - 28 : : transferOwnership(owner); + 28 : 0 : transferOwnership(owner); 29 : : } 30 : : 31 : : /** @@ -116,32 +116,32 @@ 45 : : * address augustus Address of ParaSwap's AugustusSwapper contract 46 : : * PermitSignature permitParams Struct containing the permit signatures, set to all zeroes if not used 47 : : */ - 48 : 3 : function executeOperation( + 48 : : function executeOperation( 49 : : address asset, 50 : : uint256 amount, 51 : : uint256 premium, 52 : : address initiator, 53 : : bytes calldata params 54 : : ) external override nonReentrant returns (bool) { - 55 : 6 : require(msg.sender == address(POOL), 'CALLER_MUST_BE_POOL'); + 55 : 3 : require(msg.sender == address(POOL), 'CALLER_MUST_BE_POOL'); 56 : : - 57 : 6 : uint256 flashLoanAmount = amount; - 58 : 6 : uint256 premiumLocal = premium; - 59 : 6 : address initiatorLocal = initiator; - 60 : 9 : IERC20Detailed assetToSwapFrom = IERC20Detailed(asset); - 61 : 6 : ( + 57 : 3 : uint256 flashLoanAmount = amount; + 58 : 3 : uint256 premiumLocal = premium; + 59 : 3 : address initiatorLocal = initiator; + 60 : 3 : IERC20Detailed assetToSwapFrom = IERC20Detailed(asset); + 61 : 3 : ( 62 : : IERC20Detailed assetToSwapTo, 63 : : uint256 minAmountToReceive, 64 : : uint256 swapAllBalanceOffset, 65 : : bytes memory swapCalldata, 66 : : IParaSwapAugustus augustus, 67 : : PermitSignature memory permitParams - 68 : 6 : ) = abi.decode( + 68 : 3 : ) = abi.decode( 69 : : params, 70 : : (IERC20Detailed, uint256, uint256, bytes, IParaSwapAugustus, PermitSignature) 71 : : ); 72 : : - 73 : 6 : _swapLiquidity( + 73 : 3 : _swapLiquidity( 74 : : swapAllBalanceOffset, 75 : : swapCalldata, 76 : : augustus, @@ -154,7 +154,7 @@ 83 : : minAmountToReceive 84 : : ); 85 : : - 86 : 4 : return true; + 86 : 2 : return true; 87 : : } 88 : : 89 : : /** @@ -170,7 +170,7 @@ 99 : : * @param augustus Address of ParaSwap's AugustusSwapper contract 100 : : * @param permitParams Struct containing the permit signatures, set to all zeroes if not used 101 : : */ - 102 : 3 : function swapAndDeposit( + 102 : : function swapAndDeposit( 103 : : IERC20Detailed assetToSwapFrom, 104 : : IERC20Detailed assetToSwapTo, 105 : : uint256 amountToSwap, @@ -180,17 +180,17 @@ 109 : : IParaSwapAugustus augustus, 110 : : PermitSignature calldata permitParams 111 : : ) external nonReentrant { - 112 : 9 : IERC20WithPermit aToken = IERC20WithPermit( + 112 : 3 : IERC20WithPermit aToken = IERC20WithPermit( 113 : : _getReserveData(address(assetToSwapFrom)).aTokenAddress 114 : : ); 115 : : - 116 : 6 : if (swapAllBalanceOffset != 0) { - 117 : 3 : uint256 balance = aToken.balanceOf(msg.sender); - 118 : 2 : require(balance <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); - 119 : 2 : amountToSwap = balance; + 116 : 3 : if (swapAllBalanceOffset != 0) { + 117 : 1 : uint256 balance = aToken.balanceOf(msg.sender); + 118 : 1 : require(balance <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); + 119 : 1 : amountToSwap = balance; 120 : : } 121 : : - 122 : 6 : _pullATokenAndWithdraw( + 122 : 3 : _pullATokenAndWithdraw( 123 : : address(assetToSwapFrom), 124 : : aToken, 125 : : msg.sender, @@ -198,7 +198,7 @@ 127 : : permitParams 128 : : ); 129 : : - 130 : 9 : uint256 amountReceived = _sellOnParaSwap( + 130 : 3 : uint256 amountReceived = _sellOnParaSwap( 131 : : swapAllBalanceOffset, 132 : : swapCalldata, 133 : : augustus, @@ -208,9 +208,9 @@ 137 : : minAmountToReceive 138 : : ); 139 : : - 140 : 4 : assetToSwapTo.safeApprove(address(POOL), 0); - 141 : 4 : assetToSwapTo.safeApprove(address(POOL), amountReceived); - 142 : 4 : POOL.deposit(address(assetToSwapTo), amountReceived, msg.sender, 0); + 140 : 2 : assetToSwapTo.safeApprove(address(POOL), 0); + 141 : 2 : assetToSwapTo.safeApprove(address(POOL), amountReceived); + 142 : 2 : POOL.deposit(address(assetToSwapTo), amountReceived, msg.sender, 0); 143 : : } 144 : : 145 : : /** @@ -226,7 +226,7 @@ 155 : : * @param assetToSwapTo Address of the underlying asset to be swapped to and deposited 156 : : * @param minAmountToReceive Min amount to be received from the swap 157 : : */ - 158 : 3 : function _swapLiquidity( + 158 : : function _swapLiquidity( 159 : : uint256 swapAllBalanceOffset, 160 : : bytes memory swapCalldata, 161 : : IParaSwapAugustus augustus, @@ -238,21 +238,21 @@ 167 : : IERC20Detailed assetToSwapTo, 168 : : uint256 minAmountToReceive 169 : : ) internal { - 170 : 9 : IERC20WithPermit aToken = IERC20WithPermit( + 170 : 3 : IERC20WithPermit aToken = IERC20WithPermit( 171 : : _getReserveData(address(assetToSwapFrom)).aTokenAddress 172 : : ); - 173 : 6 : uint256 amountToSwap = flashLoanAmount; + 173 : 3 : uint256 amountToSwap = flashLoanAmount; 174 : : - 175 : 9 : uint256 balance = aToken.balanceOf(initiator); - 176 : 6 : if (swapAllBalanceOffset != 0) { - 177 : 3 : uint256 balanceToSwap = balance.sub(premium); - 178 : 2 : require(balanceToSwap <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); - 179 : 2 : amountToSwap = balanceToSwap; + 175 : 3 : uint256 balance = aToken.balanceOf(initiator); + 176 : 3 : if (swapAllBalanceOffset != 0) { + 177 : 1 : uint256 balanceToSwap = balance.sub(premium); + 178 : 1 : require(balanceToSwap <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); + 179 : 1 : amountToSwap = balanceToSwap; 180 : : } else { - 181 : 4 : require(balance >= amountToSwap.add(premium), 'INSUFFICIENT_ATOKEN_BALANCE'); + 181 : 2 : require(balance >= amountToSwap.add(premium), 'INSUFFICIENT_ATOKEN_BALANCE'); 182 : : } 183 : : - 184 : 9 : uint256 amountReceived = _sellOnParaSwap( + 184 : 3 : uint256 amountReceived = _sellOnParaSwap( 185 : : swapAllBalanceOffset, 186 : : swapCalldata, 187 : : augustus, @@ -262,11 +262,11 @@ 191 : : minAmountToReceive 192 : : ); 193 : : - 194 : 4 : assetToSwapTo.safeApprove(address(POOL), 0); - 195 : 4 : assetToSwapTo.safeApprove(address(POOL), amountReceived); - 196 : 4 : POOL.deposit(address(assetToSwapTo), amountReceived, initiator, 0); + 194 : 2 : assetToSwapTo.safeApprove(address(POOL), 0); + 195 : 2 : assetToSwapTo.safeApprove(address(POOL), amountReceived); + 196 : 2 : POOL.deposit(address(assetToSwapTo), amountReceived, initiator, 0); 197 : : - 198 : 4 : _pullATokenAndWithdraw( + 198 : 2 : _pullATokenAndWithdraw( 199 : : address(assetToSwapFrom), 200 : : aToken, 201 : : initiator, @@ -275,8 +275,8 @@ 204 : : ); 205 : : 206 : : // Repay flash loan - 207 : 4 : assetToSwapFrom.safeApprove(address(POOL), 0); - 208 : 4 : assetToSwapFrom.safeApprove(address(POOL), flashLoanAmount.add(premium)); + 207 : 2 : assetToSwapFrom.safeApprove(address(POOL), 0); + 208 : 2 : assetToSwapFrom.safeApprove(address(POOL), flashLoanAmount.add(premium)); 209 : : } 210 : : } @@ -286,8 +286,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func-c.html b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func-c.html similarity index 61% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func-c.html rename to report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func-c.html index 09b21b97..542c078b 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func-c.html +++ b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapRepayAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - - + + + - + - - + + @@ -53,26 +53,33 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapRepayAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapRepayAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %363693.0 %4340
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
- + + + + + + + + - + - + @@ -93,7 +100,7 @@ - + @@ -103,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ParaSwapRepayAdapter.Hit count Sort by function hit count0
ParaSwapRepayAdapter._swapAndRepayParaSwapRepayAdapter._swapAndRepay 2
ParaSwapRepayAdapter.getDebtRepayAmountParaSwapRepayAdapter.getDebtRepayAmount 6
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func.html b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func.html similarity index 61% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func.html rename to report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func.html index fc79c5bb..9a5fa9b0 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.func.html +++ b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapRepayAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - - + + + - + - - + + @@ -53,26 +53,33 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapRepayAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapRepayAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %363693.0 %4340
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
- + + + + + + + + - + - + @@ -86,7 +93,7 @@ - + @@ -103,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ParaSwapRepayAdapter.Hit count Sort by function hit count0
ParaSwapRepayAdapter._swapAndRepayParaSwapRepayAdapter._swapAndRepay 2
ParaSwapRepayAdapter.getDebtRepayAmountParaSwapRepayAdapter.getDebtRepayAmount 6
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.gcov.html similarity index 80% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.gcov.html index fe75f161..10eff6f6 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapRepayAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapRepayAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapRepayAdapter.sol (source / functions) Coveragelcov.info.p Lines:100.0 %363693.0 %4340
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %480.0 %5 4
0 0
@@ -72,13 +72,13 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; - 5 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 6 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; - 7 : : import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; - 8 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; - 9 : : import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; - 10 : : import {SafeMath} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; + 4 : : import {DataTypes} from '../../protocol/libraries/types/DataTypes.sol'; + 5 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 6 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; + 7 : : import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; + 8 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 9 : : import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; + 10 : : import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; 11 : : import {BaseParaSwapBuyAdapter} from './BaseParaSwapBuyAdapter.sol'; 12 : : import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; 13 : : import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; @@ -106,7 +106,7 @@ 35 : : IParaSwapAugustusRegistry augustusRegistry, 36 : : address owner 37 : : ) BaseParaSwapBuyAdapter(addressesProvider, augustusRegistry) { - 38 : : transferOwnership(owner); + 38 : 0 : transferOwnership(owner); 39 : : } 40 : : 41 : : /** @@ -131,23 +131,23 @@ 60 : : * * IParaSwapAugustus augustus Address of Augustus Swapper 61 : : * PermitSignature permitParams Struct containing the permit signatures, set to all zeroes if not used 62 : : */ - 63 : 2 : function executeOperation( + 63 : : function executeOperation( 64 : : address asset, 65 : : uint256 amount, 66 : : uint256 premium, 67 : : address initiator, 68 : : bytes calldata params 69 : : ) external override nonReentrant returns (bool) { - 70 : 4 : require(msg.sender == address(POOL), 'CALLER_MUST_BE_POOL'); + 70 : 2 : require(msg.sender == address(POOL), 'CALLER_MUST_BE_POOL'); 71 : : - 72 : 4 : uint256 collateralAmount = amount; - 73 : 4 : address initiatorLocal = initiator; + 72 : 2 : uint256 collateralAmount = amount; + 73 : 2 : address initiatorLocal = initiator; 74 : : - 75 : 6 : IERC20Detailed collateralAsset = IERC20Detailed(asset); + 75 : 2 : IERC20Detailed collateralAsset = IERC20Detailed(asset); 76 : : - 77 : 4 : _swapAndRepay(params, premium, initiatorLocal, collateralAsset, collateralAmount); + 77 : 2 : _swapAndRepay(params, premium, initiatorLocal, collateralAsset, collateralAmount); 78 : : - 79 : 4 : return true; + 79 : 2 : return true; 80 : : } 81 : : 82 : : /** @@ -164,7 +164,7 @@ 93 : : * @param paraswapData Data for Paraswap Adapter 94 : : * @param permitSignature struct containing the permit signature 95 : : */ - 96 : 4 : function swapAndRepay( + 96 : : function swapAndRepay( 97 : : IERC20Detailed collateralAsset, 98 : : IERC20Detailed debtAsset, 99 : : uint256 collateralAmount, @@ -174,7 +174,7 @@ 103 : : bytes calldata paraswapData, 104 : : PermitSignature calldata permitSignature 105 : : ) external nonReentrant { - 106 : 8 : debtRepayAmount = getDebtRepayAmount( + 106 : 4 : debtRepayAmount = getDebtRepayAmount( 107 : : debtAsset, 108 : : debtRateMode, 109 : : buyAllBalanceOffset, @@ -183,9 +183,9 @@ 112 : : ); 113 : : 114 : : // Pull aTokens from user - 115 : 8 : _pullATokenAndWithdraw(address(collateralAsset), msg.sender, collateralAmount, permitSignature); + 115 : 4 : _pullATokenAndWithdraw(address(collateralAsset), msg.sender, collateralAmount, permitSignature); 116 : : //buy debt asset using collateral asset - 117 : 12 : uint256 amountSold = _buyOnParaSwap( + 117 : 4 : (uint256 amountSold, uint256 amountBought) = _buyOnParaSwap( 118 : : buyAllBalanceOffset, 119 : : paraswapData, 120 : : collateralAsset, @@ -194,107 +194,123 @@ 123 : : debtRepayAmount 124 : : ); 125 : : - 126 : 9 : uint256 collateralBalanceLeft = collateralAmount - amountSold; + 126 : 3 : uint256 collateralBalanceLeft = collateralAmount - amountSold; 127 : : 128 : : //deposit collateral back in the pool, if left after the swap(buy) - 129 : 6 : if (collateralBalanceLeft > 0) { - 130 : 2 : IERC20(collateralAsset).safeApprove(address(POOL), 0); - 131 : 2 : IERC20(collateralAsset).safeApprove(address(POOL), collateralBalanceLeft); - 132 : 2 : POOL.deposit(address(collateralAsset), collateralBalanceLeft, msg.sender, 0); + 129 : 3 : if (collateralBalanceLeft > 0) { + 130 : 1 : IERC20(collateralAsset).safeApprove(address(POOL), collateralBalanceLeft); + 131 : 1 : POOL.deposit(address(collateralAsset), collateralBalanceLeft, msg.sender, 0); + 132 : 1 : IERC20(collateralAsset).safeApprove(address(POOL), 0); 133 : : } 134 : : 135 : : // Repay debt. Approves 0 first to comply with tokens that implement the anti frontrunning approval fix - 136 : 6 : IERC20(debtAsset).safeApprove(address(POOL), 0); - 137 : 6 : IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount); - 138 : 6 : POOL.repay(address(debtAsset), debtRepayAmount, debtRateMode, msg.sender); - 139 : : } - 140 : : - 141 : : /** - 142 : : * @dev Perform the repay of the debt, pulls the initiator collateral and swaps to repay the flash loan - 143 : : * @param premium Fee of the flash loan - 144 : : * @param initiator Address of the user - 145 : : * @param collateralAsset Address of token to be swapped - 146 : : * @param collateralAmount Amount of the reserve to be swapped(flash loan amount) - 147 : : */ + 136 : 3 : IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount); + 137 : 3 : POOL.repay(address(debtAsset), debtRepayAmount, debtRateMode, msg.sender); + 138 : 3 : IERC20(debtAsset).safeApprove(address(POOL), 0); + 139 : : + 140 : : { + 141 : : //transfer excess of debtAsset back to the user, if any + 142 : 3 : uint256 debtAssetExcess = amountBought - debtRepayAmount; + 143 : 3 : if (debtAssetExcess > 0) { + 144 : 0 : IERC20(debtAsset).safeTransfer(msg.sender, debtAssetExcess); + 145 : : } + 146 : : } + 147 : : } 148 : : - 149 : 2 : function _swapAndRepay( - 150 : : bytes calldata params, - 151 : : uint256 premium, - 152 : : address initiator, - 153 : : IERC20Detailed collateralAsset, - 154 : : uint256 collateralAmount - 155 : : ) private { - 156 : 4 : ( - 157 : : IERC20Detailed debtAsset, - 158 : : uint256 debtRepayAmount, - 159 : : uint256 buyAllBalanceOffset, - 160 : : uint256 rateMode, - 161 : : bytes memory paraswapData, - 162 : : PermitSignature memory permitSignature - 163 : 4 : ) = abi.decode(params, (IERC20Detailed, uint256, uint256, uint256, bytes, PermitSignature)); - 164 : : - 165 : 4 : debtRepayAmount = getDebtRepayAmount( - 166 : : debtAsset, - 167 : : rateMode, - 168 : : buyAllBalanceOffset, - 169 : : debtRepayAmount, - 170 : : initiator - 171 : : ); + 149 : : /** + 150 : : * @dev Perform the repay of the debt, pulls the initiator collateral and swaps to repay the flash loan + 151 : : * @param premium Fee of the flash loan + 152 : : * @param initiator Address of the user + 153 : : * @param collateralAsset Address of token to be swapped + 154 : : * @param collateralAmount Amount of the reserve to be swapped(flash loan amount) + 155 : : */ + 156 : : + 157 : : function _swapAndRepay( + 158 : : bytes calldata params, + 159 : : uint256 premium, + 160 : : address initiator, + 161 : : IERC20Detailed collateralAsset, + 162 : : uint256 collateralAmount + 163 : : ) private { + 164 : 2 : ( + 165 : : IERC20Detailed debtAsset, + 166 : : uint256 debtRepayAmount, + 167 : : uint256 buyAllBalanceOffset, + 168 : : uint256 rateMode, + 169 : : bytes memory paraswapData, + 170 : : PermitSignature memory permitSignature + 171 : 2 : ) = abi.decode(params, (IERC20Detailed, uint256, uint256, uint256, bytes, PermitSignature)); 172 : : - 173 : 6 : uint256 amountSold = _buyOnParaSwap( - 174 : : buyAllBalanceOffset, - 175 : : paraswapData, - 176 : : collateralAsset, - 177 : : debtAsset, - 178 : : collateralAmount, - 179 : : debtRepayAmount - 180 : : ); - 181 : : - 182 : : // Repay debt. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix. - 183 : 4 : IERC20(debtAsset).safeApprove(address(POOL), 0); - 184 : 4 : IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount); - 185 : 4 : POOL.repay(address(debtAsset), debtRepayAmount, rateMode, initiator); - 186 : : - 187 : 6 : uint256 neededForFlashLoanRepay = amountSold.add(premium); - 188 : : - 189 : : // Pull aTokens from user - 190 : 4 : _pullATokenAndWithdraw( - 191 : : address(collateralAsset), - 192 : : initiator, - 193 : : neededForFlashLoanRepay, - 194 : : permitSignature - 195 : : ); + 173 : 2 : debtRepayAmount = getDebtRepayAmount( + 174 : : debtAsset, + 175 : : rateMode, + 176 : : buyAllBalanceOffset, + 177 : : debtRepayAmount, + 178 : : initiator + 179 : : ); + 180 : : + 181 : 2 : (uint256 amountSold, uint256 amountBought) = _buyOnParaSwap( + 182 : : buyAllBalanceOffset, + 183 : : paraswapData, + 184 : : collateralAsset, + 185 : : debtAsset, + 186 : : collateralAmount, + 187 : : debtRepayAmount + 188 : : ); + 189 : : + 190 : : // Repay debt. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix. + 191 : 2 : IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount); + 192 : 2 : POOL.repay(address(debtAsset), debtRepayAmount, rateMode, initiator); + 193 : 2 : IERC20(debtAsset).safeApprove(address(POOL), 0); + 194 : : + 195 : 2 : uint256 neededForFlashLoanRepay = amountSold.add(premium); 196 : : - 197 : : // Repay flashloan. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix. - 198 : 4 : IERC20(collateralAsset).safeApprove(address(POOL), 0); - 199 : 4 : IERC20(collateralAsset).safeApprove(address(POOL), collateralAmount.add(premium)); - 200 : : } - 201 : : - 202 : 6 : function getDebtRepayAmount( - 203 : : IERC20Detailed debtAsset, - 204 : : uint256 rateMode, - 205 : : uint256 buyAllBalanceOffset, - 206 : : uint256 debtRepayAmount, - 207 : : address initiator - 208 : : ) private view returns (uint256) { - 209 : 18 : DataTypes.ReserveDataLegacy memory debtReserveData = _getReserveData(address(debtAsset)); - 210 : : - 211 : 18 : address debtToken = DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE - 212 : : ? debtReserveData.stableDebtTokenAddress - 213 : : : debtReserveData.variableDebtTokenAddress; - 214 : : - 215 : 18 : uint256 currentDebt = IERC20(debtToken).balanceOf(initiator); - 216 : : - 217 : 12 : if (buyAllBalanceOffset != 0) { - 218 : 2 : require(currentDebt <= debtRepayAmount, 'INSUFFICIENT_AMOUNT_TO_REPAY'); - 219 : 2 : debtRepayAmount = currentDebt; - 220 : : } else { - 221 : 10 : require(debtRepayAmount <= currentDebt, 'INVALID_DEBT_REPAY_AMOUNT'); - 222 : : } - 223 : : - 224 : 12 : return debtRepayAmount; - 225 : : } - 226 : : } + 197 : : // Pull aTokens from user + 198 : 2 : _pullATokenAndWithdraw( + 199 : : address(collateralAsset), + 200 : : initiator, + 201 : : neededForFlashLoanRepay, + 202 : : permitSignature + 203 : : ); + 204 : : + 205 : : { + 206 : : //transfer excess of debtAsset back to the user, if any + 207 : 2 : uint256 debtAssetExcess = amountBought - debtRepayAmount; + 208 : 2 : if (debtAssetExcess > 0) { + 209 : 0 : IERC20(debtAsset).safeTransfer(initiator, debtAssetExcess); + 210 : : } + 211 : : } + 212 : : + 213 : : // Repay flashloan. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix. + 214 : 2 : IERC20(collateralAsset).safeApprove(address(POOL), 0); + 215 : 2 : IERC20(collateralAsset).safeApprove(address(POOL), collateralAmount.add(premium)); + 216 : : } + 217 : : + 218 : : function getDebtRepayAmount( + 219 : : IERC20Detailed debtAsset, + 220 : : uint256 rateMode, + 221 : : uint256 buyAllBalanceOffset, + 222 : : uint256 debtRepayAmount, + 223 : : address initiator + 224 : : ) private view returns (uint256) { + 225 : 6 : require( + 226 : : DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE, + 227 : : 'INVALID_RATE_MODE' + 228 : : ); + 229 : 6 : DataTypes.ReserveDataLegacy memory debtReserveData = _getReserveData(address(debtAsset)); + 230 : : + 231 : 6 : uint256 currentDebt = IERC20(debtReserveData.variableDebtTokenAddress).balanceOf(initiator); + 232 : : + 233 : 6 : if (buyAllBalanceOffset != 0) { + 234 : 1 : require(currentDebt <= debtRepayAmount, 'INSUFFICIENT_AMOUNT_TO_REPAY'); + 235 : 1 : debtRepayAmount = currentDebt; + 236 : : } else { + 237 : 5 : require(debtRepayAmount <= currentDebt, 'INVALID_DEBT_REPAY_AMOUNT'); + 238 : : } + 239 : : + 240 : 6 : return debtRepayAmount; + 241 : : } + 242 : : } @@ -302,8 +318,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func-c.html b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func-c.html similarity index 62% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func-c.html rename to report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func-c.html index df9d9ee1..54ef062d 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func-c.html +++ b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - + + - @@ -53,30 +53,37 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapWithdrawSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapWithdrawSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %90.0 %10 98
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:50.0 %66.7 %3 21
0 0
- + - + - + + + + + + + + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ParaSwapWithdrawSwapAdapter.executeOperationParaSwapWithdrawSwapAdapter. 0
ParaSwapWithdrawSwapAdapter.executeOperation1
ParaSwapWithdrawSwapAdapter.withdrawAndSwap
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func.html b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func.html similarity index 62% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func.html rename to report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func.html index 0afef10a..d0cff844 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.func.html +++ b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol - functions - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - + + - @@ -53,30 +53,37 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapWithdrawSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapWithdrawSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %90.0 %10 98
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:50.0 %66.7 %3 21
0 0
- + - + - + + + + + + + + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ParaSwapWithdrawSwapAdapter.executeOperationParaSwapWithdrawSwapAdapter. 0
ParaSwapWithdrawSwapAdapter.executeOperation1
ParaSwapWithdrawSwapAdapter.withdrawAndSwap
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.gcov.html b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.gcov.html similarity index 82% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.gcov.html rename to report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.gcov.html index b6e48189..749fd6ec 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol.gcov.html +++ b/report/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol - + LCOV - lcov.info.p - extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - + + - @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - ParaSwapWithdrawSwapAdapter.sol (source / functions)top level - extensions/paraswap-adapters - ParaSwapWithdrawSwapAdapter.sol (source / functions) Coveragelcov.info.p Lines:88.9 %90.0 %10 98
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:50.0 %66.7 %3 21
0 0
@@ -72,12 +72,12 @@ 1 : : // SPDX-License-Identifier: AGPL-3.0 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 5 : : import {IERC20WithPermit} from 'aave-v3-core/contracts/interfaces/IERC20WithPermit.sol'; - 6 : : import {IPoolAddressesProvider} from 'aave-v3-core/contracts/interfaces/IPoolAddressesProvider.sol'; + 4 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 5 : : import {IERC20WithPermit} from '../../interfaces/IERC20WithPermit.sol'; + 6 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; 7 : : import {BaseParaSwapSellAdapter} from './BaseParaSwapSellAdapter.sol'; 8 : : import {IParaSwapAugustusRegistry} from './interfaces/IParaSwapAugustusRegistry.sol'; - 9 : : import {SafeERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol'; + 9 : : import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; 10 : : import {IParaSwapAugustus} from './interfaces/IParaSwapAugustus.sol'; 11 : : import {ReentrancyGuard} from '../../dependencies/openzeppelin/ReentrancyGuard.sol'; 12 : : @@ -89,17 +89,17 @@ 18 : : IParaSwapAugustusRegistry augustusRegistry, 19 : : address owner 20 : : ) BaseParaSwapSellAdapter(addressesProvider, augustusRegistry) { - 21 : : transferOwnership(owner); + 21 : 0 : transferOwnership(owner); 22 : : } 23 : : - 24 : 0 : function executeOperation( + 24 : : function executeOperation( 25 : : address, 26 : : uint256, 27 : : uint256, 28 : : address, 29 : : bytes calldata 30 : : ) external override nonReentrant returns (bool) { - 31 : 0 : revert('NOT_SUPPORTED'); + 31 : 1 : revert('NOT_SUPPORTED'); 32 : : } 33 : : 34 : : /** @@ -114,7 +114,7 @@ 43 : : * @param augustus Address of ParaSwap's AugustusSwapper contract 44 : : * @param permitParams Struct containing the permit signatures, set to all zeroes if not used 45 : : */ - 46 : 3 : function withdrawAndSwap( + 46 : : function withdrawAndSwap( 47 : : IERC20Detailed assetToSwapFrom, 48 : : IERC20Detailed assetToSwapTo, 49 : : uint256 amountToSwap, @@ -124,17 +124,17 @@ 53 : : IParaSwapAugustus augustus, 54 : : PermitSignature calldata permitParams 55 : : ) external nonReentrant { - 56 : 9 : IERC20WithPermit aToken = IERC20WithPermit( + 56 : 3 : IERC20WithPermit aToken = IERC20WithPermit( 57 : : _getReserveData(address(assetToSwapFrom)).aTokenAddress 58 : : ); 59 : : - 60 : 6 : if (swapAllBalanceOffset != 0) { - 61 : 3 : uint256 balance = aToken.balanceOf(msg.sender); - 62 : 2 : require(balance <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); - 63 : 2 : amountToSwap = balance; + 60 : 3 : if (swapAllBalanceOffset != 0) { + 61 : 1 : uint256 balance = aToken.balanceOf(msg.sender); + 62 : 1 : require(balance <= amountToSwap, 'INSUFFICIENT_AMOUNT_TO_SWAP'); + 63 : 1 : amountToSwap = balance; 64 : : } 65 : : - 66 : 6 : _pullATokenAndWithdraw( + 66 : 3 : _pullATokenAndWithdraw( 67 : : address(assetToSwapFrom), 68 : : aToken, 69 : : msg.sender, @@ -142,7 +142,7 @@ 71 : : permitParams 72 : : ); 73 : : - 74 : 9 : uint256 amountReceived = _sellOnParaSwap( + 74 : 3 : uint256 amountReceived = _sellOnParaSwap( 75 : : swapAllBalanceOffset, 76 : : swapCalldata, 77 : : augustus, @@ -152,7 +152,7 @@ 81 : : minAmountToReceive 82 : : ); 83 : : - 84 : 4 : assetToSwapTo.safeTransfer(msg.sender, amountReceived); + 84 : 2 : assetToSwapTo.safeTransfer(msg.sender, amountReceived); 85 : : } 86 : : } @@ -162,8 +162,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-b.html b/report/extensions/paraswap-adapters/index-sort-b.html similarity index 53% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-b.html rename to report/extensions/paraswap-adapters/index-sort-b.html index 7cb4d794..6b861fa6 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-b.html +++ b/report/extensions/paraswap-adapters/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - + LCOV - lcov.info.p - extensions/paraswap-adapters + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - + + - @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswaptop level - extensions/paraswap-adapters Coveragelcov.info.p Lines:99.3 %14013987.8 %164144
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:95.0 %74.1 %27 2019
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,117 +96,117 @@ Hit - AaveParaSwapFeeClaimer.sol + AaveParaSwapFeeClaimer.sol -
100.0%
+
50.0%50.0%
- 100.0 % - 4 + 50.0 % + 8 4 - - 100.0 % - 4 + 80.0 % + 5 4 - BaseParaSwapAdapter.sol + BaseParaSwapAdapter.sol -
100.0%
+
92.3%92.3%
- 100.0 % - 12 + 92.3 % + 13 12 - - 100.0 % - 5 + 83.3 % + 6 5 - BaseParaSwapBuyAdapter.sol + BaseParaSwapBuyAdapter.sol -
100.0%
+
82.8%82.8%
- 100.0 % - 24 + 82.8 % + 29 24 - - 100.0 % - 1 + 50.0 % + 2 1 - BaseParaSwapSellAdapter.sol + BaseParaSwapSellAdapter.sol -
100.0%
+
80.8%80.8%
- 100.0 % - 21 + 80.8 % + 26 21 - - 100.0 % - 1 + 50.0 % + 2 1 - ParaSwapLiquiditySwapAdapter.sol + ParaSwapLiquiditySwapAdapter.sol -
100.0%
+
97.1%97.1%
- 100.0 % - 34 + 97.1 % + 35 34 - - 100.0 % - 3 + 75.0 % + 4 3 - ParaSwapRepayAdapter.sol + ParaSwapRepayAdapter.sol -
100.0%
+
93.0%93.0%
- 100.0 % - 36 - 36 + 93.0 % + 43 + 40 - - 100.0 % - 4 + 80.0 % + 5 4 - ParaSwapWithdrawSwapAdapter.sol + ParaSwapWithdrawSwapAdapter.sol -
88.9%88.9%
+
90.0%90.0%
- 88.9 % + 90.0 % + 10 9 - 8 - - 50.0 % + 66.7 % + 3 2 - 1

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-f.html b/report/extensions/paraswap-adapters/index-sort-f.html similarity index 53% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-f.html rename to report/extensions/paraswap-adapters/index-sort-f.html index b5b7b613..ff9f0d9f 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-f.html +++ b/report/extensions/paraswap-adapters/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - + LCOV - lcov.info.p - extensions/paraswap-adapters + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - + + - @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswaptop level - extensions/paraswap-adapters Coveragelcov.info.p Lines:99.3 %14013987.8 %164144
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:95.0 %74.1 %27 2019
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,13 +96,13 @@ Hit - ParaSwapWithdrawSwapAdapter.sol + BaseParaSwapBuyAdapter.sol -
88.9%88.9%
+
82.8%82.8%
- 88.9 % - 9 - 8 + 82.8 % + 29 + 24 - @@ -111,93 +111,93 @@ 1 - BaseParaSwapBuyAdapter.sol + BaseParaSwapSellAdapter.sol -
100.0%
+
80.8%80.8%
- 100.0 % - 24 - 24 + 80.8 % + 26 + 21 - - 100.0 % - 1 + 50.0 % + 2 1 - BaseParaSwapSellAdapter.sol + ParaSwapWithdrawSwapAdapter.sol -
100.0%
+
90.0%90.0%
- 100.0 % - 21 - 21 + 90.0 % + 10 + 9 - - 100.0 % - 1 - 1 + 66.7 % + 3 + 2 - ParaSwapLiquiditySwapAdapter.sol + ParaSwapLiquiditySwapAdapter.sol -
100.0%
+
97.1%97.1%
- 100.0 % - 34 + 97.1 % + 35 34 - - 100.0 % - 3 + 75.0 % + 4 3 - AaveParaSwapFeeClaimer.sol + AaveParaSwapFeeClaimer.sol -
100.0%
+
50.0%50.0%
- 100.0 % - 4 + 50.0 % + 8 4 - - 100.0 % - 4 + 80.0 % + 5 4 - ParaSwapRepayAdapter.sol + ParaSwapRepayAdapter.sol -
100.0%
+
93.0%93.0%
- 100.0 % - 36 - 36 + 93.0 % + 43 + 40 - - 100.0 % - 4 + 80.0 % + 5 4 - BaseParaSwapAdapter.sol + BaseParaSwapAdapter.sol -
100.0%
+
92.3%92.3%
- 100.0 % - 12 + 92.3 % + 13 12 - - 100.0 % - 5 + 83.3 % + 6 5 @@ -205,8 +205,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-l.html b/report/extensions/paraswap-adapters/index-sort-l.html similarity index 53% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-l.html rename to report/extensions/paraswap-adapters/index-sort-l.html index 2f902766..810ddf3c 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index-sort-l.html +++ b/report/extensions/paraswap-adapters/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - + LCOV - lcov.info.p - extensions/paraswap-adapters + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - + + - @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswaptop level - extensions/paraswap-adapters Coveragelcov.info.p Lines:99.3 %14013987.8 %164144
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:95.0 %74.1 %27 2019
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,117 +96,117 @@ Hit - ParaSwapWithdrawSwapAdapter.sol + AaveParaSwapFeeClaimer.sol -
88.9%88.9%
+
50.0%50.0%
- 88.9 % - 9 + 50.0 % 8 + 4 - - 50.0 % - 2 - 1 + 80.0 % + 5 + 4 - AaveParaSwapFeeClaimer.sol + BaseParaSwapSellAdapter.sol -
100.0%
+
80.8%80.8%
- 100.0 % - 4 - 4 + 80.8 % + 26 + 21 - - 100.0 % - 4 - 4 + 50.0 % + 2 + 1 - BaseParaSwapAdapter.sol + BaseParaSwapBuyAdapter.sol -
100.0%
+
82.8%82.8%
- 100.0 % - 12 - 12 + 82.8 % + 29 + 24 - - 100.0 % - 5 - 5 + 50.0 % + 2 + 1 - BaseParaSwapSellAdapter.sol + ParaSwapWithdrawSwapAdapter.sol -
100.0%
+
90.0%90.0%
- 100.0 % - 21 - 21 + 90.0 % + 10 + 9 - - 100.0 % - 1 - 1 + 66.7 % + 3 + 2 - BaseParaSwapBuyAdapter.sol + BaseParaSwapAdapter.sol -
100.0%
+
92.3%92.3%
- 100.0 % - 24 - 24 + 92.3 % + 13 + 12 - - 100.0 % - 1 - 1 + 83.3 % + 6 + 5 - ParaSwapLiquiditySwapAdapter.sol + ParaSwapRepayAdapter.sol -
100.0%
+
93.0%93.0%
- 100.0 % - 34 - 34 + 93.0 % + 43 + 40 - - 100.0 % - 3 - 3 + 80.0 % + 5 + 4 - ParaSwapRepayAdapter.sol + ParaSwapLiquiditySwapAdapter.sol -
100.0%
+
97.1%97.1%
- 100.0 % - 36 - 36 + 97.1 % + 35 + 34 - - 100.0 % - 4 + 75.0 % 4 + 3

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index.html b/report/extensions/paraswap-adapters/index.html similarity index 53% rename from report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index.html rename to report/extensions/paraswap-adapters/index.html index 37ddb722..28ebe49c 100644 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/index.html +++ b/report/extensions/paraswap-adapters/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - + LCOV - lcov.info.p - extensions/paraswap-adapters + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - + + - @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswaptop level - extensions/paraswap-adapters Coveragelcov.info.p Lines:99.3 %14013987.8 %164144
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:95.0 %74.1 %27 2019
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,117 +96,117 @@ Hit - AaveParaSwapFeeClaimer.sol + AaveParaSwapFeeClaimer.sol -
100.0%
+
50.0%50.0%
- 100.0 % - 4 + 50.0 % + 8 4 - - 100.0 % - 4 + 80.0 % + 5 4 - BaseParaSwapAdapter.sol + BaseParaSwapAdapter.sol -
100.0%
+
92.3%92.3%
- 100.0 % - 12 + 92.3 % + 13 12 - - 100.0 % - 5 + 83.3 % + 6 5 - BaseParaSwapBuyAdapter.sol + BaseParaSwapBuyAdapter.sol -
100.0%
+
82.8%82.8%
- 100.0 % - 24 + 82.8 % + 29 24 - - 100.0 % - 1 + 50.0 % + 2 1 - BaseParaSwapSellAdapter.sol + BaseParaSwapSellAdapter.sol -
100.0%
+
80.8%80.8%
- 100.0 % - 21 + 80.8 % + 26 21 - - 100.0 % - 1 + 50.0 % + 2 1 - ParaSwapLiquiditySwapAdapter.sol + ParaSwapLiquiditySwapAdapter.sol -
100.0%
+
97.1%97.1%
- 100.0 % - 34 + 97.1 % + 35 34 - - 100.0 % - 3 + 75.0 % + 4 3 - ParaSwapRepayAdapter.sol + ParaSwapRepayAdapter.sol -
100.0%
+
93.0%93.0%
- 100.0 % - 36 - 36 + 93.0 % + 43 + 40 - - 100.0 % - 4 + 80.0 % + 5 4 - ParaSwapWithdrawSwapAdapter.sol + ParaSwapWithdrawSwapAdapter.sol -
88.9%88.9%
+
90.0%90.0%
- 88.9 % + 90.0 % + 10 9 - 8 - - 50.0 % + 66.7 % + 3 2 - 1

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func-c.html b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func-c.html new file mode 100644 index 00000000..78256aa9 --- /dev/null +++ b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func-c.html @@ -0,0 +1,238 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC20AaveLMUpgradeable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC20AaveLMUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:92.5 %9386
Test Date:2024-09-24 09:34:24Functions:90.9 %2220
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
ERC20AaveLMUpgradeable.0
ERC20AaveLMUpgradeable.getCurrentRewardsIndex0
ERC20AaveLMUpgradeable.rewardTokens1
ERC20AaveLMUpgradeable.getReferenceAsset2
ERC20AaveLMUpgradeable.isRegisteredRewardToken3
ERC20AaveLMUpgradeable.__ERC20AaveLM_init85
ERC20AaveLMUpgradeable.__ERC20AaveLM_init_unchained85
ERC20AaveLMUpgradeable.claimRewards1000
ERC20AaveLMUpgradeable.claimRewardsToSelf1001
ERC20AaveLMUpgradeable.collectAndUpdateRewards1001
ERC20AaveLMUpgradeable.getTotalClaimableRewards1001
ERC20AaveLMUpgradeable.claimRewardsOnBehalf3000
ERC20AaveLMUpgradeable._claimRewardsOnBehalf4000
ERC20AaveLMUpgradeable.getUnclaimedRewards4356
ERC20AaveLMUpgradeable._registerRewardToken9003
ERC20AaveLMUpgradeable.refreshRewardTokens9003
ERC20AaveLMUpgradeable._updateUser12589
ERC20AaveLMUpgradeable._update12595
ERC20AaveLMUpgradeable.getClaimableRewards13361
ERC20AaveLMUpgradeable._getPendingRewards19949
ERC20AaveLMUpgradeable._getClaimableRewards19950
ERC20AaveLMUpgradeable._getERC20AaveLMStorage119662
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func.html b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func.html new file mode 100644 index 00000000..f908498b --- /dev/null +++ b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.func.html @@ -0,0 +1,238 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC20AaveLMUpgradeable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC20AaveLMUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:92.5 %9386
Test Date:2024-09-24 09:34:24Functions:90.9 %2220
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
ERC20AaveLMUpgradeable.0
ERC20AaveLMUpgradeable.__ERC20AaveLM_init85
ERC20AaveLMUpgradeable.__ERC20AaveLM_init_unchained85
ERC20AaveLMUpgradeable._claimRewardsOnBehalf4000
ERC20AaveLMUpgradeable._getClaimableRewards19950
ERC20AaveLMUpgradeable._getERC20AaveLMStorage119662
ERC20AaveLMUpgradeable._getPendingRewards19949
ERC20AaveLMUpgradeable._registerRewardToken9003
ERC20AaveLMUpgradeable._update12595
ERC20AaveLMUpgradeable._updateUser12589
ERC20AaveLMUpgradeable.claimRewards1000
ERC20AaveLMUpgradeable.claimRewardsOnBehalf3000
ERC20AaveLMUpgradeable.claimRewardsToSelf1001
ERC20AaveLMUpgradeable.collectAndUpdateRewards1001
ERC20AaveLMUpgradeable.getClaimableRewards13361
ERC20AaveLMUpgradeable.getCurrentRewardsIndex0
ERC20AaveLMUpgradeable.getReferenceAsset2
ERC20AaveLMUpgradeable.getTotalClaimableRewards1001
ERC20AaveLMUpgradeable.getUnclaimedRewards4356
ERC20AaveLMUpgradeable.isRegisteredRewardToken3
ERC20AaveLMUpgradeable.refreshRewardTokens9003
ERC20AaveLMUpgradeable.rewardTokens1
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.gcov.html b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.gcov.html new file mode 100644 index 00000000..2cf34616 --- /dev/null +++ b/report/extensions/static-a-token/ERC20AaveLMUpgradeable.sol.gcov.html @@ -0,0 +1,391 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC20AaveLMUpgradeable.sol + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC20AaveLMUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:92.5 %9386
Test Date:2024-09-24 09:34:24Functions:90.9 %2220
Branches:-00
+
+ + + + + + + + +

+
             Branch data     Line data    Source code
+
+       1                 :             : // SPDX-License-Identifier: BUSL-1.1
+       2                 :             : pragma solidity ^0.8.17;
+       3                 :             : 
+       4                 :             : import {ERC20Upgradeable} from 'openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol';
+       5                 :             : import {IERC20} from 'openzeppelin-contracts/contracts/interfaces/IERC20.sol';
+       6                 :             : import {SafeERC20} from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol';
+       7                 :             : import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol';
+       8                 :             : 
+       9                 :             : import {IRewardsController} from '../../rewards/interfaces/IRewardsController.sol';
+      10                 :             : import {IERC20AaveLM} from './interfaces/IERC20AaveLM.sol';
+      11                 :             : 
+      12                 :             : /**
+      13                 :             :  * @title ERC20AaveLMUpgradeable.sol
+      14                 :             :  * @notice Wrapper smart contract that supports tracking and claiming liquidity mining rewards from the Aave system
+      15                 :             :  * @dev ERC20 extension, so ERC20 initialization should be done by the children contract/s
+      16                 :             :  * @author BGD labs
+      17                 :             :  */
+      18                 :             : abstract contract ERC20AaveLMUpgradeable is ERC20Upgradeable, IERC20AaveLM {
+      19                 :             :   using SafeCast for uint256;
+      20                 :             : 
+      21                 :             :   /// @custom:storage-location erc7201:aave-dao.storage.ERC20AaveLM
+      22                 :             :   struct ERC20AaveLMStorage {
+      23                 :             :     address _referenceAsset; // a/v token to track rewards on INCENTIVES_CONTROLLER
+      24                 :             :     address[] _rewardTokens;
+      25                 :             :     mapping(address user => RewardIndexCache cache) _startIndex;
+      26                 :             :     mapping(address user => mapping(address reward => UserRewardsData cache)) _userRewardsData;
+      27                 :             :   }
+      28                 :             : 
+      29                 :             :   // keccak256(abi.encode(uint256(keccak256("aave-dao.storage.ERC20AaveLM")) - 1)) & ~bytes32(uint256(0xff))
+      30                 :             :   bytes32 private constant ERC20AaveLMStorageLocation =
+      31                 :             :     0x4fad66563f105be0bff96185c9058c4934b504d3ba15ca31e86294f0b01fd200;
+      32                 :             : 
+      33                 :             :   function _getERC20AaveLMStorage() private pure returns (ERC20AaveLMStorage storage $) {
+      34                 :             :     assembly {
+      35                 :      119662 :       $.slot := ERC20AaveLMStorageLocation
+      36                 :             :     }
+      37                 :             :   }
+      38                 :             : 
+      39                 :             :   IRewardsController public immutable INCENTIVES_CONTROLLER;
+      40                 :             : 
+      41                 :             :   constructor(IRewardsController rewardsController) {
+      42                 :           0 :     INCENTIVES_CONTROLLER = rewardsController;
+      43                 :             :   }
+      44                 :             : 
+      45                 :             :   function __ERC20AaveLM_init(address referenceAsset_) internal onlyInitializing {
+      46                 :          85 :     __ERC20AaveLM_init_unchained(referenceAsset_);
+      47                 :             :   }
+      48                 :             : 
+      49                 :             :   function __ERC20AaveLM_init_unchained(address referenceAsset_) internal onlyInitializing {
+      50                 :          85 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+      51                 :          85 :     $._referenceAsset = referenceAsset_;
+      52                 :             : 
+      53                 :          85 :     if (INCENTIVES_CONTROLLER != IRewardsController(address(0))) {
+      54                 :          85 :       refreshRewardTokens();
+      55                 :             :     }
+      56                 :             :   }
+      57                 :             : 
+      58                 :             :   ///@inheritdoc IERC20AaveLM
+      59                 :             :   function claimRewardsOnBehalf(
+      60                 :             :     address onBehalfOf,
+      61                 :             :     address receiver,
+      62                 :             :     address[] memory rewards
+      63                 :             :   ) external {
+      64                 :        3000 :     address msgSender = _msgSender();
+      65                 :        3000 :     if (msgSender != onBehalfOf && msgSender != INCENTIVES_CONTROLLER.getClaimer(onBehalfOf)) {
+      66                 :        1000 :       revert InvalidClaimer(msgSender);
+      67                 :             :     }
+      68                 :             : 
+      69                 :        2000 :     _claimRewardsOnBehalf(onBehalfOf, receiver, rewards);
+      70                 :             :   }
+      71                 :             : 
+      72                 :             :   ///@inheritdoc IERC20AaveLM
+      73                 :             :   function claimRewards(address receiver, address[] memory rewards) external {
+      74                 :        1000 :     _claimRewardsOnBehalf(_msgSender(), receiver, rewards);
+      75                 :             :   }
+      76                 :             : 
+      77                 :             :   ///@inheritdoc IERC20AaveLM
+      78                 :             :   function claimRewardsToSelf(address[] memory rewards) external {
+      79                 :        1001 :     _claimRewardsOnBehalf(_msgSender(), _msgSender(), rewards);
+      80                 :             :   }
+      81                 :             : 
+      82                 :             :   ///@inheritdoc IERC20AaveLM
+      83                 :             :   function refreshRewardTokens() public override {
+      84                 :        9088 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+      85                 :        9088 :     address[] memory rewards = INCENTIVES_CONTROLLER.getRewardsByAsset($._referenceAsset);
+      86                 :        9088 :     for (uint256 i = 0; i < rewards.length; i++) {
+      87                 :        9003 :       _registerRewardToken(rewards[i]);
+      88                 :             :     }
+      89                 :             :   }
+      90                 :             : 
+      91                 :             :   ///@inheritdoc IERC20AaveLM
+      92                 :             :   function collectAndUpdateRewards(address reward) public returns (uint256) {
+      93                 :        2517 :     if (reward == address(0)) {
+      94                 :           0 :       return 0;
+      95                 :             :     }
+      96                 :             : 
+      97                 :        2517 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+      98                 :        2517 :     address[] memory assets = new address[](1);
+      99                 :        2517 :     assets[0] = address($._referenceAsset);
+     100                 :             : 
+     101                 :        2517 :     return INCENTIVES_CONTROLLER.claimRewards(assets, type(uint256).max, address(this), reward);
+     102                 :             :   }
+     103                 :             : 
+     104                 :             :   ///@inheritdoc IERC20AaveLM
+     105                 :             :   function isRegisteredRewardToken(address reward) public view override returns (bool) {
+     106                 :        9006 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     107                 :        9006 :     return $._startIndex[reward].isRegistered;
+     108                 :             :   }
+     109                 :             : 
+     110                 :             :   ///@inheritdoc IERC20AaveLM
+     111                 :             :   function getCurrentRewardsIndex(address reward) public view returns (uint256) {
+     112                 :       37953 :     if (address(reward) == address(0)) {
+     113                 :           0 :       return 0;
+     114                 :             :     }
+     115                 :       37953 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     116                 :       37953 :     (, uint256 nextIndex) = INCENTIVES_CONTROLLER.getAssetIndex($._referenceAsset, reward);
+     117                 :       37953 :     return nextIndex;
+     118                 :             :   }
+     119                 :             : 
+     120                 :             :   ///@inheritdoc IERC20AaveLM
+     121                 :             :   function getTotalClaimableRewards(address reward) external view returns (uint256) {
+     122                 :        1001 :     if (reward == address(0)) {
+     123                 :           0 :       return 0;
+     124                 :             :     }
+     125                 :             : 
+     126                 :        1001 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     127                 :        1001 :     address[] memory assets = new address[](1);
+     128                 :        1001 :     assets[0] = $._referenceAsset;
+     129                 :        1001 :     uint256 freshRewards = INCENTIVES_CONTROLLER.getUserRewards(assets, address(this), reward);
+     130                 :        1001 :     return IERC20(reward).balanceOf(address(this)) + freshRewards;
+     131                 :             :   }
+     132                 :             : 
+     133                 :             :   ///@inheritdoc IERC20AaveLM
+     134                 :             :   function getClaimableRewards(address user, address reward) external view returns (uint256) {
+     135                 :       13361 :     return _getClaimableRewards(user, reward, balanceOf(user), getCurrentRewardsIndex(reward));
+     136                 :             :   }
+     137                 :             : 
+     138                 :             :   ///@inheritdoc IERC20AaveLM
+     139                 :             :   function getUnclaimedRewards(address user, address reward) external view returns (uint256) {
+     140                 :        4356 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     141                 :        4356 :     return $._userRewardsData[user][reward].unclaimedRewards;
+     142                 :             :   }
+     143                 :             : 
+     144                 :             :   ///@inheritdoc IERC20AaveLM
+     145                 :             :   function getReferenceAsset() external view returns (address) {
+     146                 :           2 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     147                 :           2 :     return $._referenceAsset;
+     148                 :             :   }
+     149                 :             : 
+     150                 :             :   ///@inheritdoc IERC20AaveLM
+     151                 :             :   function rewardTokens() external view returns (address[] memory) {
+     152                 :           1 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     153                 :           1 :     return $._rewardTokens;
+     154                 :             :   }
+     155                 :             : 
+     156                 :             :   /**
+     157                 :             :    * @notice Updates rewards for senders and receiver in a transfer (not updating rewards for address(0))
+     158                 :             :    * @param from The address of the sender of tokens
+     159                 :             :    * @param to The address of the receiver of tokens
+     160                 :             :    */
+     161                 :             :   function _update(address from, address to, uint256 amount) internal virtual override {
+     162                 :       12595 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     163                 :       12595 :     for (uint256 i = 0; i < $._rewardTokens.length; i++) {
+     164                 :       11589 :       address rewardToken = address($._rewardTokens[i]);
+     165                 :       11589 :       uint256 rewardsIndex = getCurrentRewardsIndex(rewardToken);
+     166                 :       11589 :       if (from != address(0)) {
+     167                 :        2000 :         _updateUser(from, rewardsIndex, rewardToken);
+     168                 :             :       }
+     169                 :       11589 :       if (to != address(0) && from != to) {
+     170                 :       10589 :         _updateUser(to, rewardsIndex, rewardToken);
+     171                 :             :       }
+     172                 :             :     }
+     173                 :       12595 :     super._update(from, to, amount);
+     174                 :             :   }
+     175                 :             : 
+     176                 :             :   /**
+     177                 :             :    * @notice Adding the pending rewards to the unclaimed for specific user and updating user index
+     178                 :             :    * @param user The address of the user to update
+     179                 :             :    * @param currentRewardsIndex The current rewardIndex
+     180                 :             :    * @param rewardToken The address of the reward token
+     181                 :             :    */
+     182                 :             :   function _updateUser(address user, uint256 currentRewardsIndex, address rewardToken) internal {
+     183                 :       12589 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     184                 :       12589 :     uint256 balance = balanceOf(user);
+     185                 :       12589 :     if (balance > 0) {
+     186                 :        2589 :       $._userRewardsData[user][rewardToken].unclaimedRewards = _getClaimableRewards(
+     187                 :             :         user,
+     188                 :             :         rewardToken,
+     189                 :             :         balance,
+     190                 :             :         currentRewardsIndex
+     191                 :             :       ).toUint128();
+     192                 :             :     }
+     193                 :       12589 :     $._userRewardsData[user][rewardToken].rewardsIndexOnLastInteraction = currentRewardsIndex
+     194                 :             :       .toUint128();
+     195                 :             :   }
+     196                 :             : 
+     197                 :             :   /**
+     198                 :             :    * @notice Compute the pending in WAD. Pending is the amount to add (not yet unclaimed) rewards in WAD.
+     199                 :             :    * @param balance The balance of the user
+     200                 :             :    * @param rewardsIndexOnLastInteraction The index which was on the last interaction of the user
+     201                 :             :    * @param currentRewardsIndex The current rewards index in the system
+     202                 :             :    * @return The amount of pending rewards in WAD
+     203                 :             :    */
+     204                 :             :   function _getPendingRewards(
+     205                 :             :     uint256 balance,
+     206                 :             :     uint256 rewardsIndexOnLastInteraction,
+     207                 :             :     uint256 currentRewardsIndex
+     208                 :             :   ) internal view returns (uint256) {
+     209                 :       19949 :     if (balance == 0) {
+     210                 :           0 :       return 0;
+     211                 :             :     }
+     212                 :       19949 :     return (balance * (currentRewardsIndex - rewardsIndexOnLastInteraction)) / 10 ** decimals();
+     213                 :             :   }
+     214                 :             : 
+     215                 :             :   /**
+     216                 :             :    * @notice Compute the claimable rewards for a user
+     217                 :             :    * @param user The address of the user
+     218                 :             :    * @param reward The address of the reward
+     219                 :             :    * @param balance The balance of the user in WAD
+     220                 :             :    * @param currentRewardsIndex The current rewards index
+     221                 :             :    * @return The total rewards that can be claimed by the user (if `fresh` flag true, after updating rewards)
+     222                 :             :    */
+     223                 :             :   function _getClaimableRewards(
+     224                 :             :     address user,
+     225                 :             :     address reward,
+     226                 :             :     uint256 balance,
+     227                 :             :     uint256 currentRewardsIndex
+     228                 :             :   ) internal view returns (uint256) {
+     229                 :       19950 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     230                 :       19950 :     RewardIndexCache memory rewardsIndexCache = $._startIndex[reward];
+     231                 :       19950 :     if (!rewardsIndexCache.isRegistered) {
+     232                 :           1 :       revert RewardNotInitialized(reward);
+     233                 :             :     }
+     234                 :             : 
+     235                 :       19949 :     UserRewardsData memory currentUserRewardsData = $._userRewardsData[user][reward];
+     236                 :       19949 :     return
+     237                 :       19949 :       currentUserRewardsData.unclaimedRewards +
+     238                 :       19949 :       _getPendingRewards(
+     239                 :             :         balance,
+     240                 :             :         currentUserRewardsData.rewardsIndexOnLastInteraction == 0
+     241                 :             :           ? rewardsIndexCache.lastUpdatedIndex
+     242                 :             :           : currentUserRewardsData.rewardsIndexOnLastInteraction,
+     243                 :             :         currentRewardsIndex
+     244                 :             :       );
+     245                 :             :   }
+     246                 :             : 
+     247                 :             :   /**
+     248                 :             :    * @notice Claim rewards on behalf of a user and send them to a receiver
+     249                 :             :    * @param onBehalfOf The address to claim on behalf of
+     250                 :             :    * @param rewards The addresses of the rewards
+     251                 :             :    * @param receiver The address to receive the rewards
+     252                 :             :    */
+     253                 :             :   function _claimRewardsOnBehalf(
+     254                 :             :     address onBehalfOf,
+     255                 :             :     address receiver,
+     256                 :             :     address[] memory rewards
+     257                 :             :   ) internal virtual {
+     258                 :        4000 :     for (uint256 i = 0; i < rewards.length; i++) {
+     259                 :        4000 :       if (address(rewards[i]) == address(0)) {
+     260                 :        4000 :         continue;
+     261                 :             :       }
+     262                 :        4000 :       uint256 currentRewardsIndex = getCurrentRewardsIndex(rewards[i]);
+     263                 :        4000 :       uint256 balance = balanceOf(onBehalfOf);
+     264                 :        4000 :       uint256 userReward = _getClaimableRewards(
+     265                 :             :         onBehalfOf,
+     266                 :             :         rewards[i],
+     267                 :             :         balance,
+     268                 :             :         currentRewardsIndex
+     269                 :             :       );
+     270                 :        4000 :       uint256 totalRewardTokenBalance = IERC20(rewards[i]).balanceOf(address(this));
+     271                 :        4000 :       uint256 unclaimedReward = 0;
+     272                 :             : 
+     273                 :        4000 :       if (userReward > totalRewardTokenBalance) {
+     274                 :        1516 :         totalRewardTokenBalance += collectAndUpdateRewards(address(rewards[i]));
+     275                 :             :       }
+     276                 :             : 
+     277                 :        4000 :       if (userReward > totalRewardTokenBalance) {
+     278                 :           0 :         unclaimedReward = userReward - totalRewardTokenBalance;
+     279                 :           0 :         userReward = totalRewardTokenBalance;
+     280                 :             :       }
+     281                 :        4000 :       if (userReward > 0) {
+     282                 :        1516 :         ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     283                 :        1516 :         $._userRewardsData[onBehalfOf][rewards[i]].unclaimedRewards = unclaimedReward.toUint128();
+     284                 :        1516 :         $
+     285                 :             :         ._userRewardsData[onBehalfOf][rewards[i]]
+     286                 :             :           .rewardsIndexOnLastInteraction = currentRewardsIndex.toUint128();
+     287                 :        1516 :         SafeERC20.safeTransfer(IERC20(rewards[i]), receiver, userReward);
+     288                 :             :       }
+     289                 :             :     }
+     290                 :             :   }
+     291                 :             : 
+     292                 :             :   /**
+     293                 :             :    * @notice Initializes a new rewardToken
+     294                 :             :    * @param reward The reward token to be registered
+     295                 :             :    */
+     296                 :             :   function _registerRewardToken(address reward) internal {
+     297                 :        9003 :     if (isRegisteredRewardToken(reward)) return;
+     298                 :        9003 :     uint256 startIndex = getCurrentRewardsIndex(reward);
+     299                 :             : 
+     300                 :        9003 :     ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage();
+     301                 :        9003 :     $._rewardTokens.push(reward);
+     302                 :        9003 :     $._startIndex[reward] = RewardIndexCache(true, startIndex.toUint240());
+     303                 :             : 
+     304                 :        9003 :     emit RewardTokenRegistered(reward, startIndex);
+     305                 :             :   }
+     306                 :             : }
+        
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func-c.html b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func-c.html new file mode 100644 index 00000000..4565cd95 --- /dev/null +++ b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func-c.html @@ -0,0 +1,217 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC4626StataTokenUpgradeable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC4626StataTokenUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:93.2 %7368
Test Date:2024-09-24 09:34:24Functions:89.5 %1917
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
ERC4626StataTokenUpgradeable.0
ERC4626StataTokenUpgradeable.aToken0
ERC4626StataTokenUpgradeable.maxMint1
ERC4626StataTokenUpgradeable.maxWithdraw1
ERC4626StataTokenUpgradeable.__ERC4626StataToken_init97
ERC4626StataTokenUpgradeable.__ERC4626StataToken_init_unchained97
ERC4626StataTokenUpgradeable.latestAnswer1001
ERC4626StataTokenUpgradeable.totalAssets1002
ERC4626StataTokenUpgradeable.maxDeposit1003
ERC4626StataTokenUpgradeable.redeemATokens3000
ERC4626StataTokenUpgradeable.maxRedeem3002
ERC4626StataTokenUpgradeable.depositWithPermit5000
ERC4626StataTokenUpgradeable._withdraw7004
ERC4626StataTokenUpgradeable.depositATokens12005
ERC4626StataTokenUpgradeable._convertToAssets14007
ERC4626StataTokenUpgradeable._deposit21009
ERC4626StataTokenUpgradeable._getERC4626StataTokenStorage21104
ERC4626StataTokenUpgradeable._convertToShares28013
ERC4626StataTokenUpgradeable._rate44021
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func.html b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func.html new file mode 100644 index 00000000..07cfdf4a --- /dev/null +++ b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.func.html @@ -0,0 +1,217 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC4626StataTokenUpgradeable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC4626StataTokenUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:93.2 %7368
Test Date:2024-09-24 09:34:24Functions:89.5 %1917
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
ERC4626StataTokenUpgradeable.0
ERC4626StataTokenUpgradeable.__ERC4626StataToken_init97
ERC4626StataTokenUpgradeable.__ERC4626StataToken_init_unchained97
ERC4626StataTokenUpgradeable._convertToAssets14007
ERC4626StataTokenUpgradeable._convertToShares28013
ERC4626StataTokenUpgradeable._deposit21009
ERC4626StataTokenUpgradeable._getERC4626StataTokenStorage21104
ERC4626StataTokenUpgradeable._rate44021
ERC4626StataTokenUpgradeable._withdraw7004
ERC4626StataTokenUpgradeable.aToken0
ERC4626StataTokenUpgradeable.depositATokens12005
ERC4626StataTokenUpgradeable.depositWithPermit5000
ERC4626StataTokenUpgradeable.latestAnswer1001
ERC4626StataTokenUpgradeable.maxDeposit1003
ERC4626StataTokenUpgradeable.maxMint1
ERC4626StataTokenUpgradeable.maxRedeem3002
ERC4626StataTokenUpgradeable.maxWithdraw1
ERC4626StataTokenUpgradeable.redeemATokens3000
ERC4626StataTokenUpgradeable.totalAssets1002
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.gcov.html b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.gcov.html new file mode 100644 index 00000000..15185fe5 --- /dev/null +++ b/report/extensions/static-a-token/ERC4626StataTokenUpgradeable.sol.gcov.html @@ -0,0 +1,376 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/ERC4626StataTokenUpgradeable.sol + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - ERC4626StataTokenUpgradeable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:93.2 %7368
Test Date:2024-09-24 09:34:24Functions:89.5 %1917
Branches:-00
+
+ + + + + + + + +

+
             Branch data     Line data    Source code
+
+       1                 :             : // SPDX-License-Identifier: BUSL-1.1
+       2                 :             : pragma solidity ^0.8.17;
+       3                 :             : 
+       4                 :             : import {ERC4626Upgradeable, Math, IERC4626} from 'openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol';
+       5                 :             : import {SafeERC20, IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol';
+       6                 :             : import {IERC20Permit} from 'openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol';
+       7                 :             : 
+       8                 :             : import {IPool, IPoolAddressesProvider} from '../../interfaces/IPool.sol';
+       9                 :             : import {IAaveOracle} from '../../interfaces/IAaveOracle.sol';
+      10                 :             : import {DataTypes, ReserveConfiguration} from '../../protocol/libraries/configuration/ReserveConfiguration.sol';
+      11                 :             : 
+      12                 :             : import {IAToken} from './interfaces/IAToken.sol';
+      13                 :             : import {IERC4626StataToken} from './interfaces/IERC4626StataToken.sol';
+      14                 :             : 
+      15                 :             : /**
+      16                 :             :  * @title ERC4626StataTokenUpgradeable
+      17                 :             :  * @notice Wrapper smart contract that allows to deposit tokens on the Aave protocol and receive
+      18                 :             :  * a token which balance doesn't increase automatically, but uses an ever-increasing exchange rate.
+      19                 :             :  * @dev ERC20 extension, so ERC20 initialization should be done by the children contract/s
+      20                 :             :  * @author BGD labs
+      21                 :             :  */
+      22                 :             : abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626StataToken {
+      23                 :             :   using Math for uint256;
+      24                 :             : 
+      25                 :             :   /// @custom:storage-location erc7201:aave-dao.storage.ERC4626StataToken
+      26                 :             :   struct ERC4626StataTokenStorage {
+      27                 :             :     IERC20 _aToken;
+      28                 :             :   }
+      29                 :             : 
+      30                 :             :   // keccak256(abi.encode(uint256(keccak256("aave-dao.storage.ERC4626StataToken")) - 1)) & ~bytes32(uint256(0xff))
+      31                 :             :   bytes32 private constant ERC4626StataTokenStorageLocation =
+      32                 :             :     0x55029d3f54709e547ed74b2fc842d93107ab1490ab7555dd9dd0bf6451101900;
+      33                 :             : 
+      34                 :             :   function _getERC4626StataTokenStorage()
+      35                 :             :     private
+      36                 :             :     pure
+      37                 :             :     returns (ERC4626StataTokenStorage storage $)
+      38                 :             :   {
+      39                 :             :     assembly {
+      40                 :       21104 :       $.slot := ERC4626StataTokenStorageLocation
+      41                 :             :     }
+      42                 :             :   }
+      43                 :             : 
+      44                 :             :   uint256 public constant RAY = 1e27;
+      45                 :             : 
+      46                 :             :   IPool public immutable POOL;
+      47                 :             :   IPoolAddressesProvider public immutable POOL_ADDRESSES_PROVIDER;
+      48                 :             : 
+      49                 :             :   constructor(IPool pool) {
+      50                 :           0 :     POOL = pool;
+      51                 :           0 :     POOL_ADDRESSES_PROVIDER = pool.ADDRESSES_PROVIDER();
+      52                 :             :   }
+      53                 :             : 
+      54                 :             :   function __ERC4626StataToken_init(address newAToken) internal onlyInitializing {
+      55                 :          97 :     IERC20 aTokenUnderlying = __ERC4626StataToken_init_unchained(newAToken);
+      56                 :          97 :     __ERC4626_init_unchained(aTokenUnderlying);
+      57                 :             :   }
+      58                 :             : 
+      59                 :             :   function __ERC4626StataToken_init_unchained(
+      60                 :             :     address newAToken
+      61                 :             :   ) internal onlyInitializing returns (IERC20) {
+      62                 :             :     // sanity check, to be sure that we support that version of the aToken
+      63                 :          97 :     address poolOfAToken = IAToken(newAToken).POOL();
+      64                 :          97 :     if (poolOfAToken != address(POOL)) revert PoolAddressMismatch(poolOfAToken);
+      65                 :             : 
+      66                 :          97 :     IERC20 aTokenUnderlying = IERC20(IAToken(newAToken).UNDERLYING_ASSET_ADDRESS());
+      67                 :             : 
+      68                 :          97 :     ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage();
+      69                 :          97 :     $._aToken = IERC20(newAToken);
+      70                 :             : 
+      71                 :          97 :     SafeERC20.forceApprove(aTokenUnderlying, address(POOL), type(uint256).max);
+      72                 :             : 
+      73                 :          97 :     return aTokenUnderlying;
+      74                 :             :   }
+      75                 :             : 
+      76                 :             :   ///@inheritdoc IERC4626StataToken
+      77                 :             :   function depositATokens(uint256 assets, address receiver) external returns (uint256) {
+      78                 :       12005 :     uint256 shares = previewDeposit(assets);
+      79                 :       12005 :     _deposit(_msgSender(), receiver, assets, shares, false);
+      80                 :             : 
+      81                 :       11005 :     return shares;
+      82                 :             :   }
+      83                 :             : 
+      84                 :             :   ///@inheritdoc IERC4626StataToken
+      85                 :             :   function depositWithPermit(
+      86                 :             :     uint256 assets,
+      87                 :             :     address receiver,
+      88                 :             :     uint256 deadline,
+      89                 :             :     SignatureParams memory sig,
+      90                 :             :     bool depositToAave
+      91                 :             :   ) external returns (uint256) {
+      92                 :        5000 :     IERC20Permit assetToDeposit = IERC20Permit(
+      93                 :             :       depositToAave ? asset() : address(_getERC4626StataTokenStorage()._aToken)
+      94                 :             :     );
+      95                 :             : 
+      96                 :             :     try
+      97                 :        5000 :       assetToDeposit.permit(_msgSender(), address(this), assets, deadline, sig.v, sig.r, sig.s)
+      98                 :           0 :     {} catch {}
+      99                 :             : 
+     100                 :        5000 :     uint256 shares = previewDeposit(assets);
+     101                 :        5000 :     _deposit(_msgSender(), receiver, assets, shares, depositToAave);
+     102                 :        4000 :     return shares;
+     103                 :             :   }
+     104                 :             : 
+     105                 :             :   ///@inheritdoc IERC4626StataToken
+     106                 :             :   function redeemATokens(
+     107                 :             :     uint256 shares,
+     108                 :             :     address receiver,
+     109                 :             :     address owner
+     110                 :             :   ) external returns (uint256) {
+     111                 :        3000 :     uint256 assets = previewRedeem(shares);
+     112                 :        3000 :     _withdraw(_msgSender(), receiver, owner, assets, shares, false);
+     113                 :             : 
+     114                 :        2000 :     return assets;
+     115                 :             :   }
+     116                 :             : 
+     117                 :             :   ///@inheritdoc IERC4626StataToken
+     118                 :             :   function aToken() public view returns (IERC20) {
+     119                 :        1002 :     ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage();
+     120                 :        1002 :     return $._aToken;
+     121                 :             :   }
+     122                 :             : 
+     123                 :             :   ///@inheritdoc IERC4626
+     124                 :             :   function maxMint(address) public view override returns (uint256) {
+     125                 :        2002 :     uint256 assets = maxDeposit(address(0));
+     126                 :        2002 :     if (assets == type(uint256).max) return type(uint256).max;
+     127                 :           0 :     return convertToShares(assets);
+     128                 :             :   }
+     129                 :             : 
+     130                 :             :   ///@inheritdoc IERC4626
+     131                 :             :   function maxWithdraw(address owner) public view override returns (uint256) {
+     132                 :        2002 :     return convertToAssets(maxRedeem(owner));
+     133                 :             :   }
+     134                 :             : 
+     135                 :             :   ///@inheritdoc IERC4626
+     136                 :             :   function totalAssets() public view override returns (uint256) {
+     137                 :        1002 :     return _convertToAssets(totalSupply(), Math.Rounding.Floor);
+     138                 :             :   }
+     139                 :             : 
+     140                 :             :   ///@inheritdoc IERC4626
+     141                 :             :   function maxRedeem(address owner) public view override returns (uint256) {
+     142                 :        6005 :     DataTypes.ReserveData memory reserveData = POOL.getReserveDataExtended(asset());
+     143                 :             : 
+     144                 :             :     // if paused or inactive users cannot withdraw underlying
+     145                 :             :     if (
+     146                 :        6005 :       !ReserveConfiguration.getActive(reserveData.configuration) ||
+     147                 :        6005 :       ReserveConfiguration.getPaused(reserveData.configuration)
+     148                 :             :     ) {
+     149                 :        1000 :       return 0;
+     150                 :             :     }
+     151                 :             : 
+     152                 :             :     // otherwise users can withdraw up to the available amount
+     153                 :        5005 :     uint256 underlyingTokenBalanceInShares = convertToShares(reserveData.virtualUnderlyingBalance);
+     154                 :        5005 :     uint256 cachedUserBalance = balanceOf(owner);
+     155                 :        5005 :     return
+     156                 :        5005 :       underlyingTokenBalanceInShares >= cachedUserBalance
+     157                 :             :         ? cachedUserBalance
+     158                 :             :         : underlyingTokenBalanceInShares;
+     159                 :             :   }
+     160                 :             : 
+     161                 :             :   ///@inheritdoc IERC4626
+     162                 :             :   function maxDeposit(address) public view override returns (uint256) {
+     163                 :        3006 :     DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(asset());
+     164                 :             : 
+     165                 :             :     // if inactive, paused or frozen users cannot deposit underlying
+     166                 :             :     if (
+     167                 :        3006 :       !ReserveConfiguration.getActive(reserveData.configuration) ||
+     168                 :        3006 :       ReserveConfiguration.getPaused(reserveData.configuration) ||
+     169                 :        3005 :       ReserveConfiguration.getFrozen(reserveData.configuration)
+     170                 :             :     ) {
+     171                 :           2 :       return 0;
+     172                 :             :     }
+     173                 :             : 
+     174                 :        3004 :     uint256 supplyCap = ReserveConfiguration.getSupplyCap(reserveData.configuration) *
+     175                 :             :       (10 ** ReserveConfiguration.getDecimals(reserveData.configuration));
+     176                 :             :     // if no supply cap deposit is unlimited
+     177                 :        3004 :     if (supplyCap == 0) return type(uint256).max;
+     178                 :             : 
+     179                 :             :     // return remaining supply cap margin
+     180                 :        1000 :     uint256 currentSupply = (IAToken(reserveData.aTokenAddress).scaledTotalSupply() +
+     181                 :             :       reserveData.accruedToTreasury).mulDiv(_rate(), RAY, Math.Rounding.Ceil);
+     182                 :        1000 :     return currentSupply > supplyCap ? 0 : supplyCap - currentSupply;
+     183                 :             :   }
+     184                 :             : 
+     185                 :             :   ///@inheritdoc IERC4626StataToken
+     186                 :             :   function latestAnswer() external view returns (int256) {
+     187                 :        1001 :     uint256 aTokenUnderlyingAssetPrice = IAaveOracle(POOL_ADDRESSES_PROVIDER.getPriceOracle())
+     188                 :             :       .getAssetPrice(asset());
+     189                 :             :     // @notice aTokenUnderlyingAssetPrice * rate / RAY
+     190                 :        1001 :     return int256(aTokenUnderlyingAssetPrice.mulDiv(_rate(), RAY, Math.Rounding.Floor));
+     191                 :             :   }
+     192                 :             : 
+     193                 :             :   function _deposit(
+     194                 :             :     address caller,
+     195                 :             :     address receiver,
+     196                 :             :     uint256 assets,
+     197                 :             :     uint256 shares,
+     198                 :             :     bool depositToAave
+     199                 :             :   ) internal virtual {
+     200                 :       19007 :     if (shares == 0) {
+     201                 :           0 :       revert StaticATokenInvalidZeroShares();
+     202                 :             :     }
+     203                 :             :     // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the
+     204                 :             :     // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,
+     205                 :             :     // calls the vault, which is assumed not malicious.
+     206                 :             :     //
+     207                 :             :     // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the
+     208                 :             :     // assets are transferred and before the shares are minted, which is a valid state.
+     209                 :             :     // slither-disable-next-line reentrancy-no-eth
+     210                 :             : 
+     211                 :       19007 :     if (depositToAave) {
+     212                 :        4002 :       address cachedAsset = asset();
+     213                 :        4002 :       SafeERC20.safeTransferFrom(IERC20(cachedAsset), caller, address(this), assets);
+     214                 :        3002 :       POOL.deposit(cachedAsset, assets, address(this), 0);
+     215                 :             :     } else {
+     216                 :       15005 :       ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage();
+     217                 :       15005 :       SafeERC20.safeTransferFrom($._aToken, caller, address(this), assets);
+     218                 :             :     }
+     219                 :       16007 :     _mint(receiver, shares);
+     220                 :             : 
+     221                 :       16005 :     emit Deposit(caller, receiver, assets, shares);
+     222                 :             :   }
+     223                 :             : 
+     224                 :             :   function _deposit(
+     225                 :             :     address caller,
+     226                 :             :     address receiver,
+     227                 :             :     uint256 assets,
+     228                 :             :     uint256 shares
+     229                 :             :   ) internal virtual override {
+     230                 :        2002 :     _deposit(caller, receiver, assets, shares, true);
+     231                 :             :   }
+     232                 :             : 
+     233                 :             :   function _withdraw(
+     234                 :             :     address caller,
+     235                 :             :     address receiver,
+     236                 :             :     address owner,
+     237                 :             :     uint256 assets,
+     238                 :             :     uint256 shares,
+     239                 :             :     bool withdrawFromAave
+     240                 :             :   ) internal virtual {
+     241                 :        5002 :     if (caller != owner) {
+     242                 :        2000 :       _spendAllowance(owner, caller, shares);
+     243                 :             :     }
+     244                 :             : 
+     245                 :             :     // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
+     246                 :             :     // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
+     247                 :             :     // calls the vault, which is assumed not malicious.
+     248                 :             :     //
+     249                 :             :     // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the
+     250                 :             :     // shares are burned and after the assets are transferred, which is a valid state.
+     251                 :        4002 :     _burn(owner, shares);
+     252                 :        4000 :     if (withdrawFromAave) {
+     253                 :        2000 :       POOL.withdraw(asset(), assets, receiver);
+     254                 :             :     } else {
+     255                 :        2000 :       ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage();
+     256                 :        2000 :       SafeERC20.safeTransfer($._aToken, receiver, assets);
+     257                 :             :     }
+     258                 :             : 
+     259                 :        4000 :     emit Withdraw(caller, receiver, owner, assets, shares);
+     260                 :             :   }
+     261                 :             : 
+     262                 :             :   function _withdraw(
+     263                 :             :     address caller,
+     264                 :             :     address receiver,
+     265                 :             :     address owner,
+     266                 :             :     uint256 assets,
+     267                 :             :     uint256 shares
+     268                 :             :   ) internal virtual override {
+     269                 :        2002 :     _withdraw(caller, receiver, owner, assets, shares, true);
+     270                 :             :   }
+     271                 :             : 
+     272                 :             :   function _convertToShares(
+     273                 :             :     uint256 assets,
+     274                 :             :     Math.Rounding rounding
+     275                 :             :   ) internal view virtual override returns (uint256) {
+     276                 :             :     // * @notice assets * RAY / exchangeRate
+     277                 :       28013 :     return assets.mulDiv(RAY, _rate(), rounding);
+     278                 :             :   }
+     279                 :             : 
+     280                 :             :   function _convertToAssets(
+     281                 :             :     uint256 shares,
+     282                 :             :     Math.Rounding rounding
+     283                 :             :   ) internal view virtual override returns (uint256) {
+     284                 :             :     // * @notice share * exchangeRate / RAY
+     285                 :       14007 :     return shares.mulDiv(_rate(), RAY, rounding);
+     286                 :             :   }
+     287                 :             : 
+     288                 :             :   function _rate() internal view returns (uint256) {
+     289                 :       44021 :     return POOL.getReserveNormalizedIncome(asset());
+     290                 :             :   }
+     291                 :             : }
+        
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenFactory.sol.func-c.html b/report/extensions/static-a-token/StataTokenFactory.sol.func-c.html new file mode 100644 index 00000000..e70d06ee --- /dev/null +++ b/report/extensions/static-a-token/StataTokenFactory.sol.func-c.html @@ -0,0 +1,119 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenFactory.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenFactory.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:66.7 %2114
Test Date:2024-09-24 09:34:24Functions:60.0 %53
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
StataTokenFactory.0
StataTokenFactory.getStataTokens0
StataTokenFactory.createStataTokens23
StataTokenFactory.getStataToken23
StataTokenFactory.initialize655
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenFactory.sol.func.html b/report/extensions/static-a-token/StataTokenFactory.sol.func.html new file mode 100644 index 00000000..a0807d2d --- /dev/null +++ b/report/extensions/static-a-token/StataTokenFactory.sol.func.html @@ -0,0 +1,119 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenFactory.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenFactory.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:66.7 %2114
Test Date:2024-09-24 09:34:24Functions:60.0 %53
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
StataTokenFactory.0
StataTokenFactory.createStataTokens23
StataTokenFactory.getStataToken23
StataTokenFactory.getStataTokens0
StataTokenFactory.initialize655
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenFactory.sol.gcov.html b/report/extensions/static-a-token/StataTokenFactory.sol.gcov.html new file mode 100644 index 00000000..d2463089 --- /dev/null +++ b/report/extensions/static-a-token/StataTokenFactory.sol.gcov.html @@ -0,0 +1,176 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenFactory.sol + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenFactory.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:66.7 %2114
Test Date:2024-09-24 09:34:24Functions:60.0 %53
Branches:-00
+
+ + + + + + + + +

+
             Branch data     Line data    Source code
+
+       1                 :             : // SPDX-License-Identifier: BUSL-1.1
+       2                 :             : pragma solidity ^0.8.10;
+       3                 :             : 
+       4                 :             : import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol';
+       5                 :             : import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
+       6                 :             : import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol';
+       7                 :             : import {IPool, DataTypes} from '../../../contracts/interfaces/IPool.sol';
+       8                 :             : import {StataTokenV2} from './StataTokenV2.sol';
+       9                 :             : import {IStataTokenFactory} from './interfaces/IStataTokenFactory.sol';
+      10                 :             : 
+      11                 :             : /**
+      12                 :             :  * @title StataTokenFactory
+      13                 :             :  * @notice Factory contract that keeps track of all deployed StataTokens for a specified pool.
+      14                 :             :  * This registry also acts as a factory, allowing to deploy new StataTokens on demand.
+      15                 :             :  * There can only be one StataToken per underlying on the registry at any time.
+      16                 :             :  * @author BGD labs
+      17                 :             :  */
+      18                 :             : contract StataTokenFactory is Initializable, IStataTokenFactory {
+      19                 :             :   IPool public immutable POOL;
+      20                 :             :   address public immutable PROXY_ADMIN;
+      21                 :             :   ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY;
+      22                 :             :   address public immutable STATA_TOKEN_IMPL;
+      23                 :             : 
+      24                 :             :   mapping(address => address) internal _underlyingToStataToken;
+      25                 :             :   address[] internal _stataTokens;
+      26                 :             : 
+      27                 :             :   event StataTokenCreated(address indexed stataToken, address indexed underlying);
+      28                 :             : 
+      29                 :             :   constructor(
+      30                 :             :     IPool pool,
+      31                 :             :     address proxyAdmin,
+      32                 :             :     ITransparentProxyFactory transparentProxyFactory,
+      33                 :             :     address stataTokenImpl
+      34                 :             :   ) {
+      35                 :           0 :     POOL = pool;
+      36                 :           0 :     PROXY_ADMIN = proxyAdmin;
+      37                 :           0 :     TRANSPARENT_PROXY_FACTORY = transparentProxyFactory;
+      38                 :           0 :     STATA_TOKEN_IMPL = stataTokenImpl;
+      39                 :             :   }
+      40                 :             : 
+      41                 :             :   function initialize() external initializer {}
+      42                 :             : 
+      43                 :             :   ///@inheritdoc IStataTokenFactory
+      44                 :             :   function createStataTokens(address[] memory underlyings) external returns (address[] memory) {
+      45                 :          23 :     address[] memory stataTokens = new address[](underlyings.length);
+      46                 :          23 :     for (uint256 i = 0; i < underlyings.length; i++) {
+      47                 :          69 :       address cachedStataToken = _underlyingToStataToken[underlyings[i]];
+      48                 :          69 :       if (cachedStataToken == address(0)) {
+      49                 :          69 :         DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(underlyings[i]);
+      50                 :          69 :         if (reserveData.aTokenAddress == address(0))
+      51                 :           0 :           revert NotListedUnderlying(reserveData.aTokenAddress);
+      52                 :          69 :         bytes memory symbol = abi.encodePacked(
+      53                 :             :           'stat',
+      54                 :             :           IERC20Metadata(reserveData.aTokenAddress).symbol(),
+      55                 :             :           'v2'
+      56                 :             :         );
+      57                 :          69 :         address stataToken = TRANSPARENT_PROXY_FACTORY.createDeterministic(
+      58                 :             :           STATA_TOKEN_IMPL,
+      59                 :             :           PROXY_ADMIN,
+      60                 :             :           abi.encodeWithSelector(
+      61                 :             :             StataTokenV2.initialize.selector,
+      62                 :             :             reserveData.aTokenAddress,
+      63                 :             :             string(
+      64                 :             :               abi.encodePacked('Static ', IERC20Metadata(reserveData.aTokenAddress).name(), ' v2')
+      65                 :             :             ),
+      66                 :             :             string(symbol)
+      67                 :             :           ),
+      68                 :             :           bytes32(uint256(uint160(underlyings[i])))
+      69                 :             :         );
+      70                 :             : 
+      71                 :          69 :         _underlyingToStataToken[underlyings[i]] = stataToken;
+      72                 :          69 :         stataTokens[i] = stataToken;
+      73                 :          69 :         _stataTokens.push(stataToken);
+      74                 :          69 :         emit StataTokenCreated(stataToken, underlyings[i]);
+      75                 :             :       } else {
+      76                 :           0 :         stataTokens[i] = cachedStataToken;
+      77                 :             :       }
+      78                 :             :     }
+      79                 :          23 :     return stataTokens;
+      80                 :             :   }
+      81                 :             : 
+      82                 :             :   ///@inheritdoc IStataTokenFactory
+      83                 :             :   function getStataTokens() external view returns (address[] memory) {
+      84                 :           0 :     return _stataTokens;
+      85                 :             :   }
+      86                 :             : 
+      87                 :             :   ///@inheritdoc IStataTokenFactory
+      88                 :             :   function getStataToken(address underlying) external view returns (address) {
+      89                 :          23 :     return _underlyingToStataToken[underlying];
+      90                 :             :   }
+      91                 :             : }
+        
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenV2.sol.func-c.html b/report/extensions/static-a-token/StataTokenV2.sol.func-c.html new file mode 100644 index 00000000..86b8663e --- /dev/null +++ b/report/extensions/static-a-token/StataTokenV2.sol.func-c.html @@ -0,0 +1,161 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenV2.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenV2.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:85.7 %2118
Test Date:2024-09-24 09:34:24Functions:72.7 %118
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
StataTokenV2.0
StataTokenV2.maxRescue0
StataTokenV2.whoCanRescue0
StataTokenV2._claimRewardsOnBehalf1
StataTokenV2.decimals1
StataTokenV2.nonces3
StataTokenV2.initialize70
StataTokenV2.canPause1001
StataTokenV2.onlyPauseGuardian1007
StataTokenV2.setPaused1007
StataTokenV2._update1009
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenV2.sol.func.html b/report/extensions/static-a-token/StataTokenV2.sol.func.html new file mode 100644 index 00000000..c1164e33 --- /dev/null +++ b/report/extensions/static-a-token/StataTokenV2.sol.func.html @@ -0,0 +1,161 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenV2.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenV2.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:85.7 %2118
Test Date:2024-09-24 09:34:24Functions:72.7 %118
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
StataTokenV2.0
StataTokenV2._claimRewardsOnBehalf1
StataTokenV2._update1009
StataTokenV2.canPause1001
StataTokenV2.decimals1
StataTokenV2.initialize70
StataTokenV2.maxRescue0
StataTokenV2.nonces3
StataTokenV2.onlyPauseGuardian1007
StataTokenV2.setPaused1007
StataTokenV2.whoCanRescue0
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/StataTokenV2.sol.gcov.html b/report/extensions/static-a-token/StataTokenV2.sol.gcov.html new file mode 100644 index 00000000..1acc806f --- /dev/null +++ b/report/extensions/static-a-token/StataTokenV2.sol.gcov.html @@ -0,0 +1,206 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token/StataTokenV2.sol + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-token - StataTokenV2.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:85.7 %2118
Test Date:2024-09-24 09:34:24Functions:72.7 %118
Branches:-00
+
+ + + + + + + + +

+
             Branch data     Line data    Source code
+
+       1                 :             : // SPDX-License-Identifier: BUSL-1.1
+       2                 :             : pragma solidity ^0.8.0;
+       3                 :             : 
+       4                 :             : import {ERC20Upgradeable, ERC20PermitUpgradeable} from 'openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol';
+       5                 :             : import {IERC20Metadata} from '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol';
+       6                 :             : import {PausableUpgradeable} from 'openzeppelin-contracts-upgradeable/contracts/utils/PausableUpgradeable.sol';
+       7                 :             : import {IRescuable, Rescuable} from 'solidity-utils/contracts/utils/Rescuable.sol';
+       8                 :             : import {IRescuableBase, RescuableBase} from 'solidity-utils/contracts/utils/RescuableBase.sol';
+       9                 :             : import {IERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol';
+      10                 :             : 
+      11                 :             : import {IACLManager} from '../../../contracts/interfaces/IACLManager.sol';
+      12                 :             : import {ERC4626Upgradeable, ERC4626StataTokenUpgradeable, IPool, Math, IERC20} from './ERC4626StataTokenUpgradeable.sol';
+      13                 :             : import {ERC20AaveLMUpgradeable, IRewardsController} from './ERC20AaveLMUpgradeable.sol';
+      14                 :             : import {IStataTokenV2} from './interfaces/IStataTokenV2.sol';
+      15                 :             : import {IAToken} from './interfaces/IAToken.sol';
+      16                 :             : 
+      17                 :             : /**
+      18                 :             :  * @title StataTokenV2
+      19                 :             :  * @notice A 4626 Vault which wrapps aTokens in order to translate the rebasing nature of yield accrual into a non-rebasing value accrual.
+      20                 :             :  * @author BGD labs
+      21                 :             :  */
+      22                 :             : contract StataTokenV2 is
+      23                 :             :   ERC20PermitUpgradeable,
+      24                 :             :   ERC20AaveLMUpgradeable,
+      25                 :             :   ERC4626StataTokenUpgradeable,
+      26                 :             :   PausableUpgradeable,
+      27                 :             :   Rescuable,
+      28                 :             :   IStataTokenV2
+      29                 :             : {
+      30                 :             :   using Math for uint256;
+      31                 :             : 
+      32                 :             :   constructor(
+      33                 :             :     IPool pool,
+      34                 :             :     IRewardsController rewardsController
+      35                 :             :   ) ERC20AaveLMUpgradeable(rewardsController) ERC4626StataTokenUpgradeable(pool) {
+      36                 :           0 :     _disableInitializers();
+      37                 :             :   }
+      38                 :             : 
+      39                 :             :   modifier onlyPauseGuardian() {
+      40                 :        1007 :     if (!canPause(_msgSender())) revert OnlyPauseGuardian(_msgSender());
+      41                 :             :     _;
+      42                 :             :   }
+      43                 :             : 
+      44                 :             :   function initialize(
+      45                 :             :     address aToken,
+      46                 :             :     string calldata staticATokenName,
+      47                 :             :     string calldata staticATokenSymbol
+      48                 :             :   ) external initializer {
+      49                 :          69 :     __ERC20_init(staticATokenName, staticATokenSymbol);
+      50                 :          69 :     __ERC20Permit_init(staticATokenName);
+      51                 :          69 :     __ERC20AaveLM_init(aToken);
+      52                 :          69 :     __ERC4626StataToken_init(aToken);
+      53                 :          69 :     __Pausable_init();
+      54                 :             :   }
+      55                 :             : 
+      56                 :             :   ///@inheritdoc IStataTokenV2
+      57                 :             :   function setPaused(bool paused) external onlyPauseGuardian {
+      58                 :           7 :     if (paused) _pause();
+      59                 :           0 :     else _unpause();
+      60                 :             :   }
+      61                 :             : 
+      62                 :             :   /// @inheritdoc IRescuable
+      63                 :             :   function whoCanRescue() public view override returns (address) {
+      64                 :        1003 :     return POOL_ADDRESSES_PROVIDER.getACLAdmin();
+      65                 :             :   }
+      66                 :             : 
+      67                 :             :   /// @inheritdoc IRescuableBase
+      68                 :             :   function maxRescue(
+      69                 :             :     address asset
+      70                 :             :   ) public view override(IRescuableBase, RescuableBase) returns (uint256) {
+      71                 :        1002 :     IERC20 cachedAToken = aToken();
+      72                 :        1002 :     if (asset == address(cachedAToken)) {
+      73                 :        1001 :       uint256 requiredBacking = _convertToAssets(totalSupply(), Math.Rounding.Ceil);
+      74                 :        1001 :       uint256 balance = cachedAToken.balanceOf(address(this));
+      75                 :        1001 :       return balance > requiredBacking ? balance - requiredBacking : 0;
+      76                 :             :     }
+      77                 :           1 :     return type(uint256).max;
+      78                 :             :   }
+      79                 :             : 
+      80                 :             :   ///@inheritdoc IStataTokenV2
+      81                 :             :   function canPause(address actor) public view returns (bool) {
+      82                 :        2008 :     return IACLManager(POOL_ADDRESSES_PROVIDER.getACLManager()).isEmergencyAdmin(actor);
+      83                 :             :   }
+      84                 :             : 
+      85                 :             :   ///@inheritdoc IERC20Permit
+      86                 :             :   function nonces(
+      87                 :             :     address owner
+      88                 :             :   ) public view virtual override(ERC20PermitUpgradeable, IERC20Permit) returns (uint256) {
+      89                 :           3 :     return super.nonces(owner);
+      90                 :             :   }
+      91                 :             : 
+      92                 :             :   ///@inheritdoc IERC20Metadata
+      93                 :             :   function decimals()
+      94                 :             :     public
+      95                 :             :     view
+      96                 :             :     override(IERC20Metadata, ERC20Upgradeable, ERC4626Upgradeable)
+      97                 :             :     returns (uint8)
+      98                 :             :   {
+      99                 :             :     /// @notice The initialization of ERC4626Upgradeable already assures that decimal are
+     100                 :             :     /// the same as the underlying asset of the StataTokenV2, e.g. decimals of WETH for stataWETH
+     101                 :           1 :     return ERC4626Upgradeable.decimals();
+     102                 :             :   }
+     103                 :             : 
+     104                 :             :   function _claimRewardsOnBehalf(
+     105                 :             :     address onBehalfOf,
+     106                 :             :     address receiver,
+     107                 :             :     address[] memory rewards
+     108                 :             :   ) internal virtual override whenNotPaused {
+     109                 :           0 :     super._claimRewardsOnBehalf(onBehalfOf, receiver, rewards);
+     110                 :             :   }
+     111                 :             : 
+     112                 :             :   // @notice to merge inheritance with ERC20AaveLMUpgradeable.sol properly we put
+     113                 :             :   // `whenNotPaused` here instead of using ERC20PausableUpgradeable
+     114                 :             :   function _update(
+     115                 :             :     address from,
+     116                 :             :     address to,
+     117                 :             :     uint256 amount
+     118                 :             :   ) internal virtual override(ERC20AaveLMUpgradeable, ERC20Upgradeable) whenNotPaused {
+     119                 :        1004 :     ERC20AaveLMUpgradeable._update(from, to, amount);
+     120                 :             :   }
+     121                 :             : }
+        
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/index-sort-b.html b/report/extensions/static-a-token/index-sort-b.html new file mode 100644 index 00000000..ee99753c --- /dev/null +++ b/report/extensions/static-a-token/index-sort-b.html @@ -0,0 +1,169 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-tokenCoverageTotalHit
Test:lcov.info.pLines:89.4 %208186
Test Date:2024-09-24 09:34:24Functions:84.2 %5748
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
ERC20AaveLMUpgradeable.sol +
92.5%92.5%
+
92.5 %9386-90.9 %2220
ERC4626StataTokenUpgradeable.sol +
93.2%93.2%
+
93.2 %7368-89.5 %1917
StataTokenFactory.sol +
66.7%66.7%
+
66.7 %2114-60.0 %53
StataTokenV2.sol +
85.7%85.7%
+
85.7 %2118-72.7 %118
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/index-sort-f.html b/report/extensions/static-a-token/index-sort-f.html new file mode 100644 index 00000000..1ddeabca --- /dev/null +++ b/report/extensions/static-a-token/index-sort-f.html @@ -0,0 +1,169 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-tokenCoverageTotalHit
Test:lcov.info.pLines:89.4 %208186
Test Date:2024-09-24 09:34:24Functions:84.2 %5748
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
StataTokenFactory.sol +
66.7%66.7%
+
66.7 %2114-60.0 %53
StataTokenV2.sol +
85.7%85.7%
+
85.7 %2118-72.7 %118
ERC4626StataTokenUpgradeable.sol +
93.2%93.2%
+
93.2 %7368-89.5 %1917
ERC20AaveLMUpgradeable.sol +
92.5%92.5%
+
92.5 %9386-90.9 %2220
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/index-sort-l.html b/report/extensions/static-a-token/index-sort-l.html new file mode 100644 index 00000000..40e641b5 --- /dev/null +++ b/report/extensions/static-a-token/index-sort-l.html @@ -0,0 +1,169 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-tokenCoverageTotalHit
Test:lcov.info.pLines:89.4 %208186
Test Date:2024-09-24 09:34:24Functions:84.2 %5748
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
StataTokenFactory.sol +
66.7%66.7%
+
66.7 %2114-60.0 %53
StataTokenV2.sol +
85.7%85.7%
+
85.7 %2118-72.7 %118
ERC20AaveLMUpgradeable.sol +
92.5%92.5%
+
92.5 %9386-90.9 %2220
ERC4626StataTokenUpgradeable.sol +
93.2%93.2%
+
93.2 %7368-89.5 %1917
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/extensions/static-a-token/index.html b/report/extensions/static-a-token/index.html new file mode 100644 index 00000000..d190267e --- /dev/null +++ b/report/extensions/static-a-token/index.html @@ -0,0 +1,169 @@ + + + + + + + LCOV - lcov.info.p - extensions/static-a-token + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - extensions/static-a-tokenCoverageTotalHit
Test:lcov.info.pLines:89.4 %208186
Test Date:2024-09-24 09:34:24Functions:84.2 %5748
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
ERC20AaveLMUpgradeable.sol +
92.5%92.5%
+
92.5 %9386-90.9 %2220
ERC4626StataTokenUpgradeable.sol +
93.2%93.2%
+
93.2 %7368-89.5 %1917
StataTokenFactory.sol +
66.7%66.7%
+
66.7 %2114-60.0 %53
StataTokenV2.sol +
85.7%85.7%
+
85.7 %2118-72.7 %118
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/gcov.css b/report/gcov.css index f3290428..6c23ba93 100644 --- a/report/gcov.css +++ b/report/gcov.css @@ -187,6 +187,17 @@ td.coverFile font-family: monospace; } +/* Directory view/File view (all): directory name entry format */ +td.coverDirectory +{ + text-align: left; + padding-left: 10px; + padding-right: 20px; + color: #284fa8; + background-color: #b8d0ff; + font-family: monospace; +} + /* Directory view/File view (all): filename entry format */ td.overallOwner { @@ -528,12 +539,29 @@ pre.source margin-top: 2px; } +/* elided/removed code */ +span.elidedSource +{ + font-family: sans-serif; + /*font-size: 8pt; */ + font-style: italic; + background-color: lightgrey; +} + /* Source code view: line number format */ span.lineNum { background-color: #efe383; } +/* Source code view: line number format when there are deleted + lines in the corresponding location */ +span.lineNumWithDelete +{ + foreground-color: #efe383; + background-color: lightgrey; +} + /* Source code view: format for Cov legend */ span.coverLegendCov { @@ -634,7 +662,7 @@ a.branchTla:visited color: #000000; } -/* Source code view/table entry backround: format for lines classified as "Uncovered New Code (+ => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered New Code (+ => 0): Newly added code is not tested" */ td.tlaUNC { @@ -645,7 +673,7 @@ td.tlaBgUNC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Uncovered New Code (+ => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered New Code (+ => 0): Newly added code is not tested" */ span.tlaUNC { @@ -670,7 +698,7 @@ td.headerCovTableHeadUNC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Lost Baseline Coverage (1 => 0): +/* Source code view/table entry background: format for lines classified as "Lost Baseline Coverage (1 => 0): Unchanged code is no longer tested" */ td.tlaLBC { @@ -681,7 +709,7 @@ td.tlaBgLBC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Lost Baseline Coverage (1 => 0): +/* Source code view/table entry background: format for lines classified as "Lost Baseline Coverage (1 => 0): Unchanged code is no longer tested" */ span.tlaLBC { @@ -706,7 +734,7 @@ td.headerCovTableHeadLBC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Uncovered Included Code (# => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered Included Code (# => 0): Previously unused code is untested" */ td.tlaUIC { @@ -717,7 +745,7 @@ td.tlaBgUIC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Uncovered Included Code (# => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered Included Code (# => 0): Previously unused code is untested" */ span.tlaUIC { @@ -742,7 +770,7 @@ td.headerCovTableHeadUIC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Uncovered Baseline Code (0 => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered Baseline Code (0 => 0): Unchanged code was untested before, is untested now" */ td.tlaUBC { @@ -753,7 +781,7 @@ td.tlaBgUBC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Uncovered Baseline Code (0 => 0): +/* Source code view/table entry background: format for lines classified as "Uncovered Baseline Code (0 => 0): Unchanged code was untested before, is untested now" */ span.tlaUBC { @@ -778,7 +806,7 @@ td.headerCovTableHeadUBC { background-color: #FF6230; } -/* Source code view/table entry backround: format for lines classified as "Gained Baseline Coverage (0 => 1): +/* Source code view/table entry background: format for lines classified as "Gained Baseline Coverage (0 => 1): Unchanged code is tested now" */ td.tlaGBC { @@ -789,7 +817,7 @@ td.tlaBgGBC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Gained Baseline Coverage (0 => 1): +/* Source code view/table entry background: format for lines classified as "Gained Baseline Coverage (0 => 1): Unchanged code is tested now" */ span.tlaGBC { @@ -814,7 +842,7 @@ td.headerCovTableHeadGBC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Gained Included Coverage (# => 1): +/* Source code view/table entry background: format for lines classified as "Gained Included Coverage (# => 1): Previously unused code is tested now" */ td.tlaGIC { @@ -825,7 +853,7 @@ td.tlaBgGIC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Gained Included Coverage (# => 1): +/* Source code view/table entry background: format for lines classified as "Gained Included Coverage (# => 1): Previously unused code is tested now" */ span.tlaGIC { @@ -850,7 +878,7 @@ td.headerCovTableHeadGIC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Gained New Coverage (+ => 1): +/* Source code view/table entry background: format for lines classified as "Gained New Coverage (+ => 1): Newly added code is tested" */ td.tlaGNC { @@ -861,7 +889,7 @@ td.tlaBgGNC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Gained New Coverage (+ => 1): +/* Source code view/table entry background: format for lines classified as "Gained New Coverage (+ => 1): Newly added code is tested" */ span.tlaGNC { @@ -886,7 +914,7 @@ td.headerCovTableHeadGNC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Covered Baseline Code (1 => 1): +/* Source code view/table entry background: format for lines classified as "Covered Baseline Code (1 => 1): Unchanged code was tested before and is still tested" */ td.tlaCBC { @@ -897,7 +925,7 @@ td.tlaBgCBC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Covered Baseline Code (1 => 1): +/* Source code view/table entry background: format for lines classified as "Covered Baseline Code (1 => 1): Unchanged code was tested before and is still tested" */ span.tlaCBC { @@ -922,7 +950,7 @@ td.headerCovTableHeadCBC { background-color: #CAD7FE; } -/* Source code view/table entry backround: format for lines classified as "Excluded Uncovered Baseline (0 => #): +/* Source code view/table entry background: format for lines classified as "Excluded Uncovered Baseline (0 => #): Previously untested code is unused now" */ td.tlaEUB { @@ -933,7 +961,7 @@ td.tlaBgEUB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Excluded Uncovered Baseline (0 => #): +/* Source code view/table entry background: format for lines classified as "Excluded Uncovered Baseline (0 => #): Previously untested code is unused now" */ span.tlaEUB { @@ -958,7 +986,7 @@ td.headerCovTableHeadEUB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Excluded Covered Baseline (1 => #): +/* Source code view/table entry background: format for lines classified as "Excluded Covered Baseline (1 => #): Previously tested code is unused now" */ td.tlaECB { @@ -969,7 +997,7 @@ td.tlaBgECB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Excluded Covered Baseline (1 => #): +/* Source code view/table entry background: format for lines classified as "Excluded Covered Baseline (1 => #): Previously tested code is unused now" */ span.tlaECB { @@ -994,7 +1022,7 @@ td.headerCovTableHeadECB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Deleted Uncovered Baseline (0 => -): +/* Source code view/table entry background: format for lines classified as "Deleted Uncovered Baseline (0 => -): Previously untested code has been deleted" */ td.tlaDUB { @@ -1005,7 +1033,7 @@ td.tlaBgDUB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Deleted Uncovered Baseline (0 => -): +/* Source code view/table entry background: format for lines classified as "Deleted Uncovered Baseline (0 => -): Previously untested code has been deleted" */ span.tlaDUB { @@ -1030,7 +1058,7 @@ td.headerCovTableHeadDUB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Deleted Covered Baseline (1 => -): +/* Source code view/table entry background: format for lines classified as "Deleted Covered Baseline (1 => -): Previously tested code has been deleted" */ td.tlaDCB { @@ -1041,7 +1069,7 @@ td.tlaBgDCB { background-color: #FFFFFF; } -/* Source code view/table entry backround: format for lines classified as "Deleted Covered Baseline (1 => -): +/* Source code view/table entry background: format for lines classified as "Deleted Covered Baseline (1 => -): Previously tested code has been deleted" */ span.tlaDCB { diff --git a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func-c.html b/report/helpers/L2Encoder.sol.func-c.html similarity index 67% rename from report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func-c.html rename to report/helpers/L2Encoder.sol.func-c.html index 5ef0d0b6..5a58c656 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func-c.html +++ b/report/helpers/L2Encoder.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/L2Encoder.sol - functions - + LCOV - lcov.info.p - helpers/L2Encoder.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,33 +53,33 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - L2Encoder.sol (source / functions)top level - helpers - L2Encoder.sol (source / functions) Coveragelcov.info.p Lines:100.0 %686898.3 %5857
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %111190.0 %109
0 0
- + - + - + - + - + @@ -100,14 +100,7 @@ - - - - - - - - + @@ -152,8 +145,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
L2Encoder.encodeLiquidationCallL2Encoder.10
L2Encoder.encodeRebalanceStableBorrowRateL2Encoder.encodeLiquidationCall 1
L2Encoder.encodeSetUserUseReserveAsCollateral1
L2Encoder.encodeSwapBorrowRateModeL2Encoder.encodeSetUserUseReserveAsCollateral 1
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func.html b/report/helpers/L2Encoder.sol.func.html similarity index 67% rename from report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func.html rename to report/helpers/L2Encoder.sol.func.html index 6a118e88..09697cc0 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.func.html +++ b/report/helpers/L2Encoder.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/L2Encoder.sol - functions - + LCOV - lcov.info.p - helpers/L2Encoder.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,40 +53,40 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - L2Encoder.sol (source / functions)top level - helpers - L2Encoder.sol (source / functions) Coveragelcov.info.p Lines:100.0 %686898.3 %5857
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %111190.0 %109
0 0
- + - + - + - + - + - + - + @@ -114,7 +114,7 @@ - + @@ -133,13 +133,6 @@ - - - - - - - @@ -152,8 +145,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
L2Encoder.encodeBorrowParamsL2Encoder.30
L2Encoder.encodeLiquidationCallL2Encoder.encodeBorrowParams13
L2Encoder.encodeRebalanceStableBorrowRateL2Encoder.encodeLiquidationCall 1
L2Encoder.encodeSetUserUseReserveAsCollateralL2Encoder.encodeSetUserUseReserveAsCollateral 11000
L2Encoder.encodeSwapBorrowRateMode1
L2Encoder.encodeWithdrawParams
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.gcov.html b/report/helpers/L2Encoder.sol.gcov.html similarity index 77% rename from report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.gcov.html rename to report/helpers/L2Encoder.sol.gcov.html index 37fa7d60..5ae42100 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/L2Encoder.sol.gcov.html +++ b/report/helpers/L2Encoder.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/L2Encoder.sol - + LCOV - lcov.info.p - helpers/L2Encoder.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - L2Encoder.sol (source / functions)top level - helpers - L2Encoder.sol (source / functions) Coveragelcov.info.p Lines:100.0 %686898.3 %5857
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %111190.0 %109
0 0
@@ -91,7 +91,7 @@ 20 : : * @param pool The address of the Pool contract 21 : : */ 22 : : constructor(IPool pool) { - 23 : : POOL = pool; + 23 : 0 : POOL = pool; 24 : : } 25 : : 26 : : /** @@ -103,21 +103,21 @@ 32 : : * 0 if the action is executed directly by the user, without any middle-man 33 : : * @return compact representation of supply parameters 34 : : */ - 35 : 7 : function encodeSupplyParams( + 35 : : function encodeSupplyParams( 36 : : address asset, 37 : : uint256 amount, 38 : : uint16 referralCode 39 : : ) external view returns (bytes32) { - 40 : 21 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 40 : 7 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 41 : : - 42 : 14 : uint16 assetId = data.id; - 43 : 21 : uint128 shortenedAmount = amount.toUint128(); - 44 : 14 : bytes32 res; + 42 : 7 : uint16 assetId = data.id; + 43 : 7 : uint128 shortenedAmount = amount.toUint128(); + 44 : 7 : bytes32 res; 45 : : 46 : : assembly { - 47 : 14 : res := add(assetId, add(shl(16, shortenedAmount), shl(144, referralCode))) + 47 : 7 : res := add(assetId, add(shl(16, shortenedAmount), shl(144, referralCode))) 48 : : } - 49 : 14 : return res; + 49 : 7 : return res; 50 : : } 51 : : 52 : : /** @@ -135,7 +135,7 @@ 64 : : * @return The R parameter of ERC712 permit sig 65 : : * @return The S parameter of ERC712 permit sig 66 : : */ - 67 : 1000 : function encodeSupplyWithPermitParams( + 67 : : function encodeSupplyWithPermitParams( 68 : : address asset, 69 : : uint256 amount, 70 : : uint16 referralCode, @@ -144,15 +144,15 @@ 73 : : bytes32 permitR, 74 : : bytes32 permitS 75 : : ) external view returns (bytes32, bytes32, bytes32) { - 76 : 3000 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 76 : 1000 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 77 : : - 78 : 2000 : uint16 assetId = data.id; - 79 : 3000 : uint128 shortenedAmount = amount.toUint128(); - 80 : 3000 : uint32 shortenedDeadline = deadline.toUint32(); + 78 : 1000 : uint16 assetId = data.id; + 79 : 1000 : uint128 shortenedAmount = amount.toUint128(); + 80 : 1000 : uint32 shortenedDeadline = deadline.toUint32(); 81 : : - 82 : 2000 : bytes32 res; + 82 : 1000 : bytes32 res; 83 : : assembly { - 84 : 2000 : res := add( + 84 : 1000 : res := add( 85 : : assetId, 86 : : add( 87 : : shl(16, shortenedAmount), @@ -161,7 +161,7 @@ 90 : : ) 91 : : } 92 : : - 93 : 2000 : return (res, permitR, permitS); + 93 : 1000 : return (res, permitR, permitS); 94 : : } 95 : : 96 : : /** @@ -171,17 +171,17 @@ 100 : : * @param amount The underlying amount to be withdrawn 101 : : * @return compact representation of withdraw parameters 102 : : */ - 103 : 2 : function encodeWithdrawParams(address asset, uint256 amount) external view returns (bytes32) { - 104 : 6 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 103 : : function encodeWithdrawParams(address asset, uint256 amount) external view returns (bytes32) { + 104 : 2 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 105 : : - 106 : 4 : uint16 assetId = data.id; - 107 : 6 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); + 106 : 2 : uint16 assetId = data.id; + 107 : 2 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); 108 : : - 109 : 4 : bytes32 res; + 109 : 2 : bytes32 res; 110 : : assembly { - 111 : 4 : res := add(assetId, shl(16, shortenedAmount)) + 111 : 2 : res := add(assetId, shl(16, shortenedAmount)) 112 : : } - 113 : 4 : return res; + 113 : 2 : return res; 114 : : } 115 : : 116 : : /** @@ -189,25 +189,25 @@ 118 : : * @dev Without an onBehalfOf parameter as the compact calls to L2Pool will use msg.sender as onBehalfOf 119 : : * @param asset The address of the underlying asset to borrow 120 : : * @param amount The amount to be borrowed - 121 : : * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + 121 : : * @param interestRateMode The interest rate mode at which the user wants to borrow: 2 for Variable, 1 is deprecated (changed on v3.2.0) 122 : : * @param referralCode The code used to register the integrator originating the operation, for potential rewards. 123 : : * 0 if the action is executed directly by the user, without any middle-man 124 : : * @return compact representation of withdraw parameters 125 : : */ - 126 : 3 : function encodeBorrowParams( + 126 : : function encodeBorrowParams( 127 : : address asset, 128 : : uint256 amount, 129 : : uint256 interestRateMode, 130 : : uint16 referralCode 131 : : ) external view returns (bytes32) { - 132 : 9 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 132 : 3 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 133 : : - 134 : 6 : uint16 assetId = data.id; - 135 : 9 : uint128 shortenedAmount = amount.toUint128(); - 136 : 9 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); - 137 : 6 : bytes32 res; + 134 : 3 : uint16 assetId = data.id; + 135 : 3 : uint128 shortenedAmount = amount.toUint128(); + 136 : 3 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); + 137 : 3 : bytes32 res; 138 : : assembly { - 139 : 6 : res := add( + 139 : 3 : res := add( 140 : : assetId, 141 : : add( 142 : : shl(16, shortenedAmount), @@ -215,7 +215,7 @@ 144 : : ) 145 : : ) 146 : : } - 147 : 6 : return res; + 147 : 3 : return res; 148 : : } 149 : : 150 : : /** @@ -224,25 +224,25 @@ 153 : : * @param asset The address of the borrowed underlying asset previously borrowed 154 : : * @param amount The amount to repay 155 : : * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `interestRateMode` - 156 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + 156 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) 157 : : * @return compact representation of repay parameters 158 : : */ - 159 : 1 : function encodeRepayParams( + 159 : : function encodeRepayParams( 160 : : address asset, 161 : : uint256 amount, 162 : : uint256 interestRateMode 163 : : ) public view returns (bytes32) { - 164 : 6 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 164 : 2 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 165 : : - 166 : 4 : uint16 assetId = data.id; - 167 : 6 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); - 168 : 6 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); + 166 : 2 : uint16 assetId = data.id; + 167 : 2 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); + 168 : 2 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); 169 : : - 170 : 4 : bytes32 res; + 170 : 2 : bytes32 res; 171 : : assembly { - 172 : 4 : res := add(assetId, add(shl(16, shortenedAmount), shl(144, shortenedInterestRateMode))) + 172 : 2 : res := add(assetId, add(shl(16, shortenedAmount), shl(144, shortenedInterestRateMode))) 173 : : } - 174 : 4 : return res; + 174 : 2 : return res; 175 : : } 176 : : 177 : : /** @@ -251,7 +251,7 @@ 180 : : * @param asset The address of the borrowed underlying asset previously borrowed 181 : : * @param amount The amount to repay 182 : : * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - 183 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + 183 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) 184 : : * @param deadline The deadline timestamp that the permit is valid 185 : : * @param permitV The V parameter of ERC712 permit sig 186 : : * @param permitR The R parameter of ERC712 permit sig @@ -260,7 +260,7 @@ 189 : : * @return The R parameter of ERC712 permit sig 190 : : * @return The S parameter of ERC712 permit sig 191 : : */ - 192 : 1000 : function encodeRepayWithPermitParams( + 192 : : function encodeRepayWithPermitParams( 193 : : address asset, 194 : : uint256 amount, 195 : : uint256 interestRateMode, @@ -269,16 +269,16 @@ 198 : : bytes32 permitR, 199 : : bytes32 permitS 200 : : ) external view returns (bytes32, bytes32, bytes32) { - 201 : 3000 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 201 : 1000 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); 202 : : - 203 : 2000 : uint16 assetId = data.id; - 204 : 3000 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); - 205 : 3000 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); - 206 : 3000 : uint32 shortenedDeadline = deadline.toUint32(); + 203 : 1000 : uint16 assetId = data.id; + 204 : 1000 : uint128 shortenedAmount = amount == type(uint256).max ? type(uint128).max : amount.toUint128(); + 205 : 1000 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); + 206 : 1000 : uint32 shortenedDeadline = deadline.toUint32(); 207 : : - 208 : 2000 : bytes32 res; + 208 : 1000 : bytes32 res; 209 : : assembly { - 210 : 2000 : res := add( + 210 : 1000 : res := add( 211 : : assetId, 212 : : add( 213 : : shl(16, shortenedAmount), @@ -289,7 +289,7 @@ 218 : : ) 219 : : ) 220 : : } - 221 : 2000 : return (res, permitR, permitS); + 221 : 1000 : return (res, permitR, permitS); 222 : : } 223 : : 224 : : /** @@ -297,114 +297,74 @@ 226 : : * @param asset The address of the borrowed underlying asset previously borrowed 227 : : * @param amount The amount to repay 228 : : * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` - 229 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + 229 : : * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 2 for Variable, 1 is deprecated (changed on v3.2.0) 230 : : * @return compact representation of repay with aToken parameters 231 : : */ - 232 : 1 : function encodeRepayWithATokensParams( + 232 : : function encodeRepayWithATokensParams( 233 : : address asset, 234 : : uint256 amount, 235 : : uint256 interestRateMode 236 : : ) external view returns (bytes32) { - 237 : 3 : return encodeRepayParams(asset, amount, interestRateMode); + 237 : 1 : return encodeRepayParams(asset, amount, interestRateMode); 238 : : } 239 : : 240 : : /** - 241 : : * @notice Encodes swap borrow rate mode parameters from standard input to compact representation of 1 bytes32 + 241 : : * @notice Encodes set user use reserve as collateral parameters from standard input to compact representation of 1 bytes32 242 : : * @param asset The address of the underlying asset borrowed - 243 : : * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable - 244 : : * @return compact representation of swap borrow rate mode parameters + 243 : : * @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise + 244 : : * @return compact representation of set user use reserve as collateral parameters 245 : : */ - 246 : 1 : function encodeSwapBorrowRateMode( + 246 : : function encodeSetUserUseReserveAsCollateral( 247 : : address asset, - 248 : : uint256 interestRateMode + 248 : : bool useAsCollateral 249 : : ) external view returns (bytes32) { - 250 : 3 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); - 251 : 2 : uint16 assetId = data.id; - 252 : 3 : uint8 shortenedInterestRateMode = interestRateMode.toUint8(); - 253 : 2 : bytes32 res; - 254 : : assembly { - 255 : 2 : res := add(assetId, shl(16, shortenedInterestRateMode)) - 256 : : } - 257 : 2 : return res; - 258 : : } - 259 : : - 260 : : /** - 261 : : * @notice Encodes rebalance stable borrow rate parameters from standard input to compact representation of 1 bytes32 - 262 : : * @param asset The address of the underlying asset borrowed - 263 : : * @param user The address of the user to be rebalanced - 264 : : * @return compact representation of rebalance stable borrow rate parameters - 265 : : */ - 266 : 1 : function encodeRebalanceStableBorrowRate( - 267 : : address asset, - 268 : : address user - 269 : : ) external view returns (bytes32) { - 270 : 3 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); - 271 : 2 : uint16 assetId = data.id; - 272 : : - 273 : 2 : bytes32 res; - 274 : : assembly { - 275 : 2 : res := add(assetId, shl(16, user)) - 276 : : } - 277 : 2 : return res; - 278 : : } + 250 : 1 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); + 251 : 1 : uint16 assetId = data.id; + 252 : 1 : bytes32 res; + 253 : : assembly { + 254 : 1 : res := add(assetId, shl(16, useAsCollateral)) + 255 : : } + 256 : 1 : return res; + 257 : : } + 258 : : + 259 : : /** + 260 : : * @notice Encodes liquidation call parameters from standard input to compact representation of 2 bytes32 + 261 : : * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation + 262 : : * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation + 263 : : * @param user The address of the borrower getting liquidated + 264 : : * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover + 265 : : * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants + 266 : : * to receive the underlying collateral asset directly + 267 : : * @return First half ot compact representation of liquidation call parameters + 268 : : * @return Second half ot compact representation of liquidation call parameters + 269 : : */ + 270 : : function encodeLiquidationCall( + 271 : : address collateralAsset, + 272 : : address debtAsset, + 273 : : address user, + 274 : : uint256 debtToCover, + 275 : : bool receiveAToken + 276 : : ) external view returns (bytes32, bytes32) { + 277 : 1 : DataTypes.ReserveDataLegacy memory collateralData = POOL.getReserveData(collateralAsset); + 278 : 1 : uint16 collateralAssetId = collateralData.id; 279 : : - 280 : : /** - 281 : : * @notice Encodes set user use reserve as collateral parameters from standard input to compact representation of 1 bytes32 - 282 : : * @param asset The address of the underlying asset borrowed - 283 : : * @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise - 284 : : * @return compact representation of set user use reserve as collateral parameters - 285 : : */ - 286 : 1 : function encodeSetUserUseReserveAsCollateral( - 287 : : address asset, - 288 : : bool useAsCollateral - 289 : : ) external view returns (bytes32) { - 290 : 3 : DataTypes.ReserveDataLegacy memory data = POOL.getReserveData(asset); - 291 : 2 : uint16 assetId = data.id; - 292 : 2 : bytes32 res; - 293 : : assembly { - 294 : 2 : res := add(assetId, shl(16, useAsCollateral)) - 295 : : } - 296 : 2 : return res; - 297 : : } - 298 : : - 299 : : /** - 300 : : * @notice Encodes liquidation call parameters from standard input to compact representation of 2 bytes32 - 301 : : * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation - 302 : : * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation - 303 : : * @param user The address of the borrower getting liquidated - 304 : : * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover - 305 : : * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants - 306 : : * to receive the underlying collateral asset directly - 307 : : * @return First half ot compact representation of liquidation call parameters - 308 : : * @return Second half ot compact representation of liquidation call parameters - 309 : : */ - 310 : 1 : function encodeLiquidationCall( - 311 : : address collateralAsset, - 312 : : address debtAsset, - 313 : : address user, - 314 : : uint256 debtToCover, - 315 : : bool receiveAToken - 316 : : ) external view returns (bytes32, bytes32) { - 317 : 3 : DataTypes.ReserveDataLegacy memory collateralData = POOL.getReserveData(collateralAsset); - 318 : 2 : uint16 collateralAssetId = collateralData.id; - 319 : : - 320 : 3 : DataTypes.ReserveDataLegacy memory debtData = POOL.getReserveData(debtAsset); - 321 : 2 : uint16 debtAssetId = debtData.id; - 322 : : - 323 : 3 : uint128 shortenedDebtToCover = debtToCover == type(uint256).max - 324 : : ? type(uint128).max - 325 : : : debtToCover.toUint128(); - 326 : : - 327 : 2 : bytes32 res1; - 328 : 2 : bytes32 res2; - 329 : : - 330 : : assembly { - 331 : 2 : res1 := add(add(collateralAssetId, shl(16, debtAssetId)), shl(32, user)) - 332 : 2 : res2 := add(shortenedDebtToCover, shl(128, receiveAToken)) - 333 : : } - 334 : 2 : return (res1, res2); - 335 : : } - 336 : : } + 280 : 1 : DataTypes.ReserveDataLegacy memory debtData = POOL.getReserveData(debtAsset); + 281 : 1 : uint16 debtAssetId = debtData.id; + 282 : : + 283 : 1 : uint128 shortenedDebtToCover = debtToCover == type(uint256).max + 284 : : ? type(uint128).max + 285 : : : debtToCover.toUint128(); + 286 : : + 287 : 1 : bytes32 res1; + 288 : 1 : bytes32 res2; + 289 : : + 290 : : assembly { + 291 : 1 : res1 := add(add(collateralAssetId, shl(16, debtAssetId)), shl(32, user)) + 292 : 1 : res2 := add(shortenedDebtToCover, shl(128, receiveAToken)) + 293 : : } + 294 : 1 : return (res1, res2); + 295 : : } + 296 : : } @@ -412,8 +372,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func-c.html b/report/helpers/WrappedTokenGatewayV3.sol.func-c.html similarity index 66% rename from report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func-c.html rename to report/helpers/WrappedTokenGatewayV3.sol.func-c.html index 839810f6..a0c3b246 100644 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func-c.html +++ b/report/helpers/WrappedTokenGatewayV3.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol - functions - + LCOV - lcov.info.p - helpers/WrappedTokenGatewayV3.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,89 +53,89 @@ - +
Current view:top level - periphery/contracts/misc/src/periphery/contracts/misc - WrappedTokenGatewayV3.sol (source / functions)top level - helpers - WrappedTokenGatewayV3.sol (source / functions) Coveragelcov.info.p Lines:100.0 %383890.2 %4137
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + - + - + - + - + - + @@ -145,8 +145,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
WrappedTokenGatewayV3.borrowETHWrappedTokenGatewayV3.borrowETH 1
WrappedTokenGatewayV3.emergencyEtherTransferWrappedTokenGatewayV3.emergencyEtherTransfer 1
WrappedTokenGatewayV3.emergencyTokenTransferWrappedTokenGatewayV3.emergencyTokenTransfer 1
WrappedTokenGatewayV3.getWETHAddressWrappedTokenGatewayV3.getWETHAddress 1
WrappedTokenGatewayV3.WrappedTokenGatewayV3. 2
WrappedTokenGatewayV3.withdrawETHWrappedTokenGatewayV3.withdrawETH 2
WrappedTokenGatewayV3.withdrawETHWithPermitWrappedTokenGatewayV3.withdrawETHWithPermit 2
WrappedTokenGatewayV3.repayETHWrappedTokenGatewayV3.repayETH 5
WrappedTokenGatewayV3._safeTransferETHWrappedTokenGatewayV3._safeTransferETH 7
WrappedTokenGatewayV3.depositETHWrappedTokenGatewayV3.depositETH 8
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func.html b/report/helpers/WrappedTokenGatewayV3.sol.func.html similarity index 66% rename from report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func.html rename to report/helpers/WrappedTokenGatewayV3.sol.func.html index 8970b385..7ee3be56 100644 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.func.html +++ b/report/helpers/WrappedTokenGatewayV3.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol - functions - + LCOV - lcov.info.p - helpers/WrappedTokenGatewayV3.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,89 +53,89 @@ - +
Current view:top level - periphery/contracts/misc/src/periphery/contracts/misc - WrappedTokenGatewayV3.sol (source / functions)top level - helpers - WrappedTokenGatewayV3.sol (source / functions) Coveragelcov.info.p Lines:100.0 %383890.2 %4137
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + - + - + - + - + - + @@ -145,8 +145,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
WrappedTokenGatewayV3.WrappedTokenGatewayV3. 2
WrappedTokenGatewayV3._safeTransferETHWrappedTokenGatewayV3._safeTransferETH 7
WrappedTokenGatewayV3.borrowETHWrappedTokenGatewayV3.borrowETH 1
WrappedTokenGatewayV3.depositETHWrappedTokenGatewayV3.depositETH 8
WrappedTokenGatewayV3.emergencyEtherTransferWrappedTokenGatewayV3.emergencyEtherTransfer 1
WrappedTokenGatewayV3.emergencyTokenTransferWrappedTokenGatewayV3.emergencyTokenTransfer 1
WrappedTokenGatewayV3.getWETHAddressWrappedTokenGatewayV3.getWETHAddress 1
WrappedTokenGatewayV3.repayETHWrappedTokenGatewayV3.repayETH 5
WrappedTokenGatewayV3.withdrawETHWrappedTokenGatewayV3.withdrawETH 2
WrappedTokenGatewayV3.withdrawETHWithPermitWrappedTokenGatewayV3.withdrawETHWithPermit 2
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.gcov.html b/report/helpers/WrappedTokenGatewayV3.sol.gcov.html similarity index 73% rename from report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.gcov.html rename to report/helpers/WrappedTokenGatewayV3.sol.gcov.html index 9e54be92..dd54419f 100644 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol.gcov.html +++ b/report/helpers/WrappedTokenGatewayV3.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc/WrappedTokenGatewayV3.sol - + LCOV - lcov.info.p - helpers/WrappedTokenGatewayV3.sol + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/misc/src/periphery/contracts/misc - WrappedTokenGatewayV3.sol (source / functions)top level - helpers - WrappedTokenGatewayV3.sol (source / functions) Coveragelcov.info.p Lines:100.0 %383890.2 %4137
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -72,209 +72,200 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; - 5 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; - 6 : : import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; - 7 : : import {IWETH} from 'aave-v3-core/contracts/misc/interfaces/IWETH.sol'; - 8 : : import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol'; - 9 : : import {IAToken} from 'aave-v3-core/contracts/interfaces/IAToken.sol'; - 10 : : import {ReserveConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; - 11 : : import {UserConfiguration} from 'aave-v3-core/contracts/protocol/libraries/configuration/UserConfiguration.sol'; - 12 : : import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; + 4 : : import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; + 5 : : import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; + 6 : : import {GPv2SafeERC20} from '../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; + 7 : : import {IWETH} from './interfaces/IWETH.sol'; + 8 : : import {IPool} from '../interfaces/IPool.sol'; + 9 : : import {IAToken} from '../interfaces/IAToken.sol'; + 10 : : import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; + 11 : : import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; + 12 : : import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; 13 : : import {IWrappedTokenGatewayV3} from './interfaces/IWrappedTokenGatewayV3.sol'; - 14 : : import {DataTypesHelper} from '../libraries/DataTypesHelper.sol'; - 15 : : - 16 : : /** - 17 : : * @dev This contract is an upgrade of the WrappedTokenGatewayV3 contract, with immutable pool address. - 18 : : * This contract keeps the same interface of the deprecated WrappedTokenGatewayV3 contract. - 19 : : */ - 20 : : contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { - 21 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 22 : : using UserConfiguration for DataTypes.UserConfigurationMap; - 23 : : using GPv2SafeERC20 for IERC20; - 24 : : - 25 : : IWETH internal immutable WETH; - 26 : : IPool internal immutable POOL; - 27 : : - 28 : : /** - 29 : : * @dev Sets the WETH address and the PoolAddressesProvider address. Infinite approves pool. - 30 : : * @param weth Address of the Wrapped Ether contract - 31 : : * @param owner Address of the owner of this contract - 32 : : **/ - 33 : : constructor(address weth, address owner, IPool pool) { - 34 : : WETH = IWETH(weth); - 35 : : POOL = pool; - 36 : : transferOwnership(owner); - 37 : : IWETH(weth).approve(address(pool), type(uint256).max); - 38 : : } - 39 : : - 40 : : /** - 41 : : * @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens) - 42 : : * is minted. - 43 : : * @param onBehalfOf address of the user who will receive the aTokens representing the deposit - 44 : : * @param referralCode integrators are assigned a referral code and can potentially receive rewards. - 45 : : **/ - 46 : 8 : function depositETH(address, address onBehalfOf, uint16 referralCode) external payable override { - 47 : 16 : WETH.deposit{value: msg.value}(); - 48 : 16 : POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode); - 49 : : } - 50 : : - 51 : : /** - 52 : : * @dev withdraws the WETH _reserves of msg.sender. - 53 : : * @param amount amount of aWETH to withdraw and receive native ETH - 54 : : * @param to address of the user who will receive native ETH - 55 : : */ - 56 : 2 : function withdrawETH(address, uint256 amount, address to) external override { - 57 : 6 : IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress); - 58 : 6 : uint256 userBalance = aWETH.balanceOf(msg.sender); - 59 : 4 : uint256 amountToWithdraw = amount; - 60 : : - 61 : : // if amount is equal to uint(-1), the user wants to redeem everything - 62 : 4 : if (amount == type(uint256).max) { - 63 : 2 : amountToWithdraw = userBalance; - 64 : : } - 65 : 4 : aWETH.transferFrom(msg.sender, address(this), amountToWithdraw); - 66 : 4 : POOL.withdraw(address(WETH), amountToWithdraw, address(this)); - 67 : 4 : WETH.withdraw(amountToWithdraw); - 68 : 4 : _safeTransferETH(to, amountToWithdraw); - 69 : : } - 70 : : - 71 : : /** - 72 : : * @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). - 73 : : * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything - 74 : : * @param rateMode the rate mode to repay - 75 : : * @param onBehalfOf the address for which msg.sender is repaying - 76 : : */ - 77 : 5 : function repayETH( - 78 : : address, - 79 : : uint256 amount, - 80 : : uint256 rateMode, - 81 : : address onBehalfOf - 82 : : ) external payable override { - 83 : 15 : (uint256 stableDebt, uint256 variableDebt) = DataTypesHelper.getUserCurrentDebt( - 84 : : onBehalfOf, - 85 : : POOL.getReserveData(address(WETH)) - 86 : : ); - 87 : : - 88 : 15 : uint256 paybackAmount = DataTypes.InterestRateMode(rateMode) == - 89 : : DataTypes.InterestRateMode.STABLE - 90 : : ? stableDebt - 91 : : : variableDebt; - 92 : : - 93 : 10 : if (amount < paybackAmount) { - 94 : 4 : paybackAmount = amount; - 95 : : } - 96 : 10 : require(msg.value >= paybackAmount, 'msg.value is less than repayment amount'); - 97 : 10 : WETH.deposit{value: paybackAmount}(); - 98 : 10 : POOL.repay(address(WETH), paybackAmount, rateMode, onBehalfOf); - 99 : : - 100 : : // refund remaining dust eth - 101 : 11 : if (msg.value > paybackAmount) _safeTransferETH(msg.sender, msg.value - paybackAmount); - 102 : : } - 103 : : - 104 : : /** - 105 : : * @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `Pool.borrow`. - 106 : : * @param amount the amount of ETH to borrow - 107 : : * @param interestRateMode the interest rate mode - 108 : : * @param referralCode integrators are assigned a referral code and can potentially receive rewards - 109 : : */ - 110 : 1 : function borrowETH( - 111 : : address, - 112 : : uint256 amount, - 113 : : uint256 interestRateMode, - 114 : : uint16 referralCode - 115 : : ) external override { - 116 : 2 : POOL.borrow(address(WETH), amount, interestRateMode, referralCode, msg.sender); - 117 : 2 : WETH.withdraw(amount); - 118 : 2 : _safeTransferETH(msg.sender, amount); - 119 : : } - 120 : : - 121 : : /** - 122 : : * @dev withdraws the WETH _reserves of msg.sender. - 123 : : * @param amount amount of aWETH to withdraw and receive native ETH - 124 : : * @param to address of the user who will receive native ETH - 125 : : * @param deadline validity deadline of permit and so depositWithPermit signature - 126 : : * @param permitV V parameter of ERC712 permit sig - 127 : : * @param permitR R parameter of ERC712 permit sig - 128 : : * @param permitS S parameter of ERC712 permit sig - 129 : : */ - 130 : 2 : function withdrawETHWithPermit( - 131 : : address, - 132 : : uint256 amount, - 133 : : address to, - 134 : : uint256 deadline, - 135 : : uint8 permitV, - 136 : : bytes32 permitR, - 137 : : bytes32 permitS - 138 : : ) external override { - 139 : 6 : IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress); - 140 : 6 : uint256 userBalance = aWETH.balanceOf(msg.sender); - 141 : 4 : uint256 amountToWithdraw = amount; - 142 : : - 143 : : // if amount is equal to type(uint256).max, the user wants to redeem everything - 144 : 4 : if (amount == type(uint256).max) { - 145 : 2 : amountToWithdraw = userBalance; - 146 : : } - 147 : : // permit `amount` rather than `amountToWithdraw` to make it easier for front-ends and integrators - 148 : 4 : aWETH.permit(msg.sender, address(this), amount, deadline, permitV, permitR, permitS); - 149 : 4 : aWETH.transferFrom(msg.sender, address(this), amountToWithdraw); - 150 : 4 : POOL.withdraw(address(WETH), amountToWithdraw, address(this)); - 151 : 4 : WETH.withdraw(amountToWithdraw); - 152 : 4 : _safeTransferETH(to, amountToWithdraw); - 153 : : } - 154 : : - 155 : : /** - 156 : : * @dev transfer ETH to an address, revert if it fails. - 157 : : * @param to recipient of the transfer - 158 : : * @param value the amount to send - 159 : : */ - 160 : 7 : function _safeTransferETH(address to, uint256 value) internal { - 161 : 21 : (bool success, ) = to.call{value: value}(new bytes(0)); - 162 : 14 : require(success, 'ETH_TRANSFER_FAILED'); - 163 : : } - 164 : : - 165 : : /** - 166 : : * @dev transfer ERC20 from the utility contract, for ERC20 recovery in case of stuck tokens due - 167 : : * direct transfers to the contract address. - 168 : : * @param token token to transfer - 169 : : * @param to recipient of the transfer - 170 : : * @param amount amount to send - 171 : : */ - 172 : 1 : function emergencyTokenTransfer(address token, address to, uint256 amount) external onlyOwner { - 173 : 2 : IERC20(token).safeTransfer(to, amount); - 174 : : } - 175 : : - 176 : : /** - 177 : : * @dev transfer native Ether from the utility contract, for native Ether recovery in case of stuck Ether - 178 : : * due to selfdestructs or ether transfers to the pre-computed contract address before deployment. - 179 : : * @param to recipient of the transfer - 180 : : * @param amount amount to send - 181 : : */ - 182 : 1 : function emergencyEtherTransfer(address to, uint256 amount) external onlyOwner { - 183 : 2 : _safeTransferETH(to, amount); - 184 : : } - 185 : : - 186 : : /** - 187 : : * @dev Get WETH address used by WrappedTokenGatewayV3 - 188 : : */ - 189 : 1 : function getWETHAddress() external view returns (address) { - 190 : 3 : return address(WETH); - 191 : : } - 192 : : - 193 : : /** - 194 : : * @dev Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract. - 195 : : */ - 196 : : receive() external payable { - 197 : : require(msg.sender == address(WETH), 'Receive not allowed'); - 198 : : } - 199 : : - 200 : : /** - 201 : : * @dev Revert fallback calls - 202 : : */ - 203 : 2 : fallback() external payable { - 204 : 4 : revert('Fallback not allowed'); - 205 : : } - 206 : : } + 14 : : + 15 : : /** + 16 : : * @dev This contract is an upgrade of the WrappedTokenGatewayV3 contract, with immutable pool address. + 17 : : * This contract keeps the same interface of the deprecated WrappedTokenGatewayV3 contract. + 18 : : */ + 19 : : contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { + 20 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 21 : : using UserConfiguration for DataTypes.UserConfigurationMap; + 22 : : using GPv2SafeERC20 for IERC20; + 23 : : + 24 : : IWETH internal immutable WETH; + 25 : : IPool internal immutable POOL; + 26 : : + 27 : : /** + 28 : : * @dev Sets the WETH address and the PoolAddressesProvider address. Infinite approves pool. + 29 : : * @param weth Address of the Wrapped Ether contract + 30 : : * @param owner Address of the owner of this contract + 31 : : **/ + 32 : : constructor(address weth, address owner, IPool pool) { + 33 : 0 : WETH = IWETH(weth); + 34 : 0 : POOL = pool; + 35 : 0 : transferOwnership(owner); + 36 : 0 : IWETH(weth).approve(address(pool), type(uint256).max); + 37 : : } + 38 : : + 39 : : /** + 40 : : * @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens) + 41 : : * is minted. + 42 : : * @param onBehalfOf address of the user who will receive the aTokens representing the deposit + 43 : : * @param referralCode integrators are assigned a referral code and can potentially receive rewards. + 44 : : **/ + 45 : : function depositETH(address, address onBehalfOf, uint16 referralCode) external payable override { + 46 : 8 : WETH.deposit{value: msg.value}(); + 47 : 8 : POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode); + 48 : : } + 49 : : + 50 : : /** + 51 : : * @dev withdraws the WETH _reserves of msg.sender. + 52 : : * @param amount amount of aWETH to withdraw and receive native ETH + 53 : : * @param to address of the user who will receive native ETH + 54 : : */ + 55 : : function withdrawETH(address, uint256 amount, address to) external override { + 56 : 2 : IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress); + 57 : 2 : uint256 userBalance = aWETH.balanceOf(msg.sender); + 58 : 2 : uint256 amountToWithdraw = amount; + 59 : : + 60 : : // if amount is equal to uint(-1), the user wants to redeem everything + 61 : 2 : if (amount == type(uint256).max) { + 62 : 1 : amountToWithdraw = userBalance; + 63 : : } + 64 : 2 : aWETH.transferFrom(msg.sender, address(this), amountToWithdraw); + 65 : 2 : POOL.withdraw(address(WETH), amountToWithdraw, address(this)); + 66 : 2 : WETH.withdraw(amountToWithdraw); + 67 : 2 : _safeTransferETH(to, amountToWithdraw); + 68 : : } + 69 : : + 70 : : /** + 71 : : * @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). + 72 : : * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything + 73 : : * @param onBehalfOf the address for which msg.sender is repaying + 74 : : */ + 75 : : function repayETH(address, uint256 amount, address onBehalfOf) external payable override { + 76 : 5 : uint256 paybackAmount = IERC20((POOL.getReserveData(address(WETH))).variableDebtTokenAddress) + 77 : : .balanceOf(onBehalfOf); + 78 : : + 79 : 5 : if (amount < paybackAmount) { + 80 : 2 : paybackAmount = amount; + 81 : : } + 82 : 5 : require(msg.value >= paybackAmount, 'msg.value is less than repayment amount'); + 83 : 5 : WETH.deposit{value: paybackAmount}(); + 84 : 5 : POOL.repay( + 85 : : address(WETH), + 86 : : paybackAmount, + 87 : : uint256(DataTypes.InterestRateMode.VARIABLE), + 88 : : onBehalfOf + 89 : : ); + 90 : : + 91 : : // refund remaining dust eth + 92 : 5 : if (msg.value > paybackAmount) _safeTransferETH(msg.sender, msg.value - paybackAmount); + 93 : : } + 94 : : + 95 : : /** + 96 : : * @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `Pool.borrow`. + 97 : : * @param amount the amount of ETH to borrow + 98 : : * @param referralCode integrators are assigned a referral code and can potentially receive rewards + 99 : : */ + 100 : : function borrowETH(address, uint256 amount, uint16 referralCode) external override { + 101 : 1 : POOL.borrow( + 102 : : address(WETH), + 103 : : amount, + 104 : : uint256(DataTypes.InterestRateMode.VARIABLE), + 105 : : referralCode, + 106 : : msg.sender + 107 : : ); + 108 : 1 : WETH.withdraw(amount); + 109 : 1 : _safeTransferETH(msg.sender, amount); + 110 : : } + 111 : : + 112 : : /** + 113 : : * @dev withdraws the WETH _reserves of msg.sender. + 114 : : * @param amount amount of aWETH to withdraw and receive native ETH + 115 : : * @param to address of the user who will receive native ETH + 116 : : * @param deadline validity deadline of permit and so depositWithPermit signature + 117 : : * @param permitV V parameter of ERC712 permit sig + 118 : : * @param permitR R parameter of ERC712 permit sig + 119 : : * @param permitS S parameter of ERC712 permit sig + 120 : : */ + 121 : : function withdrawETHWithPermit( + 122 : : address, + 123 : : uint256 amount, + 124 : : address to, + 125 : : uint256 deadline, + 126 : : uint8 permitV, + 127 : : bytes32 permitR, + 128 : : bytes32 permitS + 129 : : ) external override { + 130 : 2 : IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress); + 131 : 2 : uint256 userBalance = aWETH.balanceOf(msg.sender); + 132 : 2 : uint256 amountToWithdraw = amount; + 133 : : + 134 : : // if amount is equal to type(uint256).max, the user wants to redeem everything + 135 : 2 : if (amount == type(uint256).max) { + 136 : 1 : amountToWithdraw = userBalance; + 137 : : } + 138 : : // permit `amount` rather than `amountToWithdraw` to make it easier for front-ends and integrators + 139 : 2 : aWETH.permit(msg.sender, address(this), amount, deadline, permitV, permitR, permitS); + 140 : 2 : aWETH.transferFrom(msg.sender, address(this), amountToWithdraw); + 141 : 2 : POOL.withdraw(address(WETH), amountToWithdraw, address(this)); + 142 : 2 : WETH.withdraw(amountToWithdraw); + 143 : 2 : _safeTransferETH(to, amountToWithdraw); + 144 : : } + 145 : : + 146 : : /** + 147 : : * @dev transfer ETH to an address, revert if it fails. + 148 : : * @param to recipient of the transfer + 149 : : * @param value the amount to send + 150 : : */ + 151 : : function _safeTransferETH(address to, uint256 value) internal { + 152 : 7 : (bool success, ) = to.call{value: value}(new bytes(0)); + 153 : 7 : require(success, 'ETH_TRANSFER_FAILED'); + 154 : : } + 155 : : + 156 : : /** + 157 : : * @dev transfer ERC20 from the utility contract, for ERC20 recovery in case of stuck tokens due + 158 : : * direct transfers to the contract address. + 159 : : * @param token token to transfer + 160 : : * @param to recipient of the transfer + 161 : : * @param amount amount to send + 162 : : */ + 163 : : function emergencyTokenTransfer(address token, address to, uint256 amount) external onlyOwner { + 164 : 1 : IERC20(token).safeTransfer(to, amount); + 165 : : } + 166 : : + 167 : : /** + 168 : : * @dev transfer native Ether from the utility contract, for native Ether recovery in case of stuck Ether + 169 : : * due to selfdestructs or ether transfers to the pre-computed contract address before deployment. + 170 : : * @param to recipient of the transfer + 171 : : * @param amount amount to send + 172 : : */ + 173 : : function emergencyEtherTransfer(address to, uint256 amount) external onlyOwner { + 174 : 1 : _safeTransferETH(to, amount); + 175 : : } + 176 : : + 177 : : /** + 178 : : * @dev Get WETH address used by WrappedTokenGatewayV3 + 179 : : */ + 180 : : function getWETHAddress() external view returns (address) { + 181 : 1 : return address(WETH); + 182 : : } + 183 : : + 184 : : /** + 185 : : * @dev Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract. + 186 : : */ + 187 : : receive() external payable { + 188 : : require(msg.sender == address(WETH), 'Receive not allowed'); + 189 : : } + 190 : : + 191 : : /** + 192 : : * @dev Revert fallback calls + 193 : : */ + 194 : : fallback() external payable { + 195 : 2 : revert('Fallback not allowed'); + 196 : : } + 197 : : } @@ -282,8 +273,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/helpers/index-sort-b.html b/report/helpers/index-sort-b.html new file mode 100644 index 00000000..913d2408 --- /dev/null +++ b/report/helpers/index-sort-b.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - helpers + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - helpersCoverageTotalHit
Test:lcov.info.pLines:94.9 %9994
Test Date:2024-09-24 09:34:24Functions:95.0 %2019
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Encoder.sol +
98.3%98.3%
+
98.3 %5857-90.0 %109
WrappedTokenGatewayV3.sol +
90.2%90.2%
+
90.2 %4137-100.0 %1010
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/helpers/index-sort-f.html b/report/helpers/index-sort-f.html new file mode 100644 index 00000000..9a72208b --- /dev/null +++ b/report/helpers/index-sort-f.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - helpers + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - helpersCoverageTotalHit
Test:lcov.info.pLines:94.9 %9994
Test Date:2024-09-24 09:34:24Functions:95.0 %2019
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Encoder.sol +
98.3%98.3%
+
98.3 %5857-90.0 %109
WrappedTokenGatewayV3.sol +
90.2%90.2%
+
90.2 %4137-100.0 %1010
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/helpers/index-sort-l.html b/report/helpers/index-sort-l.html new file mode 100644 index 00000000..61f2165b --- /dev/null +++ b/report/helpers/index-sort-l.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - helpers + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - helpersCoverageTotalHit
Test:lcov.info.pLines:94.9 %9994
Test Date:2024-09-24 09:34:24Functions:95.0 %2019
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
WrappedTokenGatewayV3.sol +
90.2%90.2%
+
90.2 %4137-100.0 %1010
L2Encoder.sol +
98.3%98.3%
+
98.3 %5857-90.0 %109
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/helpers/index.html b/report/helpers/index.html new file mode 100644 index 00000000..f94d5a6d --- /dev/null +++ b/report/helpers/index.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - helpers + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - helpersCoverageTotalHit
Test:lcov.info.pLines:94.9 %9994
Test Date:2024-09-24 09:34:24Functions:95.0 %2019
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Encoder.sol +
98.3%98.3%
+
98.3 %5857-90.0 %109
WrappedTokenGatewayV3.sol +
90.2%90.2%
+
90.2 %4137-100.0 %1010
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/index-sort-b.html b/report/index-sort-b.html index 5f1a2742..cd0fba43 100644 --- a/report/index-sort-b.html +++ b/report/index-sort-b.html @@ -31,18 +31,18 @@ lcov.info.p Lines: - 98.3 % - 1826 - 1795 + 96.4 % + 2009 + 1937 Test Date: - 2024-04-09 14:12:28 + 2024-09-24 09:34:24 Functions: - 98.7 % - 469 - 463 + 95.4 % + 545 + 520 @@ -96,229 +96,229 @@ Hit - core/contracts/misc/src/core/contracts/misc + extensions/paraswap-adapters/ -
100.0%
+
87.8%87.8%
- 100.0 % - 93 - 93 + 87.8 % + 164 + 144 - - 100.0 % - 20 + 74.1 % + 27 20 - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration + extensions/static-a-token/ -
100.0%
+
89.4%89.4%
- 100.0 % - 111 - 111 + 89.4 % + 208 + 186 - - 100.0 % - 55 - 55 + 84.2 % + 57 + 48 - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability + helpers/ -
100.0%
+
94.9%94.9%
- 100.0 % - 12 - 12 + 94.9 % + 99 + 94 - - 100.0 % - 7 - 7 + 95.0 % + 20 + 19 - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers + instances/
100.0%
100.0 % - 1 - 1 + 24 + 24 - 100.0 % - 1 - 1 + 11 + 11 - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic + misc/ -
97.9%97.9%
+
93.2%93.2%
- 97.9 % - 576 - 564 + 93.2 % + 88 + 82 - - 100.0 % - 64 - 64 + 97.1 % + 35 + 34 - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math + misc/aave-upgradeability/
100.0%
100.0 % - 37 - 37 + 23 + 23 - 100.0 % - 10 - 10 + 11 + 11 - core/contracts/protocol/pool/src/core/contracts/protocol/pool + misc/flashloan/base/ -
98.1%98.1%
+
50.0%50.0%
- 98.1 % - 365 - 358 + 50.0 % + 4 + 2 - - 97.6 % - 124 - 121 + 50.0 % + 2 + 1 - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base + protocol/configuration/ -
100.0%
+
95.4%95.4%
- 100.0 % - 115 - 115 + 95.4 % + 108 + 103 - - 100.0 % - 35 - 35 + 96.1 % + 51 + 49 - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization + protocol/libraries/logic/ -
90.5%90.5%
+
99.8%99.8%
- 90.5 % - 74 - 67 + 99.8 % + 493 + 492 - 100.0 % - 47 - 47 + 54 + 54 - core/instances/src/core/instances + protocol/libraries/math/ -
94.1%94.1%
+
95.6%95.6%
- 94.1 % - 34 - 32 + 95.6 % + 45 + 43 - - 80.0 % + 100.0 % + 10 10 - 8 - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap + protocol/pool/ -
99.3%99.3%
+
99.4%99.4%
- 99.3 % - 140 - 139 + 99.4 % + 331 + 329 - - 95.0 % - 20 - 19 + 100.0 % + 119 + 119 - periphery/contracts/libraries/src/periphery/contracts/libraries + protocol/tokenization/
100.0%
100.0 % - 1 - 1 + 55 + 55 - 100.0 % - 1 - 1 + 30 + 30 - periphery/contracts/misc/src/periphery/contracts/misc + protocol/tokenization/base/
100.0%
100.0 % - 38 - 38 + 124 + 124 - - 100.0 % - 10 - 10 + 97.6 % + 42 + 41 - periphery/contracts/rewards/src/periphery/contracts/rewards + rewards/ -
99.1%99.1%
+
98.6%98.6%
- 99.1 % - 214 - 212 + 98.6 % + 219 + 216 - - 100.0 % - 55 - 55 + 96.7 % + 61 + 59 - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies + rewards/transfer-strategies/ -
100.0%
+
83.3%83.3%
- 100.0 % - 15 - 15 + 83.3 % + 24 + 20 - - 100.0 % - 10 - 10 + 93.3 % + 15 + 14
@@ -326,7 +326,7 @@ - +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/index-sort-f.html b/report/index-sort-f.html index 0c255fb4..1f749f29 100644 --- a/report/index-sort-f.html +++ b/report/index-sort-f.html @@ -31,18 +31,18 @@ lcov.info.p Lines: - 98.3 % - 1826 - 1795 + 96.4 % + 2009 + 1937 Test Date: - 2024-04-09 14:12:28 + 2024-09-24 09:34:24 Functions: - 98.7 % - 469 - 463 + 95.4 % + 545 + 520 @@ -96,229 +96,229 @@ Hit - core/instances/src/core/instances + misc/flashloan/base/ -
94.1%94.1%
+
50.0%50.0%
- 94.1 % - 34 - 32 + 50.0 % + 4 + 2 - - 80.0 % - 10 - 8 + 50.0 % + 2 + 1 - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap + extensions/paraswap-adapters/ -
99.3%99.3%
+
87.8%87.8%
- 99.3 % - 140 - 139 + 87.8 % + 164 + 144 - - 95.0 % + 74.1 % + 27 20 - 19 - core/contracts/protocol/pool/src/core/contracts/protocol/pool + extensions/static-a-token/ -
98.1%98.1%
+
89.4%89.4%
- 98.1 % - 365 - 358 + 89.4 % + 208 + 186 - - 97.6 % - 124 - 121 + 84.2 % + 57 + 48 - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers + rewards/transfer-strategies/ -
100.0%
+
83.3%83.3%
- 100.0 % - 1 - 1 + 83.3 % + 24 + 20 - - 100.0 % - 1 - 1 + 93.3 % + 15 + 14 - periphery/contracts/libraries/src/periphery/contracts/libraries + helpers/ -
100.0%
+
94.9%94.9%
- 100.0 % - 1 - 1 + 94.9 % + 99 + 94 - - 100.0 % - 1 - 1 + 95.0 % + 20 + 19 - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability + protocol/configuration/ -
100.0%
+
95.4%95.4%
- 100.0 % - 12 - 12 + 95.4 % + 108 + 103 - - 100.0 % - 7 - 7 + 96.1 % + 51 + 49 - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math + rewards/ -
100.0%
+
98.6%98.6%
- 100.0 % - 37 - 37 + 98.6 % + 219 + 216 - - 100.0 % - 10 - 10 + 96.7 % + 61 + 59 - periphery/contracts/misc/src/periphery/contracts/misc + misc/ -
100.0%
+
93.2%93.2%
- 100.0 % - 38 - 38 + 93.2 % + 88 + 82 - - 100.0 % - 10 - 10 + 97.1 % + 35 + 34 - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies + protocol/tokenization/base/
100.0%
100.0 % - 15 - 15 + 124 + 124 - - 100.0 % - 10 - 10 + 97.6 % + 42 + 41 - core/contracts/misc/src/core/contracts/misc + protocol/libraries/math/ -
100.0%
+
95.6%95.6%
- 100.0 % - 93 - 93 + 95.6 % + 45 + 43 - 100.0 % - 20 - 20 + 10 + 10 - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base + instances/
100.0%
100.0 % - 115 - 115 + 24 + 24 - 100.0 % - 35 - 35 + 11 + 11 - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization + misc/aave-upgradeability/ -
90.5%90.5%
+
100.0%
- 90.5 % - 74 - 67 + 100.0 % + 23 + 23 - 100.0 % - 47 - 47 + 11 + 11 - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration + protocol/tokenization/
100.0%
100.0 % - 111 - 111 + 55 + 55 - 100.0 % - 55 - 55 + 30 + 30 - periphery/contracts/rewards/src/periphery/contracts/rewards + protocol/libraries/logic/ -
99.1%99.1%
+
99.8%99.8%
- 99.1 % - 214 - 212 + 99.8 % + 493 + 492 - 100.0 % - 55 - 55 + 54 + 54 - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic + protocol/pool/ -
97.9%97.9%
+
99.4%99.4%
- 97.9 % - 576 - 564 + 99.4 % + 331 + 329 - 100.0 % - 64 - 64 + 119 + 119
@@ -326,7 +326,7 @@ - +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/index-sort-l.html b/report/index-sort-l.html index fdb18d18..780d900a 100644 --- a/report/index-sort-l.html +++ b/report/index-sort-l.html @@ -31,18 +31,18 @@ lcov.info.p Lines: - 98.3 % - 1826 - 1795 + 96.4 % + 2009 + 1937 Test Date: - 2024-04-09 14:12:28 + 2024-09-24 09:34:24 Functions: - 98.7 % - 469 - 463 + 95.4 % + 545 + 520 @@ -96,88 +96,88 @@ Hit - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization + misc/flashloan/base/ -
90.5%90.5%
+
50.0%50.0%
- 90.5 % - 74 - 67 + 50.0 % + 4 + 2 - - 100.0 % - 47 - 47 + 50.0 % + 2 + 1 - core/instances/src/core/instances + rewards/transfer-strategies/ -
94.1%94.1%
+
83.3%83.3%
- 94.1 % - 34 - 32 + 83.3 % + 24 + 20 - - 80.0 % - 10 - 8 + 93.3 % + 15 + 14 - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic + extensions/paraswap-adapters/ -
97.9%97.9%
+
87.8%87.8%
- 97.9 % - 576 - 564 + 87.8 % + 164 + 144 - - 100.0 % - 64 - 64 + 74.1 % + 27 + 20 - core/contracts/protocol/pool/src/core/contracts/protocol/pool + extensions/static-a-token/ -
98.1%98.1%
+
89.4%89.4%
- 98.1 % - 365 - 358 + 89.4 % + 208 + 186 - - 97.6 % - 124 - 121 + 84.2 % + 57 + 48 - periphery/contracts/rewards/src/periphery/contracts/rewards + misc/ -
99.1%99.1%
+
93.2%93.2%
- 99.1 % - 214 - 212 + 93.2 % + 88 + 82 - - 100.0 % - 55 - 55 + 97.1 % + 35 + 34 - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap + helpers/ -
99.3%99.3%
+
94.9%94.9%
- 99.3 % - 140 - 139 + 94.9 % + 99 + 94 - @@ -186,139 +186,139 @@ 19 - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers + protocol/configuration/ -
100.0%
+
95.4%95.4%
- 100.0 % - 1 - 1 + 95.4 % + 108 + 103 - - 100.0 % - 1 - 1 + 96.1 % + 51 + 49 - periphery/contracts/libraries/src/periphery/contracts/libraries + protocol/libraries/math/ -
100.0%
+
95.6%95.6%
- 100.0 % - 1 - 1 + 95.6 % + 45 + 43 - 100.0 % - 1 - 1 + 10 + 10 - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability + rewards/ -
100.0%
+
98.6%98.6%
- 100.0 % - 12 - 12 + 98.6 % + 219 + 216 - - 100.0 % - 7 - 7 + 96.7 % + 61 + 59 - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies + protocol/pool/ -
100.0%
+
99.4%99.4%
- 100.0 % - 15 - 15 + 99.4 % + 331 + 329 - 100.0 % - 10 - 10 + 119 + 119 - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math + protocol/libraries/logic/ -
100.0%
+
99.8%99.8%
- 100.0 % - 37 - 37 + 99.8 % + 493 + 492 - 100.0 % - 10 - 10 + 54 + 54 - periphery/contracts/misc/src/periphery/contracts/misc + misc/aave-upgradeability/
100.0%
100.0 % - 38 - 38 + 23 + 23 - 100.0 % - 10 - 10 + 11 + 11 - core/contracts/misc/src/core/contracts/misc + instances/
100.0%
100.0 % - 93 - 93 + 24 + 24 - 100.0 % - 20 - 20 + 11 + 11 - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration + protocol/tokenization/
100.0%
100.0 % - 111 - 111 + 55 + 55 - 100.0 % - 55 - 55 + 30 + 30 - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base + protocol/tokenization/base/
100.0%
100.0 % - 115 - 115 + 124 + 124 - - 100.0 % - 35 - 35 + 97.6 % + 42 + 41
@@ -326,7 +326,7 @@ - +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/index.html b/report/index.html index c4ee4cdb..1a8e5fc2 100644 --- a/report/index.html +++ b/report/index.html @@ -31,18 +31,18 @@ lcov.info.p Lines: - 98.3 % - 1826 - 1795 + 96.4 % + 2009 + 1937 Test Date: - 2024-04-09 14:12:28 + 2024-09-24 09:34:24 Functions: - 98.7 % - 469 - 463 + 95.4 % + 545 + 520 @@ -96,229 +96,229 @@ Hit - core/contracts/misc/src/core/contracts/misc + extensions/paraswap-adapters/ -
100.0%
+
87.8%87.8%
- 100.0 % - 93 - 93 + 87.8 % + 164 + 144 - - 100.0 % - 20 + 74.1 % + 27 20 - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration + extensions/static-a-token/ -
100.0%
+
89.4%89.4%
- 100.0 % - 111 - 111 + 89.4 % + 208 + 186 - - 100.0 % - 55 - 55 + 84.2 % + 57 + 48 - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability + helpers/ -
100.0%
+
94.9%94.9%
- 100.0 % - 12 - 12 + 94.9 % + 99 + 94 - - 100.0 % - 7 - 7 + 95.0 % + 20 + 19 - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers + instances/
100.0%
100.0 % - 1 - 1 + 24 + 24 - 100.0 % - 1 - 1 + 11 + 11 - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic + misc/ -
97.9%97.9%
+
93.2%93.2%
- 97.9 % - 576 - 564 + 93.2 % + 88 + 82 - - 100.0 % - 64 - 64 + 97.1 % + 35 + 34 - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math + misc/aave-upgradeability/
100.0%
100.0 % - 37 - 37 + 23 + 23 - 100.0 % - 10 - 10 + 11 + 11 - core/contracts/protocol/pool/src/core/contracts/protocol/pool + misc/flashloan/base/ -
98.1%98.1%
+
50.0%50.0%
- 98.1 % - 365 - 358 + 50.0 % + 4 + 2 - - 97.6 % - 124 - 121 + 50.0 % + 2 + 1 - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base + protocol/configuration/ -
100.0%
+
95.4%95.4%
- 100.0 % - 115 - 115 + 95.4 % + 108 + 103 - - 100.0 % - 35 - 35 + 96.1 % + 51 + 49 - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization + protocol/libraries/logic/ -
90.5%90.5%
+
99.8%99.8%
- 90.5 % - 74 - 67 + 99.8 % + 493 + 492 - 100.0 % - 47 - 47 + 54 + 54 - core/instances/src/core/instances + protocol/libraries/math/ -
94.1%94.1%
+
95.6%95.6%
- 94.1 % - 34 - 32 + 95.6 % + 45 + 43 - - 80.0 % + 100.0 % + 10 10 - 8 - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap + protocol/pool/ -
99.3%99.3%
+
99.4%99.4%
- 99.3 % - 140 - 139 + 99.4 % + 331 + 329 - - 95.0 % - 20 - 19 + 100.0 % + 119 + 119 - periphery/contracts/libraries/src/periphery/contracts/libraries + protocol/tokenization/
100.0%
100.0 % - 1 - 1 + 55 + 55 - 100.0 % - 1 - 1 + 30 + 30 - periphery/contracts/misc/src/periphery/contracts/misc + protocol/tokenization/base/
100.0%
100.0 % - 38 - 38 + 124 + 124 - - 100.0 % - 10 - 10 + 97.6 % + 42 + 41 - periphery/contracts/rewards/src/periphery/contracts/rewards + rewards/ -
99.1%99.1%
+
98.6%98.6%
- 99.1 % - 214 - 212 + 98.6 % + 219 + 216 - - 100.0 % - 55 - 55 + 96.7 % + 61 + 59 - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies + rewards/transfer-strategies/ -
100.0%
+
83.3%83.3%
- 100.0 % - 15 - 15 + 83.3 % + 24 + 20 - - 100.0 % - 10 - 10 + 93.3 % + 15 + 14
@@ -326,7 +326,7 @@ - +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/ATokenInstance.sol.func-c.html b/report/instances/ATokenInstance.sol.func-c.html similarity index 63% rename from report/core/instances/src/core/instances/ATokenInstance.sol.func-c.html rename to report/instances/ATokenInstance.sol.func-c.html index 9c9950d0..d83b22b7 100644 --- a/report/core/instances/src/core/instances/ATokenInstance.sol.func-c.html +++ b/report/instances/ATokenInstance.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/ATokenInstance.sol - functions - + LCOV - lcov.info.p - instances/ATokenInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/instances/src/core/instances - ATokenInstance.sol (source / functions)top level - instances - ATokenInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + - + + + + + + + + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ATokenInstance.11
ATokenInstance.getRevision3469166696
ATokenInstance.initialize3470166697
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/ATokenInstance.sol.func.html b/report/instances/ATokenInstance.sol.func.html similarity index 63% rename from report/core/instances/src/core/instances/ATokenInstance.sol.func.html rename to report/instances/ATokenInstance.sol.func.html index 4ea020d2..8e578d85 100644 --- a/report/core/instances/src/core/instances/ATokenInstance.sol.func.html +++ b/report/instances/ATokenInstance.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/ATokenInstance.sol - functions - + LCOV - lcov.info.p - instances/ATokenInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/instances/src/core/instances - ATokenInstance.sol (source / functions)top level - instances - ATokenInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + - + + + + + + + + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ATokenInstance.11
ATokenInstance.getRevision3469166696
ATokenInstance.initialize3470166697
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/ATokenInstance.sol.gcov.html b/report/instances/ATokenInstance.sol.gcov.html similarity index 79% rename from report/core/instances/src/core/instances/ATokenInstance.sol.gcov.html rename to report/instances/ATokenInstance.sol.gcov.html index 9c0e3a35..fe163efd 100644 --- a/report/core/instances/src/core/instances/ATokenInstance.sol.gcov.html +++ b/report/instances/ATokenInstance.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/ATokenInstance.sol - + LCOV - lcov.info.p - instances/ATokenInstance.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instances - ATokenInstance.sol (source / functions)top level - instances - ATokenInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
@@ -72,7 +72,7 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : - 4 : : import {AToken, IPool, IAaveIncentivesController, IInitializableAToken, Errors, VersionedInitializable} from '../contracts/protocol/tokenization/AToken.sol'; + 4 : : import {AToken, IPool, IAaveIncentivesController, IInitializableAToken, Errors, VersionedInitializable} from '../protocol/tokenization/AToken.sol'; 5 : : 6 : : contract ATokenInstance is AToken { 7 : : uint256 public constant ATOKEN_REVISION = 1; @@ -80,12 +80,12 @@ 9 : : constructor(IPool pool) AToken(pool) {} 10 : : 11 : : /// @inheritdoc VersionedInitializable - 12 : 3469 : function getRevision() internal pure virtual override returns (uint256) { - 13 : 6938 : return ATOKEN_REVISION; + 12 : : function getRevision() internal pure virtual override returns (uint256) { + 13 : 166696 : return ATOKEN_REVISION; 14 : : } 15 : : 16 : : /// @inheritdoc IInitializableAToken - 17 : 3470 : function initialize( + 17 : : function initialize( 18 : : IPool initializingPool, 19 : : address treasury, 20 : : address underlyingAsset, @@ -95,18 +95,18 @@ 24 : : string calldata aTokenSymbol, 25 : : bytes calldata params 26 : : ) public virtual override initializer { - 27 : 6940 : require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH); - 28 : 6940 : _setName(aTokenName); - 29 : 6940 : _setSymbol(aTokenSymbol); - 30 : 6940 : _setDecimals(aTokenDecimals); + 27 : 166697 : require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH); + 28 : 166697 : _setName(aTokenName); + 29 : 166697 : _setSymbol(aTokenSymbol); + 30 : 166697 : _setDecimals(aTokenDecimals); 31 : : - 32 : 6940 : _treasury = treasury; - 33 : 6940 : _underlyingAsset = underlyingAsset; - 34 : 6940 : _incentivesController = incentivesController; + 32 : 166697 : _treasury = treasury; + 33 : 166697 : _underlyingAsset = underlyingAsset; + 34 : 166697 : _incentivesController = incentivesController; 35 : : - 36 : 6940 : _domainSeparator = _calculateDomainSeparator(); + 36 : 166697 : _domainSeparator = _calculateDomainSeparator(); 37 : : - 38 : 6940 : emit Initialized( + 38 : 166697 : emit Initialized( 39 : : underlyingAsset, 40 : : address(POOL), 41 : : treasury, @@ -125,8 +125,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func-c.html b/report/instances/PoolConfiguratorInstance.sol.func-c.html similarity index 68% rename from report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func-c.html rename to report/instances/PoolConfiguratorInstance.sol.func-c.html index f69764a3..a679cce6 100644 --- a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func-c.html +++ b/report/instances/PoolConfiguratorInstance.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolConfiguratorInstance.sol - functions - + LCOV - lcov.info.p - instances/PoolConfiguratorInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - PoolConfiguratorInstance.sol (source / functions)top level - instances - PoolConfiguratorInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolConfiguratorInstance.getRevision12321389
PoolConfiguratorInstance.initialize12321389
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func.html b/report/instances/PoolConfiguratorInstance.sol.func.html similarity index 68% rename from report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func.html rename to report/instances/PoolConfiguratorInstance.sol.func.html index 8fe1d16b..39a526df 100644 --- a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.func.html +++ b/report/instances/PoolConfiguratorInstance.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolConfiguratorInstance.sol - functions - + LCOV - lcov.info.p - instances/PoolConfiguratorInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/instances/src/core/instances - PoolConfiguratorInstance.sol (source / functions)top level - instances - PoolConfiguratorInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolConfiguratorInstance.getRevision12321389
PoolConfiguratorInstance.initialize12321389
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.gcov.html b/report/instances/PoolConfiguratorInstance.sol.gcov.html similarity index 72% rename from report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.gcov.html rename to report/instances/PoolConfiguratorInstance.sol.gcov.html index 92e18a88..86aefa61 100644 --- a/report/core/instances/src/core/instances/PoolConfiguratorInstance.sol.gcov.html +++ b/report/instances/PoolConfiguratorInstance.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolConfiguratorInstance.sol - + LCOV - lcov.info.p - instances/PoolConfiguratorInstance.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instances - PoolConfiguratorInstance.sol (source / functions)top level - instances - PoolConfiguratorInstance.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -72,19 +72,19 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : - 4 : : import {PoolConfigurator, IPoolAddressesProvider, IPool, VersionedInitializable} from 'aave-v3-core/contracts/protocol/pool/PoolConfigurator.sol'; + 4 : : import {PoolConfigurator, IPoolAddressesProvider, IPool, VersionedInitializable} from '../protocol/pool/PoolConfigurator.sol'; 5 : : 6 : : contract PoolConfiguratorInstance is PoolConfigurator { - 7 : : uint256 public constant CONFIGURATOR_REVISION = 3; + 7 : : uint256 public constant CONFIGURATOR_REVISION = 4; 8 : : 9 : : /// @inheritdoc VersionedInitializable - 10 : 1232 : function getRevision() internal pure virtual override returns (uint256) { - 11 : 2464 : return CONFIGURATOR_REVISION; + 10 : : function getRevision() internal pure virtual override returns (uint256) { + 11 : 1389 : return CONFIGURATOR_REVISION; 12 : : } 13 : : - 14 : 1232 : function initialize(IPoolAddressesProvider provider) public virtual override initializer { - 15 : 2464 : _addressesProvider = provider; - 16 : 2464 : _pool = IPool(_addressesProvider.getPool()); + 14 : : function initialize(IPoolAddressesProvider provider) public virtual override initializer { + 15 : 1389 : _addressesProvider = provider; + 16 : 1389 : _pool = IPool(_addressesProvider.getPool()); 17 : : } 18 : : } @@ -94,8 +94,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolInstance.sol.func-c.html b/report/instances/PoolInstance.sol.func-c.html similarity index 64% rename from report/core/instances/src/core/instances/PoolInstance.sol.func-c.html rename to report/instances/PoolInstance.sol.func-c.html index 9587d444..2187e044 100644 --- a/report/core/instances/src/core/instances/PoolInstance.sol.func-c.html +++ b/report/instances/PoolInstance.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolInstance.sol - functions - + LCOV - lcov.info.p - instances/PoolInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/instances/src/core/instances - PoolInstance.sol (source / functions)top level - instances - PoolInstance.sol (source / functions) Coverage Lines: 100.0 %3322
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + + + + + + + + - + - + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
PoolInstance.Hit count Sort by function hit count194
PoolInstance.getRevisionPoolInstance.getRevision12381395
PoolInstance.initialize12381395
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolInstance.sol.func.html b/report/instances/PoolInstance.sol.func.html similarity index 64% rename from report/core/instances/src/core/instances/PoolInstance.sol.func.html rename to report/instances/PoolInstance.sol.func.html index 1d449c53..c5b24f36 100644 --- a/report/core/instances/src/core/instances/PoolInstance.sol.func.html +++ b/report/instances/PoolInstance.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolInstance.sol - functions - + LCOV - lcov.info.p - instances/PoolInstance.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/instances/src/core/instances - PoolInstance.sol (source / functions)top level - instances - PoolInstance.sol (source / functions) Coverage Lines: 100.0 %3322
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + + + + + + + + - + - + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
PoolInstance.Hit count Sort by function hit count194
PoolInstance.getRevisionPoolInstance.getRevision12381395
PoolInstance.initialize12381395
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/PoolInstance.sol.gcov.html b/report/instances/PoolInstance.sol.gcov.html similarity index 72% rename from report/core/instances/src/core/instances/PoolInstance.sol.gcov.html rename to report/instances/PoolInstance.sol.gcov.html index a90e1377..1a6d65d6 100644 --- a/report/core/instances/src/core/instances/PoolInstance.sol.gcov.html +++ b/report/instances/PoolInstance.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/PoolInstance.sol - + LCOV - lcov.info.p - instances/PoolInstance.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instances - PoolInstance.sol (source / functions)top level - instances - PoolInstance.sol (source / functions) Coverage Lines: 100.0 %3322
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
@@ -72,12 +72,12 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : - 4 : : import {Pool} from '../contracts/protocol/pool/Pool.sol'; - 5 : : import {IPoolAddressesProvider} from '../contracts/interfaces/IPoolAddressesProvider.sol'; - 6 : : import {Errors} from '../contracts/protocol/libraries/helpers/Errors.sol'; + 4 : : import {Pool} from '../protocol/pool/Pool.sol'; + 5 : : import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; + 6 : : import {Errors} from '../protocol/libraries/helpers/Errors.sol'; 7 : : 8 : : contract PoolInstance is Pool { - 9 : : uint256 public constant POOL_REVISION = 4; + 9 : : uint256 public constant POOL_REVISION = 5; 10 : : 11 : : constructor(IPoolAddressesProvider provider) Pool(provider) {} 12 : : @@ -88,15 +88,14 @@ 17 : : * @dev Caching the address of the PoolAddressesProvider in order to reduce gas consumption on subsequent operations 18 : : * @param provider The address of the PoolAddressesProvider 19 : : */ - 20 : 1238 : function initialize(IPoolAddressesProvider provider) external virtual override initializer { - 21 : 2476 : require(provider == ADDRESSES_PROVIDER, Errors.INVALID_ADDRESSES_PROVIDER); - 22 : 2472 : _maxStableRateBorrowSizePercent = 0.25e4; - 23 : : } - 24 : : - 25 : 1238 : function getRevision() internal pure virtual override returns (uint256) { - 26 : 2476 : return POOL_REVISION; - 27 : : } - 28 : : } + 20 : : function initialize(IPoolAddressesProvider provider) external virtual override initializer { + 21 : 1395 : require(provider == ADDRESSES_PROVIDER, Errors.INVALID_ADDRESSES_PROVIDER); + 22 : : } + 23 : : + 24 : : function getRevision() internal pure virtual override returns (uint256) { + 25 : 1395 : return POOL_REVISION; + 26 : : } + 27 : : } @@ -104,8 +103,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/instances/VariableDebtTokenInstance.sol.func-c.html b/report/instances/VariableDebtTokenInstance.sol.func-c.html new file mode 100644 index 00000000..ea596034 --- /dev/null +++ b/report/instances/VariableDebtTokenInstance.sol.func-c.html @@ -0,0 +1,105 @@ + + + + + + + LCOV - lcov.info.p - instances/VariableDebtTokenInstance.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - instances - VariableDebtTokenInstance.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %99
Test Date:2024-09-24 09:34:24Functions:100.0 %33
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
VariableDebtTokenInstance.7103
VariableDebtTokenInstance.getRevision174696
VariableDebtTokenInstance.initialize174697
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/instances/VariableDebtTokenInstance.sol.func.html b/report/instances/VariableDebtTokenInstance.sol.func.html new file mode 100644 index 00000000..d228d81b --- /dev/null +++ b/report/instances/VariableDebtTokenInstance.sol.func.html @@ -0,0 +1,105 @@ + + + + + + + LCOV - lcov.info.p - instances/VariableDebtTokenInstance.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - instances - VariableDebtTokenInstance.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %99
Test Date:2024-09-24 09:34:24Functions:100.0 %33
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
VariableDebtTokenInstance.7103
VariableDebtTokenInstance.getRevision174696
VariableDebtTokenInstance.initialize174697
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.gcov.html b/report/instances/VariableDebtTokenInstance.sol.gcov.html similarity index 76% rename from report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.gcov.html rename to report/instances/VariableDebtTokenInstance.sol.gcov.html index 8445d25a..2a2860c8 100644 --- a/report/core/instances/src/core/instances/VariableDebtTokenInstance.sol.gcov.html +++ b/report/instances/VariableDebtTokenInstance.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances/VariableDebtTokenInstance.sol - + LCOV - lcov.info.p - instances/VariableDebtTokenInstance.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instances - VariableDebtTokenInstance.sol (source / functions)top level - instances - VariableDebtTokenInstance.sol (source / functions) Coveragelcov.info.p Lines:88.9 %100.0 %9 98
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:50.0 %21100.0 %33
0 0
@@ -72,7 +72,7 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : - 4 : : import {VariableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../contracts/protocol/tokenization/VariableDebtToken.sol'; + 4 : : import {VariableDebtToken, IPool, IInitializableDebtToken, VersionedInitializable, IAaveIncentivesController, Errors} from '../protocol/tokenization/VariableDebtToken.sol'; 5 : : 6 : : contract VariableDebtTokenInstance is VariableDebtToken { 7 : : uint256 public constant DEBT_TOKEN_REVISION = 1; @@ -80,12 +80,12 @@ 9 : : constructor(IPool pool) VariableDebtToken(pool) {} 10 : : 11 : : /// @inheritdoc VersionedInitializable - 12 : 0 : function getRevision() internal pure virtual override returns (uint256) { - 13 : 0 : return DEBT_TOKEN_REVISION; + 12 : : function getRevision() internal pure virtual override returns (uint256) { + 13 : 174696 : return DEBT_TOKEN_REVISION; 14 : : } 15 : : 16 : : /// @inheritdoc IInitializableDebtToken - 17 : 3478 : function initialize( + 17 : : function initialize( 18 : : IPool initializingPool, 19 : : address underlyingAsset, 20 : : IAaveIncentivesController incentivesController, @@ -94,17 +94,17 @@ 23 : : string memory debtTokenSymbol, 24 : : bytes calldata params 25 : : ) external override initializer { - 26 : 6954 : require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH); - 27 : 6952 : _setName(debtTokenName); - 28 : 6952 : _setSymbol(debtTokenSymbol); - 29 : 6952 : _setDecimals(debtTokenDecimals); + 26 : 173697 : require(initializingPool == POOL, Errors.POOL_ADDRESSES_DO_NOT_MATCH); + 27 : 172697 : _setName(debtTokenName); + 28 : 172697 : _setSymbol(debtTokenSymbol); + 29 : 172697 : _setDecimals(debtTokenDecimals); 30 : : - 31 : 6952 : _underlyingAsset = underlyingAsset; - 32 : 6952 : _incentivesController = incentivesController; + 31 : 172697 : _underlyingAsset = underlyingAsset; + 32 : 172697 : _incentivesController = incentivesController; 33 : : - 34 : 6952 : _domainSeparator = _calculateDomainSeparator(); + 34 : 172697 : _domainSeparator = _calculateDomainSeparator(); 35 : : - 36 : 6952 : emit Initialized( + 36 : 172697 : emit Initialized( 37 : : underlyingAsset, 38 : : address(POOL), 39 : : address(incentivesController), @@ -122,8 +122,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/index-sort-b.html b/report/instances/index-sort-b.html similarity index 58% rename from report/core/instances/src/core/instances/index-sort-b.html rename to report/instances/index-sort-b.html index 028d3cdd..c211fc71 100644 --- a/report/core/instances/src/core/instances/index-sort-b.html +++ b/report/instances/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances - + LCOV - lcov.info.p - instances + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instancestop level - instances Coveragelcov.info.p Lines:94.1 %3432100.0 %2424
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:80.0 %108100.0 %1111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - ATokenInstance.sol + ATokenInstance.sol -
100.0%
+
100.0%
100.0 % 10 @@ -107,13 +107,13 @@ 100.0 % - 2 - 2 + 3 + 3 - PoolConfiguratorInstance.sol + PoolConfiguratorInstance.sol -
100.0%
+
100.0%
100.0 % 3 @@ -126,57 +126,42 @@ 2 - PoolInstance.sol + PoolInstance.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 - - - - - 100.0 % 2 2 - - - StableDebtTokenInstance.sol - -
88.9%88.9%
- - 88.9 % - 9 - 8 - - 50.0 % - 2 - 1 + 100.0 % + 3 + 3 - VariableDebtTokenInstance.sol + VariableDebtTokenInstance.sol -
88.9%88.9%
+
100.0%
- 88.9 % + 100.0 % + 9 9 - 8 - - 50.0 % - 2 - 1 + 100.0 % + 3 + 3

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/index-sort-f.html b/report/instances/index-sort-f.html similarity index 58% rename from report/core/instances/src/core/instances/index-sort-f.html rename to report/instances/index-sort-f.html index ac8828b3..bdf13aeb 100644 --- a/report/core/instances/src/core/instances/index-sort-f.html +++ b/report/instances/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances - + LCOV - lcov.info.p - instances + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instancestop level - instances Coveragelcov.info.p Lines:94.1 %3432100.0 %2424
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:80.0 %108100.0 %1111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,39 +96,24 @@ Hit - StableDebtTokenInstance.sol + PoolConfiguratorInstance.sol -
88.9%88.9%
+
100.0%
- 88.9 % - 9 - 8 + 100.0 % + 3 + 3 - - 50.0 % + 100.0 % 2 - 1 - - - VariableDebtTokenInstance.sol - -
88.9%88.9%
- - 88.9 % - 9 - 8 - - - - - 50.0 % 2 - 1 - ATokenInstance.sol + ATokenInstance.sol -
100.0%
+
100.0%
100.0 % 10 @@ -137,46 +122,46 @@ 100.0 % - 2 - 2 + 3 + 3 - PoolConfiguratorInstance.sol + PoolInstance.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 2 + 2 - 100.0 % - 2 - 2 + 3 + 3 - PoolInstance.sol + VariableDebtTokenInstance.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 9 + 9 - 100.0 % - 2 - 2 + 3 + 3

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/index-sort-l.html b/report/instances/index-sort-l.html similarity index 58% rename from report/core/instances/src/core/instances/index-sort-l.html rename to report/instances/index-sort-l.html index 4cf73f34..9da9aab6 100644 --- a/report/core/instances/src/core/instances/index-sort-l.html +++ b/report/instances/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances - + LCOV - lcov.info.p - instances + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instancestop level - instances Coveragelcov.info.p Lines:94.1 %3432100.0 %2424
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:80.0 %108100.0 %1111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,39 +96,24 @@ Hit - StableDebtTokenInstance.sol + PoolInstance.sol -
88.9%88.9%
+
100.0%
- 88.9 % - 9 - 8 - - - - - 50.0 % + 100.0 % + 2 2 - 1 - - - VariableDebtTokenInstance.sol - -
88.9%88.9%
- - 88.9 % - 9 - 8 - - 50.0 % - 2 - 1 + 100.0 % + 3 + 3 - PoolConfiguratorInstance.sol + PoolConfiguratorInstance.sol -
100.0%
+
100.0%
100.0 % 3 @@ -141,24 +126,24 @@ 2 - PoolInstance.sol + VariableDebtTokenInstance.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 9 + 9 - 100.0 % - 2 - 2 + 3 + 3 - ATokenInstance.sol + ATokenInstance.sol -
100.0%
+
100.0%
100.0 % 10 @@ -167,16 +152,16 @@ 100.0 % - 2 - 2 + 3 + 3

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/instances/src/core/instances/index.html b/report/instances/index.html similarity index 58% rename from report/core/instances/src/core/instances/index.html rename to report/instances/index.html index 71308d47..cc65427a 100644 --- a/report/core/instances/src/core/instances/index.html +++ b/report/instances/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/instances/src/core/instances - + LCOV - lcov.info.p - instances + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/instances/src/core/instancestop level - instances Coveragelcov.info.p Lines:94.1 %3432100.0 %2424
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:80.0 %108100.0 %1111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - ATokenInstance.sol + ATokenInstance.sol -
100.0%
+
100.0%
100.0 % 10 @@ -107,13 +107,13 @@ 100.0 % - 2 - 2 + 3 + 3 - PoolConfiguratorInstance.sol + PoolConfiguratorInstance.sol -
100.0%
+
100.0%
100.0 % 3 @@ -126,57 +126,42 @@ 2 - PoolInstance.sol + PoolInstance.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 - - - - - 100.0 % 2 2 - - - StableDebtTokenInstance.sol - -
88.9%88.9%
- - 88.9 % - 9 - 8 - - 50.0 % - 2 - 1 + 100.0 % + 3 + 3 - VariableDebtTokenInstance.sol + VariableDebtTokenInstance.sol -
88.9%88.9%
+
100.0%
- 88.9 % + 100.0 % + 9 9 - 8 - - 50.0 % - 2 - 1 + 100.0 % + 3 + 3

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func-c.html b/report/misc/AaveOracle.sol.func-c.html similarity index 65% rename from report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func-c.html rename to report/misc/AaveOracle.sol.func-c.html index 05b9424a..45980202 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func-c.html +++ b/report/misc/AaveOracle.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/AaveOracle.sol - functions - + LCOV - lcov.info.p - misc/AaveOracle.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - AaveOracle.sol (source / functions)top level - misc - AaveOracle.sol (source / functions) Coveragelcov.info.p Lines:100.0 %252581.2 %3226
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %9990.9 %1110
0 0
- + - + + + + + + + + @@ -91,6 +98,13 @@ + + + + + + + @@ -102,35 +116,35 @@ - + - + - + - + - + @@ -138,8 +152,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
AaveOracle.0
4
AaveOracle.onlyAssetListingOrPoolAdmins4
AaveOracle.setFallbackOracle
AaveOracle._setAssetsSources590659
AaveOracle.setAssetSources591660
AaveOracle._onlyAssetListingOrPoolAdmins595664
AaveOracle.getSourceOfAsset30304115
AaveOracle.getAssetPrice69942111429
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func.html b/report/misc/AaveOracle.sol.func.html similarity index 65% rename from report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func.html rename to report/misc/AaveOracle.sol.func.html index ac9e07c2..c7bd647e 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.func.html +++ b/report/misc/AaveOracle.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/AaveOracle.sol - functions - + LCOV - lcov.info.p - misc/AaveOracle.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - AaveOracle.sol (source / functions)top level - misc - AaveOracle.sol (source / functions) Coveragelcov.info.p Lines:100.0 %252581.2 %3226
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %9990.9 %1110
0 0
- + - + + + + + + + + - + - + @@ -95,7 +102,7 @@ - + @@ -116,14 +123,21 @@ - + + + + + + + + - + @@ -138,8 +152,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
AaveOracle.0
AaveOracle._onlyAssetListingOrPoolAdmins595664
AaveOracle._setAssetsSources590659
AaveOracle.getAssetPrice69942111429
AaveOracle.getSourceOfAsset30304115
AaveOracle.onlyAssetListingOrPoolAdmins4
AaveOracle.setAssetSources591660
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.gcov.html b/report/misc/AaveOracle.sol.gcov.html similarity index 80% rename from report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.gcov.html rename to report/misc/AaveOracle.sol.gcov.html index a334d9fd..e3d70004 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/AaveOracle.sol.gcov.html +++ b/report/misc/AaveOracle.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc/AaveOracle.sol - + LCOV - lcov.info.p - misc/AaveOracle.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misc - AaveOracle.sol (source / functions)top level - misc - AaveOracle.sol (source / functions) Coveragelcov.info.p Lines:100.0 %252581.2 %3226
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %9990.9 %1110
0 0
@@ -101,7 +101,7 @@ 30 : : * @dev Only asset listing or pool admin can call functions marked by this modifier. 31 : : */ 32 : : modifier onlyAssetListingOrPoolAdmins() { - 33 : : _onlyAssetListingOrPoolAdmins(); + 33 : 4 : _onlyAssetListingOrPoolAdmins(); 34 : : _; 35 : : } 36 : : @@ -123,27 +123,27 @@ 52 : : address baseCurrency, 53 : : uint256 baseCurrencyUnit 54 : : ) { - 55 : : ADDRESSES_PROVIDER = provider; - 56 : : _setFallbackOracle(fallbackOracle); - 57 : : _setAssetsSources(assets, sources); - 58 : : BASE_CURRENCY = baseCurrency; - 59 : : BASE_CURRENCY_UNIT = baseCurrencyUnit; - 60 : : emit BaseCurrencySet(baseCurrency, baseCurrencyUnit); + 55 : 0 : ADDRESSES_PROVIDER = provider; + 56 : 0 : _setFallbackOracle(fallbackOracle); + 57 : 0 : _setAssetsSources(assets, sources); + 58 : 0 : BASE_CURRENCY = baseCurrency; + 59 : 0 : BASE_CURRENCY_UNIT = baseCurrencyUnit; + 60 : 0 : emit BaseCurrencySet(baseCurrency, baseCurrencyUnit); 61 : : } 62 : : 63 : : /// @inheritdoc IAaveOracle - 64 : 591 : function setAssetSources( + 64 : : function setAssetSources( 65 : : address[] calldata assets, 66 : : address[] calldata sources 67 : : ) external override onlyAssetListingOrPoolAdmins { - 68 : 1180 : _setAssetsSources(assets, sources); + 68 : 659 : _setAssetsSources(assets, sources); 69 : : } 70 : : 71 : : /// @inheritdoc IAaveOracle - 72 : 4 : function setFallbackOracle( + 72 : : function setFallbackOracle( 73 : : address fallbackOracle 74 : : ) external override onlyAssetListingOrPoolAdmins { - 75 : 8 : _setFallbackOracle(fallbackOracle); + 75 : 4 : _setFallbackOracle(fallbackOracle); 76 : : } 77 : : 78 : : /** @@ -151,11 +151,11 @@ 80 : : * @param assets The addresses of the assets 81 : : * @param sources The address of the source of each asset 82 : : */ - 83 : 590 : function _setAssetsSources(address[] memory assets, address[] memory sources) internal { - 84 : 1180 : require(assets.length == sources.length, Errors.INCONSISTENT_PARAMS_LENGTH); - 85 : 5273 : for (uint256 i = 0; i < assets.length; i++) { - 86 : 3506 : assetsSources[assets[i]] = AggregatorInterface(sources[i]); - 87 : 3506 : emit AssetSourceUpdated(assets[i], sources[i]); + 83 : : function _setAssetsSources(address[] memory assets, address[] memory sources) internal { + 84 : 659 : require(assets.length == sources.length, Errors.INCONSISTENT_PARAMS_LENGTH); + 85 : 658 : for (uint256 i = 0; i < assets.length; i++) { + 86 : 1954 : assetsSources[assets[i]] = AggregatorInterface(sources[i]); + 87 : 1954 : emit AssetSourceUpdated(assets[i], sources[i]); 88 : : } 89 : : } 90 : : @@ -163,53 +163,53 @@ 92 : : * @notice Internal function to set the fallback oracle 93 : : * @param fallbackOracle The address of the fallback oracle 94 : : */ - 95 : 4 : function _setFallbackOracle(address fallbackOracle) internal { - 96 : 8 : _fallbackOracle = IPriceOracleGetter(fallbackOracle); - 97 : 8 : emit FallbackOracleUpdated(fallbackOracle); + 95 : : function _setFallbackOracle(address fallbackOracle) internal { + 96 : 4 : _fallbackOracle = IPriceOracleGetter(fallbackOracle); + 97 : 4 : emit FallbackOracleUpdated(fallbackOracle); 98 : : } 99 : : 100 : : /// @inheritdoc IPriceOracleGetter - 101 : 69942 : function getAssetPrice(address asset) public view override returns (uint256) { - 102 : 139890 : AggregatorInterface source = assetsSources[asset]; + 101 : : function getAssetPrice(address asset) public view override returns (uint256) { + 102 : 111432 : AggregatorInterface source = assetsSources[asset]; 103 : : - 104 : 139890 : if (asset == BASE_CURRENCY) { - 105 : 4 : return BASE_CURRENCY_UNIT; - 106 : 279772 : } else if (address(source) == address(0)) { - 107 : 9 : return _fallbackOracle.getAssetPrice(asset); + 104 : 111432 : if (asset == BASE_CURRENCY) { + 105 : 2 : return BASE_CURRENCY_UNIT; + 106 : 111430 : } else if (address(source) == address(0)) { + 107 : 3 : return _fallbackOracle.getAssetPrice(asset); 108 : : } else { - 109 : 209820 : int256 price = source.latestAnswer(); - 110 : 139880 : if (price > 0) { - 111 : 209811 : return uint256(price); + 109 : 111427 : int256 price = source.latestAnswer(); + 110 : 111427 : if (price > 0) { + 111 : 111424 : return uint256(price); 112 : : } else { - 113 : 9 : return _fallbackOracle.getAssetPrice(asset); + 113 : 3 : return _fallbackOracle.getAssetPrice(asset); 114 : : } 115 : : } 116 : : } 117 : : 118 : : /// @inheritdoc IAaveOracle - 119 : 3 : function getAssetsPrices( + 119 : : function getAssetsPrices( 120 : : address[] calldata assets 121 : : ) external view override returns (uint256[] memory) { - 122 : 9 : uint256[] memory prices = new uint256[](assets.length); - 123 : 13 : for (uint256 i = 0; i < assets.length; i++) { - 124 : 6 : prices[i] = getAssetPrice(assets[i]); + 122 : 3 : uint256[] memory prices = new uint256[](assets.length); + 123 : 3 : for (uint256 i = 0; i < assets.length; i++) { + 124 : 3 : prices[i] = getAssetPrice(assets[i]); 125 : : } - 126 : 4 : return prices; + 126 : 2 : return prices; 127 : : } 128 : : 129 : : /// @inheritdoc IAaveOracle - 130 : 3030 : function getSourceOfAsset(address asset) external view override returns (address) { - 131 : 9090 : return address(assetsSources[asset]); + 130 : : function getSourceOfAsset(address asset) external view override returns (address) { + 131 : 4115 : return address(assetsSources[asset]); 132 : : } 133 : : 134 : : /// @inheritdoc IAaveOracle - 135 : 3 : function getFallbackOracle() external view returns (address) { - 136 : 9 : return address(_fallbackOracle); + 135 : : function getFallbackOracle() external view returns (address) { + 136 : 3 : return address(_fallbackOracle); 137 : : } 138 : : - 139 : 595 : function _onlyAssetListingOrPoolAdmins() internal view { - 140 : 1785 : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); - 141 : 1190 : require( + 139 : : function _onlyAssetListingOrPoolAdmins() internal view { + 140 : 664 : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); + 141 : 664 : require( 142 : : aclManager.isAssetListingAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), 143 : : Errors.CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN 144 : : ); @@ -222,8 +222,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func-c.html b/report/misc/DefaultReserveInterestRateStrategyV2.sol.func-c.html similarity index 64% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func-c.html rename to report/misc/DefaultReserveInterestRateStrategyV2.sol.func-c.html index 529f1d46..3c30b0e5 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func-c.html +++ b/report/misc/DefaultReserveInterestRateStrategyV2.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol - functions - + LCOV - lcov.info.p - misc/DefaultReserveInterestRateStrategyV2.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,112 +53,119 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - DefaultReserveInterestRateStrategyV2.sol (source / functions)top level - misc - DefaultReserveInterestRateStrategyV2.sol (source / functions) Coverage Lines: 100.0 %43433939
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %13131414
0 0
- + - + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -166,8 +173,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
DefaultReserveInterestRateStrategyV2.getInterestRateDataDefaultReserveInterestRateStrategyV2.242
DefaultReserveInterestRateStrategyV2.getInterestRateData 1000
DefaultReserveInterestRateStrategyV2.getInterestRateDataBpsDefaultReserveInterestRateStrategyV2.getInterestRateDataBps 1000
DefaultReserveInterestRateStrategyV2.getMaxVariableBorrowRateDefaultReserveInterestRateStrategyV2.getMaxVariableBorrowRate30025084
DefaultReserveInterestRateStrategyV2.getVariableRateSlope2DefaultReserveInterestRateStrategyV2.getVariableRateSlope230045088
DefaultReserveInterestRateStrategyV2.getOptimalUsageRatioDefaultReserveInterestRateStrategyV2.getOptimalUsageRatio60038088
DefaultReserveInterestRateStrategyV2.getVariableRateSlope1DefaultReserveInterestRateStrategyV2.getVariableRateSlope160088092
DefaultReserveInterestRateStrategyV2.getBaseVariableBorrowRateDefaultReserveInterestRateStrategyV2.getBaseVariableBorrowRate900811092
DefaultReserveInterestRateStrategyV2._getOverallBorrowRateDefaultReserveInterestRateStrategyV2.calculateInterestRates2375692717
DefaultReserveInterestRateStrategyV2._setInterestRateParamsDefaultReserveInterestRateStrategyV2._rayifyRateData2389193717
DefaultReserveInterestRateStrategyV2.setInterestRateParamsDefaultReserveInterestRateStrategyV2.onlyPoolConfigurator25891190067
DefaultReserveInterestRateStrategyV2.calculateInterestRatesDefaultReserveInterestRateStrategyV2._setInterestRateParams49547198067
DefaultReserveInterestRateStrategyV2._rayifyRateDataDefaultReserveInterestRateStrategyV2.setInterestRateParams50547201067
DefaultReserveInterestRateStrategyV2._bpsToRayDefaultReserveInterestRateStrategyV2._bpsToRay229213412312
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func.html b/report/misc/DefaultReserveInterestRateStrategyV2.sol.func.html similarity index 64% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func.html rename to report/misc/DefaultReserveInterestRateStrategyV2.sol.func.html index 7c05a933..c58484f3 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.func.html +++ b/report/misc/DefaultReserveInterestRateStrategyV2.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol - functions - + LCOV - lcov.info.p - misc/DefaultReserveInterestRateStrategyV2.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,112 +53,119 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - DefaultReserveInterestRateStrategyV2.sol (source / functions)top level - misc - DefaultReserveInterestRateStrategyV2.sol (source / functions) Coverage Lines: 100.0 %43433939
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %13131414
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + @@ -166,8 +173,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
DefaultReserveInterestRateStrategyV2._bpsToRayDefaultReserveInterestRateStrategyV2.229213242
DefaultReserveInterestRateStrategyV2._getOverallBorrowRateDefaultReserveInterestRateStrategyV2._bpsToRay23756412312
DefaultReserveInterestRateStrategyV2._rayifyRateDataDefaultReserveInterestRateStrategyV2._rayifyRateData5054793717
DefaultReserveInterestRateStrategyV2._setInterestRateParamsDefaultReserveInterestRateStrategyV2._setInterestRateParams23891198067
DefaultReserveInterestRateStrategyV2.calculateInterestRatesDefaultReserveInterestRateStrategyV2.calculateInterestRates4954792717
DefaultReserveInterestRateStrategyV2.getBaseVariableBorrowRateDefaultReserveInterestRateStrategyV2.getBaseVariableBorrowRate900811092
DefaultReserveInterestRateStrategyV2.getInterestRateDataDefaultReserveInterestRateStrategyV2.getInterestRateData 1000
DefaultReserveInterestRateStrategyV2.getInterestRateDataBpsDefaultReserveInterestRateStrategyV2.getInterestRateDataBps 1000
DefaultReserveInterestRateStrategyV2.getMaxVariableBorrowRateDefaultReserveInterestRateStrategyV2.getMaxVariableBorrowRate30025084
DefaultReserveInterestRateStrategyV2.getOptimalUsageRatioDefaultReserveInterestRateStrategyV2.getOptimalUsageRatio60038088
DefaultReserveInterestRateStrategyV2.getVariableRateSlope1DefaultReserveInterestRateStrategyV2.getVariableRateSlope160088092
DefaultReserveInterestRateStrategyV2.getVariableRateSlope2DefaultReserveInterestRateStrategyV2.getVariableRateSlope230045088
DefaultReserveInterestRateStrategyV2.setInterestRateParamsDefaultReserveInterestRateStrategyV2.onlyPoolConfigurator25891190067
DefaultReserveInterestRateStrategyV2.setInterestRateParams201067
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.gcov.html b/report/misc/DefaultReserveInterestRateStrategyV2.sol.gcov.html similarity index 70% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.gcov.html rename to report/misc/DefaultReserveInterestRateStrategyV2.sol.gcov.html index 4e879f02..b12fad4c 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol.gcov.html +++ b/report/misc/DefaultReserveInterestRateStrategyV2.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol - + LCOV - lcov.info.p - misc/DefaultReserveInterestRateStrategyV2.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - DefaultReserveInterestRateStrategyV2.sol (source / functions)top level - misc - DefaultReserveInterestRateStrategyV2.sol (source / functions) Coverage Lines: 100.0 %43433939
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %13131414
0 0
@@ -72,14 +72,14 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : - 4 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; - 5 : : import {WadRayMath} from '../libraries/math/WadRayMath.sol'; - 6 : : import {PercentageMath} from '../libraries/math/PercentageMath.sol'; - 7 : : import {DataTypes} from '../libraries/types/DataTypes.sol'; - 8 : : import {Errors} from '../libraries/helpers/Errors.sol'; - 9 : : import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; - 10 : : import {IReserveInterestRateStrategy} from '../../interfaces/IReserveInterestRateStrategy.sol'; - 11 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 4 : : import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; + 5 : : import {WadRayMath} from '../protocol/libraries/math/WadRayMath.sol'; + 6 : : import {PercentageMath} from '../protocol/libraries/math/PercentageMath.sol'; + 7 : : import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; + 8 : : import {Errors} from '../protocol/libraries/helpers/Errors.sol'; + 9 : : import {IDefaultInterestRateStrategyV2} from '../interfaces/IDefaultInterestRateStrategyV2.sol'; + 10 : : import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; + 11 : : import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; 12 : : 13 : : /** 14 : : * @title DefaultReserveInterestRateStrategyV2 contract @@ -93,247 +93,223 @@ 22 : : using WadRayMath for uint256; 23 : : using PercentageMath for uint256; 24 : : - 25 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 26 : : IPoolAddressesProvider public immutable ADDRESSES_PROVIDER; - 27 : : - 28 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 29 : : uint256 public constant MAX_BORROW_RATE = 1000_00; - 30 : : - 31 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 32 : : uint256 public constant MIN_OPTIMAL_POINT = 1_00; + 25 : : struct CalcInterestRatesLocalVars { + 26 : : uint256 availableLiquidity; + 27 : : uint256 currentVariableBorrowRate; + 28 : : uint256 currentLiquidityRate; + 29 : : uint256 borrowUsageRatio; + 30 : : uint256 supplyUsageRatio; + 31 : : uint256 availableLiquidityPlusDebt; + 32 : : } 33 : : 34 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 35 : : uint256 public constant MAX_OPTIMAL_POINT = 99_00; + 35 : : IPoolAddressesProvider public immutable ADDRESSES_PROVIDER; 36 : : - 37 : : /// @dev Underlying asset listed on the Aave pool => rate data - 38 : : mapping(address reserve => InterestRateData) internal _interestRateData; + 37 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 38 : : uint256 public constant MAX_BORROW_RATE = 1000_00; 39 : : - 40 : : /** - 41 : : * @param provider The address of the PoolAddressesProvider of the associated Aave pool - 42 : : */ - 43 : : constructor(address provider) { - 44 : : require(provider != address(0), Errors.INVALID_ADDRESSES_PROVIDER); - 45 : : ADDRESSES_PROVIDER = IPoolAddressesProvider(provider); - 46 : : } - 47 : : - 48 : : modifier onlyPoolConfigurator() { - 49 : : require( - 50 : : msg.sender == ADDRESSES_PROVIDER.getPoolConfigurator(), - 51 : : Errors.CALLER_NOT_POOL_CONFIGURATOR - 52 : : ); - 53 : : _; - 54 : : } - 55 : : - 56 : : /// @inheritdoc IReserveInterestRateStrategy - 57 : 25891 : function setInterestRateParams( - 58 : : address reserve, - 59 : : bytes calldata rateData - 60 : : ) external onlyPoolConfigurator { - 61 : 37782 : _setInterestRateParams(reserve, abi.decode(rateData, (InterestRateData))); - 62 : : } - 63 : : - 64 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 65 : : function setInterestRateParams( - 66 : : address reserve, - 67 : : InterestRateData calldata rateData - 68 : : ) external onlyPoolConfigurator { - 69 : 10000 : _setInterestRateParams(reserve, rateData); - 70 : : } - 71 : : - 72 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 73 : 1000 : function getInterestRateData(address reserve) external view returns (InterestRateDataRay memory) { - 74 : 3000 : return _rayifyRateData(_interestRateData[reserve]); - 75 : : } - 76 : : - 77 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 78 : 1000 : function getInterestRateDataBps(address reserve) external view returns (InterestRateData memory) { - 79 : 2000 : return _interestRateData[reserve]; + 40 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 41 : : uint256 public constant MIN_OPTIMAL_POINT = 1_00; + 42 : : + 43 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 44 : : uint256 public constant MAX_OPTIMAL_POINT = 99_00; + 45 : : + 46 : : /// @dev Map of reserves address and their interest rate data (reserveAddress => interestRateData) + 47 : : mapping(address => InterestRateData) internal _interestRateData; + 48 : : + 49 : : modifier onlyPoolConfigurator() { + 50 : 190067 : require( + 51 : : msg.sender == ADDRESSES_PROVIDER.getPoolConfigurator(), + 52 : : Errors.CALLER_NOT_POOL_CONFIGURATOR + 53 : : ); + 54 : : _; + 55 : : } + 56 : : + 57 : : /** + 58 : : * @dev Constructor. + 59 : : * @param provider The address of the PoolAddressesProvider of the associated Aave pool + 60 : : */ + 61 : : constructor(address provider) { + 62 : 147 : require(provider != address(0), Errors.INVALID_ADDRESSES_PROVIDER); + 63 : 165 : ADDRESSES_PROVIDER = IPoolAddressesProvider(provider); + 64 : : } + 65 : : + 66 : : /// @inheritdoc IReserveInterestRateStrategy + 67 : : function setInterestRateParams( + 68 : : address reserve, + 69 : : bytes calldata rateData + 70 : : ) external onlyPoolConfigurator { + 71 : 188067 : _setInterestRateParams(reserve, abi.decode(rateData, (InterestRateData))); + 72 : : } + 73 : : + 74 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 75 : : function setInterestRateParams( + 76 : : address reserve, + 77 : : InterestRateData calldata rateData + 78 : : ) external onlyPoolConfigurator { + 79 : 10000 : _setInterestRateParams(reserve, rateData); 80 : : } 81 : : 82 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 83 : 6003 : function getOptimalUsageRatio(address reserve) external view returns (uint256) { - 84 : 18009 : return _bpsToRay(uint256(_interestRateData[reserve].optimalUsageRatio)); + 83 : : function getInterestRateData(address reserve) external view returns (InterestRateDataRay memory) { + 84 : 1000 : return _rayifyRateData(_interestRateData[reserve]); 85 : : } 86 : : 87 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 88 : 6008 : function getVariableRateSlope1(address reserve) external view returns (uint256) { - 89 : 18024 : return _bpsToRay(uint256(_interestRateData[reserve].variableRateSlope1)); + 88 : : function getInterestRateDataBps(address reserve) external view returns (InterestRateData memory) { + 89 : 1000 : return _interestRateData[reserve]; 90 : : } 91 : : 92 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 93 : 3004 : function getVariableRateSlope2(address reserve) external view returns (uint256) { - 94 : 9012 : return _bpsToRay(uint256(_interestRateData[reserve].variableRateSlope2)); + 93 : : function getOptimalUsageRatio(address reserve) external view returns (uint256) { + 94 : 8088 : return _bpsToRay(uint256(_interestRateData[reserve].optimalUsageRatio)); 95 : : } 96 : : 97 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 98 : 9008 : function getBaseVariableBorrowRate(address reserve) external view override returns (uint256) { - 99 : 27024 : return _bpsToRay(uint256(_interestRateData[reserve].baseVariableBorrowRate)); + 98 : : function getVariableRateSlope1(address reserve) external view returns (uint256) { + 99 : 8092 : return _bpsToRay(uint256(_interestRateData[reserve].variableRateSlope1)); 100 : : } 101 : : 102 : : /// @inheritdoc IDefaultInterestRateStrategyV2 - 103 : 3002 : function getMaxVariableBorrowRate(address reserve) external view override returns (uint256) { - 104 : 6004 : return - 105 : 6004 : _bpsToRay( - 106 : : uint256( - 107 : : _interestRateData[reserve].baseVariableBorrowRate + - 108 : : _interestRateData[reserve].variableRateSlope1 + - 109 : : _interestRateData[reserve].variableRateSlope2 - 110 : : ) - 111 : : ); - 112 : : } - 113 : : - 114 : : /// @inheritdoc IReserveInterestRateStrategy - 115 : 49547 : function calculateInterestRates( - 116 : : DataTypes.CalculateInterestRatesParams memory params - 117 : : ) public view virtual override returns (uint256, uint256, uint256) { - 118 : 148641 : InterestRateDataRay memory rateData = _rayifyRateData(_interestRateData[params.reserve]); - 119 : : - 120 : : // @note This is a short circuit to allow mintable assets, which by definition cannot be supplied - 121 : : // and thus do not use virtual underlying balances. - 122 : 99094 : if (!params.usingVirtualBalance) { - 123 : 2000 : return (0, 0, rateData.baseVariableBorrowRate); - 124 : : } - 125 : : - 126 : 97094 : CalcInterestRatesLocalVars memory vars; - 127 : : - 128 : 97094 : vars.totalDebt = params.totalStableDebt + params.totalVariableDebt; + 103 : : function getVariableRateSlope2(address reserve) external view returns (uint256) { + 104 : 5088 : return _bpsToRay(uint256(_interestRateData[reserve].variableRateSlope2)); + 105 : : } + 106 : : + 107 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 108 : : function getBaseVariableBorrowRate(address reserve) external view override returns (uint256) { + 109 : 11092 : return _bpsToRay(uint256(_interestRateData[reserve].baseVariableBorrowRate)); + 110 : : } + 111 : : + 112 : : /// @inheritdoc IDefaultInterestRateStrategyV2 + 113 : : function getMaxVariableBorrowRate(address reserve) external view override returns (uint256) { + 114 : 5084 : return + 115 : 5084 : _bpsToRay( + 116 : : uint256( + 117 : : _interestRateData[reserve].baseVariableBorrowRate + + 118 : : _interestRateData[reserve].variableRateSlope1 + + 119 : : _interestRateData[reserve].variableRateSlope2 + 120 : : ) + 121 : : ); + 122 : : } + 123 : : + 124 : : /// @inheritdoc IReserveInterestRateStrategy + 125 : : function calculateInterestRates( + 126 : : DataTypes.CalculateInterestRatesParams memory params + 127 : : ) external view virtual override returns (uint256, uint256) { + 128 : 92717 : InterestRateDataRay memory rateData = _rayifyRateData(_interestRateData[params.reserve]); 129 : : - 130 : 97094 : vars.currentLiquidityRate = 0; - 131 : 97094 : vars.currentVariableBorrowRate = rateData.baseVariableBorrowRate; - 132 : : - 133 : 97094 : if (vars.totalDebt != 0) { - 134 : 47514 : vars.availableLiquidity = - 135 : : params.virtualUnderlyingBalance + - 136 : : params.liquidityAdded - - 137 : : params.liquidityTaken; - 138 : : - 139 : 47512 : vars.availableLiquidityPlusDebt = vars.availableLiquidity + vars.totalDebt; - 140 : 47512 : vars.borrowUsageRatio = vars.totalDebt.rayDiv(vars.availableLiquidityPlusDebt); - 141 : 47512 : vars.supplyUsageRatio = vars.totalDebt.rayDiv( - 142 : : vars.availableLiquidityPlusDebt + params.unbacked - 143 : : ); - 144 : : } else { - 145 : 49580 : return (0, 0, vars.currentVariableBorrowRate); - 146 : : } - 147 : : - 148 : 47512 : if (vars.borrowUsageRatio > rateData.optimalUsageRatio) { - 149 : 12192 : uint256 excessBorrowUsageRatio = (vars.borrowUsageRatio - rateData.optimalUsageRatio).rayDiv( - 150 : : WadRayMath.RAY - rateData.optimalUsageRatio + 130 : : // @note This is a short circuit to allow mintable assets (ex. GHO), which by definition cannot be supplied + 131 : : // and thus do not use virtual underlying balances. + 132 : 92717 : if (!params.usingVirtualBalance) { + 133 : 1000 : return (0, rateData.baseVariableBorrowRate); + 134 : : } + 135 : : + 136 : 91717 : CalcInterestRatesLocalVars memory vars; + 137 : : + 138 : 91717 : vars.currentLiquidityRate = 0; + 139 : 91717 : vars.currentVariableBorrowRate = rateData.baseVariableBorrowRate; + 140 : : + 141 : 91717 : if (params.totalDebt != 0) { + 142 : 32099 : vars.availableLiquidity = + 143 : : params.virtualUnderlyingBalance + + 144 : : params.liquidityAdded - + 145 : : params.liquidityTaken; + 146 : : + 147 : 32098 : vars.availableLiquidityPlusDebt = vars.availableLiquidity + params.totalDebt; + 148 : 32098 : vars.borrowUsageRatio = params.totalDebt.rayDiv(vars.availableLiquidityPlusDebt); + 149 : 32098 : vars.supplyUsageRatio = params.totalDebt.rayDiv( + 150 : : vars.availableLiquidityPlusDebt + params.unbacked 151 : : ); - 152 : : - 153 : 8128 : vars.currentVariableBorrowRate += - 154 : : rateData.variableRateSlope1 + - 155 : : rateData.variableRateSlope2.rayMul(excessBorrowUsageRatio); - 156 : : } else { - 157 : 39384 : vars.currentVariableBorrowRate += rateData - 158 : : .variableRateSlope1 - 159 : : .rayMul(vars.borrowUsageRatio) - 160 : : .rayDiv(rateData.optimalUsageRatio); - 161 : : } - 162 : : - 163 : 47512 : vars.currentLiquidityRate = _getOverallBorrowRate( - 164 : : params.totalStableDebt, - 165 : : params.totalVariableDebt, - 166 : : vars.currentVariableBorrowRate, - 167 : : params.averageStableBorrowRate - 168 : : ).rayMul(vars.supplyUsageRatio).percentMul( - 169 : : PercentageMath.PERCENTAGE_FACTOR - params.reserveFactor - 170 : : ); - 171 : : - 172 : 47512 : return (vars.currentLiquidityRate, 0, vars.currentVariableBorrowRate); - 173 : : } - 174 : : - 175 : : /** - 176 : : * @dev Calculates the overall borrow rate as the weighted average between the total variable debt and total stable - 177 : : * debt - 178 : : * @param totalStableDebt The total borrowed from the reserve at a stable rate - 179 : : * @param totalVariableDebt The total borrowed from the reserve at a variable rate - 180 : : * @param currentVariableBorrowRate The current variable borrow rate of the reserve - 181 : : * @param currentAverageStableBorrowRate The current weighted average of all the stable rate loans - 182 : : * @return The weighted averaged borrow rate + 152 : : } else { + 153 : 59618 : return (0, vars.currentVariableBorrowRate); + 154 : : } + 155 : : + 156 : 32098 : if (vars.borrowUsageRatio > rateData.optimalUsageRatio) { + 157 : 6390 : uint256 excessBorrowUsageRatio = (vars.borrowUsageRatio - rateData.optimalUsageRatio).rayDiv( + 158 : : WadRayMath.RAY - rateData.optimalUsageRatio + 159 : : ); + 160 : : + 161 : 6390 : vars.currentVariableBorrowRate += + 162 : : rateData.variableRateSlope1 + + 163 : : rateData.variableRateSlope2.rayMul(excessBorrowUsageRatio); + 164 : : } else { + 165 : 25708 : vars.currentVariableBorrowRate += rateData + 166 : : .variableRateSlope1 + 167 : : .rayMul(vars.borrowUsageRatio) + 168 : : .rayDiv(rateData.optimalUsageRatio); + 169 : : } + 170 : : + 171 : 32098 : vars.currentLiquidityRate = vars + 172 : : .currentVariableBorrowRate + 173 : : .rayMul(vars.supplyUsageRatio) + 174 : : .percentMul(PercentageMath.PERCENTAGE_FACTOR - params.reserveFactor); + 175 : : + 176 : 32098 : return (vars.currentLiquidityRate, vars.currentVariableBorrowRate); + 177 : : } + 178 : : + 179 : : /** + 180 : : * @dev Doing validations and data update for an asset + 181 : : * @param reserve address of the underlying asset of the reserve + 182 : : * @param rateData Encoded reserve interest rate data to apply 183 : : */ - 184 : 23756 : function _getOverallBorrowRate( - 185 : : uint256 totalStableDebt, - 186 : : uint256 totalVariableDebt, - 187 : : uint256 currentVariableBorrowRate, - 188 : : uint256 currentAverageStableBorrowRate - 189 : : ) internal pure returns (uint256) { - 190 : 71268 : uint256 totalDebt = totalStableDebt + totalVariableDebt; - 191 : : - 192 : 71268 : uint256 weightedVariableRate = totalVariableDebt.wadToRay().rayMul(currentVariableBorrowRate); - 193 : : - 194 : 71268 : uint256 weightedStableRate = totalStableDebt.wadToRay().rayMul(currentAverageStableBorrowRate); - 195 : : - 196 : 71268 : uint256 overallBorrowRate = (weightedVariableRate + weightedStableRate).rayDiv( - 197 : : totalDebt.wadToRay() - 198 : : ); - 199 : : - 200 : 47512 : return overallBorrowRate; - 201 : : } - 202 : : - 203 : : /** - 204 : : * @dev Doing validations and data update for an asset - 205 : : * @param reserve address of the underlying asset of the reserve - 206 : : * @param rateData Encoded eserve interest rate data to apply - 207 : : */ - 208 : 23891 : function _setInterestRateParams(address reserve, InterestRateData memory rateData) internal { - 209 : 47782 : require(reserve != address(0), Errors.ZERO_ADDRESS_NOT_VALID); - 210 : : - 211 : 43782 : require( - 212 : : rateData.optimalUsageRatio <= MAX_OPTIMAL_POINT && - 213 : : rateData.optimalUsageRatio >= MIN_OPTIMAL_POINT, - 214 : : Errors.INVALID_OPTIMAL_USAGE_RATIO - 215 : : ); + 184 : : function _setInterestRateParams(address reserve, InterestRateData memory rateData) internal { + 185 : 198067 : require(reserve != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 186 : : + 187 : 194067 : require( + 188 : : rateData.optimalUsageRatio <= MAX_OPTIMAL_POINT && + 189 : : rateData.optimalUsageRatio >= MIN_OPTIMAL_POINT, + 190 : : Errors.INVALID_OPTIMAL_USAGE_RATIO + 191 : : ); + 192 : : + 193 : 186067 : require( + 194 : : rateData.variableRateSlope1 <= rateData.variableRateSlope2, + 195 : : Errors.SLOPE_2_MUST_BE_GTE_SLOPE_1 + 196 : : ); + 197 : : + 198 : : // The maximum rate should not be above certain threshold + 199 : 182067 : require( + 200 : : uint256(rateData.baseVariableBorrowRate) + + 201 : : uint256(rateData.variableRateSlope1) + + 202 : : uint256(rateData.variableRateSlope2) <= + 203 : : MAX_BORROW_RATE, + 204 : : Errors.INVALID_MAX_RATE + 205 : : ); + 206 : : + 207 : 178067 : _interestRateData[reserve] = rateData; + 208 : 178067 : emit RateDataUpdate( + 209 : : reserve, + 210 : : rateData.optimalUsageRatio, + 211 : : rateData.baseVariableBorrowRate, + 212 : : rateData.variableRateSlope1, + 213 : : rateData.variableRateSlope2 + 214 : : ); + 215 : : } 216 : : - 217 : 35782 : require( - 218 : : rateData.variableRateSlope1 <= rateData.variableRateSlope2, - 219 : : Errors.SLOPE_2_MUST_BE_GTE_SLOPE_1 - 220 : : ); - 221 : : - 222 : : // The maximum rate should not be above certain threshold - 223 : 31782 : require( - 224 : : uint256(rateData.baseVariableBorrowRate) + - 225 : : uint256(rateData.variableRateSlope1) + - 226 : : uint256(rateData.variableRateSlope2) <= - 227 : : MAX_BORROW_RATE, - 228 : : Errors.INVALID_MAXRATE - 229 : : ); - 230 : : - 231 : 27782 : _interestRateData[reserve] = rateData; - 232 : 27782 : emit RateDataUpdate( - 233 : : reserve, - 234 : : rateData.optimalUsageRatio, - 235 : : rateData.baseVariableBorrowRate, - 236 : : rateData.variableRateSlope1, - 237 : : rateData.variableRateSlope2 - 238 : : ); - 239 : : } - 240 : : - 241 : : /** - 242 : : * @dev Transforms an InterestRateData struct to an InterestRateDataRay struct by multiplying all values - 243 : : * by 1e23, turning them into ray values - 244 : : * - 245 : : * @param data The InterestRateData struct to transform - 246 : : * - 247 : : * @return The resulting InterestRateDataRay struct - 248 : : */ - 249 : 50547 : function _rayifyRateData( - 250 : : InterestRateData memory data - 251 : : ) internal pure returns (InterestRateDataRay memory) { - 252 : 101094 : return - 253 : 101094 : InterestRateDataRay({ - 254 : : optimalUsageRatio: _bpsToRay(uint256(data.optimalUsageRatio)), - 255 : : baseVariableBorrowRate: _bpsToRay(uint256(data.baseVariableBorrowRate)), - 256 : : variableRateSlope1: _bpsToRay(uint256(data.variableRateSlope1)), - 257 : : variableRateSlope2: _bpsToRay(uint256(data.variableRateSlope2)) - 258 : : }); - 259 : : } - 260 : : - 261 : : // @dev helper function added here, as generally the protocol doesn't use bps - 262 : 229213 : function _bpsToRay(uint256 n) internal pure returns (uint256) { - 263 : 687639 : return n * 1e23; - 264 : : } - 265 : : } + 217 : : /** + 218 : : * @dev Transforms an InterestRateData struct to an InterestRateDataRay struct by multiplying all values + 219 : : * by 1e23, turning them into ray values + 220 : : * + 221 : : * @param data The InterestRateData struct to transform + 222 : : * + 223 : : * @return The resulting InterestRateDataRay struct + 224 : : */ + 225 : : function _rayifyRateData( + 226 : : InterestRateData memory data + 227 : : ) internal pure returns (InterestRateDataRay memory) { + 228 : 93717 : return + 229 : : InterestRateDataRay({ + 230 : : optimalUsageRatio: _bpsToRay(uint256(data.optimalUsageRatio)), + 231 : : baseVariableBorrowRate: _bpsToRay(uint256(data.baseVariableBorrowRate)), + 232 : : variableRateSlope1: _bpsToRay(uint256(data.variableRateSlope1)), + 233 : : variableRateSlope2: _bpsToRay(uint256(data.variableRateSlope2)) + 234 : : }); + 235 : : } + 236 : : + 237 : : // @dev helper function added here, as generally the protocol doesn't use bps + 238 : : function _bpsToRay(uint256 n) internal pure returns (uint256) { + 239 : 412312 : return n * 1e23; + 240 : : } + 241 : : } @@ -341,8 +317,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func-c.html b/report/misc/PriceOracleSentinel.sol.func-c.html similarity index 67% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func-c.html rename to report/misc/PriceOracleSentinel.sol.func-c.html index d63dff30..6e8daa7d 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func-c.html +++ b/report/misc/PriceOracleSentinel.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol - functions - + LCOV - lcov.info.p - misc/PriceOracleSentinel.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PriceOracleSentinel.sol (source / functions)top level - misc - PriceOracleSentinel.sol (source / functions) Coverage Lines: 100.0 %10101717
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771010
0 0
- + - + @@ -84,6 +84,20 @@ + + + + + + + + + + + + + + @@ -119,13 +133,20 @@ + + + + + + +

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
1
PriceOracleSentinel.onlyPoolAdmin2
PriceOracleSentinel.onlyRiskOrPoolAdmins2
PriceOracleSentinel.setGracePeriod10
PriceOracleSentinel.50

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func.html b/report/misc/PriceOracleSentinel.sol.func.html similarity index 67% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func.html rename to report/misc/PriceOracleSentinel.sol.func.html index 7b4171e0..e024a865 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.func.html +++ b/report/misc/PriceOracleSentinel.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol - functions - + LCOV - lcov.info.p - misc/PriceOracleSentinel.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PriceOracleSentinel.sol (source / functions)top level - misc - PriceOracleSentinel.sol (source / functions) Coverage Lines: 100.0 %10101717
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771010
0 0
- + - + + + + + + + + @@ -105,6 +112,20 @@ + + + + + + + + + + + + + + @@ -124,8 +145,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PriceOracleSentinel.50
5
PriceOracleSentinel.onlyPoolAdmin2
PriceOracleSentinel.onlyRiskOrPoolAdmins2
PriceOracleSentinel.setGracePeriod
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.gcov.html b/report/misc/PriceOracleSentinel.sol.gcov.html similarity index 77% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.gcov.html rename to report/misc/PriceOracleSentinel.sol.gcov.html index bcae9cb6..b3ade1e7 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol.gcov.html +++ b/report/misc/PriceOracleSentinel.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PriceOracleSentinel.sol - + LCOV - lcov.info.p - misc/PriceOracleSentinel.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PriceOracleSentinel.sol (source / functions)top level - misc - PriceOracleSentinel.sol (source / functions) Coverage Lines: 100.0 %10101717
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771010
0 0
@@ -72,11 +72,11 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {Errors} from '../libraries/helpers/Errors.sol'; - 5 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; - 6 : : import {IPriceOracleSentinel} from '../../interfaces/IPriceOracleSentinel.sol'; - 7 : : import {ISequencerOracle} from '../../interfaces/ISequencerOracle.sol'; - 8 : : import {IACLManager} from '../../interfaces/IACLManager.sol'; + 4 : : import {Errors} from '../protocol/libraries/helpers/Errors.sol'; + 5 : : import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol'; + 6 : : import {IPriceOracleSentinel} from '../interfaces/IPriceOracleSentinel.sol'; + 7 : : import {ISequencerOracle} from '../interfaces/ISequencerOracle.sol'; + 8 : : import {IACLManager} from '../interfaces/IACLManager.sol'; 9 : : 10 : : /** 11 : : * @title PriceOracleSentinel @@ -90,8 +90,8 @@ 19 : : * @dev Only pool admin can call functions marked by this modifier. 20 : : */ 21 : : modifier onlyPoolAdmin() { - 22 : : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); - 23 : : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); + 22 : 2 : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); + 23 : 2 : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); 24 : : _; 25 : : } 26 : : @@ -99,8 +99,8 @@ 28 : : * @dev Only risk or pool admin can call functions marked by this modifier. 29 : : */ 30 : : modifier onlyRiskOrPoolAdmins() { - 31 : : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); - 32 : : require( + 31 : 2 : IACLManager aclManager = IACLManager(ADDRESSES_PROVIDER.getACLManager()); + 32 : 2 : require( 33 : : aclManager.isRiskAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), 34 : : Errors.CALLER_NOT_RISK_OR_POOL_ADMIN 35 : : ); @@ -120,50 +120,50 @@ 49 : : * @param gracePeriod The duration of the grace period in seconds 50 : : */ 51 : : constructor(IPoolAddressesProvider provider, ISequencerOracle oracle, uint256 gracePeriod) { - 52 : : ADDRESSES_PROVIDER = provider; - 53 : : _sequencerOracle = oracle; - 54 : : _gracePeriod = gracePeriod; + 52 : 31 : ADDRESSES_PROVIDER = provider; + 53 : 28 : _sequencerOracle = oracle; + 54 : 20 : _gracePeriod = gracePeriod; 55 : : } 56 : : 57 : : /// @inheritdoc IPriceOracleSentinel - 58 : 5 : function isBorrowAllowed() public view override returns (bool) { - 59 : 15 : return _isUpAndGracePeriodPassed(); + 58 : : function isBorrowAllowed() external view override returns (bool) { + 59 : 5 : return _isUpAndGracePeriodPassed(); 60 : : } 61 : : 62 : : /// @inheritdoc IPriceOracleSentinel - 63 : 5 : function isLiquidationAllowed() public view override returns (bool) { - 64 : 15 : return _isUpAndGracePeriodPassed(); + 63 : : function isLiquidationAllowed() external view override returns (bool) { + 64 : 5 : return _isUpAndGracePeriodPassed(); 65 : : } 66 : : 67 : : /** 68 : : * @notice Checks the sequencer oracle is healthy: is up and grace period passed. 69 : : * @return True if the SequencerOracle is up and the grace period passed, false otherwise 70 : : */ - 71 : 10 : function _isUpAndGracePeriodPassed() internal view returns (bool) { - 72 : 30 : (, int256 answer, uint256 startedAt, , ) = _sequencerOracle.latestRoundData(); - 73 : 48 : return answer == 0 && block.timestamp - startedAt > _gracePeriod; + 71 : : function _isUpAndGracePeriodPassed() internal view returns (bool) { + 72 : 10 : (, int256 answer, uint256 startedAt, , ) = _sequencerOracle.latestRoundData(); + 73 : 10 : return answer == 0 && block.timestamp - startedAt > _gracePeriod; 74 : : } 75 : : 76 : : /// @inheritdoc IPriceOracleSentinel - 77 : 2 : function setSequencerOracle(address newSequencerOracle) public onlyPoolAdmin { - 78 : 2 : _sequencerOracle = ISequencerOracle(newSequencerOracle); - 79 : 2 : emit SequencerOracleUpdated(newSequencerOracle); + 77 : : function setSequencerOracle(address newSequencerOracle) external onlyPoolAdmin { + 78 : 1 : _sequencerOracle = ISequencerOracle(newSequencerOracle); + 79 : 1 : emit SequencerOracleUpdated(newSequencerOracle); 80 : : } 81 : : 82 : : /// @inheritdoc IPriceOracleSentinel - 83 : 2 : function setGracePeriod(uint256 newGracePeriod) public onlyRiskOrPoolAdmins { - 84 : 2 : _gracePeriod = newGracePeriod; - 85 : 2 : emit GracePeriodUpdated(newGracePeriod); + 83 : : function setGracePeriod(uint256 newGracePeriod) external onlyRiskOrPoolAdmins { + 84 : 1 : _gracePeriod = newGracePeriod; + 85 : 1 : emit GracePeriodUpdated(newGracePeriod); 86 : : } 87 : : 88 : : /// @inheritdoc IPriceOracleSentinel - 89 : 1 : function getSequencerOracle() public view returns (address) { - 90 : 3 : return address(_sequencerOracle); + 89 : : function getSequencerOracle() external view returns (address) { + 90 : 1 : return address(_sequencerOracle); 91 : : } 92 : : 93 : : /// @inheritdoc IPriceOracleSentinel - 94 : 1 : function getGracePeriod() public view returns (uint256) { - 95 : 2 : return _gracePeriod; + 94 : : function getGracePeriod() external view returns (uint256) { + 95 : 1 : return _gracePeriod; 96 : : } 97 : : } @@ -173,8 +173,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html similarity index 63% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html rename to report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html index 6e5d290f..eeea7ea9 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html +++ b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol - functions - + LCOV - lcov.info.p - misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage Lines: 100.0 %881111
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %5577
0 0
- + - + + + + + + + + @@ -95,14 +102,21 @@ - + + + + + + + + - + @@ -110,8 +124,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
BaseImmutableAdminUpgradeabilityProxy.ifAdmin2
BaseImmutableAdminUpgradeabilityProxy.upgradeToAndCall1413
BaseImmutableAdminUpgradeabilityProxy.46
BaseImmutableAdminUpgradeabilityProxy._willFallback7236232165226
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html similarity index 63% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html rename to report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html index eaed6f00..181045ea 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html +++ b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol - functions - + LCOV - lcov.info.p - misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,28 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage Lines: 100.0 %881111
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %5577
0 0
- + - + + + + + + + + - + @@ -84,6 +91,13 @@ + + + + + + + @@ -102,7 +116,7 @@ - + @@ -110,8 +124,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
BaseImmutableAdminUpgradeabilityProxy.46
BaseImmutableAdminUpgradeabilityProxy._willFallback7236232165226
8
BaseImmutableAdminUpgradeabilityProxy.ifAdmin2
BaseImmutableAdminUpgradeabilityProxy.implementation
BaseImmutableAdminUpgradeabilityProxy.upgradeToAndCall1413
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html similarity index 81% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html rename to report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html index c8f68263..52c8d83b 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html +++ b/report/misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol - + LCOV - lcov.info.p - misc/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - BaseImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage Lines: 100.0 %881111
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %5577
0 0
@@ -72,7 +72,7 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {BaseUpgradeabilityProxy} from '../../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; + 4 : : import {BaseUpgradeabilityProxy} from '../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; 5 : : 6 : : /** 7 : : * @title BaseImmutableAdminUpgradeabilityProxy @@ -92,14 +92,14 @@ 21 : : * @param admin_ The address of the admin 22 : : */ 23 : : constructor(address admin_) { - 24 : : _admin = admin_; + 24 : 46 : _admin = admin_; 25 : : } 26 : : 27 : : modifier ifAdmin() { - 28 : : if (msg.sender == _admin) { + 28 : 2 : if (msg.sender == _admin) { 29 : : _; 30 : : } else { - 31 : : _fallback(); + 31 : 1 : _fallback(); 32 : : } 33 : : } 34 : : @@ -107,16 +107,16 @@ 36 : : * @notice Return the admin address 37 : : * @return The address of the proxy admin. 38 : : */ - 39 : 8 : function admin() external ifAdmin returns (address) { - 40 : 16 : return _admin; + 39 : : function admin() external ifAdmin returns (address) { + 40 : 8 : return _admin; 41 : : } 42 : : 43 : : /** 44 : : * @notice Return the implementation address 45 : : * @return The address of the implementation. 46 : : */ - 47 : 3 : function implementation() external ifAdmin returns (address) { - 48 : 9 : return _implementation(); + 47 : : function implementation() external ifAdmin returns (address) { + 48 : 3 : return _implementation(); 49 : : } 50 : : 51 : : /** @@ -124,8 +124,8 @@ 53 : : * @dev Only the admin can call this function. 54 : : * @param newImplementation The address of the new implementation. 55 : : */ - 56 : 2 : function upgradeTo(address newImplementation) external ifAdmin { - 57 : 2 : _upgradeTo(newImplementation); + 56 : : function upgradeTo(address newImplementation) external ifAdmin { + 57 : 1 : _upgradeTo(newImplementation); 58 : : } 59 : : 60 : : /** @@ -137,21 +137,21 @@ 66 : : * It should include the signature and the parameters of the function to be called, as described in 67 : : * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. 68 : : */ - 69 : 14 : function upgradeToAndCall( + 69 : : function upgradeToAndCall( 70 : : address newImplementation, 71 : : bytes calldata data 72 : : ) external payable ifAdmin { - 73 : 26 : _upgradeTo(newImplementation); - 74 : 39 : (bool success, ) = newImplementation.delegatecall(data); - 75 : 26 : require(success); + 73 : 12 : _upgradeTo(newImplementation); + 74 : 12 : (bool success, ) = newImplementation.delegatecall(data); + 75 : 12 : require(success); 76 : : } 77 : : 78 : : /** 79 : : * @notice Only fall back when the sender is not the admin. 80 : : */ - 81 : 723623 : function _willFallback() internal virtual override { - 82 : 1447246 : require(msg.sender != _admin, 'Cannot call fallback function from the proxy admin'); - 83 : 1447246 : super._willFallback(); + 81 : : function _willFallback() internal virtual override { + 82 : 2165226 : require(msg.sender != _admin, 'Cannot call fallback function from the proxy admin'); + 83 : 2165226 : super._willFallback(); 84 : : } 85 : : } @@ -161,8 +161,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html similarity index 60% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html rename to report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html index 4d2f52d6..bf41678a 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html +++ b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol - functions - + LCOV - lcov.info.p - misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,28 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %1122
0 0
- + + + + + + + + - + - + @@ -82,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
InitializableImmutableAdminUpgradeabilityProxy.Hit count Sort by function hit count142
InitializableImmutableAdminUpgradeabilityProxy._willFallback7236232165226
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html similarity index 60% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html rename to report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html index d1d87275..11f67cbb 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html +++ b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol - functions - + LCOV - lcov.info.p - misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,28 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %1122
0 0
- + + + + + + + + - + - + @@ -82,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
InitializableImmutableAdminUpgradeabilityProxy.Hit count Sort by function hit count142
InitializableImmutableAdminUpgradeabilityProxy._willFallback7236232165226
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html similarity index 75% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html rename to report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html index 248a1551..07ba6326 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html +++ b/report/misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol - + LCOV - lcov.info.p - misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions)top level - misc/aave-upgradeability - InitializableImmutableAdminUpgradeabilityProxy.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %1122
0 0
@@ -72,8 +72,8 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {InitializableUpgradeabilityProxy} from '../../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; - 5 : : import {Proxy} from '../../../dependencies/openzeppelin/upgradeability/Proxy.sol'; + 4 : : import {InitializableUpgradeabilityProxy} from '../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; + 5 : : import {Proxy} from '../../dependencies/openzeppelin/upgradeability/Proxy.sol'; 6 : : import {BaseImmutableAdminUpgradeabilityProxy} from './BaseImmutableAdminUpgradeabilityProxy.sol'; 7 : : 8 : : /** @@ -94,8 +94,8 @@ 23 : : } 24 : : 25 : : /// @inheritdoc BaseImmutableAdminUpgradeabilityProxy - 26 : 723623 : function _willFallback() internal override(BaseImmutableAdminUpgradeabilityProxy, Proxy) { - 27 : 1447246 : BaseImmutableAdminUpgradeabilityProxy._willFallback(); + 26 : : function _willFallback() internal override(BaseImmutableAdminUpgradeabilityProxy, Proxy) { + 27 : 2165226 : BaseImmutableAdminUpgradeabilityProxy._willFallback(); 28 : : } 29 : : } @@ -105,8 +105,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/misc/aave-upgradeability/VersionedInitializable.sol.func-c.html b/report/misc/aave-upgradeability/VersionedInitializable.sol.func-c.html new file mode 100644 index 00000000..e6d9f827 --- /dev/null +++ b/report/misc/aave-upgradeability/VersionedInitializable.sol.func-c.html @@ -0,0 +1,98 @@ + + + + + + + LCOV - lcov.info.p - misc/aave-upgradeability/VersionedInitializable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/aave-upgradeability - VersionedInitializable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %1111
Test Date:2024-09-24 09:34:24Functions:100.0 %22
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
VersionedInitializable.initializer346987
VersionedInitializable.isConstructor346987
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/aave-upgradeability/VersionedInitializable.sol.func.html b/report/misc/aave-upgradeability/VersionedInitializable.sol.func.html new file mode 100644 index 00000000..c9988d86 --- /dev/null +++ b/report/misc/aave-upgradeability/VersionedInitializable.sol.func.html @@ -0,0 +1,98 @@ + + + + + + + LCOV - lcov.info.p - misc/aave-upgradeability/VersionedInitializable.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/aave-upgradeability - VersionedInitializable.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %1111
Test Date:2024-09-24 09:34:24Functions:100.0 %22
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
VersionedInitializable.initializer346987
VersionedInitializable.isConstructor346987
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.gcov.html b/report/misc/aave-upgradeability/VersionedInitializable.sol.gcov.html similarity index 83% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.gcov.html rename to report/misc/aave-upgradeability/VersionedInitializable.sol.gcov.html index 41805ea2..298962d7 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol.gcov.html +++ b/report/misc/aave-upgradeability/VersionedInitializable.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol - + LCOV - lcov.info.p - misc/aave-upgradeability/VersionedInitializable.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - VersionedInitializable.sol (source / functions)top level - misc/aave-upgradeability - VersionedInitializable.sol (source / functions) Coverage Lines: 100.0 %331111
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %1122
0 0
@@ -99,22 +99,22 @@ 28 : : * @dev Modifier to use in the initializer function of a contract. 29 : : */ 30 : : modifier initializer() { - 31 : : uint256 revision = getRevision(); - 32 : : require( + 31 : 346987 : uint256 revision = getRevision(); + 32 : 346987 : require( 33 : : initializing || isConstructor() || revision > lastInitializedRevision, 34 : : 'Contract instance has already been initialized' 35 : : ); 36 : : - 37 : : bool isTopLevelCall = !initializing; - 38 : : if (isTopLevelCall) { - 39 : : initializing = true; - 40 : : lastInitializedRevision = revision; + 37 : 345986 : bool isTopLevelCall = !initializing; + 38 : 345986 : if (isTopLevelCall) { + 39 : 345986 : initializing = true; + 40 : 345986 : lastInitializedRevision = revision; 41 : : } 42 : : 43 : : _; 44 : : - 45 : : if (isTopLevelCall) { - 46 : : initializing = false; + 45 : 344984 : if (isTopLevelCall) { + 46 : 344984 : initializing = false; 47 : : } 48 : : } 49 : : @@ -129,18 +129,18 @@ 58 : : * @notice Returns true if and only if the function is running in the constructor 59 : : * @return True if the function is running in the constructor 60 : : */ - 61 : 15381 : function isConstructor() private view returns (bool) { + 61 : : function isConstructor() private view returns (bool) { 62 : : // extcodesize checks the size of the code stored in an address, and 63 : : // address returns the current address. Since the code is still not 64 : : // deployed when running a constructor, any checks on its code size will 65 : : // yield zero, making it an effective way to detect if a contract is 66 : : // under construction or not. - 67 : 30762 : uint256 cs; + 67 : 346987 : uint256 cs; 68 : : //solium-disable-next-line 69 : : assembly { - 70 : 30762 : cs := extcodesize(address()) + 70 : 346987 : cs := extcodesize(address()) 71 : : } - 72 : 46143 : return cs == 0; + 72 : 346987 : return cs == 0; 73 : : } 74 : : 75 : : // Reserved storage space to allow for layout changes in the future. @@ -153,8 +153,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-b.html b/report/misc/aave-upgradeability/index-sort-b.html similarity index 59% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-b.html rename to report/misc/aave-upgradeability/index-sort-b.html index e9076aeb..6fbec03e 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-b.html +++ b/report/misc/aave-upgradeability/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - + LCOV - lcov.info.p - misc/aave-upgradeability + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeabilitytop level - misc/aave-upgradeability Coverage Lines: 100.0 %12122323
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - BaseImmutableAdminUpgradeabilityProxy.sol + BaseImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % - 8 - 8 + 11 + 11 - 100.0 % - 5 - 5 + 7 + 7 - InitializableImmutableAdminUpgradeabilityProxy.sol + InitializableImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % 1 @@ -122,31 +122,31 @@ 100.0 % - 1 - 1 + 2 + 2 - VersionedInitializable.sol + VersionedInitializable.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 11 + 11 - 100.0 % - 1 - 1 + 2 + 2

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-f.html b/report/misc/aave-upgradeability/index-sort-f.html similarity index 59% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-f.html rename to report/misc/aave-upgradeability/index-sort-f.html index b5084b97..c743f57f 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-f.html +++ b/report/misc/aave-upgradeability/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - + LCOV - lcov.info.p - misc/aave-upgradeability + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeabilitytop level - misc/aave-upgradeability Coverage Lines: 100.0 %12122323
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - InitializableImmutableAdminUpgradeabilityProxy.sol + InitializableImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % 1 @@ -107,46 +107,46 @@ 100.0 % - 1 - 1 + 2 + 2 - VersionedInitializable.sol + VersionedInitializable.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 11 + 11 - 100.0 % - 1 - 1 + 2 + 2 - BaseImmutableAdminUpgradeabilityProxy.sol + BaseImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % - 8 - 8 + 11 + 11 - 100.0 % - 5 - 5 + 7 + 7

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-l.html b/report/misc/aave-upgradeability/index-sort-l.html similarity index 59% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-l.html rename to report/misc/aave-upgradeability/index-sort-l.html index 9ecef43f..b8ae0b74 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index-sort-l.html +++ b/report/misc/aave-upgradeability/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - + LCOV - lcov.info.p - misc/aave-upgradeability + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeabilitytop level - misc/aave-upgradeability Coverage Lines: 100.0 %12122323
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - InitializableImmutableAdminUpgradeabilityProxy.sol + InitializableImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % 1 @@ -107,46 +107,46 @@ 100.0 % - 1 - 1 + 2 + 2 - VersionedInitializable.sol + BaseImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 11 + 11 - 100.0 % - 1 - 1 + 7 + 7 - BaseImmutableAdminUpgradeabilityProxy.sol + VersionedInitializable.sol -
100.0%
+
100.0%
100.0 % - 8 - 8 + 11 + 11 - 100.0 % - 5 - 5 + 2 + 2

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index.html b/report/misc/aave-upgradeability/index.html similarity index 59% rename from report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index.html rename to report/misc/aave-upgradeability/index.html index db271224..2fc18e97 100644 --- a/report/core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability/index.html +++ b/report/misc/aave-upgradeability/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeability - + LCOV - lcov.info.p - misc/aave-upgradeability + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/aave-upgradeability/src/core/contracts/protocol/libraries/aave-upgradeabilitytop level - misc/aave-upgradeability Coverage Lines: 100.0 %12122323
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %771111
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - BaseImmutableAdminUpgradeabilityProxy.sol + BaseImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % - 8 - 8 + 11 + 11 - 100.0 % - 5 - 5 + 7 + 7 - InitializableImmutableAdminUpgradeabilityProxy.sol + InitializableImmutableAdminUpgradeabilityProxy.sol -
100.0%
+
100.0%
100.0 % 1 @@ -122,31 +122,31 @@ 100.0 % - 1 - 1 + 2 + 2 - VersionedInitializable.sol + VersionedInitializable.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 11 + 11 - 100.0 % - 1 - 1 + 2 + 2

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func-c.html b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func-c.html new file mode 100644 index 00000000..a035c960 --- /dev/null +++ b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func-c.html @@ -0,0 +1,91 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanReceiverBase.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/base - FlashLoanReceiverBase.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:0.0 %20
Test Date:2024-09-24 09:34:24Functions:0.0 %10
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
FlashLoanReceiverBase.0
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func.html b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func.html new file mode 100644 index 00000000..cf8732da --- /dev/null +++ b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.func.html @@ -0,0 +1,91 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanReceiverBase.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/base - FlashLoanReceiverBase.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:0.0 %20
Test Date:2024-09-24 09:34:24Functions:0.0 %10
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
FlashLoanReceiverBase.0
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.gcov.html b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.gcov.html similarity index 54% rename from report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.gcov.html rename to report/misc/flashloan/base/FlashLoanReceiverBase.sol.gcov.html index 8762d67b..540e9e6e 100644 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.gcov.html +++ b/report/misc/flashloan/base/FlashLoanReceiverBase.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol - + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanReceiverBase.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/libraries - DataTypesHelper.sol (source / functions)top level - misc/flashloan/base - FlashLoanReceiverBase.sol (source / functions) Coveragelcov.info.p Lines:100.0 %110.0 %20
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %10.0 % 10
0 0
@@ -72,32 +72,24 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; - 5 : : import {DataTypes} from 'aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol'; - 6 : : - 7 : : /** - 8 : : * @title DataTypesHelper - 9 : : * @author Aave - 10 : : * @dev Helper library to track user current debt balance, used by WrappedTokenGatewayV3 - 11 : : */ - 12 : : library DataTypesHelper { - 13 : : /** - 14 : : * @notice Fetches the user current stable and variable debt balances - 15 : : * @param user The user address - 16 : : * @param reserve The reserve data object - 17 : : * @return The stable debt balance - 18 : : * @return The variable debt balance - 19 : : **/ - 20 : 5 : function getUserCurrentDebt( - 21 : : address user, - 22 : : DataTypes.ReserveDataLegacy memory reserve - 23 : : ) internal view returns (uint256, uint256) { - 24 : 10 : return ( - 25 : : IERC20(reserve.stableDebtTokenAddress).balanceOf(user), - 26 : : IERC20(reserve.variableDebtTokenAddress).balanceOf(user) - 27 : : ); - 28 : : } - 29 : : } + 4 : : import {IFlashLoanReceiver} from '../interfaces/IFlashLoanReceiver.sol'; + 5 : : import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; + 6 : : import {IPool} from '../../../interfaces/IPool.sol'; + 7 : : + 8 : : /** + 9 : : * @title FlashLoanReceiverBase + 10 : : * @author Aave + 11 : : * @notice Base contract to develop a flashloan-receiver contract. + 12 : : */ + 13 : : abstract contract FlashLoanReceiverBase is IFlashLoanReceiver { + 14 : : IPoolAddressesProvider public immutable override ADDRESSES_PROVIDER; + 15 : : IPool public immutable override POOL; + 16 : : + 17 : : constructor(IPoolAddressesProvider provider) { + 18 : 0 : ADDRESSES_PROVIDER = provider; + 19 : 0 : POOL = IPool(provider.getPool()); + 20 : : } + 21 : : } @@ -105,8 +97,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func-c.html b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func-c.html similarity index 65% rename from report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func-c.html rename to report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func-c.html index d37d5d7d..c50fb247 100644 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func-c.html +++ b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol - functions - + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanSimpleReceiverBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,28 +53,28 @@ - +
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/libraries - DataTypesHelper.sol (source / functions)top level - misc/flashloan/base - FlashLoanSimpleReceiverBase.sol (source / functions) Coverage Lines: 100.0 %1122
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
DataTypesHelper.getUserCurrentDebtFlashLoanSimpleReceiverBase.558
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func.html b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func.html similarity index 65% rename from report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func.html rename to report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func.html index e8c58a59..882c4121 100644 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol.func.html +++ b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries/DataTypesHelper.sol - functions - + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanSimpleReceiverBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,28 +53,28 @@ - +
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/libraries - DataTypesHelper.sol (source / functions)top level - misc/flashloan/base - FlashLoanSimpleReceiverBase.sol (source / functions) Coverage Lines: 100.0 %1122
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
DataTypesHelper.getUserCurrentDebtFlashLoanSimpleReceiverBase.558
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.gcov.html b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.gcov.html similarity index 57% rename from report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.gcov.html rename to report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.gcov.html index 17c7eb68..786fcf67 100644 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.gcov.html +++ b/report/misc/flashloan/base/FlashLoanSimpleReceiverBase.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol - + LCOV - lcov.info.p - misc/flashloan/base/FlashLoanSimpleReceiverBase.sol + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - Helpers.sol (source / functions)top level - misc/flashloan/base - FlashLoanSimpleReceiverBase.sol (source / functions) Coverage Lines: 100.0 %1122
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -70,33 +70,26 @@
             Branch data     Line data    Source code
        1                 :             : // SPDX-License-Identifier: MIT
-       2                 :             : pragma solidity ^0.8.0;
+       2                 :             : pragma solidity ^0.8.10;
        3                 :             : 
-       4                 :             : import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol';
-       5                 :             : import {DataTypes} from '../types/DataTypes.sol';
-       6                 :             : 
-       7                 :             : /**
-       8                 :             :  * @title Helpers library
-       9                 :             :  * @author Aave
-      10                 :             :  */
-      11                 :             : library Helpers {
-      12                 :             :   /**
-      13                 :             :    * @notice Fetches the user current stable and variable debt balances
-      14                 :             :    * @param user The user address
-      15                 :             :    * @param reserveCache The reserve cache data object
-      16                 :             :    * @return The stable debt balance
-      17                 :             :    * @return The variable debt balance
-      18                 :             :    */
-      19                 :       16329 :   function getUserCurrentDebt(
-      20                 :             :     address user,
-      21                 :             :     DataTypes.ReserveCache memory reserveCache
-      22                 :             :   ) internal view returns (uint256, uint256) {
-      23                 :       32658 :     return (
-      24                 :             :       IERC20(reserveCache.stableDebtTokenAddress).balanceOf(user),
-      25                 :             :       IERC20(reserveCache.variableDebtTokenAddress).balanceOf(user)
-      26                 :             :     );
-      27                 :             :   }
-      28                 :             : }
+       4                 :             : import {IFlashLoanSimpleReceiver} from '../interfaces/IFlashLoanSimpleReceiver.sol';
+       5                 :             : import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol';
+       6                 :             : import {IPool} from '../../../interfaces/IPool.sol';
+       7                 :             : 
+       8                 :             : /**
+       9                 :             :  * @title FlashLoanSimpleReceiverBase
+      10                 :             :  * @author Aave
+      11                 :             :  * @notice Base contract to develop a flashloan-receiver contract.
+      12                 :             :  */
+      13                 :             : abstract contract FlashLoanSimpleReceiverBase is IFlashLoanSimpleReceiver {
+      14                 :             :   IPoolAddressesProvider public immutable override ADDRESSES_PROVIDER;
+      15                 :             :   IPool public immutable override POOL;
+      16                 :             : 
+      17                 :             :   constructor(IPoolAddressesProvider provider) {
+      18                 :          58 :     ADDRESSES_PROVIDER = provider;
+      19                 :          68 :     POOL = IPool(provider.getPool());
+      20                 :             :   }
+      21                 :             : }
         
@@ -104,8 +97,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/misc/flashloan/base/index-sort-b.html b/report/misc/flashloan/base/index-sort-b.html new file mode 100644 index 00000000..b77bf200 --- /dev/null +++ b/report/misc/flashloan/base/index-sort-b.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/baseCoverageTotalHit
Test:lcov.info.pLines:50.0 %42
Test Date:2024-09-24 09:34:24Functions:50.0 %21
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
FlashLoanReceiverBase.sol +
0.0%
+
0.0 %2-0.0 %1
FlashLoanSimpleReceiverBase.sol +
100.0%
+
100.0 %22-100.0 %11
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/flashloan/base/index-sort-f.html b/report/misc/flashloan/base/index-sort-f.html new file mode 100644 index 00000000..95df52ec --- /dev/null +++ b/report/misc/flashloan/base/index-sort-f.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/baseCoverageTotalHit
Test:lcov.info.pLines:50.0 %42
Test Date:2024-09-24 09:34:24Functions:50.0 %21
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
FlashLoanReceiverBase.sol +
0.0%
+
0.0 %2-0.0 %1
FlashLoanSimpleReceiverBase.sol +
100.0%
+
100.0 %22-100.0 %11
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/flashloan/base/index-sort-l.html b/report/misc/flashloan/base/index-sort-l.html new file mode 100644 index 00000000..6dfece1e --- /dev/null +++ b/report/misc/flashloan/base/index-sort-l.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/baseCoverageTotalHit
Test:lcov.info.pLines:50.0 %42
Test Date:2024-09-24 09:34:24Functions:50.0 %21
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
FlashLoanReceiverBase.sol +
0.0%
+
0.0 %2-0.0 %1
FlashLoanSimpleReceiverBase.sol +
100.0%
+
100.0 %22-100.0 %11
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/flashloan/base/index.html b/report/misc/flashloan/base/index.html new file mode 100644 index 00000000..7ce3a1d7 --- /dev/null +++ b/report/misc/flashloan/base/index.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - lcov.info.p - misc/flashloan/base + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - misc/flashloan/baseCoverageTotalHit
Test:lcov.info.pLines:50.0 %42
Test Date:2024-09-24 09:34:24Functions:50.0 %21
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
FlashLoanReceiverBase.sol +
0.0%
+
0.0 %2-0.0 %1
FlashLoanSimpleReceiverBase.sol +
100.0%
+
100.0 %22-100.0 %11
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/index-sort-b.html b/report/misc/index-sort-b.html new file mode 100644 index 00000000..4dab1ea9 --- /dev/null +++ b/report/misc/index-sort-b.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - misc + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - miscCoverageTotalHit
Test:lcov.info.pLines:93.2 %8882
Test Date:2024-09-24 09:34:24Functions:97.1 %3534
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
AaveOracle.sol +
81.2%81.2%
+
81.2 %3226-90.9 %1110
DefaultReserveInterestRateStrategyV2.sol +
100.0%
+
100.0 %3939-100.0 %1414
PriceOracleSentinel.sol +
100.0%
+
100.0 %1717-100.0 %1010
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/index-sort-f.html b/report/misc/index-sort-f.html new file mode 100644 index 00000000..eb5ba0f1 --- /dev/null +++ b/report/misc/index-sort-f.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - misc + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - miscCoverageTotalHit
Test:lcov.info.pLines:93.2 %8882
Test Date:2024-09-24 09:34:24Functions:97.1 %3534
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
AaveOracle.sol +
81.2%81.2%
+
81.2 %3226-90.9 %1110
PriceOracleSentinel.sol +
100.0%
+
100.0 %1717-100.0 %1010
DefaultReserveInterestRateStrategyV2.sol +
100.0%
+
100.0 %3939-100.0 %1414
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/index-sort-l.html b/report/misc/index-sort-l.html new file mode 100644 index 00000000..01bfd04d --- /dev/null +++ b/report/misc/index-sort-l.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - misc + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - miscCoverageTotalHit
Test:lcov.info.pLines:93.2 %8882
Test Date:2024-09-24 09:34:24Functions:97.1 %3534
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
AaveOracle.sol +
81.2%81.2%
+
81.2 %3226-90.9 %1110
PriceOracleSentinel.sol +
100.0%
+
100.0 %1717-100.0 %1010
DefaultReserveInterestRateStrategyV2.sol +
100.0%
+
100.0 %3939-100.0 %1414
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/misc/index.html b/report/misc/index.html new file mode 100644 index 00000000..8c76bd84 --- /dev/null +++ b/report/misc/index.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - misc + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - miscCoverageTotalHit
Test:lcov.info.pLines:93.2 %8882
Test Date:2024-09-24 09:34:24Functions:97.1 %3534
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
AaveOracle.sol +
81.2%81.2%
+
81.2 %3226-90.9 %1110
DefaultReserveInterestRateStrategyV2.sol +
100.0%
+
100.0 %3939-100.0 %1414
PriceOracleSentinel.sol +
100.0%
+
100.0 %1717-100.0 %1010
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func-c.html b/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func-c.html deleted file mode 100644 index ef077afb..00000000 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func-c.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapBuyAdapter.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %2424
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BaseParaSwapBuyAdapter._buyOnParaSwap6
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func.html b/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func.html deleted file mode 100644 index 5c15c254..00000000 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol.func.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapBuyAdapter.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %2424
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BaseParaSwapBuyAdapter._buyOnParaSwap6
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func-c.html b/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func-c.html deleted file mode 100644 index 72e640e0..00000000 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func-c.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapSellAdapter.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %2121
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BaseParaSwapSellAdapter._sellOnParaSwap9
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func.html b/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func.html deleted file mode 100644 index 9953c476..00000000 --- a/report/periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol.func.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol - functions - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/adapters/paraswap/src/periphery/contracts/adapters/paraswap - BaseParaSwapSellAdapter.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %2121
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - -

Function Name Sort by function nameHit count Sort by function hit count
BaseParaSwapSellAdapter._sellOnParaSwap9
-
-
- - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-b.html b/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-b.html deleted file mode 100644 index b0c9d92c..00000000 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-b.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/librariesCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DataTypesHelper.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-f.html b/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-f.html deleted file mode 100644 index 48dbe985..00000000 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-f.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/librariesCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DataTypesHelper.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-l.html b/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-l.html deleted file mode 100644 index 3adc162a..00000000 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index-sort-l.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/librariesCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DataTypesHelper.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index.html b/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index.html deleted file mode 100644 index 5055d076..00000000 --- a/report/periphery/contracts/libraries/src/periphery/contracts/libraries/index.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/libraries/src/periphery/contracts/libraries - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/libraries/src/periphery/contracts/librariesCoverageTotalHit
Test:lcov.info.pLines:100.0 %11
Test Date:2024-04-09 14:12:28Functions:100.0 %11
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
DataTypesHelper.sol -
100.0%
-
100.0 %11-100.0 %11
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-b.html b/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-b.html deleted file mode 100644 index 0f9f4c34..00000000 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-b.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/misc/src/periphery/contracts/miscCoverageTotalHit
Test:lcov.info.pLines:100.0 %3838
Test Date:2024-04-09 14:12:28Functions:100.0 %1010
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
WrappedTokenGatewayV3.sol -
100.0%
-
100.0 %3838-100.0 %1010
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-f.html b/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-f.html deleted file mode 100644 index 491ae36d..00000000 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-f.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/misc/src/periphery/contracts/miscCoverageTotalHit
Test:lcov.info.pLines:100.0 %3838
Test Date:2024-04-09 14:12:28Functions:100.0 %1010
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
WrappedTokenGatewayV3.sol -
100.0%
-
100.0 %3838-100.0 %1010
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-l.html b/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-l.html deleted file mode 100644 index 949ca423..00000000 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/index-sort-l.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/misc/src/periphery/contracts/miscCoverageTotalHit
Test:lcov.info.pLines:100.0 %3838
Test Date:2024-04-09 14:12:28Functions:100.0 %1010
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
WrappedTokenGatewayV3.sol -
100.0%
-
100.0 %3838-100.0 %1010
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/periphery/contracts/misc/src/periphery/contracts/misc/index.html b/report/periphery/contracts/misc/src/periphery/contracts/misc/index.html deleted file mode 100644 index 6a4c8cf0..00000000 --- a/report/periphery/contracts/misc/src/periphery/contracts/misc/index.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - LCOV - lcov.info.p - periphery/contracts/misc/src/periphery/contracts/misc - - - - - - - - - - - - - - -
LCOV - code coverage report
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Current view:top level - periphery/contracts/misc/src/periphery/contracts/miscCoverageTotalHit
Test:lcov.info.pLines:100.0 %3838
Test Date:2024-04-09 14:12:28Functions:100.0 %1010
Branches:-00
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Filename Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
WrappedTokenGatewayV3.sol -
100.0%
-
100.0 %3838-100.0 %1010
-
-
- - - - -
Generated by: LCOV version 2.0-1
-
- - - diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func-c.html b/report/protocol/configuration/ACLManager.sol.func-c.html similarity index 75% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func-c.html rename to report/protocol/configuration/ACLManager.sol.func-c.html index 9a24bbad..5f6427f2 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func-c.html +++ b/report/protocol/configuration/ACLManager.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol - functions - + LCOV - lcov.info.p - protocol/configuration/ACLManager.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - ACLManager.sol (source / functions)top level - protocol/configuration - ACLManager.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1982.6 %23 19
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %1995.0 %20 19
0 0
- + + + + + + + + - + @@ -133,13 +140,6 @@ - - - - - - - @@ -165,42 +165,49 @@ - + + + + + + + + - + - + - + - + - + @@ -208,8 +215,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ACLManager.Hit count Sort by function hit count0
6
ACLManager.isFlashBorrower11
ACLManager.addBridge
ACLManager.addEmergencyAdmin608683
ACLManager.isFlashBorrower1012
ACLManager.addPoolAdmin17942028
ACLManager.isAssetListingAdmin318810317
ACLManager.isEmergencyAdmin1000417013
ACLManager.isRiskAdmin2533684695
ACLManager.isPoolAdmin51690140446
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func.html b/report/protocol/configuration/ACLManager.sol.func.html similarity index 75% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func.html rename to report/protocol/configuration/ACLManager.sol.func.html index 093dcf6d..59cf45d2 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.func.html +++ b/report/protocol/configuration/ACLManager.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol - functions - + LCOV - lcov.info.p - protocol/configuration/ACLManager.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - ACLManager.sol (source / functions)top level - protocol/configuration - ACLManager.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1982.6 %23 19
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %1995.0 %20 19
0 0
- + + + + + + + + - + @@ -88,7 +95,7 @@ - + @@ -102,7 +109,7 @@ - + @@ -116,7 +123,7 @@ - + @@ -130,28 +137,28 @@ - + - + - + - + @@ -208,8 +215,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
ACLManager.Hit count Sort by function hit count0
ACLManager.addEmergencyAdmin608683
ACLManager.addPoolAdmin17942028
ACLManager.isAssetListingAdmin318810317
ACLManager.isEmergencyAdmin1000417013
ACLManager.isFlashBorrower111012
ACLManager.isPoolAdmin51690140446
ACLManager.isRiskAdmin2533684695
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.gcov.html b/report/protocol/configuration/ACLManager.sol.gcov.html similarity index 75% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.gcov.html rename to report/protocol/configuration/ACLManager.sol.gcov.html index bf60ee78..9f69f4dd 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol.gcov.html +++ b/report/protocol/configuration/ACLManager.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/ACLManager.sol - + LCOV - lcov.info.p - protocol/configuration/ACLManager.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - ACLManager.sol (source / functions)top level - protocol/configuration - ACLManager.sol (source / functions) Coveragelcov.info.p Lines:100.0 %1982.6 %23 19
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %1995.0 %20 19
0 0
@@ -98,108 +98,108 @@ 27 : : * @param provider The address of the PoolAddressesProvider 28 : : */ 29 : : constructor(IPoolAddressesProvider provider) { - 30 : : ADDRESSES_PROVIDER = provider; - 31 : : address aclAdmin = provider.getACLAdmin(); - 32 : : require(aclAdmin != address(0), Errors.ACL_ADMIN_CANNOT_BE_ZERO); - 33 : : _setupRole(DEFAULT_ADMIN_ROLE, aclAdmin); + 30 : 0 : ADDRESSES_PROVIDER = provider; + 31 : 0 : address aclAdmin = provider.getACLAdmin(); + 32 : 0 : require(aclAdmin != address(0), Errors.ACL_ADMIN_CANNOT_BE_ZERO); + 33 : 0 : _setupRole(DEFAULT_ADMIN_ROLE, aclAdmin); 34 : : } 35 : : 36 : : /// @inheritdoc IACLManager - 37 : 6 : function setRoleAdmin( + 37 : : function setRoleAdmin( 38 : : bytes32 role, 39 : : bytes32 adminRole 40 : : ) external override onlyRole(DEFAULT_ADMIN_ROLE) { - 41 : 10 : _setRoleAdmin(role, adminRole); + 41 : 5 : _setRoleAdmin(role, adminRole); 42 : : } 43 : : 44 : : /// @inheritdoc IACLManager - 45 : 1794 : function addPoolAdmin(address admin) external override { - 46 : 3588 : grantRole(POOL_ADMIN_ROLE, admin); + 45 : : function addPoolAdmin(address admin) external override { + 46 : 2028 : grantRole(POOL_ADMIN_ROLE, admin); 47 : : } 48 : : 49 : : /// @inheritdoc IACLManager - 50 : 1 : function removePoolAdmin(address admin) external override { - 51 : 2 : revokeRole(POOL_ADMIN_ROLE, admin); + 50 : : function removePoolAdmin(address admin) external override { + 51 : 1 : revokeRole(POOL_ADMIN_ROLE, admin); 52 : : } 53 : : 54 : : /// @inheritdoc IACLManager - 55 : 51690 : function isPoolAdmin(address admin) external view override returns (bool) { - 56 : 155070 : return hasRole(POOL_ADMIN_ROLE, admin); + 55 : : function isPoolAdmin(address admin) external view override returns (bool) { + 56 : 140446 : return hasRole(POOL_ADMIN_ROLE, admin); 57 : : } 58 : : 59 : : /// @inheritdoc IACLManager - 60 : 608 : function addEmergencyAdmin(address admin) external override { - 61 : 1216 : grantRole(EMERGENCY_ADMIN_ROLE, admin); + 60 : : function addEmergencyAdmin(address admin) external override { + 61 : 683 : grantRole(EMERGENCY_ADMIN_ROLE, admin); 62 : : } 63 : : 64 : : /// @inheritdoc IACLManager - 65 : 1 : function removeEmergencyAdmin(address admin) external override { - 66 : 2 : revokeRole(EMERGENCY_ADMIN_ROLE, admin); + 65 : : function removeEmergencyAdmin(address admin) external override { + 66 : 1 : revokeRole(EMERGENCY_ADMIN_ROLE, admin); 67 : : } 68 : : 69 : : /// @inheritdoc IACLManager - 70 : 10004 : function isEmergencyAdmin(address admin) external view override returns (bool) { - 71 : 30012 : return hasRole(EMERGENCY_ADMIN_ROLE, admin); + 70 : : function isEmergencyAdmin(address admin) external view override returns (bool) { + 71 : 17013 : return hasRole(EMERGENCY_ADMIN_ROLE, admin); 72 : : } 73 : : 74 : : /// @inheritdoc IACLManager - 75 : 14 : function addRiskAdmin(address admin) external override { - 76 : 28 : grantRole(RISK_ADMIN_ROLE, admin); + 75 : : function addRiskAdmin(address admin) external override { + 76 : 14 : grantRole(RISK_ADMIN_ROLE, admin); 77 : : } 78 : : 79 : : /// @inheritdoc IACLManager - 80 : 1 : function removeRiskAdmin(address admin) external override { - 81 : 2 : revokeRole(RISK_ADMIN_ROLE, admin); + 80 : : function removeRiskAdmin(address admin) external override { + 81 : 1 : revokeRole(RISK_ADMIN_ROLE, admin); 82 : : } 83 : : 84 : : /// @inheritdoc IACLManager - 85 : 25336 : function isRiskAdmin(address admin) external view override returns (bool) { - 86 : 76008 : return hasRole(RISK_ADMIN_ROLE, admin); + 85 : : function isRiskAdmin(address admin) external view override returns (bool) { + 86 : 84695 : return hasRole(RISK_ADMIN_ROLE, admin); 87 : : } 88 : : 89 : : /// @inheritdoc IACLManager - 90 : 4 : function addFlashBorrower(address borrower) external override { - 91 : 8 : grantRole(FLASH_BORROWER_ROLE, borrower); + 90 : : function addFlashBorrower(address borrower) external override { + 91 : 4 : grantRole(FLASH_BORROWER_ROLE, borrower); 92 : : } 93 : : 94 : : /// @inheritdoc IACLManager - 95 : 2 : function removeFlashBorrower(address borrower) external override { - 96 : 4 : revokeRole(FLASH_BORROWER_ROLE, borrower); + 95 : : function removeFlashBorrower(address borrower) external override { + 96 : 2 : revokeRole(FLASH_BORROWER_ROLE, borrower); 97 : : } 98 : : 99 : : /// @inheritdoc IACLManager - 100 : 11 : function isFlashBorrower(address borrower) external view override returns (bool) { - 101 : 33 : return hasRole(FLASH_BORROWER_ROLE, borrower); + 100 : : function isFlashBorrower(address borrower) external view override returns (bool) { + 101 : 1012 : return hasRole(FLASH_BORROWER_ROLE, borrower); 102 : : } 103 : : 104 : : /// @inheritdoc IACLManager - 105 : 14 : function addBridge(address bridge) external override { - 106 : 28 : grantRole(BRIDGE_ROLE, bridge); + 105 : : function addBridge(address bridge) external override { + 106 : 14 : grantRole(BRIDGE_ROLE, bridge); 107 : : } 108 : : 109 : : /// @inheritdoc IACLManager - 110 : 1 : function removeBridge(address bridge) external override { - 111 : 2 : revokeRole(BRIDGE_ROLE, bridge); + 110 : : function removeBridge(address bridge) external override { + 111 : 1 : revokeRole(BRIDGE_ROLE, bridge); 112 : : } 113 : : 114 : : /// @inheritdoc IACLManager - 115 : 26 : function isBridge(address bridge) external view override returns (bool) { - 116 : 78 : return hasRole(BRIDGE_ROLE, bridge); + 115 : : function isBridge(address bridge) external view override returns (bool) { + 116 : 26 : return hasRole(BRIDGE_ROLE, bridge); 117 : : } 118 : : 119 : : /// @inheritdoc IACLManager - 120 : 3 : function addAssetListingAdmin(address admin) external override { - 121 : 6 : grantRole(ASSET_LISTING_ADMIN_ROLE, admin); + 120 : : function addAssetListingAdmin(address admin) external override { + 121 : 3 : grantRole(ASSET_LISTING_ADMIN_ROLE, admin); 122 : : } 123 : : 124 : : /// @inheritdoc IACLManager - 125 : 2 : function removeAssetListingAdmin(address admin) external override { - 126 : 4 : revokeRole(ASSET_LISTING_ADMIN_ROLE, admin); + 125 : : function removeAssetListingAdmin(address admin) external override { + 126 : 2 : revokeRole(ASSET_LISTING_ADMIN_ROLE, admin); 127 : : } 128 : : 129 : : /// @inheritdoc IACLManager - 130 : 3188 : function isAssetListingAdmin(address admin) external view override returns (bool) { - 131 : 9564 : return hasRole(ASSET_LISTING_ADMIN_ROLE, admin); + 130 : : function isAssetListingAdmin(address admin) external view override returns (bool) { + 131 : 10317 : return hasRole(ASSET_LISTING_ADMIN_ROLE, admin); 132 : : } 133 : : } @@ -209,8 +209,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func-c.html b/report/protocol/configuration/PoolAddressesProvider.sol.func-c.html similarity index 72% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func-c.html rename to report/protocol/configuration/PoolAddressesProvider.sol.func-c.html index bd71f553..04404e4a 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func-c.html +++ b/report/protocol/configuration/PoolAddressesProvider.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol - functions - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProvider.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,175 +53,182 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProvider.sol (source / functions)top level - protocol/configuration - PoolAddressesProvider.sol (source / functions) Coverage Lines: 100.0 %56565858
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %22222323
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + @@ -229,8 +236,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolAddressesProvider._setMarketIdPoolAddressesProvider.setMarketId12
PoolAddressesProvider.setMarketIdPoolAddressesProvider.getMarketId26
PoolAddressesProvider.setAddress56
PoolAddressesProvider.getMarketIdPoolAddressesProvider.setPriceOracleSentinel621
PoolAddressesProvider.setPriceOracleSentinelPoolAddressesProvider._setMarketId6446
PoolAddressesProvider.setACLManager609684
PoolAddressesProvider.setPoolConfiguratorImplPoolAddressesProvider.setAddressAsProxy609684
PoolAddressesProvider.setPoolDataProviderPoolAddressesProvider.setPoolConfiguratorImpl609684
PoolAddressesProvider.setPoolImplPoolAddressesProvider.setPoolDataProvider609684
PoolAddressesProvider.setPriceOraclePoolAddressesProvider.setPoolImpl609684
PoolAddressesProvider.setAddressAsProxyPoolAddressesProvider.setPriceOracle610684
PoolAddressesProvider.getAddress613688
PoolAddressesProvider.getACLAdminPoolAddressesProvider.6321116
PoolAddressesProvider.setACLAdmin12341384
PoolAddressesProvider.getPoolDataProviderPoolAddressesProvider.getACLAdmin17831711
PoolAddressesProvider._getProxyImplementation18242048
PoolAddressesProvider._updateImpl18242048
PoolAddressesProvider.getPriceOracleSentinelPoolAddressesProvider.getPoolDataProvider204153034
PoolAddressesProvider.getPoolPoolAddressesProvider.getPriceOracleSentinel2143330644
PoolAddressesProvider.getPriceOracle2476171014
PoolAddressesProvider.getACLManager46744119508
PoolAddressesProvider.getPool165196
PoolAddressesProvider.getPoolConfigurator106989649253
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func.html b/report/protocol/configuration/PoolAddressesProvider.sol.func.html similarity index 72% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func.html rename to report/protocol/configuration/PoolAddressesProvider.sol.func.html index 605822fa..a5f4ebac 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.func.html +++ b/report/protocol/configuration/PoolAddressesProvider.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol - functions - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProvider.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,63 +53,70 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProvider.sol (source / functions)top level - protocol/configuration - PoolAddressesProvider.sol (source / functions) Coverage Lines: 100.0 %56565858
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %22222323
0 0
- + - + + + + + + + + - + - + - + - + - + - + @@ -123,63 +130,63 @@ - + - + - + - + - + - + - + - + - + @@ -193,35 +200,35 @@ - + - + - + - + - + @@ -229,8 +236,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolAddressesProvider.1116
PoolAddressesProvider._getProxyImplementation18242048
PoolAddressesProvider._setMarketId1446
PoolAddressesProvider._updateImpl18242048
PoolAddressesProvider.getACLAdmin6321711
PoolAddressesProvider.getACLManager46744119508
PoolAddressesProvider.getAddress613688
PoolAddressesProvider.getPool21433165196
PoolAddressesProvider.getPoolConfigurator106989649253
PoolAddressesProvider.getPoolDataProvider17833034
PoolAddressesProvider.getPriceOracle2476171014
PoolAddressesProvider.getPriceOracleSentinel2041530644
PoolAddressesProvider.setACLAdmin12341384
PoolAddressesProvider.setACLManager609684
PoolAddressesProvider.setAddress56
PoolAddressesProvider.setAddressAsProxy610684
PoolAddressesProvider.setPoolConfiguratorImpl609684
PoolAddressesProvider.setPoolDataProvider609684
PoolAddressesProvider.setPoolImpl609684
PoolAddressesProvider.setPriceOracle609684
PoolAddressesProvider.setPriceOracleSentinel621
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.gcov.html b/report/protocol/configuration/PoolAddressesProvider.sol.gcov.html similarity index 75% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.gcov.html rename to report/protocol/configuration/PoolAddressesProvider.sol.gcov.html index 6cab0271..d8d491d9 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol.gcov.html +++ b/report/protocol/configuration/PoolAddressesProvider.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProvider.sol - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProvider.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProvider.sol (source / functions)top level - protocol/configuration - PoolAddressesProvider.sol (source / functions) Coverage Lines: 100.0 %56565858
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %22222323
0 0
@@ -74,7 +74,7 @@ 3 : : 4 : : import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; 5 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; - 6 : : import {InitializableImmutableAdminUpgradeabilityProxy} from '../libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; + 6 : : import {InitializableImmutableAdminUpgradeabilityProxy} from '../../misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; 7 : : 8 : : /** 9 : : * @title PoolAddressesProvider @@ -105,125 +105,125 @@ 34 : : * @param owner The owner address of this contract. 35 : : */ 36 : : constructor(string memory marketId, address owner) { - 37 : : _setMarketId(marketId); - 38 : : transferOwnership(owner); + 37 : 419 : _setMarketId(marketId); + 38 : 627 : transferOwnership(owner); 39 : : } 40 : : 41 : : /// @inheritdoc IPoolAddressesProvider - 42 : 6 : function getMarketId() external view override returns (string memory) { - 43 : 12 : return _marketId; + 42 : : function getMarketId() external view override returns (string memory) { + 43 : 6 : return _marketId; 44 : : } 45 : : 46 : : /// @inheritdoc IPoolAddressesProvider - 47 : 2 : function setMarketId(string memory newMarketId) external override onlyOwner { - 48 : 2 : _setMarketId(newMarketId); + 47 : : function setMarketId(string memory newMarketId) external override onlyOwner { + 48 : 1 : _setMarketId(newMarketId); 49 : : } 50 : : 51 : : /// @inheritdoc IPoolAddressesProvider - 52 : 613 : function getAddress(bytes32 id) public view override returns (address) { - 53 : 446740 : return _addresses[id]; + 52 : : function getAddress(bytes32 id) public view override returns (address) { + 53 : 1041048 : return _addresses[id]; 54 : : } 55 : : 56 : : /// @inheritdoc IPoolAddressesProvider - 57 : 5 : function setAddress(bytes32 id, address newAddress) external override onlyOwner { - 58 : 6 : address oldAddress = _addresses[id]; - 59 : 6 : _addresses[id] = newAddress; - 60 : 6 : emit AddressSet(id, oldAddress, newAddress); + 57 : : function setAddress(bytes32 id, address newAddress) external override onlyOwner { + 58 : 4 : address oldAddress = _addresses[id]; + 59 : 4 : _addresses[id] = newAddress; + 60 : 4 : emit AddressSet(id, oldAddress, newAddress); 61 : : } 62 : : 63 : : /// @inheritdoc IPoolAddressesProvider - 64 : 610 : function setAddressAsProxy( + 64 : : function setAddressAsProxy( 65 : : bytes32 id, 66 : : address newImplementationAddress 67 : : ) external override onlyOwner { - 68 : 1216 : address proxyAddress = _addresses[id]; - 69 : 1824 : address oldImplementationAddress = _getProxyImplementation(id); - 70 : 1216 : _updateImpl(id, newImplementationAddress); - 71 : 1216 : emit AddressSetAsProxy(id, proxyAddress, oldImplementationAddress, newImplementationAddress); + 68 : 682 : address proxyAddress = _addresses[id]; + 69 : 682 : address oldImplementationAddress = _getProxyImplementation(id); + 70 : 682 : _updateImpl(id, newImplementationAddress); + 71 : 682 : emit AddressSetAsProxy(id, proxyAddress, oldImplementationAddress, newImplementationAddress); 72 : : } 73 : : 74 : : /// @inheritdoc IPoolAddressesProvider - 75 : 21433 : function getPool() external view override returns (address) { - 76 : 64299 : return getAddress(POOL); + 75 : : function getPool() external view override returns (address) { + 76 : 165196 : return getAddress(POOL); 77 : : } 78 : : 79 : : /// @inheritdoc IPoolAddressesProvider - 80 : 609 : function setPoolImpl(address newPoolImpl) external override onlyOwner { - 81 : 1824 : address oldPoolImpl = _getProxyImplementation(POOL); - 82 : 1216 : _updateImpl(POOL, newPoolImpl); - 83 : 1216 : emit PoolUpdated(oldPoolImpl, newPoolImpl); + 80 : : function setPoolImpl(address newPoolImpl) external override onlyOwner { + 81 : 683 : address oldPoolImpl = _getProxyImplementation(POOL); + 82 : 683 : _updateImpl(POOL, newPoolImpl); + 83 : 683 : emit PoolUpdated(oldPoolImpl, newPoolImpl); 84 : : } 85 : : 86 : : /// @inheritdoc IPoolAddressesProvider - 87 : 106989 : function getPoolConfigurator() external view override returns (address) { - 88 : 320967 : return getAddress(POOL_CONFIGURATOR); + 87 : : function getPoolConfigurator() external view override returns (address) { + 88 : 649253 : return getAddress(POOL_CONFIGURATOR); 89 : : } 90 : : 91 : : /// @inheritdoc IPoolAddressesProvider - 92 : 609 : function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external override onlyOwner { - 93 : 1824 : address oldPoolConfiguratorImpl = _getProxyImplementation(POOL_CONFIGURATOR); - 94 : 1216 : _updateImpl(POOL_CONFIGURATOR, newPoolConfiguratorImpl); - 95 : 1216 : emit PoolConfiguratorUpdated(oldPoolConfiguratorImpl, newPoolConfiguratorImpl); + 92 : : function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external override onlyOwner { + 93 : 683 : address oldPoolConfiguratorImpl = _getProxyImplementation(POOL_CONFIGURATOR); + 94 : 683 : _updateImpl(POOL_CONFIGURATOR, newPoolConfiguratorImpl); + 95 : 683 : emit PoolConfiguratorUpdated(oldPoolConfiguratorImpl, newPoolConfiguratorImpl); 96 : : } 97 : : 98 : : /// @inheritdoc IPoolAddressesProvider - 99 : 24761 : function getPriceOracle() external view override returns (address) { - 100 : 74283 : return getAddress(PRICE_ORACLE); + 99 : : function getPriceOracle() external view override returns (address) { + 100 : 71014 : return getAddress(PRICE_ORACLE); 101 : : } 102 : : 103 : : /// @inheritdoc IPoolAddressesProvider - 104 : 609 : function setPriceOracle(address newPriceOracle) external override onlyOwner { - 105 : 1216 : address oldPriceOracle = _addresses[PRICE_ORACLE]; - 106 : 1216 : _addresses[PRICE_ORACLE] = newPriceOracle; - 107 : 1216 : emit PriceOracleUpdated(oldPriceOracle, newPriceOracle); + 104 : : function setPriceOracle(address newPriceOracle) external override onlyOwner { + 105 : 683 : address oldPriceOracle = _addresses[PRICE_ORACLE]; + 106 : 683 : _addresses[PRICE_ORACLE] = newPriceOracle; + 107 : 683 : emit PriceOracleUpdated(oldPriceOracle, newPriceOracle); 108 : : } 109 : : 110 : : /// @inheritdoc IPoolAddressesProvider - 111 : 46744 : function getACLManager() external view override returns (address) { - 112 : 140232 : return getAddress(ACL_MANAGER); + 111 : : function getACLManager() external view override returns (address) { + 112 : 119508 : return getAddress(ACL_MANAGER); 113 : : } 114 : : 115 : : /// @inheritdoc IPoolAddressesProvider - 116 : 609 : function setACLManager(address newAclManager) external override onlyOwner { - 117 : 1216 : address oldAclManager = _addresses[ACL_MANAGER]; - 118 : 1216 : _addresses[ACL_MANAGER] = newAclManager; - 119 : 1216 : emit ACLManagerUpdated(oldAclManager, newAclManager); + 116 : : function setACLManager(address newAclManager) external override onlyOwner { + 117 : 683 : address oldAclManager = _addresses[ACL_MANAGER]; + 118 : 683 : _addresses[ACL_MANAGER] = newAclManager; + 119 : 683 : emit ACLManagerUpdated(oldAclManager, newAclManager); 120 : : } 121 : : 122 : : /// @inheritdoc IPoolAddressesProvider - 123 : 632 : function getACLAdmin() external view override returns (address) { - 124 : 1896 : return getAddress(ACL_ADMIN); + 123 : : function getACLAdmin() external view override returns (address) { + 124 : 1711 : return getAddress(ACL_ADMIN); 125 : : } 126 : : 127 : : /// @inheritdoc IPoolAddressesProvider - 128 : 1234 : function setACLAdmin(address newAclAdmin) external override onlyOwner { - 129 : 2466 : address oldAclAdmin = _addresses[ACL_ADMIN]; - 130 : 2466 : _addresses[ACL_ADMIN] = newAclAdmin; - 131 : 2466 : emit ACLAdminUpdated(oldAclAdmin, newAclAdmin); + 128 : : function setACLAdmin(address newAclAdmin) external override onlyOwner { + 129 : 1383 : address oldAclAdmin = _addresses[ACL_ADMIN]; + 130 : 1383 : _addresses[ACL_ADMIN] = newAclAdmin; + 131 : 1383 : emit ACLAdminUpdated(oldAclAdmin, newAclAdmin); 132 : : } 133 : : 134 : : /// @inheritdoc IPoolAddressesProvider - 135 : 20415 : function getPriceOracleSentinel() external view override returns (address) { - 136 : 61245 : return getAddress(PRICE_ORACLE_SENTINEL); + 135 : : function getPriceOracleSentinel() external view override returns (address) { + 136 : 30644 : return getAddress(PRICE_ORACLE_SENTINEL); 137 : : } 138 : : 139 : : /// @inheritdoc IPoolAddressesProvider - 140 : 6 : function setPriceOracleSentinel(address newPriceOracleSentinel) external override onlyOwner { - 141 : 10 : address oldPriceOracleSentinel = _addresses[PRICE_ORACLE_SENTINEL]; - 142 : 10 : _addresses[PRICE_ORACLE_SENTINEL] = newPriceOracleSentinel; - 143 : 10 : emit PriceOracleSentinelUpdated(oldPriceOracleSentinel, newPriceOracleSentinel); + 140 : : function setPriceOracleSentinel(address newPriceOracleSentinel) external override onlyOwner { + 141 : 20 : address oldPriceOracleSentinel = _addresses[PRICE_ORACLE_SENTINEL]; + 142 : 20 : _addresses[PRICE_ORACLE_SENTINEL] = newPriceOracleSentinel; + 143 : 20 : emit PriceOracleSentinelUpdated(oldPriceOracleSentinel, newPriceOracleSentinel); 144 : : } 145 : : 146 : : /// @inheritdoc IPoolAddressesProvider - 147 : 1783 : function getPoolDataProvider() external view override returns (address) { - 148 : 5349 : return getAddress(DATA_PROVIDER); + 147 : : function getPoolDataProvider() external view override returns (address) { + 148 : 3034 : return getAddress(DATA_PROVIDER); 149 : : } 150 : : 151 : : /// @inheritdoc IPoolAddressesProvider - 152 : 609 : function setPoolDataProvider(address newDataProvider) external override onlyOwner { - 153 : 1216 : address oldDataProvider = _addresses[DATA_PROVIDER]; - 154 : 1216 : _addresses[DATA_PROVIDER] = newDataProvider; - 155 : 1216 : emit PoolDataProviderUpdated(oldDataProvider, newDataProvider); + 152 : : function setPoolDataProvider(address newDataProvider) external override onlyOwner { + 153 : 683 : address oldDataProvider = _addresses[DATA_PROVIDER]; + 154 : 683 : _addresses[DATA_PROVIDER] = newDataProvider; + 155 : 683 : emit PoolDataProviderUpdated(oldDataProvider, newDataProvider); 156 : : } 157 : : 158 : : /** @@ -235,19 +235,19 @@ 164 : : * @param id The id of the proxy to be updated 165 : : * @param newAddress The address of the new implementation 166 : : */ - 167 : 1824 : function _updateImpl(bytes32 id, address newAddress) internal { - 168 : 3648 : address proxyAddress = _addresses[id]; - 169 : 3648 : InitializableImmutableAdminUpgradeabilityProxy proxy; - 170 : 5472 : bytes memory params = abi.encodeWithSignature('initialize(address)', address(this)); + 167 : : function _updateImpl(bytes32 id, address newAddress) internal { + 168 : 2048 : address proxyAddress = _addresses[id]; + 169 : 2048 : InitializableImmutableAdminUpgradeabilityProxy proxy; + 170 : 2048 : bytes memory params = abi.encodeWithSignature('initialize(address)', address(this)); 171 : : - 172 : 5472 : if (proxyAddress == address(0)) { - 173 : 3642 : proxy = new InitializableImmutableAdminUpgradeabilityProxy(address(this)); - 174 : 3642 : _addresses[id] = proxyAddress = address(proxy); - 175 : 3642 : proxy.initialize(newAddress, params); - 176 : 3642 : emit ProxyCreated(id, proxyAddress, newAddress); + 172 : 2048 : if (proxyAddress == address(0)) { + 173 : 2045 : proxy = new InitializableImmutableAdminUpgradeabilityProxy(address(this)); + 174 : 2045 : _addresses[id] = proxyAddress = address(proxy); + 175 : 2045 : proxy.initialize(newAddress, params); + 176 : 2045 : emit ProxyCreated(id, proxyAddress, newAddress); 177 : : } else { - 178 : 6 : proxy = InitializableImmutableAdminUpgradeabilityProxy(payable(proxyAddress)); - 179 : 6 : proxy.upgradeToAndCall(newAddress, params); + 178 : 3 : proxy = InitializableImmutableAdminUpgradeabilityProxy(payable(proxyAddress)); + 179 : 3 : proxy.upgradeToAndCall(newAddress, params); 180 : : } 181 : : } 182 : : @@ -255,10 +255,10 @@ 184 : : * @notice Updates the identifier of the Aave market. 185 : : * @param newMarketId The new id of the market 186 : : */ - 187 : 1 : function _setMarketId(string memory newMarketId) internal { - 188 : 2 : string memory oldMarketId = _marketId; - 189 : 2 : _marketId = newMarketId; - 190 : 2 : emit MarketIdSet(oldMarketId, newMarketId); + 187 : : function _setMarketId(string memory newMarketId) internal { + 188 : 380 : string memory oldMarketId = _marketId; + 189 : 377 : _marketId = newMarketId; + 190 : 265 : emit MarketIdSet(oldMarketId, newMarketId); 191 : : } 192 : : 193 : : /** @@ -268,13 +268,13 @@ 197 : : * @param id The id 198 : : * @return The address of the implementation contract 199 : : */ - 200 : 1824 : function _getProxyImplementation(bytes32 id) internal returns (address) { - 201 : 3648 : address proxyAddress = _addresses[id]; - 202 : 5472 : if (proxyAddress == address(0)) { - 203 : 5463 : return address(0); + 200 : : function _getProxyImplementation(bytes32 id) internal returns (address) { + 201 : 2048 : address proxyAddress = _addresses[id]; + 202 : 2048 : if (proxyAddress == address(0)) { + 203 : 2045 : return address(0); 204 : : } else { - 205 : 9 : address payable payableProxyAddress = payable(proxyAddress); - 206 : 9 : return InitializableImmutableAdminUpgradeabilityProxy(payableProxyAddress).implementation(); + 205 : 3 : address payable payableProxyAddress = payable(proxyAddress); + 206 : 3 : return InitializableImmutableAdminUpgradeabilityProxy(payableProxyAddress).implementation(); 207 : : } 208 : : } 209 : : } @@ -285,8 +285,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html similarity index 69% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html rename to report/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html index 699162a0..053a501b 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html +++ b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol - functions - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProviderRegistry.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions)top level - protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions) Coveragelcov.info.p Lines:100.0 %2696.3 %27 26
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %787.5 %8 7
0 0
- + + + + + + + + - + @@ -109,14 +116,14 @@ - + - + @@ -124,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
PoolAddressesProviderRegistry.Hit count Sort by function hit count0
PoolAddressesProviderRegistry._addToAddressesProvidersList628710
PoolAddressesProviderRegistry.registerAddressesProvider629711
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html similarity index 69% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html rename to report/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html index f7e1688d..c2a87e04 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html +++ b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol - functions - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProviderRegistry.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,28 +53,35 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions)top level - protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions) Coveragelcov.info.p Lines:100.0 %2696.3 %27 26
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %787.5 %8 7
0 0
- + + + + + + + + - + - + @@ -109,7 +116,7 @@ - + @@ -124,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
PoolAddressesProviderRegistry.Hit count Sort by function hit count0
PoolAddressesProviderRegistry._addToAddressesProvidersList628710
PoolAddressesProviderRegistry.registerAddressesProvider629711
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html similarity index 77% rename from report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html rename to report/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html index 2addb373..acb39b7e 100644 --- a/report/core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html +++ b/report/protocol/configuration/PoolAddressesProviderRegistry.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration/PoolAddressesProviderRegistry.sol - + LCOV - lcov.info.p - protocol/configuration/PoolAddressesProviderRegistry.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/configuration/src/core/contracts/protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions)top level - protocol/configuration - PoolAddressesProviderRegistry.sol (source / functions) Coveragelcov.info.p Lines:100.0 %2696.3 %27 26
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %787.5 %8 7
0 0
@@ -98,77 +98,77 @@ 27 : : * @param owner The owner address of this contract. 28 : : */ 29 : : constructor(address owner) { - 30 : : transferOwnership(owner); + 30 : 0 : transferOwnership(owner); 31 : : } 32 : : 33 : : /// @inheritdoc IPoolAddressesProviderRegistry - 34 : 5 : function getAddressesProvidersList() external view override returns (address[] memory) { - 35 : 10 : return _addressesProvidersList; + 34 : : function getAddressesProvidersList() external view override returns (address[] memory) { + 35 : 5 : return _addressesProvidersList; 36 : : } 37 : : 38 : : /// @inheritdoc IPoolAddressesProviderRegistry - 39 : 629 : function registerAddressesProvider(address provider, uint256 id) external override onlyOwner { - 40 : 1258 : require(id != 0, Errors.INVALID_ADDRESSES_PROVIDER_ID); - 41 : 1256 : require(_idToAddressesProvider[id] == address(0), Errors.INVALID_ADDRESSES_PROVIDER_ID); - 42 : 1256 : require(_addressesProviderToId[provider] == 0, Errors.ADDRESSES_PROVIDER_ALREADY_ADDED); + 39 : : function registerAddressesProvider(address provider, uint256 id) external override onlyOwner { + 40 : 711 : require(id != 0, Errors.INVALID_ADDRESSES_PROVIDER_ID); + 41 : 710 : require(_idToAddressesProvider[id] == address(0), Errors.INVALID_ADDRESSES_PROVIDER_ID); + 42 : 710 : require(_addressesProviderToId[provider] == 0, Errors.ADDRESSES_PROVIDER_ALREADY_ADDED); 43 : : - 44 : 1256 : _addressesProviderToId[provider] = id; - 45 : 1256 : _idToAddressesProvider[id] = provider; + 44 : 710 : _addressesProviderToId[provider] = id; + 45 : 710 : _idToAddressesProvider[id] = provider; 46 : : - 47 : 1256 : _addToAddressesProvidersList(provider); - 48 : 1256 : emit AddressesProviderRegistered(provider, id); + 47 : 710 : _addToAddressesProvidersList(provider); + 48 : 710 : emit AddressesProviderRegistered(provider, id); 49 : : } 50 : : 51 : : /// @inheritdoc IPoolAddressesProviderRegistry - 52 : 4 : function unregisterAddressesProvider(address provider) external override onlyOwner { - 53 : 8 : require(_addressesProviderToId[provider] != 0, Errors.ADDRESSES_PROVIDER_NOT_REGISTERED); - 54 : 6 : uint256 oldId = _addressesProviderToId[provider]; - 55 : 6 : _idToAddressesProvider[oldId] = address(0); - 56 : 6 : _addressesProviderToId[provider] = 0; + 52 : : function unregisterAddressesProvider(address provider) external override onlyOwner { + 53 : 4 : require(_addressesProviderToId[provider] != 0, Errors.ADDRESSES_PROVIDER_NOT_REGISTERED); + 54 : 3 : uint256 oldId = _addressesProviderToId[provider]; + 55 : 3 : _idToAddressesProvider[oldId] = address(0); + 56 : 3 : _addressesProviderToId[provider] = 0; 57 : : - 58 : 6 : _removeFromAddressesProvidersList(provider); + 58 : 3 : _removeFromAddressesProvidersList(provider); 59 : : - 60 : 6 : emit AddressesProviderUnregistered(provider, oldId); + 60 : 3 : emit AddressesProviderUnregistered(provider, oldId); 61 : : } 62 : : 63 : : /// @inheritdoc IPoolAddressesProviderRegistry - 64 : 6 : function getAddressesProviderIdByAddress( + 64 : : function getAddressesProviderIdByAddress( 65 : : address addressesProvider 66 : : ) external view override returns (uint256) { - 67 : 12 : return _addressesProviderToId[addressesProvider]; + 67 : 6 : return _addressesProviderToId[addressesProvider]; 68 : : } 69 : : 70 : : /// @inheritdoc IPoolAddressesProviderRegistry - 71 : 4 : function getAddressesProviderAddressById(uint256 id) external view override returns (address) { - 72 : 8 : return _idToAddressesProvider[id]; + 71 : : function getAddressesProviderAddressById(uint256 id) external view override returns (address) { + 72 : 4 : return _idToAddressesProvider[id]; 73 : : } 74 : : 75 : : /** 76 : : * @notice Adds the addresses provider address to the list. 77 : : * @param provider The address of the PoolAddressesProvider 78 : : */ - 79 : 628 : function _addToAddressesProvidersList(address provider) internal { - 80 : 1256 : _addressesProvidersIndexes[provider] = _addressesProvidersList.length; - 81 : 1256 : _addressesProvidersList.push(provider); + 79 : : function _addToAddressesProvidersList(address provider) internal { + 80 : 710 : _addressesProvidersIndexes[provider] = _addressesProvidersList.length; + 81 : 710 : _addressesProvidersList.push(provider); 82 : : } 83 : : 84 : : /** 85 : : * @notice Removes the addresses provider address from the list. 86 : : * @param provider The address of the PoolAddressesProvider 87 : : */ - 88 : 3 : function _removeFromAddressesProvidersList(address provider) internal { - 89 : 6 : uint256 index = _addressesProvidersIndexes[provider]; + 88 : : function _removeFromAddressesProvidersList(address provider) internal { + 89 : 3 : uint256 index = _addressesProvidersIndexes[provider]; 90 : : - 91 : 6 : _addressesProvidersIndexes[provider] = 0; + 91 : 3 : _addressesProvidersIndexes[provider] = 0; 92 : : 93 : : // Swap the index of the last addresses provider in the list with the index of the provider to remove - 94 : 9 : uint256 lastIndex = _addressesProvidersList.length - 1; - 95 : 6 : if (index < lastIndex) { - 96 : 2 : address lastProvider = _addressesProvidersList[lastIndex]; - 97 : 2 : _addressesProvidersList[index] = lastProvider; - 98 : 2 : _addressesProvidersIndexes[lastProvider] = index; + 94 : 3 : uint256 lastIndex = _addressesProvidersList.length - 1; + 95 : 3 : if (index < lastIndex) { + 96 : 1 : address lastProvider = _addressesProvidersList[lastIndex]; + 97 : 1 : _addressesProvidersList[index] = lastProvider; + 98 : 1 : _addressesProvidersIndexes[lastProvider] = index; 99 : : } - 100 : 6 : _addressesProvidersList.pop(); + 100 : 3 : _addressesProvidersList.pop(); 101 : : } 102 : : } @@ -178,8 +178,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-b.html b/report/protocol/configuration/index-sort-b.html similarity index 53% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-b.html rename to report/protocol/configuration/index-sort-b.html index ab2df64c..984082d6 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-b.html +++ b/report/protocol/configuration/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - + LCOV - lcov.info.p - protocol/configuration + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenizationtop level - protocol/configuration Coveragelcov.info.p Lines:90.5 %746795.4 %108103
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %474796.1 %5149
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - AToken.sol + ACLManager.sol -
100.0%
+
82.6%82.6%
- 100.0 % - 37 - 37 + 82.6 % + 23 + 19 - - 100.0 % - 16 - 16 + 95.0 % + 20 + 19 - StableDebtToken.sol + PoolAddressesProvider.sol -
63.2%63.2%
+
100.0%
- 63.2 % - 19 - 12 + 100.0 % + 58 + 58 - 100.0 % - 19 - 19 + 23 + 23 - VariableDebtToken.sol + PoolAddressesProviderRegistry.sol -
100.0%
+
96.3%96.3%
- 100.0 % - 18 - 18 + 96.3 % + 27 + 26 - - 100.0 % - 12 - 12 + 87.5 % + 8 + 7

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-f.html b/report/protocol/configuration/index-sort-f.html similarity index 53% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-f.html rename to report/protocol/configuration/index-sort-f.html index 292c8f20..3a7ac3a3 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-f.html +++ b/report/protocol/configuration/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - + LCOV - lcov.info.p - protocol/configuration + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenizationtop level - protocol/configuration Coveragelcov.info.p Lines:90.5 %746795.4 %108103
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %474796.1 %5149
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - VariableDebtToken.sol + PoolAddressesProviderRegistry.sol -
100.0%
+
96.3%96.3%
- 100.0 % - 18 - 18 + 96.3 % + 27 + 26 - - 100.0 % - 12 - 12 + 87.5 % + 8 + 7 - AToken.sol + ACLManager.sol -
100.0%
+
82.6%82.6%
- 100.0 % - 37 - 37 + 82.6 % + 23 + 19 - - 100.0 % - 16 - 16 + 95.0 % + 20 + 19 - StableDebtToken.sol + PoolAddressesProvider.sol -
63.2%63.2%
+
100.0%
- 63.2 % - 19 - 12 + 100.0 % + 58 + 58 - 100.0 % - 19 - 19 + 23 + 23

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-l.html b/report/protocol/configuration/index-sort-l.html similarity index 53% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-l.html rename to report/protocol/configuration/index-sort-l.html index 8e982fdb..af67b94b 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index-sort-l.html +++ b/report/protocol/configuration/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - + LCOV - lcov.info.p - protocol/configuration + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenizationtop level - protocol/configuration Coveragelcov.info.p Lines:90.5 %746795.4 %108103
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %474796.1 %5149
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - StableDebtToken.sol + ACLManager.sol -
63.2%63.2%
+
82.6%82.6%
- 63.2 % + 82.6 % + 23 19 - 12 - - 100.0 % - 19 + 95.0 % + 20 19 - VariableDebtToken.sol + PoolAddressesProviderRegistry.sol -
100.0%
+
96.3%96.3%
- 100.0 % - 18 - 18 + 96.3 % + 27 + 26 - - 100.0 % - 12 - 12 + 87.5 % + 8 + 7 - AToken.sol + PoolAddressesProvider.sol -
100.0%
+
100.0%
100.0 % - 37 - 37 + 58 + 58 - 100.0 % - 16 - 16 + 23 + 23

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index.html b/report/protocol/configuration/index.html similarity index 53% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index.html rename to report/protocol/configuration/index.html index 8353c61b..7c2000b3 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/index.html +++ b/report/protocol/configuration/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - + LCOV - lcov.info.p - protocol/configuration + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenizationtop level - protocol/configuration Coveragelcov.info.p Lines:90.5 %746795.4 %108103
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %474796.1 %5149
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - AToken.sol + ACLManager.sol -
100.0%
+
82.6%82.6%
- 100.0 % - 37 - 37 + 82.6 % + 23 + 19 - - 100.0 % - 16 - 16 + 95.0 % + 20 + 19 - StableDebtToken.sol + PoolAddressesProvider.sol -
63.2%63.2%
+
100.0%
- 63.2 % - 19 - 12 + 100.0 % + 58 + 58 - 100.0 % - 19 - 19 + 23 + 23 - VariableDebtToken.sol + PoolAddressesProviderRegistry.sol -
100.0%
+
96.3%96.3%
- 100.0 % - 18 - 18 + 96.3 % + 27 + 26 - - 100.0 % - 12 - 12 + 87.5 % + 8 + 7

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/protocol/libraries/logic/BorrowLogic.sol.func-c.html b/report/protocol/libraries/logic/BorrowLogic.sol.func-c.html new file mode 100644 index 00000000..84a67cc3 --- /dev/null +++ b/report/protocol/libraries/logic/BorrowLogic.sol.func-c.html @@ -0,0 +1,98 @@ + + + + + + + LCOV - lcov.info.p - protocol/libraries/logic/BorrowLogic.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/libraries/logic - BorrowLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %4141
Test Date:2024-09-24 09:34:24Functions:100.0 %22
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
BorrowLogic.executeRepay5030
BorrowLogic.executeBorrow16110
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/protocol/libraries/logic/BorrowLogic.sol.func.html b/report/protocol/libraries/logic/BorrowLogic.sol.func.html new file mode 100644 index 00000000..bb80c94e --- /dev/null +++ b/report/protocol/libraries/logic/BorrowLogic.sol.func.html @@ -0,0 +1,98 @@ + + + + + + + LCOV - lcov.info.p - protocol/libraries/logic/BorrowLogic.sol - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/libraries/logic - BorrowLogic.sol (source / functions)CoverageTotalHit
Test:lcov.info.pLines:100.0 %4141
Test Date:2024-09-24 09:34:24Functions:100.0 %22
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by function hit count
BorrowLogic.executeBorrow16110
BorrowLogic.executeRepay5030
+
+
+ + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.gcov.html b/report/protocol/libraries/logic/BorrowLogic.sol.gcov.html similarity index 56% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.gcov.html rename to report/protocol/libraries/logic/BorrowLogic.sol.gcov.html index dc79b92f..ef740d79 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/BorrowLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BorrowLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/BorrowLogic.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BorrowLogic.sol (source / functions)top level - protocol/libraries/logic - BorrowLogic.sol (source / functions) Coveragelcov.info.p Lines:88.1 %6759100.0 %4141
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %4422
0 0
@@ -75,357 +75,234 @@ 4 : : import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; 5 : : import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol'; 6 : : import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; - 7 : : import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; - 8 : : import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; - 9 : : import {IAToken} from '../../../interfaces/IAToken.sol'; - 10 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; - 11 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; - 12 : : import {Helpers} from '../helpers/Helpers.sol'; - 13 : : import {DataTypes} from '../types/DataTypes.sol'; - 14 : : import {ValidationLogic} from './ValidationLogic.sol'; - 15 : : import {ReserveLogic} from './ReserveLogic.sol'; - 16 : : import {IsolationModeLogic} from './IsolationModeLogic.sol'; - 17 : : - 18 : : /** - 19 : : * @title BorrowLogic library - 20 : : * @author Aave - 21 : : * @notice Implements the base logic for all the actions related to borrowing - 22 : : */ - 23 : : library BorrowLogic { - 24 : : using ReserveLogic for DataTypes.ReserveCache; - 25 : : using ReserveLogic for DataTypes.ReserveData; - 26 : : using GPv2SafeERC20 for IERC20; - 27 : : using UserConfiguration for DataTypes.UserConfigurationMap; - 28 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 29 : : using SafeCast for uint256; - 30 : : - 31 : : // See `IPool` for descriptions - 32 : : event Borrow( - 33 : : address indexed reserve, - 34 : : address user, - 35 : : address indexed onBehalfOf, - 36 : : uint256 amount, - 37 : : DataTypes.InterestRateMode interestRateMode, - 38 : : uint256 borrowRate, - 39 : : uint16 indexed referralCode - 40 : : ); - 41 : : event Repay( - 42 : : address indexed reserve, - 43 : : address indexed user, - 44 : : address indexed repayer, - 45 : : uint256 amount, - 46 : : bool useATokens - 47 : : ); - 48 : : event RebalanceStableBorrowRate(address indexed reserve, address indexed user); - 49 : : event SwapBorrowRateMode( - 50 : : address indexed reserve, - 51 : : address indexed user, - 52 : : DataTypes.InterestRateMode interestRateMode - 53 : : ); - 54 : : event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); - 55 : : event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); - 56 : : - 57 : : /** - 58 : : * @notice Implements the borrow feature. Borrowing allows users that provided collateral to draw liquidity from the - 59 : : * Aave protocol proportionally to their collateralization power. For isolated positions, it also increases the - 60 : : * isolated debt. - 61 : : * @dev Emits the `Borrow()` event - 62 : : * @param reservesData The state of all the reserves - 63 : : * @param reservesList The addresses of all the active reserves - 64 : : * @param eModeCategories The configuration of all the efficiency mode categories - 65 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - 66 : : * @param params The additional parameters needed to execute the borrow function - 67 : : */ - 68 : 9117 : function executeBorrow( - 69 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 70 : : mapping(uint256 => address) storage reservesList, - 71 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 72 : : DataTypes.UserConfigurationMap storage userConfig, - 73 : : DataTypes.ExecuteBorrowParams memory params - 74 : : ) public { - 75 : 18234 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; - 76 : 27351 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 7 : : import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; + 8 : : import {IAToken} from '../../../interfaces/IAToken.sol'; + 9 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; + 10 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; + 11 : : import {DataTypes} from '../types/DataTypes.sol'; + 12 : : import {ValidationLogic} from './ValidationLogic.sol'; + 13 : : import {ReserveLogic} from './ReserveLogic.sol'; + 14 : : import {IsolationModeLogic} from './IsolationModeLogic.sol'; + 15 : : + 16 : : /** + 17 : : * @title BorrowLogic library + 18 : : * @author Aave + 19 : : * @notice Implements the base logic for all the actions related to borrowing + 20 : : */ + 21 : : library BorrowLogic { + 22 : : using ReserveLogic for DataTypes.ReserveCache; + 23 : : using ReserveLogic for DataTypes.ReserveData; + 24 : : using GPv2SafeERC20 for IERC20; + 25 : : using UserConfiguration for DataTypes.UserConfigurationMap; + 26 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 27 : : using SafeCast for uint256; + 28 : : + 29 : : // See `IPool` for descriptions + 30 : : event Borrow( + 31 : : address indexed reserve, + 32 : : address user, + 33 : : address indexed onBehalfOf, + 34 : : uint256 amount, + 35 : : DataTypes.InterestRateMode interestRateMode, + 36 : : uint256 borrowRate, + 37 : : uint16 indexed referralCode + 38 : : ); + 39 : : event Repay( + 40 : : address indexed reserve, + 41 : : address indexed user, + 42 : : address indexed repayer, + 43 : : uint256 amount, + 44 : : bool useATokens + 45 : : ); + 46 : : event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); + 47 : : event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); + 48 : : + 49 : : /** + 50 : : * @notice Implements the borrow feature. Borrowing allows users that provided collateral to draw liquidity from the + 51 : : * Aave protocol proportionally to their collateralization power. For isolated positions, it also increases the + 52 : : * isolated debt. + 53 : : * @dev Emits the `Borrow()` event + 54 : : * @param reservesData The state of all the reserves + 55 : : * @param reservesList The addresses of all the active reserves + 56 : : * @param eModeCategories The configuration of all the efficiency mode categories + 57 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets + 58 : : * @param params The additional parameters needed to execute the borrow function + 59 : : */ + 60 : : function executeBorrow( + 61 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 62 : : mapping(uint256 => address) storage reservesList, + 63 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 64 : : DataTypes.UserConfigurationMap storage userConfig, + 65 : : DataTypes.ExecuteBorrowParams memory params + 66 : : ) external { + 67 : 16110 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; + 68 : 16110 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 69 : : + 70 : 16110 : reserve.updateState(reserveCache); + 71 : : + 72 : 16110 : ( + 73 : : bool isolationModeActive, + 74 : : address isolationModeCollateralAddress, + 75 : : uint256 isolationModeDebtCeiling + 76 : 16110 : ) = userConfig.getIsolationModeState(reservesData, reservesList); 77 : : - 78 : 18234 : reserve.updateState(reserveCache); - 79 : : - 80 : 18234 : ( - 81 : : bool isolationModeActive, - 82 : : address isolationModeCollateralAddress, - 83 : : uint256 isolationModeDebtCeiling - 84 : 18234 : ) = userConfig.getIsolationModeState(reservesData, reservesList); - 85 : : - 86 : 18234 : ValidationLogic.validateBorrow( - 87 : : reservesData, - 88 : : reservesList, - 89 : : eModeCategories, - 90 : : DataTypes.ValidateBorrowParams({ - 91 : : reserveCache: reserveCache, - 92 : : userConfig: userConfig, - 93 : : asset: params.asset, - 94 : : userAddress: params.onBehalfOf, - 95 : : amount: params.amount, - 96 : : interestRateMode: params.interestRateMode, - 97 : : maxStableLoanPercent: params.maxStableRateBorrowSizePercent, - 98 : : reservesCount: params.reservesCount, - 99 : : oracle: params.oracle, - 100 : : userEModeCategory: params.userEModeCategory, - 101 : : priceOracleSentinel: params.priceOracleSentinel, - 102 : : isolationModeActive: isolationModeActive, - 103 : : isolationModeCollateralAddress: isolationModeCollateralAddress, - 104 : : isolationModeDebtCeiling: isolationModeDebtCeiling - 105 : : }) - 106 : : ); - 107 : : - 108 : 18192 : uint256 currentStableRate = 0; - 109 : 18192 : bool isFirstBorrowing = false; - 110 : : - 111 : 18192 : if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - 112 : 2 : currentStableRate = reserve.currentStableBorrowRate; - 113 : : - 114 : 2 : ( - 115 : : isFirstBorrowing, - 116 : : reserveCache.nextTotalStableDebt, - 117 : : reserveCache.nextAvgStableBorrowRate - 118 : : ) = IStableDebtToken(reserveCache.stableDebtTokenAddress).mint( - 119 : : params.user, - 120 : : params.onBehalfOf, - 121 : : params.amount, - 122 : : currentStableRate - 123 : : ); - 124 : : } else { - 125 : 18190 : (isFirstBorrowing, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( - 126 : : reserveCache.variableDebtTokenAddress - 127 : : ).mint(params.user, params.onBehalfOf, params.amount, reserveCache.nextVariableBorrowIndex); - 128 : : } - 129 : : - 130 : 9095 : if (isFirstBorrowing) { - 131 : 18188 : userConfig.setBorrowing(reserve.id, true); - 132 : : } - 133 : : - 134 : 9095 : if (isolationModeActive) { - 135 : 24 : uint256 nextIsolationModeTotalDebt = reservesData[isolationModeCollateralAddress] - 136 : : .isolationModeTotalDebt += (params.amount / - 137 : : 10 ** - 138 : : (reserveCache.reserveConfiguration.getDecimals() - - 139 : : ReserveConfiguration.DEBT_CEILING_DECIMALS)).toUint128(); - 140 : 16 : emit IsolationModeTotalDebtUpdated( - 141 : : isolationModeCollateralAddress, - 142 : : nextIsolationModeTotalDebt - 143 : : ); - 144 : : } - 145 : : - 146 : 18190 : reserve.updateInterestRatesAndVirtualBalance( - 147 : : reserveCache, - 148 : : params.asset, - 149 : : 0, - 150 : : params.releaseUnderlying ? params.amount : 0 - 151 : : ); - 152 : : - 153 : 9094 : if (params.releaseUnderlying) { - 154 : 18186 : IAToken(reserveCache.aTokenAddress).transferUnderlyingTo(params.user, params.amount); - 155 : : } - 156 : : - 157 : 18188 : emit Borrow( - 158 : : params.asset, - 159 : : params.user, - 160 : : params.onBehalfOf, - 161 : : params.amount, - 162 : : params.interestRateMode, - 163 : : params.interestRateMode == DataTypes.InterestRateMode.STABLE - 164 : : ? currentStableRate - 165 : : : reserve.currentVariableBorrowRate, - 166 : : params.referralCode - 167 : : ); - 168 : : } - 169 : : - 170 : : /** - 171 : : * @notice Implements the repay feature. Repaying transfers the underlying back to the aToken and clears the - 172 : : * equivalent amount of debt for the user by burning the corresponding debt token. For isolated positions, it also - 173 : : * reduces the isolated debt. - 174 : : * @dev Emits the `Repay()` event - 175 : : * @param reservesData The state of all the reserves - 176 : : * @param reservesList The addresses of all the active reserves - 177 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - 178 : : * @param params The additional parameters needed to execute the repay function - 179 : : * @return The actual amount being repaid - 180 : : */ - 181 : 5029 : function executeRepay( - 182 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 183 : : mapping(uint256 => address) storage reservesList, - 184 : : DataTypes.UserConfigurationMap storage userConfig, - 185 : : DataTypes.ExecuteRepayParams memory params - 186 : : ) external returns (uint256) { - 187 : 10058 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; - 188 : 15087 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 189 : 10058 : reserve.updateState(reserveCache); - 190 : : - 191 : 15087 : (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt( - 192 : : params.onBehalfOf, - 193 : : reserveCache - 194 : : ); - 195 : : - 196 : 10058 : ValidationLogic.validateRepay( - 197 : : reserveCache, - 198 : : params.amount, - 199 : : params.interestRateMode, - 200 : : params.onBehalfOf, - 201 : : stableDebt, - 202 : : variableDebt - 203 : : ); - 204 : : - 205 : 15072 : uint256 paybackAmount = params.interestRateMode == DataTypes.InterestRateMode.STABLE - 206 : : ? stableDebt - 207 : : : variableDebt; + 78 : 16110 : ValidationLogic.validateBorrow( + 79 : : reservesData, + 80 : : reservesList, + 81 : : eModeCategories, + 82 : : DataTypes.ValidateBorrowParams({ + 83 : : reserveCache: reserveCache, + 84 : : userConfig: userConfig, + 85 : : asset: params.asset, + 86 : : userAddress: params.onBehalfOf, + 87 : : amount: params.amount, + 88 : : interestRateMode: params.interestRateMode, + 89 : : reservesCount: params.reservesCount, + 90 : : oracle: params.oracle, + 91 : : userEModeCategory: params.userEModeCategory, + 92 : : priceOracleSentinel: params.priceOracleSentinel, + 93 : : isolationModeActive: isolationModeActive, + 94 : : isolationModeCollateralAddress: isolationModeCollateralAddress, + 95 : : isolationModeDebtCeiling: isolationModeDebtCeiling + 96 : : }) + 97 : : ); + 98 : : + 99 : 15091 : bool isFirstBorrowing = false; + 100 : : + 101 : 15091 : (isFirstBorrowing, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( + 102 : : reserveCache.variableDebtTokenAddress + 103 : : ).mint(params.user, params.onBehalfOf, params.amount, reserveCache.nextVariableBorrowIndex); + 104 : : + 105 : 15091 : if (isFirstBorrowing) { + 106 : 15090 : userConfig.setBorrowing(reserve.id, true); + 107 : : } + 108 : : + 109 : 15091 : if (isolationModeActive) { + 110 : 8 : uint256 nextIsolationModeTotalDebt = reservesData[isolationModeCollateralAddress] + 111 : : .isolationModeTotalDebt += (params.amount / + 112 : : 10 ** + 113 : : (reserveCache.reserveConfiguration.getDecimals() - + 114 : : ReserveConfiguration.DEBT_CEILING_DECIMALS)).toUint128(); + 115 : 8 : emit IsolationModeTotalDebtUpdated( + 116 : : isolationModeCollateralAddress, + 117 : : nextIsolationModeTotalDebt + 118 : : ); + 119 : : } + 120 : : + 121 : 15091 : reserve.updateInterestRatesAndVirtualBalance( + 122 : : reserveCache, + 123 : : params.asset, + 124 : : 0, + 125 : : params.releaseUnderlying ? params.amount : 0 + 126 : : ); + 127 : : + 128 : 15090 : if (params.releaseUnderlying) { + 129 : 15089 : IAToken(reserveCache.aTokenAddress).transferUnderlyingTo(params.user, params.amount); + 130 : : } + 131 : : + 132 : 15090 : emit Borrow( + 133 : : params.asset, + 134 : : params.user, + 135 : : params.onBehalfOf, + 136 : : params.amount, + 137 : : DataTypes.InterestRateMode.VARIABLE, + 138 : : reserve.currentVariableBorrowRate, + 139 : : params.referralCode + 140 : : ); + 141 : : } + 142 : : + 143 : : /** + 144 : : * @notice Implements the repay feature. Repaying transfers the underlying back to the aToken and clears the + 145 : : * equivalent amount of debt for the user by burning the corresponding debt token. For isolated positions, it also + 146 : : * reduces the isolated debt. + 147 : : * @dev Emits the `Repay()` event + 148 : : * @param reservesData The state of all the reserves + 149 : : * @param reservesList The addresses of all the active reserves + 150 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets + 151 : : * @param params The additional parameters needed to execute the repay function + 152 : : * @return The actual amount being repaid + 153 : : */ + 154 : : function executeRepay( + 155 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 156 : : mapping(uint256 => address) storage reservesList, + 157 : : DataTypes.UserConfigurationMap storage userConfig, + 158 : : DataTypes.ExecuteRepayParams memory params + 159 : : ) external returns (uint256) { + 160 : 5030 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; + 161 : 5030 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 162 : 5030 : reserve.updateState(reserveCache); + 163 : : + 164 : 5030 : uint256 variableDebt = IERC20(reserveCache.variableDebtTokenAddress).balanceOf( + 165 : : params.onBehalfOf + 166 : : ); + 167 : : + 168 : 5030 : ValidationLogic.validateRepay( + 169 : : reserveCache, + 170 : : params.amount, + 171 : : params.interestRateMode, + 172 : : params.onBehalfOf, + 173 : : variableDebt + 174 : : ); + 175 : : + 176 : 5024 : uint256 paybackAmount = variableDebt; + 177 : : + 178 : : // Allows a user to repay with aTokens without leaving dust from interest. + 179 : 5024 : if (params.useATokens && params.amount == type(uint256).max) { + 180 : 4 : params.amount = IAToken(reserveCache.aTokenAddress).balanceOf(msg.sender); + 181 : : } + 182 : : + 183 : 5024 : if (params.amount < paybackAmount) { + 184 : 4971 : paybackAmount = params.amount; + 185 : : } + 186 : : + 187 : 5024 : reserveCache.nextScaledVariableDebt = IVariableDebtToken(reserveCache.variableDebtTokenAddress) + 188 : : .burn(params.onBehalfOf, paybackAmount, reserveCache.nextVariableBorrowIndex); + 189 : : + 190 : 5024 : reserve.updateInterestRatesAndVirtualBalance( + 191 : : reserveCache, + 192 : : params.asset, + 193 : : params.useATokens ? 0 : paybackAmount, + 194 : : 0 + 195 : : ); + 196 : : + 197 : 5024 : if (variableDebt - paybackAmount == 0) { + 198 : 53 : userConfig.setBorrowing(reserve.id, false); + 199 : : } + 200 : : + 201 : 5024 : IsolationModeLogic.updateIsolatedDebtIfIsolated( + 202 : : reservesData, + 203 : : reservesList, + 204 : : userConfig, + 205 : : reserveCache, + 206 : : paybackAmount + 207 : : ); 208 : : - 209 : : // Allows a user to repay with aTokens without leaving dust from interest. - 210 : 11054 : if (params.useATokens && params.amount == type(uint256).max) { - 211 : 8 : params.amount = IAToken(reserveCache.aTokenAddress).balanceOf(msg.sender); - 212 : : } - 213 : : - 214 : 10048 : if (params.amount < paybackAmount) { - 215 : 9246 : paybackAmount = params.amount; - 216 : : } - 217 : : - 218 : 10048 : if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - 219 : 0 : (reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - 220 : : reserveCache.stableDebtTokenAddress - 221 : : ).burn(params.onBehalfOf, paybackAmount); - 222 : : } else { - 223 : 10048 : reserveCache.nextScaledVariableDebt = IVariableDebtToken( - 224 : : reserveCache.variableDebtTokenAddress - 225 : : ).burn(params.onBehalfOf, paybackAmount, reserveCache.nextVariableBorrowIndex); - 226 : : } - 227 : : - 228 : 10048 : reserve.updateInterestRatesAndVirtualBalance( - 229 : : reserveCache, - 230 : : params.asset, - 231 : : params.useATokens ? 0 : paybackAmount, - 232 : : 0 - 233 : : ); - 234 : : - 235 : 20096 : if (stableDebt + variableDebt - paybackAmount == 0) { - 236 : 802 : userConfig.setBorrowing(reserve.id, false); - 237 : : } - 238 : : - 239 : 10048 : IsolationModeLogic.updateIsolatedDebtIfIsolated( - 240 : : reservesData, - 241 : : reservesList, - 242 : : userConfig, - 243 : : reserveCache, - 244 : : paybackAmount - 245 : : ); - 246 : : - 247 : 5024 : if (params.useATokens) { - 248 : 2012 : IAToken(reserveCache.aTokenAddress).burn( - 249 : : msg.sender, - 250 : : reserveCache.aTokenAddress, - 251 : : paybackAmount, - 252 : : reserveCache.nextLiquidityIndex - 253 : : ); - 254 : : // in case of aToken repayment the msg.sender must always repay on behalf of itself - 255 : 3015 : if (IAToken(reserveCache.aTokenAddress).scaledBalanceOf(msg.sender) == 0) { - 256 : 4 : userConfig.setUsingAsCollateral(reserve.id, false); - 257 : 4 : emit ReserveUsedAsCollateralDisabled(params.asset, msg.sender); - 258 : : } - 259 : : } else { - 260 : 8036 : IERC20(params.asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, paybackAmount); - 261 : 6036 : IAToken(reserveCache.aTokenAddress).handleRepayment( - 262 : : msg.sender, - 263 : : params.onBehalfOf, - 264 : : paybackAmount - 265 : : ); - 266 : : } - 267 : : - 268 : 8046 : emit Repay(params.asset, params.onBehalfOf, msg.sender, paybackAmount, params.useATokens); - 269 : : - 270 : 8046 : return paybackAmount; - 271 : : } - 272 : : - 273 : : /** - 274 : : * @notice Implements the rebalance stable borrow rate feature. In case of liquidity crunches on the protocol, stable - 275 : : * rate borrows might need to be rebalanced to bring back equilibrium between the borrow and supply APYs. - 276 : : * @dev The rules that define if a position can be rebalanced are implemented in `ValidationLogic.validateRebalanceStableBorrowRate()` - 277 : : * @dev Emits the `RebalanceStableBorrowRate()` event - 278 : : * @param reserve The state of the reserve of the asset being repaid - 279 : : * @param asset The asset of the position being rebalanced - 280 : : * @param user The user being rebalanced - 281 : : */ - 282 : 5 : function executeRebalanceStableBorrowRate( - 283 : : DataTypes.ReserveData storage reserve, - 284 : : address asset, - 285 : : address user - 286 : : ) external { - 287 : 15 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 288 : 10 : reserve.updateState(reserveCache); - 289 : : - 290 : 10 : ValidationLogic.validateRebalanceStableBorrowRate(reserve, reserveCache, asset); - 291 : : - 292 : 6 : IStableDebtToken stableDebtToken = IStableDebtToken(reserveCache.stableDebtTokenAddress); - 293 : 6 : uint256 stableDebt = IERC20(address(stableDebtToken)).balanceOf(user); - 294 : : - 295 : 4 : stableDebtToken.burn(user, stableDebt); - 296 : : - 297 : 0 : (, reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = stableDebtToken - 298 : : .mint(user, user, stableDebt, reserve.currentStableBorrowRate); - 299 : : - 300 : 0 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); - 301 : : - 302 : 0 : emit RebalanceStableBorrowRate(asset, user); - 303 : : } - 304 : : - 305 : : /** - 306 : : * @notice Implements the swap borrow rate feature. Borrowers can swap from variable to stable positions at any time. - 307 : : * @dev Emits the `Swap()` event - 308 : : * @param reserve The of the reserve of the asset being repaid - 309 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - 310 : : * @param asset The asset of the position being swapped - 311 : : * @param interestRateMode The current interest rate mode of the position being swapped - 312 : : */ - 313 : 8 : function executeSwapBorrowRateMode( - 314 : : DataTypes.ReserveData storage reserve, - 315 : : DataTypes.UserConfigurationMap storage userConfig, - 316 : : address asset, - 317 : : address user, - 318 : : DataTypes.InterestRateMode interestRateMode - 319 : : ) external { - 320 : 24 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 321 : : - 322 : 16 : reserve.updateState(reserveCache); - 323 : : - 324 : 24 : (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(user, reserveCache); - 325 : : - 326 : 16 : ValidationLogic.validateSwapRateMode( - 327 : : reserve, - 328 : : reserveCache, - 329 : : userConfig, - 330 : : stableDebt, - 331 : : variableDebt, - 332 : : interestRateMode - 333 : : ); - 334 : : - 335 : 6 : if (interestRateMode == DataTypes.InterestRateMode.STABLE) { - 336 : 0 : (reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - 337 : : reserveCache.stableDebtTokenAddress - 338 : : ).burn(user, stableDebt); - 339 : : - 340 : 0 : (, reserveCache.nextScaledVariableDebt) = IVariableDebtToken( - 341 : : reserveCache.variableDebtTokenAddress - 342 : : ).mint(user, user, stableDebt, reserveCache.nextVariableBorrowIndex); - 343 : : } else { - 344 : 6 : reserveCache.nextScaledVariableDebt = IVariableDebtToken( - 345 : : reserveCache.variableDebtTokenAddress - 346 : : ).burn(user, variableDebt, reserveCache.nextVariableBorrowIndex); - 347 : : - 348 : 6 : (, reserveCache.nextTotalStableDebt, reserveCache.nextAvgStableBorrowRate) = IStableDebtToken( - 349 : : reserveCache.stableDebtTokenAddress - 350 : : ).mint(user, user, variableDebt, reserve.currentStableBorrowRate); - 351 : : } - 352 : : - 353 : 0 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); - 354 : : - 355 : 0 : emit SwapBorrowRateMode(asset, user, interestRateMode); - 356 : : } - 357 : : } + 209 : 5024 : if (params.useATokens) { + 210 : 1006 : IAToken(reserveCache.aTokenAddress).burn( + 211 : : msg.sender, + 212 : : reserveCache.aTokenAddress, + 213 : : paybackAmount, + 214 : : reserveCache.nextLiquidityIndex + 215 : : ); + 216 : : // in case of aToken repayment the msg.sender must always repay on behalf of itself + 217 : 1005 : if (IAToken(reserveCache.aTokenAddress).scaledBalanceOf(msg.sender) == 0) { + 218 : 2 : userConfig.setUsingAsCollateral(reserve.id, false); + 219 : 2 : emit ReserveUsedAsCollateralDisabled(params.asset, msg.sender); + 220 : : } + 221 : : } else { + 222 : 4018 : IERC20(params.asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, paybackAmount); + 223 : 3018 : IAToken(reserveCache.aTokenAddress).handleRepayment( + 224 : : msg.sender, + 225 : : params.onBehalfOf, + 226 : : paybackAmount + 227 : : ); + 228 : : } + 229 : : + 230 : 4023 : emit Repay(params.asset, params.onBehalfOf, msg.sender, paybackAmount, params.useATokens); + 231 : : + 232 : 4023 : return paybackAmount; + 233 : : } + 234 : : } @@ -433,8 +310,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func-c.html b/report/protocol/libraries/logic/BridgeLogic.sol.func-c.html similarity index 68% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func-c.html rename to report/protocol/libraries/logic/BridgeLogic.sol.func-c.html index bcdb3d86..7ef58872 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/BridgeLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/BridgeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BridgeLogic.sol (source / functions)top level - protocol/libraries/logic - BridgeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func.html b/report/protocol/libraries/logic/BridgeLogic.sol.func.html similarity index 68% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func.html rename to report/protocol/libraries/logic/BridgeLogic.sol.func.html index b7642685..b66c60e4 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.func.html +++ b/report/protocol/libraries/logic/BridgeLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/BridgeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BridgeLogic.sol (source / functions)top level - protocol/libraries/logic - BridgeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.gcov.html b/report/protocol/libraries/logic/BridgeLogic.sol.gcov.html similarity index 87% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.gcov.html rename to report/protocol/libraries/logic/BridgeLogic.sol.gcov.html index aa403b76..572a41b7 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/BridgeLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/BridgeLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/BridgeLogic.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - BridgeLogic.sol (source / functions)top level - protocol/libraries/logic - BridgeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -120,7 +120,7 @@ 49 : : * @param referralCode Code used to register the integrator originating the operation, for potential rewards. 50 : : * 0 if the action is executed directly by the user, without any middle-man 51 : : */ - 52 : 16 : function executeMintUnbacked( + 52 : : function executeMintUnbacked( 53 : : mapping(address => DataTypes.ReserveData) storage reservesData, 54 : : mapping(uint256 => address) storage reservesList, 55 : : DataTypes.UserConfigurationMap storage userConfig, @@ -129,26 +129,26 @@ 58 : : address onBehalfOf, 59 : : uint16 referralCode 60 : : ) external { - 61 : 32 : DataTypes.ReserveData storage reserve = reservesData[asset]; - 62 : 48 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 61 : 16 : DataTypes.ReserveData storage reserve = reservesData[asset]; + 62 : 16 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); 63 : : - 64 : 32 : reserve.updateState(reserveCache); + 64 : 16 : reserve.updateState(reserveCache); 65 : : - 66 : 32 : ValidationLogic.validateSupply(reserveCache, reserve, amount, onBehalfOf); + 66 : 16 : ValidationLogic.validateSupply(reserveCache, reserve, amount, onBehalfOf); 67 : : - 68 : 48 : uint256 unbackedMintCap = reserveCache.reserveConfiguration.getUnbackedMintCap(); - 69 : 48 : uint256 reserveDecimals = reserveCache.reserveConfiguration.getDecimals(); + 68 : 16 : uint256 unbackedMintCap = reserveCache.reserveConfiguration.getUnbackedMintCap(); + 69 : 16 : uint256 reserveDecimals = reserveCache.reserveConfiguration.getDecimals(); 70 : : - 71 : 48 : uint256 unbacked = reserve.unbacked += amount.toUint128(); + 71 : 16 : uint256 unbacked = reserve.unbacked += amount.toUint128(); 72 : : - 73 : 32 : require( + 73 : 16 : require( 74 : : unbacked <= unbackedMintCap * (10 ** reserveDecimals), 75 : : Errors.UNBACKED_MINT_CAP_EXCEEDED 76 : : ); 77 : : - 78 : 28 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); + 78 : 14 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, 0, 0); 79 : : - 80 : 42 : bool isFirstSupply = IAToken(reserveCache.aTokenAddress).mint( + 80 : 14 : bool isFirstSupply = IAToken(reserveCache.aTokenAddress).mint( 81 : : msg.sender, 82 : : onBehalfOf, 83 : : amount, @@ -157,7 +157,7 @@ 86 : : 87 : 14 : if (isFirstSupply) { 88 : : if ( - 89 : 14 : ValidationLogic.validateAutomaticUseAsCollateral( + 89 : 7 : ValidationLogic.validateAutomaticUseAsCollateral( 90 : : reservesData, 91 : : reservesList, 92 : : userConfig, @@ -165,12 +165,12 @@ 94 : : reserveCache.aTokenAddress 95 : : ) 96 : : ) { - 97 : 14 : userConfig.setUsingAsCollateral(reserve.id, true); - 98 : 14 : emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf); + 97 : 7 : userConfig.setUsingAsCollateral(reserve.id, true); + 98 : 7 : emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf); 99 : : } 100 : : } 101 : : - 102 : 28 : emit MintUnbacked(asset, msg.sender, onBehalfOf, amount, referralCode); + 102 : 14 : emit MintUnbacked(asset, msg.sender, onBehalfOf, amount, referralCode); 103 : : } 104 : : 105 : : /** @@ -184,39 +184,39 @@ 113 : : * @param protocolFeeBps The fraction of fees in basis points paid to the protocol 114 : : * @return The backed amount 115 : : */ - 116 : 9 : function executeBackUnbacked( + 116 : : function executeBackUnbacked( 117 : : DataTypes.ReserveData storage reserve, 118 : : address asset, 119 : : uint256 amount, 120 : : uint256 fee, 121 : : uint256 protocolFeeBps 122 : : ) external returns (uint256) { - 123 : 27 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 123 : 9 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); 124 : : - 125 : 18 : reserve.updateState(reserveCache); + 125 : 9 : reserve.updateState(reserveCache); 126 : : - 127 : 27 : uint256 backingAmount = (amount < reserve.unbacked) ? amount : reserve.unbacked; + 127 : 9 : uint256 backingAmount = (amount < reserve.unbacked) ? amount : reserve.unbacked; 128 : : - 129 : 27 : uint256 feeToProtocol = fee.percentMul(protocolFeeBps); - 130 : 27 : uint256 feeToLP = fee - feeToProtocol; - 131 : 27 : uint256 added = backingAmount + fee; + 129 : 9 : uint256 feeToProtocol = fee.percentMul(protocolFeeBps); + 130 : 9 : uint256 feeToLP = fee - feeToProtocol; + 131 : 9 : uint256 added = backingAmount + fee; 132 : : - 133 : 18 : reserveCache.nextLiquidityIndex = reserve.cumulateToLiquidityIndex( + 133 : 9 : reserveCache.nextLiquidityIndex = reserve.cumulateToLiquidityIndex( 134 : : IERC20(reserveCache.aTokenAddress).totalSupply() + 135 : : uint256(reserve.accruedToTreasury).rayMul(reserveCache.nextLiquidityIndex), 136 : : feeToLP 137 : : ); 138 : : - 139 : 18 : reserve.accruedToTreasury += feeToProtocol.rayDiv(reserveCache.nextLiquidityIndex).toUint128(); + 139 : 9 : reserve.accruedToTreasury += feeToProtocol.rayDiv(reserveCache.nextLiquidityIndex).toUint128(); 140 : : - 141 : 18 : reserve.unbacked -= backingAmount.toUint128(); - 142 : 18 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, added, 0); + 141 : 9 : reserve.unbacked -= backingAmount.toUint128(); + 142 : 9 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, asset, added, 0); 143 : : - 144 : 18 : IERC20(asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, added); + 144 : 9 : IERC20(asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, added); 145 : : - 146 : 18 : emit BackUnbacked(asset, msg.sender, backingAmount, fee); + 146 : 9 : emit BackUnbacked(asset, msg.sender, backingAmount, fee); 147 : : - 148 : 18 : return backingAmount; + 148 : 9 : return backingAmount; 149 : : } 150 : : } @@ -226,8 +226,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func-c.html b/report/protocol/libraries/logic/CalldataLogic.sol.func-c.html similarity index 65% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func-c.html rename to report/protocol/libraries/logic/CalldataLogic.sol.func-c.html index 086a5787..09c229f7 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/CalldataLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/CalldataLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,47 +53,33 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - CalldataLogic.sol (source / functions)top level - protocol/libraries/logic - CalldataLogic.sol (source / functions) Coverage Lines: 100.0 %72726262
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %101088
0 0
- + - + - + - - - - - - - - - - - - - - - + @@ -145,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
CalldataLogic.decodeLiquidationCallParamsCalldataLogic.decodeLiquidationCallParams 1
CalldataLogic.decodeRebalanceStableBorrowRateParams1
CalldataLogic.decodeSetUserUseReserveAsCollateralParams1
CalldataLogic.decodeSwapBorrowRateModeParamsCalldataLogic.decodeSetUserUseReserveAsCollateralParams 1
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func.html b/report/protocol/libraries/logic/CalldataLogic.sol.func.html similarity index 65% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func.html rename to report/protocol/libraries/logic/CalldataLogic.sol.func.html index 7e5722ec..6ac13f15 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.func.html +++ b/report/protocol/libraries/logic/CalldataLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/CalldataLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - CalldataLogic.sol (source / functions)top level - protocol/libraries/logic - CalldataLogic.sol (source / functions) Coverage Lines: 100.0 %72726262
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %101088
0 0
- + - + @@ -79,14 +79,7 @@ - - - - - - - - + @@ -107,7 +100,7 @@ - + @@ -126,13 +119,6 @@ - - - - - - - @@ -145,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
CalldataLogic.decodeLiquidationCallParams1
CalldataLogic.decodeRebalanceStableBorrowRateParamsCalldataLogic.decodeLiquidationCallParams 1
CalldataLogic.decodeSetUserUseReserveAsCollateralParamsCalldataLogic.decodeSetUserUseReserveAsCollateralParams 11000
CalldataLogic.decodeSwapBorrowRateModeParams1
CalldataLogic.decodeWithdrawParams
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.gcov.html b/report/protocol/libraries/logic/CalldataLogic.sol.gcov.html similarity index 70% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.gcov.html rename to report/protocol/libraries/logic/CalldataLogic.sol.gcov.html index f8e61c0a..9e8e2849 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/CalldataLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/CalldataLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/CalldataLogic.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - CalldataLogic.sol (source / functions)top level - protocol/libraries/logic - CalldataLogic.sol (source / functions) Coverage Lines: 100.0 %72726262
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %101088
0 0
@@ -86,20 +86,20 @@ 15 : : * @return The amount to supply 16 : : * @return The referralCode 17 : : */ - 18 : 1007 : function decodeSupplyParams( + 18 : : function decodeSupplyParams( 19 : : mapping(uint256 => address) storage reservesList, 20 : : bytes32 args 21 : : ) internal view returns (address, uint256, uint16) { - 22 : 2014 : uint16 assetId; - 23 : 2014 : uint256 amount; - 24 : 2014 : uint16 referralCode; + 22 : 1007 : uint16 assetId; + 23 : 1007 : uint256 amount; + 24 : 1007 : uint16 referralCode; 25 : : 26 : : assembly { - 27 : 2014 : assetId := and(args, 0xFFFF) - 28 : 2014 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 29 : 2014 : referralCode := and(shr(144, args), 0xFFFF) + 27 : 1007 : assetId := and(args, 0xFFFF) + 28 : 1007 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 29 : 1007 : referralCode := and(shr(144, args), 0xFFFF) 30 : : } - 31 : 2014 : return (reservesList[assetId], amount, referralCode); + 31 : 1007 : return (reservesList[assetId], amount, referralCode); 32 : : } 33 : : 34 : : /** @@ -112,20 +112,20 @@ 41 : : * @return The deadline of the permit 42 : : * @return The V value of the permit signature 43 : : */ - 44 : 1000 : function decodeSupplyWithPermitParams( + 44 : : function decodeSupplyWithPermitParams( 45 : : mapping(uint256 => address) storage reservesList, 46 : : bytes32 args 47 : : ) internal view returns (address, uint256, uint16, uint256, uint8) { - 48 : 2000 : uint256 deadline; - 49 : 2000 : uint8 permitV; + 48 : 1000 : uint256 deadline; + 49 : 1000 : uint8 permitV; 50 : : 51 : : assembly { - 52 : 2000 : deadline := and(shr(160, args), 0xFFFFFFFF) - 53 : 2000 : permitV := and(shr(192, args), 0xFF) + 52 : 1000 : deadline := and(shr(160, args), 0xFFFFFFFF) + 53 : 1000 : permitV := and(shr(192, args), 0xFF) 54 : : } - 55 : 3000 : (address asset, uint256 amount, uint16 referralCode) = decodeSupplyParams(reservesList, args); + 55 : 1000 : (address asset, uint256 amount, uint16 referralCode) = decodeSupplyParams(reservesList, args); 56 : : - 57 : 2000 : return (asset, amount, referralCode, deadline, permitV); + 57 : 1000 : return (asset, amount, referralCode, deadline, permitV); 58 : : } 59 : : 60 : : /** @@ -135,20 +135,20 @@ 64 : : * @return The address of the underlying reserve 65 : : * @return The amount to withdraw 66 : : */ - 67 : 2 : function decodeWithdrawParams( + 67 : : function decodeWithdrawParams( 68 : : mapping(uint256 => address) storage reservesList, 69 : : bytes32 args 70 : : ) internal view returns (address, uint256) { - 71 : 4 : uint16 assetId; - 72 : 4 : uint256 amount; + 71 : 2 : uint16 assetId; + 72 : 2 : uint256 amount; 73 : : assembly { - 74 : 4 : assetId := and(args, 0xFFFF) - 75 : 4 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 74 : 2 : assetId := and(args, 0xFFFF) + 75 : 2 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) 76 : : } - 77 : 4 : if (amount == type(uint128).max) { - 78 : 2 : amount = type(uint256).max; + 77 : 2 : if (amount == type(uint128).max) { + 78 : 1 : amount = type(uint256).max; 79 : : } - 80 : 4 : return (reservesList[assetId], amount); + 80 : 2 : return (reservesList[assetId], amount); 81 : : } 82 : : 83 : : /** @@ -157,26 +157,26 @@ 86 : : * @param args The packed borrow params 87 : : * @return The address of the underlying reserve 88 : : * @return The amount to borrow - 89 : : * @return The interestRateMode, 1 for stable or 2 for variable debt + 89 : : * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) 90 : : * @return The referralCode 91 : : */ - 92 : 3 : function decodeBorrowParams( + 92 : : function decodeBorrowParams( 93 : : mapping(uint256 => address) storage reservesList, 94 : : bytes32 args 95 : : ) internal view returns (address, uint256, uint256, uint16) { - 96 : 6 : uint16 assetId; - 97 : 6 : uint256 amount; - 98 : 6 : uint256 interestRateMode; - 99 : 6 : uint16 referralCode; + 96 : 3 : uint16 assetId; + 97 : 3 : uint256 amount; + 98 : 3 : uint256 interestRateMode; + 99 : 3 : uint16 referralCode; 100 : : 101 : : assembly { - 102 : 6 : assetId := and(args, 0xFFFF) - 103 : 6 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 104 : 6 : interestRateMode := and(shr(144, args), 0xFF) - 105 : 6 : referralCode := and(shr(152, args), 0xFFFF) + 102 : 3 : assetId := and(args, 0xFFFF) + 103 : 3 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 104 : 3 : interestRateMode := and(shr(144, args), 0xFF) + 105 : 3 : referralCode := and(shr(152, args), 0xFFFF) 106 : : } 107 : : - 108 : 6 : return (reservesList[assetId], amount, interestRateMode, referralCode); + 108 : 3 : return (reservesList[assetId], amount, interestRateMode, referralCode); 109 : : } 110 : : 111 : : /** @@ -185,27 +185,27 @@ 114 : : * @param args The packed repay params 115 : : * @return The address of the underlying reserve 116 : : * @return The amount to repay - 117 : : * @return The interestRateMode, 1 for stable or 2 for variable debt + 117 : : * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) 118 : : */ - 119 : 1002 : function decodeRepayParams( + 119 : : function decodeRepayParams( 120 : : mapping(uint256 => address) storage reservesList, 121 : : bytes32 args 122 : : ) internal view returns (address, uint256, uint256) { - 123 : 2004 : uint16 assetId; - 124 : 2004 : uint256 amount; - 125 : 2004 : uint256 interestRateMode; + 123 : 1002 : uint16 assetId; + 124 : 1002 : uint256 amount; + 125 : 1002 : uint256 interestRateMode; 126 : : 127 : : assembly { - 128 : 2004 : assetId := and(args, 0xFFFF) - 129 : 2004 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 130 : 2004 : interestRateMode := and(shr(144, args), 0xFF) + 128 : 1002 : assetId := and(args, 0xFFFF) + 129 : 1002 : amount := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 130 : 1002 : interestRateMode := and(shr(144, args), 0xFF) 131 : : } 132 : : - 133 : 2004 : if (amount == type(uint128).max) { - 134 : 4 : amount = type(uint256).max; + 133 : 1002 : if (amount == type(uint128).max) { + 134 : 2 : amount = type(uint256).max; 135 : : } 136 : : - 137 : 2004 : return (reservesList[assetId], amount, interestRateMode); + 137 : 1002 : return (reservesList[assetId], amount, interestRateMode); 138 : : } 139 : : 140 : : /** @@ -214,136 +214,94 @@ 143 : : * @param args The packed repay with permit params 144 : : * @return The address of the underlying reserve 145 : : * @return The amount to repay - 146 : : * @return The interestRateMode, 1 for stable or 2 for variable debt + 146 : : * @return The interestRateMode, 2 for variable debt, 1 is deprecated (changed on v3.2.0) 147 : : * @return The deadline of the permit 148 : : * @return The V value of the permit signature 149 : : */ - 150 : 1000 : function decodeRepayWithPermitParams( + 150 : : function decodeRepayWithPermitParams( 151 : : mapping(uint256 => address) storage reservesList, 152 : : bytes32 args 153 : : ) internal view returns (address, uint256, uint256, uint256, uint8) { - 154 : 2000 : uint256 deadline; - 155 : 2000 : uint8 permitV; + 154 : 1000 : uint256 deadline; + 155 : 1000 : uint8 permitV; 156 : : - 157 : 3000 : (address asset, uint256 amount, uint256 interestRateMode) = decodeRepayParams( + 157 : 1000 : (address asset, uint256 amount, uint256 interestRateMode) = decodeRepayParams( 158 : : reservesList, 159 : : args 160 : : ); 161 : : 162 : : assembly { - 163 : 2000 : deadline := and(shr(152, args), 0xFFFFFFFF) - 164 : 2000 : permitV := and(shr(184, args), 0xFF) + 163 : 1000 : deadline := and(shr(152, args), 0xFFFFFFFF) + 164 : 1000 : permitV := and(shr(184, args), 0xFF) 165 : : } 166 : : - 167 : 2000 : return (asset, amount, interestRateMode, deadline, permitV); + 167 : 1000 : return (asset, amount, interestRateMode, deadline, permitV); 168 : : } 169 : : 170 : : /** - 171 : : * @notice Decodes compressed swap borrow rate mode params to standard params + 171 : : * @notice Decodes compressed set user use reserve as collateral params to standard params 172 : : * @param reservesList The addresses of all the active reserves - 173 : : * @param args The packed swap borrow rate mode params + 173 : : * @param args The packed set user use reserve as collateral params 174 : : * @return The address of the underlying reserve - 175 : : * @return The interest rate mode, 1 for stable 2 for variable debt + 175 : : * @return True if to set using as collateral, false otherwise 176 : : */ - 177 : 1 : function decodeSwapBorrowRateModeParams( + 177 : : function decodeSetUserUseReserveAsCollateralParams( 178 : : mapping(uint256 => address) storage reservesList, 179 : : bytes32 args - 180 : : ) internal view returns (address, uint256) { - 181 : 2 : uint16 assetId; - 182 : 2 : uint256 interestRateMode; - 183 : : - 184 : : assembly { - 185 : 2 : assetId := and(args, 0xFFFF) - 186 : 2 : interestRateMode := and(shr(16, args), 0xFF) - 187 : : } - 188 : : - 189 : 2 : return (reservesList[assetId], interestRateMode); - 190 : : } - 191 : : - 192 : : /** - 193 : : * @notice Decodes compressed rebalance stable borrow rate params to standard params - 194 : : * @param reservesList The addresses of all the active reserves - 195 : : * @param args The packed rabalance stable borrow rate params - 196 : : * @return The address of the underlying reserve - 197 : : * @return The address of the user to rebalance - 198 : : */ - 199 : 1 : function decodeRebalanceStableBorrowRateParams( - 200 : : mapping(uint256 => address) storage reservesList, - 201 : : bytes32 args - 202 : : ) internal view returns (address, address) { - 203 : 2 : uint16 assetId; - 204 : 2 : address user; - 205 : : assembly { - 206 : 2 : assetId := and(args, 0xFFFF) - 207 : 2 : user := and(shr(16, args), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 208 : : } - 209 : 2 : return (reservesList[assetId], user); - 210 : : } + 180 : : ) internal view returns (address, bool) { + 181 : 1 : uint16 assetId; + 182 : 1 : bool useAsCollateral; + 183 : : assembly { + 184 : 1 : assetId := and(args, 0xFFFF) + 185 : 1 : useAsCollateral := and(shr(16, args), 0x1) + 186 : : } + 187 : 1 : return (reservesList[assetId], useAsCollateral); + 188 : : } + 189 : : + 190 : : /** + 191 : : * @notice Decodes compressed liquidation call params to standard params + 192 : : * @param reservesList The addresses of all the active reserves + 193 : : * @param args1 The first half of packed liquidation call params + 194 : : * @param args2 The second half of the packed liquidation call params + 195 : : * @return The address of the underlying collateral asset + 196 : : * @return The address of the underlying debt asset + 197 : : * @return The address of the user to liquidate + 198 : : * @return The amount of debt to cover + 199 : : * @return True if receiving aTokens, false otherwise + 200 : : */ + 201 : : function decodeLiquidationCallParams( + 202 : : mapping(uint256 => address) storage reservesList, + 203 : : bytes32 args1, + 204 : : bytes32 args2 + 205 : : ) internal view returns (address, address, address, uint256, bool) { + 206 : 1 : uint16 collateralAssetId; + 207 : 1 : uint16 debtAssetId; + 208 : 1 : address user; + 209 : 1 : uint256 debtToCover; + 210 : 1 : bool receiveAToken; 211 : : - 212 : : /** - 213 : : * @notice Decodes compressed set user use reserve as collateral params to standard params - 214 : : * @param reservesList The addresses of all the active reserves - 215 : : * @param args The packed set user use reserve as collateral params - 216 : : * @return The address of the underlying reserve - 217 : : * @return True if to set using as collateral, false otherwise - 218 : : */ - 219 : 1 : function decodeSetUserUseReserveAsCollateralParams( - 220 : : mapping(uint256 => address) storage reservesList, - 221 : : bytes32 args - 222 : : ) internal view returns (address, bool) { - 223 : 2 : uint16 assetId; - 224 : 2 : bool useAsCollateral; - 225 : : assembly { - 226 : 2 : assetId := and(args, 0xFFFF) - 227 : 2 : useAsCollateral := and(shr(16, args), 0x1) - 228 : : } - 229 : 2 : return (reservesList[assetId], useAsCollateral); - 230 : : } - 231 : : - 232 : : /** - 233 : : * @notice Decodes compressed liquidation call params to standard params - 234 : : * @param reservesList The addresses of all the active reserves - 235 : : * @param args1 The first half of packed liquidation call params - 236 : : * @param args2 The second half of the packed liquidation call params - 237 : : * @return The address of the underlying collateral asset - 238 : : * @return The address of the underlying debt asset - 239 : : * @return The address of the user to liquidate - 240 : : * @return The amount of debt to cover - 241 : : * @return True if receiving aTokens, false otherwise - 242 : : */ - 243 : 1 : function decodeLiquidationCallParams( - 244 : : mapping(uint256 => address) storage reservesList, - 245 : : bytes32 args1, - 246 : : bytes32 args2 - 247 : : ) internal view returns (address, address, address, uint256, bool) { - 248 : 2 : uint16 collateralAssetId; - 249 : 2 : uint16 debtAssetId; - 250 : 2 : address user; - 251 : 2 : uint256 debtToCover; - 252 : 2 : bool receiveAToken; - 253 : : - 254 : : assembly { - 255 : 2 : collateralAssetId := and(args1, 0xFFFF) - 256 : 2 : debtAssetId := and(shr(16, args1), 0xFFFF) - 257 : 2 : user := and(shr(32, args1), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 258 : : - 259 : 2 : debtToCover := and(args2, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - 260 : 2 : receiveAToken := and(shr(128, args2), 0x1) - 261 : : } - 262 : : - 263 : 2 : if (debtToCover == type(uint128).max) { - 264 : 2 : debtToCover = type(uint256).max; - 265 : : } - 266 : : - 267 : 2 : return ( - 268 : : reservesList[collateralAssetId], - 269 : : reservesList[debtAssetId], - 270 : : user, - 271 : : debtToCover, - 272 : : receiveAToken - 273 : : ); - 274 : : } - 275 : : } + 212 : : assembly { + 213 : 1 : collateralAssetId := and(args1, 0xFFFF) + 214 : 1 : debtAssetId := and(shr(16, args1), 0xFFFF) + 215 : 1 : user := and(shr(32, args1), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 216 : : + 217 : 1 : debtToCover := and(args2, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + 218 : 1 : receiveAToken := and(shr(128, args2), 0x1) + 219 : : } + 220 : : + 221 : 1 : if (debtToCover == type(uint128).max) { + 222 : 1 : debtToCover = type(uint256).max; + 223 : : } + 224 : : + 225 : 1 : return ( + 226 : : reservesList[collateralAssetId], + 227 : : reservesList[debtAssetId], + 228 : : user, + 229 : : debtToCover, + 230 : : receiveAToken + 231 : : ); + 232 : : } + 233 : : } @@ -351,8 +309,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html b/report/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html similarity index 58% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html rename to report/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html index 18a1b637..f02cd1f0 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/ConfiguratorLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/ConfiguratorLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,63 +53,56 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ConfiguratorLogic.sol (source / functions)top level - protocol/libraries/logic - ConfiguratorLogic.sol (source / functions) Coverage Lines: 100.0 %33332929
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %6655
0 0
- + - + - + - + - + - - - - - - - - + - + - + - + - + @@ -117,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ConfiguratorLogic.executeUpdateATokenConfiguratorLogic.executeUpdateAToken 1
ConfiguratorLogic.executeUpdateStableDebtTokenConfiguratorLogic.executeUpdateVariableDebtToken 1
ConfiguratorLogic.executeUpdateVariableDebtTokenConfiguratorLogic._upgradeTokenImplementation1
ConfiguratorLogic._upgradeTokenImplementation32
ConfiguratorLogic.executeInitReserveConfiguratorLogic.executeInitReserve2882167016
ConfiguratorLogic._initTokenWithProxyConfiguratorLogic._initTokenWithProxy8646332032
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func.html b/report/protocol/libraries/logic/ConfiguratorLogic.sol.func.html similarity index 58% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func.html rename to report/protocol/libraries/logic/ConfiguratorLogic.sol.func.html index 7c2a5362..a049e220 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.func.html +++ b/report/protocol/libraries/logic/ConfiguratorLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/ConfiguratorLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,61 +53,54 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ConfiguratorLogic.sol (source / functions)top level - protocol/libraries/logic - ConfiguratorLogic.sol (source / functions) Coverage Lines: 100.0 %33332929
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %6655
0 0
- + - + - + - + - + - + - + - + - + - - - - - - - - + @@ -117,8 +110,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ConfiguratorLogic._initTokenWithProxyConfiguratorLogic._initTokenWithProxy8646332032
ConfiguratorLogic._upgradeTokenImplementationConfiguratorLogic._upgradeTokenImplementation32
ConfiguratorLogic.executeInitReserveConfiguratorLogic.executeInitReserve2882167016
ConfiguratorLogic.executeUpdateATokenConfiguratorLogic.executeUpdateAToken 1
ConfiguratorLogic.executeUpdateStableDebtToken1
ConfiguratorLogic.executeUpdateVariableDebtTokenConfiguratorLogic.executeUpdateVariableDebtToken 1
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html b/report/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html similarity index 70% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html rename to report/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html index 4fdc41b6..631f7a40 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/ConfiguratorLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ConfiguratorLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/ConfiguratorLogic.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ConfiguratorLogic.sol (source / functions)top level - protocol/libraries/logic - ConfiguratorLogic.sol (source / functions) Coverage Lines: 100.0 %33332929
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %6655
0 0
@@ -75,275 +75,223 @@ 4 : : import {IPool} from '../../../interfaces/IPool.sol'; 5 : : import {IInitializableAToken} from '../../../interfaces/IInitializableAToken.sol'; 6 : : import {IInitializableDebtToken} from '../../../interfaces/IInitializableDebtToken.sol'; - 7 : : import {InitializableImmutableAdminUpgradeabilityProxy} from '../aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; + 7 : : import {InitializableImmutableAdminUpgradeabilityProxy} from '../../../misc/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; 8 : : import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; 9 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; 10 : : import {DataTypes} from '../types/DataTypes.sol'; - 11 : : import {ConfiguratorInputTypes} from '../types/ConfiguratorInputTypes.sol'; - 12 : : - 13 : : /** - 14 : : * @title ConfiguratorLogic library - 15 : : * @author Aave - 16 : : * @notice Implements the functions to initialize reserves and update aTokens and debtTokens - 17 : : */ - 18 : : library ConfiguratorLogic { - 19 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 20 : : - 21 : : // See `IPoolConfigurator` for descriptions - 22 : : event ReserveInitialized( - 23 : : address indexed asset, - 24 : : address indexed aToken, - 25 : : address stableDebtToken, - 26 : : address variableDebtToken, - 27 : : address interestRateStrategyAddress - 28 : : ); - 29 : : event ATokenUpgraded( - 30 : : address indexed asset, - 31 : : address indexed proxy, - 32 : : address indexed implementation - 33 : : ); - 34 : : event StableDebtTokenUpgraded( - 35 : : address indexed asset, - 36 : : address indexed proxy, - 37 : : address indexed implementation - 38 : : ); - 39 : : event VariableDebtTokenUpgraded( - 40 : : address indexed asset, - 41 : : address indexed proxy, - 42 : : address indexed implementation - 43 : : ); - 44 : : - 45 : : /** - 46 : : * @notice Initialize a reserve by creating and initializing aToken, stable debt token and variable debt token - 47 : : * @dev Emits the `ReserveInitialized` event - 48 : : * @param pool The Pool in which the reserve will be initialized - 49 : : * @param input The needed parameters for the initialization - 50 : : */ - 51 : 2882 : function executeInitReserve( - 52 : : IPool pool, - 53 : : ConfiguratorInputTypes.InitReserveInput calldata input - 54 : : ) public { - 55 : 8646 : address aTokenProxyAddress = _initTokenWithProxy( - 56 : : input.aTokenImpl, - 57 : : abi.encodeWithSelector( - 58 : : IInitializableAToken.initialize.selector, - 59 : : pool, - 60 : : input.treasury, - 61 : : input.underlyingAsset, - 62 : : input.incentivesController, - 63 : : input.underlyingAssetDecimals, - 64 : : input.aTokenName, - 65 : : input.aTokenSymbol, - 66 : : input.params - 67 : : ) - 68 : : ); - 69 : : - 70 : 8646 : address stableDebtTokenProxyAddress = _initTokenWithProxy( - 71 : : input.stableDebtTokenImpl, - 72 : : abi.encodeWithSelector( - 73 : : IInitializableDebtToken.initialize.selector, - 74 : : pool, - 75 : : input.underlyingAsset, - 76 : : input.incentivesController, - 77 : : input.underlyingAssetDecimals, - 78 : : input.stableDebtTokenName, - 79 : : input.stableDebtTokenSymbol, - 80 : : input.params - 81 : : ) - 82 : : ); - 83 : : - 84 : 8646 : address variableDebtTokenProxyAddress = _initTokenWithProxy( - 85 : : input.variableDebtTokenImpl, - 86 : : abi.encodeWithSelector( - 87 : : IInitializableDebtToken.initialize.selector, - 88 : : pool, - 89 : : input.underlyingAsset, - 90 : : input.incentivesController, - 91 : : input.underlyingAssetDecimals, - 92 : : input.variableDebtTokenName, - 93 : : input.variableDebtTokenSymbol, - 94 : : input.params - 95 : : ) - 96 : : ); - 97 : : - 98 : 5764 : pool.initReserve( - 99 : : input.underlyingAsset, - 100 : : aTokenProxyAddress, - 101 : : stableDebtTokenProxyAddress, - 102 : : variableDebtTokenProxyAddress, - 103 : : input.interestRateStrategyAddress - 104 : : ); - 105 : : - 106 : 8643 : DataTypes.ReserveConfigurationMap memory currentConfig = DataTypes.ReserveConfigurationMap(0); + 11 : : import {Errors} from '../helpers/Errors.sol'; + 12 : : import {ConfiguratorInputTypes} from '../types/ConfiguratorInputTypes.sol'; + 13 : : import {IERC20Detailed} from '../../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 14 : : + 15 : : /** + 16 : : * @title ConfiguratorLogic library + 17 : : * @author Aave + 18 : : * @notice Implements the functions to initialize reserves and update aTokens and debtTokens + 19 : : */ + 20 : : library ConfiguratorLogic { + 21 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 22 : : + 23 : : // See `IPoolConfigurator` for descriptions + 24 : : event ReserveInitialized( + 25 : : address indexed asset, + 26 : : address indexed aToken, + 27 : : address stableDebtToken, + 28 : : address variableDebtToken, + 29 : : address interestRateStrategyAddress + 30 : : ); + 31 : : event ATokenUpgraded( + 32 : : address indexed asset, + 33 : : address indexed proxy, + 34 : : address indexed implementation + 35 : : ); + 36 : : event VariableDebtTokenUpgraded( + 37 : : address indexed asset, + 38 : : address indexed proxy, + 39 : : address indexed implementation + 40 : : ); + 41 : : + 42 : : /** + 43 : : * @notice Initialize a reserve by creating and initializing aToken and variable debt token + 44 : : * @dev Emits the `ReserveInitialized` event + 45 : : * @param pool The Pool in which the reserve will be initialized + 46 : : * @param input The needed parameters for the initialization + 47 : : */ + 48 : : function executeInitReserve( + 49 : : IPool pool, + 50 : : ConfiguratorInputTypes.InitReserveInput calldata input + 51 : : ) external { + 52 : : // It is an assumption that the asset listed is non-malicious, and the external call doesn't create re-entrancies + 53 : 167016 : uint8 underlyingAssetDecimals = IERC20Detailed(input.underlyingAsset).decimals(); + 54 : 167016 : require(underlyingAssetDecimals > 5, Errors.INVALID_DECIMALS); + 55 : : + 56 : 166016 : address aTokenProxyAddress = _initTokenWithProxy( + 57 : : input.aTokenImpl, + 58 : : abi.encodeWithSelector( + 59 : : IInitializableAToken.initialize.selector, + 60 : : pool, + 61 : : input.treasury, + 62 : : input.underlyingAsset, + 63 : : input.incentivesController, + 64 : : underlyingAssetDecimals, + 65 : : input.aTokenName, + 66 : : input.aTokenSymbol, + 67 : : input.params + 68 : : ) + 69 : : ); + 70 : : + 71 : 166016 : address variableDebtTokenProxyAddress = _initTokenWithProxy( + 72 : : input.variableDebtTokenImpl, + 73 : : abi.encodeWithSelector( + 74 : : IInitializableDebtToken.initialize.selector, + 75 : : pool, + 76 : : input.underlyingAsset, + 77 : : input.incentivesController, + 78 : : underlyingAssetDecimals, + 79 : : input.variableDebtTokenName, + 80 : : input.variableDebtTokenSymbol, + 81 : : input.params + 82 : : ) + 83 : : ); + 84 : : + 85 : 166016 : pool.initReserve( + 86 : : input.underlyingAsset, + 87 : : aTokenProxyAddress, + 88 : : variableDebtTokenProxyAddress, + 89 : : input.interestRateStrategyAddress + 90 : : ); + 91 : : + 92 : 165016 : DataTypes.ReserveConfigurationMap memory currentConfig = DataTypes.ReserveConfigurationMap(0); + 93 : : + 94 : 165016 : currentConfig.setDecimals(underlyingAssetDecimals); + 95 : : + 96 : 165016 : currentConfig.setActive(true); + 97 : 165016 : currentConfig.setPaused(false); + 98 : 165016 : currentConfig.setFrozen(false); + 99 : 165016 : currentConfig.setVirtualAccActive(input.useVirtualBalance); + 100 : : + 101 : 165016 : pool.setConfiguration(input.underlyingAsset, currentConfig); + 102 : : + 103 : 165016 : IReserveInterestRateStrategy(input.interestRateStrategyAddress).setInterestRateParams( + 104 : : input.underlyingAsset, + 105 : : input.interestRateData + 106 : : ); 107 : : - 108 : 5762 : currentConfig.setDecimals(input.underlyingAssetDecimals); - 109 : : - 110 : 5762 : currentConfig.setActive(true); - 111 : 5762 : currentConfig.setPaused(false); - 112 : 5762 : currentConfig.setFrozen(false); - 113 : 5762 : currentConfig.setVirtualAccActive(input.useVirtualBalance); - 114 : : - 115 : 5762 : pool.setConfiguration(input.underlyingAsset, currentConfig); + 108 : 165016 : emit ReserveInitialized( + 109 : : input.underlyingAsset, + 110 : : aTokenProxyAddress, + 111 : : address(0), + 112 : : variableDebtTokenProxyAddress, + 113 : : input.interestRateStrategyAddress + 114 : : ); + 115 : : } 116 : : - 117 : 5762 : IReserveInterestRateStrategy(input.interestRateStrategyAddress).setInterestRateParams( - 118 : : input.underlyingAsset, - 119 : : input.interestRateData - 120 : : ); - 121 : : - 122 : 5762 : emit ReserveInitialized( - 123 : : input.underlyingAsset, - 124 : : aTokenProxyAddress, - 125 : : stableDebtTokenProxyAddress, - 126 : : variableDebtTokenProxyAddress, - 127 : : input.interestRateStrategyAddress - 128 : : ); - 129 : : } + 117 : : /** + 118 : : * @notice Updates the aToken implementation and initializes it + 119 : : * @dev Emits the `ATokenUpgraded` event + 120 : : * @param cachedPool The Pool containing the reserve with the aToken + 121 : : * @param input The parameters needed for the initialize call + 122 : : */ + 123 : : function executeUpdateAToken( + 124 : : IPool cachedPool, + 125 : : ConfiguratorInputTypes.UpdateATokenInput calldata input + 126 : : ) external { + 127 : 1 : DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); + 128 : : + 129 : 1 : (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParams(); 130 : : - 131 : : /** - 132 : : * @notice Updates the aToken implementation and initializes it - 133 : : * @dev Emits the `ATokenUpgraded` event - 134 : : * @param cachedPool The Pool containing the reserve with the aToken - 135 : : * @param input The parameters needed for the initialize call - 136 : : */ - 137 : 1 : function executeUpdateAToken( - 138 : : IPool cachedPool, - 139 : : ConfiguratorInputTypes.UpdateATokenInput calldata input - 140 : : ) public { - 141 : 3 : DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); + 131 : 1 : bytes memory encodedCall = abi.encodeWithSelector( + 132 : : IInitializableAToken.initialize.selector, + 133 : : cachedPool, + 134 : : input.treasury, + 135 : : input.asset, + 136 : : input.incentivesController, + 137 : : decimals, + 138 : : input.name, + 139 : : input.symbol, + 140 : : input.params + 141 : : ); 142 : : - 143 : 3 : (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); + 143 : 1 : _upgradeTokenImplementation(reserveData.aTokenAddress, input.implementation, encodedCall); 144 : : - 145 : 3 : bytes memory encodedCall = abi.encodeWithSelector( - 146 : : IInitializableAToken.initialize.selector, - 147 : : cachedPool, - 148 : : input.treasury, - 149 : : input.asset, - 150 : : input.incentivesController, - 151 : : decimals, - 152 : : input.name, - 153 : : input.symbol, - 154 : : input.params - 155 : : ); - 156 : : - 157 : 2 : _upgradeTokenImplementation(reserveData.aTokenAddress, input.implementation, encodedCall); - 158 : : - 159 : 2 : emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); - 160 : : } + 145 : 1 : emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); + 146 : : } + 147 : : + 148 : : /** + 149 : : * @notice Updates the variable debt token implementation and initializes it + 150 : : * @dev Emits the `VariableDebtTokenUpgraded` event + 151 : : * @param cachedPool The Pool containing the reserve with the variable debt token + 152 : : * @param input The parameters needed for the initialize call + 153 : : */ + 154 : : function executeUpdateVariableDebtToken( + 155 : : IPool cachedPool, + 156 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input + 157 : : ) external { + 158 : 1 : DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); + 159 : : + 160 : 1 : (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParams(); 161 : : - 162 : : /** - 163 : : * @notice Updates the stable debt token implementation and initializes it - 164 : : * @dev Emits the `StableDebtTokenUpgraded` event - 165 : : * @param cachedPool The Pool containing the reserve with the stable debt token - 166 : : * @param input The parameters needed for the initialize call - 167 : : */ - 168 : 1 : function executeUpdateStableDebtToken( - 169 : : IPool cachedPool, - 170 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - 171 : : ) public { - 172 : 3 : DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); - 173 : : - 174 : 3 : (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); - 175 : : - 176 : 3 : bytes memory encodedCall = abi.encodeWithSelector( - 177 : : IInitializableDebtToken.initialize.selector, - 178 : : cachedPool, - 179 : : input.asset, - 180 : : input.incentivesController, - 181 : : decimals, - 182 : : input.name, - 183 : : input.symbol, - 184 : : input.params - 185 : : ); - 186 : : - 187 : 2 : _upgradeTokenImplementation( - 188 : : reserveData.stableDebtTokenAddress, - 189 : : input.implementation, - 190 : : encodedCall - 191 : : ); - 192 : : - 193 : 2 : emit StableDebtTokenUpgraded( - 194 : : input.asset, - 195 : : reserveData.stableDebtTokenAddress, - 196 : : input.implementation - 197 : : ); - 198 : : } + 162 : 1 : bytes memory encodedCall = abi.encodeWithSelector( + 163 : : IInitializableDebtToken.initialize.selector, + 164 : : cachedPool, + 165 : : input.asset, + 166 : : input.incentivesController, + 167 : : decimals, + 168 : : input.name, + 169 : : input.symbol, + 170 : : input.params + 171 : : ); + 172 : : + 173 : 1 : _upgradeTokenImplementation( + 174 : : reserveData.variableDebtTokenAddress, + 175 : : input.implementation, + 176 : : encodedCall + 177 : : ); + 178 : : + 179 : 1 : emit VariableDebtTokenUpgraded( + 180 : : input.asset, + 181 : : reserveData.variableDebtTokenAddress, + 182 : : input.implementation + 183 : : ); + 184 : : } + 185 : : + 186 : : /** + 187 : : * @notice Creates a new proxy and initializes the implementation + 188 : : * @param implementation The address of the implementation + 189 : : * @param initParams The parameters that is passed to the implementation to initialize + 190 : : * @return The address of initialized proxy + 191 : : */ + 192 : : function _initTokenWithProxy( + 193 : : address implementation, + 194 : : bytes memory initParams + 195 : : ) internal returns (address) { + 196 : 332032 : InitializableImmutableAdminUpgradeabilityProxy proxy = new InitializableImmutableAdminUpgradeabilityProxy( + 197 : : address(this) + 198 : : ); 199 : : - 200 : : /** - 201 : : * @notice Updates the variable debt token implementation and initializes it - 202 : : * @dev Emits the `VariableDebtTokenUpgraded` event - 203 : : * @param cachedPool The Pool containing the reserve with the variable debt token - 204 : : * @param input The parameters needed for the initialize call - 205 : : */ - 206 : 1 : function executeUpdateVariableDebtToken( - 207 : : IPool cachedPool, - 208 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - 209 : : ) public { - 210 : 3 : DataTypes.ReserveDataLegacy memory reserveData = cachedPool.getReserveData(input.asset); - 211 : : - 212 : 3 : (, , , uint256 decimals, , ) = cachedPool.getConfiguration(input.asset).getParams(); - 213 : : - 214 : 3 : bytes memory encodedCall = abi.encodeWithSelector( - 215 : : IInitializableDebtToken.initialize.selector, - 216 : : cachedPool, - 217 : : input.asset, - 218 : : input.incentivesController, - 219 : : decimals, - 220 : : input.name, - 221 : : input.symbol, - 222 : : input.params - 223 : : ); - 224 : : - 225 : 2 : _upgradeTokenImplementation( - 226 : : reserveData.variableDebtTokenAddress, - 227 : : input.implementation, - 228 : : encodedCall - 229 : : ); - 230 : : - 231 : 2 : emit VariableDebtTokenUpgraded( - 232 : : input.asset, - 233 : : reserveData.variableDebtTokenAddress, - 234 : : input.implementation - 235 : : ); - 236 : : } - 237 : : - 238 : : /** - 239 : : * @notice Creates a new proxy and initializes the implementation - 240 : : * @param implementation The address of the implementation - 241 : : * @param initParams The parameters that is passed to the implementation to initialize - 242 : : * @return The address of initialized proxy - 243 : : */ - 244 : 8646 : function _initTokenWithProxy( - 245 : : address implementation, - 246 : : bytes memory initParams - 247 : : ) internal returns (address) { - 248 : 25938 : InitializableImmutableAdminUpgradeabilityProxy proxy = new InitializableImmutableAdminUpgradeabilityProxy( - 249 : : address(this) - 250 : : ); - 251 : : - 252 : 17292 : proxy.initialize(implementation, initParams); - 253 : : - 254 : 25938 : return address(proxy); - 255 : : } - 256 : : - 257 : : /** - 258 : : * @notice Upgrades the implementation and makes call to the proxy - 259 : : * @dev The call is used to initialize the new implementation. - 260 : : * @param proxyAddress The address of the proxy - 261 : : * @param implementation The address of the new implementation - 262 : : * @param initParams The parameters to the call after the upgrade - 263 : : */ - 264 : 3 : function _upgradeTokenImplementation( - 265 : : address proxyAddress, - 266 : : address implementation, - 267 : : bytes memory initParams - 268 : : ) internal { - 269 : 9 : InitializableImmutableAdminUpgradeabilityProxy proxy = InitializableImmutableAdminUpgradeabilityProxy( - 270 : : payable(proxyAddress) - 271 : : ); - 272 : : - 273 : 6 : proxy.upgradeToAndCall(implementation, initParams); - 274 : : } - 275 : : } + 200 : 332032 : proxy.initialize(implementation, initParams); + 201 : : + 202 : 332032 : return address(proxy); + 203 : : } + 204 : : + 205 : : /** + 206 : : * @notice Upgrades the implementation and makes call to the proxy + 207 : : * @dev The call is used to initialize the new implementation. + 208 : : * @param proxyAddress The address of the proxy + 209 : : * @param implementation The address of the new implementation + 210 : : * @param initParams The parameters to the call after the upgrade + 211 : : */ + 212 : : function _upgradeTokenImplementation( + 213 : : address proxyAddress, + 214 : : address implementation, + 215 : : bytes memory initParams + 216 : : ) internal { + 217 : 2 : InitializableImmutableAdminUpgradeabilityProxy proxy = InitializableImmutableAdminUpgradeabilityProxy( + 218 : : payable(proxyAddress) + 219 : : ); + 220 : : + 221 : 2 : proxy.upgradeToAndCall(implementation, initParams); + 222 : : } + 223 : : } @@ -351,8 +299,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func-c.html b/report/protocol/libraries/logic/EModeLogic.sol.func-c.html similarity index 61% rename from report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func-c.html rename to report/protocol/libraries/logic/EModeLogic.sol.func-c.html index a08c245a..b91e86f1 100644 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func-c.html +++ b/report/protocol/libraries/logic/EModeLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/EModeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,28 +53,28 @@ - +
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - Helpers.sol (source / functions)top level - protocol/libraries/logic - EModeLogic.sol (source / functions) Coverage Lines: 100.0 %1155
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
Helpers.getUserCurrentDebtEModeLogic.executeSetUserEMode1632910023
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func.html b/report/protocol/libraries/logic/EModeLogic.sol.func.html similarity index 61% rename from report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func.html rename to report/protocol/libraries/logic/EModeLogic.sol.func.html index 19e5c2c8..da8b6f51 100644 --- a/report/core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol.func.html +++ b/report/protocol/libraries/logic/EModeLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers/Helpers.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/EModeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,28 +53,28 @@ - +
Current view:top level - core/contracts/protocol/libraries/helpers/src/core/contracts/protocol/libraries/helpers - Helpers.sol (source / functions)top level - protocol/libraries/logic - EModeLogic.sol (source / functions) Coverage Lines: 100.0 %1155
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
Helpers.getUserCurrentDebtEModeLogic.executeSetUserEMode1632910023
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.gcov.html b/report/protocol/libraries/logic/EModeLogic.sol.gcov.html similarity index 58% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.gcov.html rename to report/protocol/libraries/logic/EModeLogic.sol.gcov.html index 384dd6a1..8a40b95b 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/EModeLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/EModeLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/EModeLogic.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - EModeLogic.sol (source / functions)top level - protocol/libraries/logic - EModeLogic.sol (source / functions) Coverage Lines: 100.0 %121255
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3311
0 0
@@ -76,111 +76,71 @@ 5 : : import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; 6 : : import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; 7 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; - 8 : : import {Errors} from '../helpers/Errors.sol'; - 9 : : import {WadRayMath} from '../math/WadRayMath.sol'; - 10 : : import {PercentageMath} from '../math/PercentageMath.sol'; - 11 : : import {DataTypes} from '../types/DataTypes.sol'; - 12 : : import {ValidationLogic} from './ValidationLogic.sol'; - 13 : : import {ReserveLogic} from './ReserveLogic.sol'; - 14 : : - 15 : : /** - 16 : : * @title EModeLogic library - 17 : : * @author Aave - 18 : : * @notice Implements the base logic for all the actions related to the eMode - 19 : : */ - 20 : : library EModeLogic { - 21 : : using ReserveLogic for DataTypes.ReserveCache; - 22 : : using ReserveLogic for DataTypes.ReserveData; - 23 : : using GPv2SafeERC20 for IERC20; - 24 : : using UserConfiguration for DataTypes.UserConfigurationMap; - 25 : : using WadRayMath for uint256; - 26 : : using PercentageMath for uint256; - 27 : : - 28 : : // See `IPool` for descriptions - 29 : : event UserEModeSet(address indexed user, uint8 categoryId); - 30 : : - 31 : : /** - 32 : : * @notice Updates the user efficiency mode category - 33 : : * @dev Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD - 34 : : * @dev Emits the `UserEModeSet` event - 35 : : * @param reservesData The state of all the reserves - 36 : : * @param reservesList The addresses of all the active reserves - 37 : : * @param eModeCategories The configuration of all the efficiency mode categories - 38 : : * @param usersEModeCategory The state of all users efficiency mode category - 39 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - 40 : : * @param params The additional parameters needed to execute the setUserEMode function - 41 : : */ - 42 : 17 : function executeSetUserEMode( - 43 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 44 : : mapping(uint256 => address) storage reservesList, - 45 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 46 : : mapping(address => uint8) storage usersEModeCategory, - 47 : : DataTypes.UserConfigurationMap storage userConfig, - 48 : : DataTypes.ExecuteSetUserEModeParams memory params - 49 : : ) external { - 50 : 34 : ValidationLogic.validateSetUserEMode( - 51 : : reservesData, - 52 : : reservesList, - 53 : : eModeCategories, - 54 : : userConfig, - 55 : : params.reservesCount, - 56 : : params.categoryId - 57 : : ); - 58 : : - 59 : 30 : uint8 prevCategoryId = usersEModeCategory[msg.sender]; - 60 : 30 : usersEModeCategory[msg.sender] = params.categoryId; - 61 : : - 62 : 30 : if (prevCategoryId != 0) { - 63 : 8 : ValidationLogic.validateHealthFactor( - 64 : : reservesData, - 65 : : reservesList, - 66 : : eModeCategories, - 67 : : userConfig, - 68 : : msg.sender, - 69 : : params.categoryId, - 70 : : params.reservesCount, - 71 : : params.oracle - 72 : : ); - 73 : : } - 74 : 26 : emit UserEModeSet(msg.sender, params.categoryId); - 75 : : } - 76 : : - 77 : : /** - 78 : : * @notice Gets the eMode configuration and calculates the eMode asset price if a custom oracle is configured - 79 : : * @dev The eMode asset price returned is 0 if no oracle is specified - 80 : : * @param category The user eMode category - 81 : : * @param oracle The price oracle - 82 : : * @return The eMode ltv - 83 : : * @return The eMode liquidation threshold - 84 : : * @return The eMode asset price - 85 : : */ - 86 : 10 : function getEModeConfiguration( - 87 : : DataTypes.EModeCategory storage category, - 88 : : IPriceOracleGetter oracle - 89 : : ) internal view returns (uint256, uint256, uint256) { - 90 : 20 : uint256 eModeAssetPrice = 0; - 91 : 20 : address eModePriceSource = category.priceSource; - 92 : : - 93 : 30 : if (eModePriceSource != address(0)) { - 94 : 6 : eModeAssetPrice = oracle.getAssetPrice(eModePriceSource); - 95 : : } - 96 : : - 97 : 20 : return (category.ltv, category.liquidationThreshold, eModeAssetPrice); - 98 : : } - 99 : : - 100 : : /** - 101 : : * @notice Checks if eMode is active for a user and if yes, if the asset belongs to the eMode category chosen - 102 : : * @param eModeUserCategory The user eMode category - 103 : : * @param eModeAssetCategory The asset eMode category - 104 : : * @return True if eMode is active and the asset belongs to the eMode category chosen by the user, false otherwise - 105 : : */ - 106 : 25421 : function isInEModeCategory( - 107 : : uint256 eModeUserCategory, - 108 : : uint256 eModeAssetCategory - 109 : : ) internal pure returns (bool) { - 110 : 50842 : return (eModeUserCategory != 0 && eModeAssetCategory == eModeUserCategory); - 111 : : } - 112 : : } + 8 : : import {WadRayMath} from '../math/WadRayMath.sol'; + 9 : : import {PercentageMath} from '../math/PercentageMath.sol'; + 10 : : import {DataTypes} from '../types/DataTypes.sol'; + 11 : : import {ValidationLogic} from './ValidationLogic.sol'; + 12 : : import {ReserveLogic} from './ReserveLogic.sol'; + 13 : : + 14 : : /** + 15 : : * @title EModeLogic library + 16 : : * @author Aave + 17 : : * @notice Implements the base logic for all the actions related to the eMode + 18 : : */ + 19 : : library EModeLogic { + 20 : : using ReserveLogic for DataTypes.ReserveCache; + 21 : : using ReserveLogic for DataTypes.ReserveData; + 22 : : using GPv2SafeERC20 for IERC20; + 23 : : using UserConfiguration for DataTypes.UserConfigurationMap; + 24 : : using WadRayMath for uint256; + 25 : : using PercentageMath for uint256; + 26 : : + 27 : : // See `IPool` for descriptions + 28 : : event UserEModeSet(address indexed user, uint8 categoryId); + 29 : : + 30 : : /** + 31 : : * @notice Updates the user efficiency mode category + 32 : : * @dev Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD + 33 : : * @dev Emits the `UserEModeSet` event + 34 : : * @param reservesData The state of all the reserves + 35 : : * @param reservesList The addresses of all the active reserves + 36 : : * @param eModeCategories The configuration of all the efficiency mode categories + 37 : : * @param usersEModeCategory The state of all users efficiency mode category + 38 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets + 39 : : * @param params The additional parameters needed to execute the setUserEMode function + 40 : : */ + 41 : : function executeSetUserEMode( + 42 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 43 : : mapping(uint256 => address) storage reservesList, + 44 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 45 : : mapping(address => uint8) storage usersEModeCategory, + 46 : : DataTypes.UserConfigurationMap storage userConfig, + 47 : : DataTypes.ExecuteSetUserEModeParams memory params + 48 : : ) external { + 49 : 10023 : if (usersEModeCategory[msg.sender] == params.categoryId) return; + 50 : : + 51 : 9617 : ValidationLogic.validateSetUserEMode( + 52 : : eModeCategories, + 53 : : userConfig, + 54 : : params.reservesCount, + 55 : : params.categoryId + 56 : : ); + 57 : : + 58 : 8614 : usersEModeCategory[msg.sender] = params.categoryId; + 59 : : + 60 : 8614 : ValidationLogic.validateHealthFactor( + 61 : : reservesData, + 62 : : reservesList, + 63 : : eModeCategories, + 64 : : userConfig, + 65 : : msg.sender, + 66 : : params.categoryId, + 67 : : params.reservesCount, + 68 : : params.oracle + 69 : : ); + 70 : 7612 : emit UserEModeSet(msg.sender, params.categoryId); + 71 : : } + 72 : : } @@ -188,8 +148,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html b/report/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html similarity index 64% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html rename to report/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html index 0c15f6b5..7b2a86e7 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/FlashLoanLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/FlashLoanLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,42 +53,42 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - FlashLoanLogic.sol (source / functions)top level - protocol/libraries/logic - FlashLoanLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + @@ -96,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
FlashLoanLogic._handleFlashLoanRepaymentFlashLoanLogic._handleFlashLoanRepayment 9
FlashLoanLogic.executeFlashLoanFlashLoanLogic.executeFlashLoanSimple1011
FlashLoanLogic.executeFlashLoanSimpleFlashLoanLogic.executeFlashLoan101011
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func.html b/report/protocol/libraries/logic/FlashLoanLogic.sol.func.html similarity index 64% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func.html rename to report/protocol/libraries/logic/FlashLoanLogic.sol.func.html index 109511c1..8a6facb9 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.func.html +++ b/report/protocol/libraries/logic/FlashLoanLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/FlashLoanLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,42 +53,42 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - FlashLoanLogic.sol (source / functions)top level - protocol/libraries/logic - FlashLoanLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + @@ -96,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
FlashLoanLogic._handleFlashLoanRepaymentFlashLoanLogic._handleFlashLoanRepayment 9
FlashLoanLogic.executeFlashLoanFlashLoanLogic.executeFlashLoan101011
FlashLoanLogic.executeFlashLoanSimpleFlashLoanLogic.executeFlashLoanSimple1011
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html b/report/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html similarity index 86% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html rename to report/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html index e1f8cbf5..fe13e711 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/FlashLoanLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/FlashLoanLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/FlashLoanLogic.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - FlashLoanLogic.sol (source / functions)top level - protocol/libraries/logic - FlashLoanLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -77,282 +77,275 @@ 6 : : import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; 7 : : import {IAToken} from '../../../interfaces/IAToken.sol'; 8 : : import {IPool} from '../../../interfaces/IPool.sol'; - 9 : : import {IFlashLoanReceiver} from '../../../flashloan/interfaces/IFlashLoanReceiver.sol'; - 10 : : import {IFlashLoanSimpleReceiver} from '../../../flashloan/interfaces/IFlashLoanSimpleReceiver.sol'; + 9 : : import {IFlashLoanReceiver} from '../../../misc/flashloan/interfaces/IFlashLoanReceiver.sol'; + 10 : : import {IFlashLoanSimpleReceiver} from '../../../misc/flashloan/interfaces/IFlashLoanSimpleReceiver.sol'; 11 : : import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; - 12 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; - 13 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; - 14 : : import {Errors} from '../helpers/Errors.sol'; - 15 : : import {WadRayMath} from '../math/WadRayMath.sol'; - 16 : : import {PercentageMath} from '../math/PercentageMath.sol'; - 17 : : import {DataTypes} from '../types/DataTypes.sol'; - 18 : : import {ValidationLogic} from './ValidationLogic.sol'; - 19 : : import {BorrowLogic} from './BorrowLogic.sol'; - 20 : : import {ReserveLogic} from './ReserveLogic.sol'; - 21 : : - 22 : : /** - 23 : : * @title FlashLoanLogic library - 24 : : * @author Aave - 25 : : * @notice Implements the logic for the flash loans - 26 : : */ - 27 : : library FlashLoanLogic { - 28 : : using ReserveLogic for DataTypes.ReserveCache; - 29 : : using ReserveLogic for DataTypes.ReserveData; - 30 : : using GPv2SafeERC20 for IERC20; - 31 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 32 : : using WadRayMath for uint256; - 33 : : using PercentageMath for uint256; - 34 : : using SafeCast for uint256; - 35 : : - 36 : : // See `IPool` for descriptions - 37 : : event FlashLoan( - 38 : : address indexed target, - 39 : : address initiator, - 40 : : address indexed asset, - 41 : : uint256 amount, - 42 : : DataTypes.InterestRateMode interestRateMode, - 43 : : uint256 premium, - 44 : : uint16 indexed referralCode - 45 : : ); - 46 : : - 47 : : // Helper struct for internal variables used in the `executeFlashLoan` function - 48 : : struct FlashLoanLocalVars { - 49 : : IFlashLoanReceiver receiver; - 50 : : uint256 i; - 51 : : address currentAsset; - 52 : : uint256 currentAmount; - 53 : : uint256[] totalPremiums; - 54 : : uint256 flashloanPremiumTotal; - 55 : : uint256 flashloanPremiumToProtocol; - 56 : : } - 57 : : - 58 : : /** - 59 : : * @notice Implements the flashloan feature that allow users to access liquidity of the pool for one transaction - 60 : : * as long as the amount taken plus fee is returned or debt is opened. - 61 : : * @dev For authorized flashborrowers the fee is waived - 62 : : * @dev At the end of the transaction the pool will pull amount borrowed + fee from the receiver, - 63 : : * if the receiver have not approved the pool the transaction will revert. - 64 : : * @dev Emits the `FlashLoan()` event - 65 : : * @param reservesData The state of all the reserves - 66 : : * @param reservesList The addresses of all the active reserves - 67 : : * @param eModeCategories The configuration of all the efficiency mode categories - 68 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets - 69 : : * @param params The additional parameters needed to execute the flashloan function - 70 : : */ - 71 : 10 : function executeFlashLoan( - 72 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 73 : : mapping(uint256 => address) storage reservesList, - 74 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 75 : : DataTypes.UserConfigurationMap storage userConfig, - 76 : : DataTypes.FlashloanParams memory params - 77 : : ) external { - 78 : : // The usual action flow (cache -> updateState -> validation -> changeState -> updateRates) - 79 : : // is altered to (validation -> user payload -> cache -> updateState -> changeState -> updateRates) for flashloans. - 80 : : // This is done to protect against reentrance and rate manipulation within the user specified payload. + 12 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; + 13 : : import {Errors} from '../helpers/Errors.sol'; + 14 : : import {WadRayMath} from '../math/WadRayMath.sol'; + 15 : : import {PercentageMath} from '../math/PercentageMath.sol'; + 16 : : import {DataTypes} from '../types/DataTypes.sol'; + 17 : : import {ValidationLogic} from './ValidationLogic.sol'; + 18 : : import {BorrowLogic} from './BorrowLogic.sol'; + 19 : : import {ReserveLogic} from './ReserveLogic.sol'; + 20 : : + 21 : : /** + 22 : : * @title FlashLoanLogic library + 23 : : * @author Aave + 24 : : * @notice Implements the logic for the flash loans + 25 : : */ + 26 : : library FlashLoanLogic { + 27 : : using ReserveLogic for DataTypes.ReserveCache; + 28 : : using ReserveLogic for DataTypes.ReserveData; + 29 : : using GPv2SafeERC20 for IERC20; + 30 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 31 : : using WadRayMath for uint256; + 32 : : using PercentageMath for uint256; + 33 : : using SafeCast for uint256; + 34 : : + 35 : : // See `IPool` for descriptions + 36 : : event FlashLoan( + 37 : : address indexed target, + 38 : : address initiator, + 39 : : address indexed asset, + 40 : : uint256 amount, + 41 : : DataTypes.InterestRateMode interestRateMode, + 42 : : uint256 premium, + 43 : : uint16 indexed referralCode + 44 : : ); + 45 : : + 46 : : // Helper struct for internal variables used in the `executeFlashLoan` function + 47 : : struct FlashLoanLocalVars { + 48 : : IFlashLoanReceiver receiver; + 49 : : address currentAsset; + 50 : : uint256 currentAmount; + 51 : : uint256[] totalPremiums; + 52 : : uint256 flashloanPremiumTotal; + 53 : : uint256 flashloanPremiumToProtocol; + 54 : : } + 55 : : + 56 : : /** + 57 : : * @notice Implements the flashloan feature that allow users to access liquidity of the pool for one transaction + 58 : : * as long as the amount taken plus fee is returned or debt is opened. + 59 : : * @dev For authorized flashborrowers the fee is waived + 60 : : * @dev At the end of the transaction the pool will pull amount borrowed + fee from the receiver, + 61 : : * if the receiver have not approved the pool the transaction will revert. + 62 : : * @dev Emits the `FlashLoan()` event + 63 : : * @param reservesData The state of all the reserves + 64 : : * @param reservesList The addresses of all the active reserves + 65 : : * @param eModeCategories The configuration of all the efficiency mode categories + 66 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets + 67 : : * @param params The additional parameters needed to execute the flashloan function + 68 : : */ + 69 : : function executeFlashLoan( + 70 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 71 : : mapping(uint256 => address) storage reservesList, + 72 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 73 : : DataTypes.UserConfigurationMap storage userConfig, + 74 : : DataTypes.FlashloanParams memory params + 75 : : ) external { + 76 : : // The usual action flow (cache -> updateState -> validation -> changeState -> updateRates) + 77 : : // is altered to (validation -> user payload -> cache -> updateState -> changeState -> updateRates) for flashloans. + 78 : : // This is done to protect against reentrance and rate manipulation within the user specified payload. + 79 : : + 80 : 1011 : ValidationLogic.validateFlashloan(reservesData, params.assets, params.amounts); 81 : : - 82 : 20 : ValidationLogic.validateFlashloan(reservesData, params.assets, params.amounts); + 82 : 7 : FlashLoanLocalVars memory vars; 83 : : - 84 : 12 : FlashLoanLocalVars memory vars; + 84 : 7 : vars.totalPremiums = new uint256[](params.assets.length); 85 : : - 86 : 12 : vars.totalPremiums = new uint256[](params.assets.length); - 87 : : - 88 : 12 : vars.receiver = IFlashLoanReceiver(params.receiverAddress); - 89 : 12 : (vars.flashloanPremiumTotal, vars.flashloanPremiumToProtocol) = params.isAuthorizedFlashBorrower - 90 : : ? (0, 0) - 91 : : : (params.flashLoanPremiumTotal, params.flashLoanPremiumToProtocol); - 92 : : - 93 : 32 : for (vars.i = 0; vars.i < params.assets.length; vars.i++) { - 94 : 14 : vars.currentAmount = params.amounts[vars.i]; - 95 : 14 : vars.totalPremiums[vars.i] = DataTypes.InterestRateMode(params.interestRateModes[vars.i]) == - 96 : : DataTypes.InterestRateMode.NONE - 97 : : ? vars.currentAmount.percentMul(vars.flashloanPremiumTotal) - 98 : : : 0; - 99 : : - 100 : 14 : if (reservesData[params.assets[vars.i]].configuration.getIsVirtualAccActive()) { - 101 : 14 : reservesData[params.assets[vars.i]].virtualUnderlyingBalance -= vars - 102 : : .currentAmount - 103 : : .toUint128(); - 104 : : } - 105 : : - 106 : 14 : IAToken(reservesData[params.assets[vars.i]].aTokenAddress).transferUnderlyingTo( - 107 : : params.receiverAddress, - 108 : : vars.currentAmount - 109 : : ); - 110 : : } - 111 : : - 112 : 12 : require( - 113 : : vars.receiver.executeOperation( - 114 : : params.assets, - 115 : : params.amounts, - 116 : : vars.totalPremiums, - 117 : : msg.sender, - 118 : : params.params - 119 : : ), - 120 : : Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN - 121 : : ); + 86 : 7 : vars.receiver = IFlashLoanReceiver(params.receiverAddress); + 87 : 7 : (vars.flashloanPremiumTotal, vars.flashloanPremiumToProtocol) = params.isAuthorizedFlashBorrower + 88 : : ? (0, 0) + 89 : : : (params.flashLoanPremiumTotal, params.flashLoanPremiumToProtocol); + 90 : : + 91 : 7 : for (uint256 i = 0; i < params.assets.length; i++) { + 92 : 8 : vars.currentAmount = params.amounts[i]; + 93 : 8 : vars.totalPremiums[i] = DataTypes.InterestRateMode(params.interestRateModes[i]) == + 94 : : DataTypes.InterestRateMode.NONE + 95 : : ? vars.currentAmount.percentMul(vars.flashloanPremiumTotal) + 96 : : : 0; + 97 : : + 98 : 8 : if (reservesData[params.assets[i]].configuration.getIsVirtualAccActive()) { + 99 : 8 : reservesData[params.assets[i]].virtualUnderlyingBalance -= vars.currentAmount.toUint128(); + 100 : : } + 101 : : + 102 : 8 : IAToken(reservesData[params.assets[i]].aTokenAddress).transferUnderlyingTo( + 103 : : params.receiverAddress, + 104 : : vars.currentAmount + 105 : : ); + 106 : : } + 107 : : + 108 : 7 : require( + 109 : : vars.receiver.executeOperation( + 110 : : params.assets, + 111 : : params.amounts, + 112 : : vars.totalPremiums, + 113 : : msg.sender, + 114 : : params.params + 115 : : ), + 116 : : Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN + 117 : : ); + 118 : : + 119 : 4 : for (uint256 i = 0; i < params.assets.length; i++) { + 120 : 5 : vars.currentAsset = params.assets[i]; + 121 : 5 : vars.currentAmount = params.amounts[i]; 122 : : - 123 : 17 : for (vars.i = 0; vars.i < params.assets.length; vars.i++) { - 124 : 8 : vars.currentAsset = params.assets[vars.i]; - 125 : 8 : vars.currentAmount = params.amounts[vars.i]; - 126 : : - 127 : : if ( - 128 : 12 : DataTypes.InterestRateMode(params.interestRateModes[vars.i]) == - 129 : : DataTypes.InterestRateMode.NONE - 130 : : ) { - 131 : 6 : _handleFlashLoanRepayment( - 132 : : reservesData[vars.currentAsset], - 133 : : DataTypes.FlashLoanRepaymentParams({ - 134 : : asset: vars.currentAsset, - 135 : : receiverAddress: params.receiverAddress, - 136 : : amount: vars.currentAmount, - 137 : : totalPremium: vars.totalPremiums[vars.i], - 138 : : flashLoanPremiumToProtocol: vars.flashloanPremiumToProtocol, - 139 : : referralCode: params.referralCode - 140 : : }) - 141 : : ); - 142 : : } else { - 143 : : // If the user chose to not return the funds, the system checks if there is enough collateral and - 144 : : // eventually opens a debt position - 145 : 2 : BorrowLogic.executeBorrow( - 146 : : reservesData, - 147 : : reservesList, - 148 : : eModeCategories, - 149 : : userConfig, - 150 : : DataTypes.ExecuteBorrowParams({ - 151 : : asset: vars.currentAsset, - 152 : : user: msg.sender, - 153 : : onBehalfOf: params.onBehalfOf, - 154 : : amount: vars.currentAmount, - 155 : : interestRateMode: DataTypes.InterestRateMode(params.interestRateModes[vars.i]), - 156 : : referralCode: params.referralCode, - 157 : : releaseUnderlying: false, - 158 : : maxStableRateBorrowSizePercent: IPool(params.pool) - 159 : : .MAX_STABLE_RATE_BORROW_SIZE_PERCENT(), - 160 : : reservesCount: IPool(params.pool).getReservesCount(), - 161 : : oracle: IPoolAddressesProvider(params.addressesProvider).getPriceOracle(), - 162 : : userEModeCategory: IPool(params.pool).getUserEMode(params.onBehalfOf).toUint8(), - 163 : : priceOracleSentinel: IPoolAddressesProvider(params.addressesProvider) - 164 : : .getPriceOracleSentinel() - 165 : : }) - 166 : : ); - 167 : : // no premium is paid when taking on the flashloan as debt - 168 : 2 : emit FlashLoan( - 169 : : params.receiverAddress, - 170 : : msg.sender, - 171 : : vars.currentAsset, - 172 : : vars.currentAmount, - 173 : : DataTypes.InterestRateMode(params.interestRateModes[vars.i]), - 174 : : 0, - 175 : : params.referralCode - 176 : : ); - 177 : : } - 178 : : } - 179 : : } - 180 : : - 181 : : /** - 182 : : * @notice Implements the simple flashloan feature that allow users to access liquidity of ONE reserve for one - 183 : : * transaction as long as the amount taken plus fee is returned. - 184 : : * @dev Does not waive fee for approved flashborrowers nor allow taking on debt instead of repaying to save gas - 185 : : * @dev At the end of the transaction the pool will pull amount borrowed + fee from the receiver, - 186 : : * if the receiver have not approved the pool the transaction will revert. - 187 : : * @dev Emits the `FlashLoan()` event - 188 : : * @param reserve The state of the flashloaned reserve - 189 : : * @param params The additional parameters needed to execute the simple flashloan function - 190 : : */ - 191 : 10 : function executeFlashLoanSimple( - 192 : : DataTypes.ReserveData storage reserve, - 193 : : DataTypes.FlashloanSimpleParams memory params - 194 : : ) external { - 195 : : // The usual action flow (cache -> updateState -> validation -> changeState -> updateRates) - 196 : : // is altered to (validation -> user payload -> cache -> updateState -> changeState -> updateRates) for flashloans. - 197 : : // This is done to protect against reentrance and rate manipulation within the user specified payload. - 198 : : - 199 : 20 : ValidationLogic.validateFlashloanSimple(reserve, params.amount); + 123 : : if ( + 124 : 5 : DataTypes.InterestRateMode(params.interestRateModes[i]) == DataTypes.InterestRateMode.NONE + 125 : : ) { + 126 : 3 : _handleFlashLoanRepayment( + 127 : : reservesData[vars.currentAsset], + 128 : : DataTypes.FlashLoanRepaymentParams({ + 129 : : asset: vars.currentAsset, + 130 : : receiverAddress: params.receiverAddress, + 131 : : amount: vars.currentAmount, + 132 : : totalPremium: vars.totalPremiums[i], + 133 : : flashLoanPremiumToProtocol: vars.flashloanPremiumToProtocol, + 134 : : referralCode: params.referralCode + 135 : : }) + 136 : : ); + 137 : : } else { + 138 : : // If the user chose to not return the funds, the system checks if there is enough collateral and + 139 : : // eventually opens a debt position + 140 : 2 : BorrowLogic.executeBorrow( + 141 : : reservesData, + 142 : : reservesList, + 143 : : eModeCategories, + 144 : : userConfig, + 145 : : DataTypes.ExecuteBorrowParams({ + 146 : : asset: vars.currentAsset, + 147 : : user: msg.sender, + 148 : : onBehalfOf: params.onBehalfOf, + 149 : : amount: vars.currentAmount, + 150 : : interestRateMode: DataTypes.InterestRateMode(params.interestRateModes[i]), + 151 : : referralCode: params.referralCode, + 152 : : releaseUnderlying: false, + 153 : : reservesCount: IPool(params.pool).getReservesCount(), + 154 : : oracle: IPoolAddressesProvider(params.addressesProvider).getPriceOracle(), + 155 : : userEModeCategory: IPool(params.pool).getUserEMode(params.onBehalfOf).toUint8(), + 156 : : priceOracleSentinel: IPoolAddressesProvider(params.addressesProvider) + 157 : : .getPriceOracleSentinel() + 158 : : }) + 159 : : ); + 160 : : // no premium is paid when taking on the flashloan as debt + 161 : 1 : emit FlashLoan( + 162 : : params.receiverAddress, + 163 : : msg.sender, + 164 : : vars.currentAsset, + 165 : : vars.currentAmount, + 166 : : DataTypes.InterestRateMode(params.interestRateModes[i]), + 167 : : 0, + 168 : : params.referralCode + 169 : : ); + 170 : : } + 171 : : } + 172 : : } + 173 : : + 174 : : /** + 175 : : * @notice Implements the simple flashloan feature that allow users to access liquidity of ONE reserve for one + 176 : : * transaction as long as the amount taken plus fee is returned. + 177 : : * @dev Does not waive fee for approved flashborrowers nor allow taking on debt instead of repaying to save gas + 178 : : * @dev At the end of the transaction the pool will pull amount borrowed + fee from the receiver, + 179 : : * if the receiver have not approved the pool the transaction will revert. + 180 : : * @dev Emits the `FlashLoan()` event + 181 : : * @param reserve The state of the flashloaned reserve + 182 : : * @param params The additional parameters needed to execute the simple flashloan function + 183 : : */ + 184 : : function executeFlashLoanSimple( + 185 : : DataTypes.ReserveData storage reserve, + 186 : : DataTypes.FlashloanSimpleParams memory params + 187 : : ) external { + 188 : : // The usual action flow (cache -> updateState -> validation -> changeState -> updateRates) + 189 : : // is altered to (validation -> user payload -> cache -> updateState -> changeState -> updateRates) for flashloans. + 190 : : // This is done to protect against reentrance and rate manipulation within the user specified payload. + 191 : : + 192 : 11 : ValidationLogic.validateFlashloanSimple(reserve, params.amount); + 193 : : + 194 : 10 : IFlashLoanSimpleReceiver receiver = IFlashLoanSimpleReceiver(params.receiverAddress); + 195 : 10 : uint256 totalPremium = params.amount.percentMul(params.flashLoanPremiumTotal); + 196 : : + 197 : 10 : if (reserve.configuration.getIsVirtualAccActive()) { + 198 : 10 : reserve.virtualUnderlyingBalance -= params.amount.toUint128(); + 199 : : } 200 : : - 201 : 27 : IFlashLoanSimpleReceiver receiver = IFlashLoanSimpleReceiver(params.receiverAddress); - 202 : 27 : uint256 totalPremium = params.amount.percentMul(params.flashLoanPremiumTotal); - 203 : : - 204 : 18 : if (reserve.configuration.getIsVirtualAccActive()) { - 205 : 18 : reserve.virtualUnderlyingBalance -= params.amount.toUint128(); - 206 : : } - 207 : : - 208 : 18 : IAToken(reserve.aTokenAddress).transferUnderlyingTo(params.receiverAddress, params.amount); - 209 : : - 210 : 18 : require( - 211 : : receiver.executeOperation( - 212 : : params.asset, - 213 : : params.amount, - 214 : : totalPremium, - 215 : : msg.sender, - 216 : : params.params - 217 : : ), - 218 : : Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN - 219 : : ); - 220 : : - 221 : 12 : _handleFlashLoanRepayment( - 222 : : reserve, - 223 : : DataTypes.FlashLoanRepaymentParams({ - 224 : : asset: params.asset, - 225 : : receiverAddress: params.receiverAddress, - 226 : : amount: params.amount, - 227 : : totalPremium: totalPremium, - 228 : : flashLoanPremiumToProtocol: params.flashLoanPremiumToProtocol, - 229 : : referralCode: params.referralCode - 230 : : }) - 231 : : ); - 232 : : } - 233 : : - 234 : : /** - 235 : : * @notice Handles repayment of flashloaned assets + premium - 236 : : * @dev Will pull the amount + premium from the receiver, so must have approved pool - 237 : : * @param reserve The state of the flashloaned reserve - 238 : : * @param params The additional parameters needed to execute the repayment function - 239 : : */ - 240 : 9 : function _handleFlashLoanRepayment( - 241 : : DataTypes.ReserveData storage reserve, - 242 : : DataTypes.FlashLoanRepaymentParams memory params - 243 : : ) internal { - 244 : 27 : uint256 premiumToProtocol = params.totalPremium.percentMul(params.flashLoanPremiumToProtocol); - 245 : 27 : uint256 premiumToLP = params.totalPremium - premiumToProtocol; - 246 : 27 : uint256 amountPlusPremium = params.amount + params.totalPremium; - 247 : : - 248 : 27 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 249 : 18 : reserve.updateState(reserveCache); - 250 : 18 : reserveCache.nextLiquidityIndex = reserve.cumulateToLiquidityIndex( - 251 : : IERC20(reserveCache.aTokenAddress).totalSupply() + - 252 : : uint256(reserve.accruedToTreasury).rayMul(reserveCache.nextLiquidityIndex), - 253 : : premiumToLP - 254 : : ); - 255 : : - 256 : 18 : reserve.accruedToTreasury += premiumToProtocol - 257 : : .rayDiv(reserveCache.nextLiquidityIndex) - 258 : : .toUint128(); - 259 : : - 260 : 18 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, amountPlusPremium, 0); - 261 : : - 262 : 18 : IERC20(params.asset).safeTransferFrom( + 201 : 10 : IAToken(reserve.aTokenAddress).transferUnderlyingTo(params.receiverAddress, params.amount); + 202 : : + 203 : 10 : require( + 204 : : receiver.executeOperation( + 205 : : params.asset, + 206 : : params.amount, + 207 : : totalPremium, + 208 : : msg.sender, + 209 : : params.params + 210 : : ), + 211 : : Errors.INVALID_FLASHLOAN_EXECUTOR_RETURN + 212 : : ); + 213 : : + 214 : 6 : _handleFlashLoanRepayment( + 215 : : reserve, + 216 : : DataTypes.FlashLoanRepaymentParams({ + 217 : : asset: params.asset, + 218 : : receiverAddress: params.receiverAddress, + 219 : : amount: params.amount, + 220 : : totalPremium: totalPremium, + 221 : : flashLoanPremiumToProtocol: params.flashLoanPremiumToProtocol, + 222 : : referralCode: params.referralCode + 223 : : }) + 224 : : ); + 225 : : } + 226 : : + 227 : : /** + 228 : : * @notice Handles repayment of flashloaned assets + premium + 229 : : * @dev Will pull the amount + premium from the receiver, so must have approved pool + 230 : : * @param reserve The state of the flashloaned reserve + 231 : : * @param params The additional parameters needed to execute the repayment function + 232 : : */ + 233 : : function _handleFlashLoanRepayment( + 234 : : DataTypes.ReserveData storage reserve, + 235 : : DataTypes.FlashLoanRepaymentParams memory params + 236 : : ) internal { + 237 : 9 : uint256 premiumToProtocol = params.totalPremium.percentMul(params.flashLoanPremiumToProtocol); + 238 : 9 : uint256 premiumToLP = params.totalPremium - premiumToProtocol; + 239 : 9 : uint256 amountPlusPremium = params.amount + params.totalPremium; + 240 : : + 241 : 9 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 242 : 9 : reserve.updateState(reserveCache); + 243 : 9 : reserveCache.nextLiquidityIndex = reserve.cumulateToLiquidityIndex( + 244 : : IERC20(reserveCache.aTokenAddress).totalSupply() + + 245 : : uint256(reserve.accruedToTreasury).rayMul(reserveCache.nextLiquidityIndex), + 246 : : premiumToLP + 247 : : ); + 248 : : + 249 : 9 : reserve.accruedToTreasury += premiumToProtocol + 250 : : .rayDiv(reserveCache.nextLiquidityIndex) + 251 : : .toUint128(); + 252 : : + 253 : 9 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, amountPlusPremium, 0); + 254 : : + 255 : 9 : IERC20(params.asset).safeTransferFrom( + 256 : : params.receiverAddress, + 257 : : reserveCache.aTokenAddress, + 258 : : amountPlusPremium + 259 : : ); + 260 : : + 261 : 9 : IAToken(reserveCache.aTokenAddress).handleRepayment( + 262 : : params.receiverAddress, 263 : : params.receiverAddress, - 264 : : reserveCache.aTokenAddress, - 265 : : amountPlusPremium - 266 : : ); - 267 : : - 268 : 18 : IAToken(reserveCache.aTokenAddress).handleRepayment( - 269 : : params.receiverAddress, - 270 : : params.receiverAddress, - 271 : : amountPlusPremium - 272 : : ); - 273 : : - 274 : 18 : emit FlashLoan( - 275 : : params.receiverAddress, - 276 : : msg.sender, - 277 : : params.asset, - 278 : : params.amount, - 279 : : DataTypes.InterestRateMode(0), - 280 : : params.totalPremium, - 281 : : params.referralCode - 282 : : ); - 283 : : } - 284 : : } + 264 : : amountPlusPremium + 265 : : ); + 266 : : + 267 : 9 : emit FlashLoan( + 268 : : params.receiverAddress, + 269 : : msg.sender, + 270 : : params.asset, + 271 : : params.amount, + 272 : : DataTypes.InterestRateMode.NONE, + 273 : : params.totalPremium, + 274 : : params.referralCode + 275 : : ); + 276 : : } + 277 : : } @@ -360,8 +353,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html b/report/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html similarity index 65% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html rename to report/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html index c37d4afa..529e0686 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/IsolationModeLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/IsolationModeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,28 +53,28 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - IsolationModeLogic.sol (source / functions)top level - protocol/libraries/logic - IsolationModeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
IsolationModeLogic.updateIsolatedDebtIfIsolated1103613035
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func.html b/report/protocol/libraries/logic/IsolationModeLogic.sol.func.html similarity index 65% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func.html rename to report/protocol/libraries/logic/IsolationModeLogic.sol.func.html index b92f61c3..0568d3b2 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.func.html +++ b/report/protocol/libraries/logic/IsolationModeLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/IsolationModeLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,28 +53,28 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - IsolationModeLogic.sol (source / functions)top level - protocol/libraries/logic - IsolationModeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + @@ -82,8 +82,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
IsolationModeLogic.updateIsolatedDebtIfIsolated1103613035
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html b/report/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html similarity index 85% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html rename to report/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html index ecc7f0d8..f750b6e9 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/IsolationModeLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/IsolationModeLogic.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - IsolationModeLogic.sol (source / functions)top level - protocol/libraries/logic - IsolationModeLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -98,34 +98,34 @@ 27 : : * @param reserveCache The cached data of the reserve 28 : : * @param repayAmount The amount being repaid 29 : : */ - 30 : 11036 : function updateIsolatedDebtIfIsolated( + 30 : : function updateIsolatedDebtIfIsolated( 31 : : mapping(address => DataTypes.ReserveData) storage reservesData, 32 : : mapping(uint256 => address) storage reservesList, 33 : : DataTypes.UserConfigurationMap storage userConfig, 34 : : DataTypes.ReserveCache memory reserveCache, 35 : : uint256 repayAmount 36 : : ) internal { - 37 : 33108 : (bool isolationModeActive, address isolationModeCollateralAddress, ) = userConfig + 37 : 13035 : (bool isolationModeActive, address isolationModeCollateralAddress, ) = userConfig 38 : : .getIsolationModeState(reservesData, reservesList); 39 : : - 40 : 11036 : if (isolationModeActive) { - 41 : 4 : uint128 isolationModeTotalDebt = reservesData[isolationModeCollateralAddress] + 40 : 13035 : if (isolationModeActive) { + 41 : 2 : uint128 isolationModeTotalDebt = reservesData[isolationModeCollateralAddress] 42 : : .isolationModeTotalDebt; 43 : : - 44 : 6 : uint128 isolatedDebtRepaid = (repayAmount / + 44 : 2 : uint128 isolatedDebtRepaid = (repayAmount / 45 : : 10 ** 46 : : (reserveCache.reserveConfiguration.getDecimals() - 47 : : ReserveConfiguration.DEBT_CEILING_DECIMALS)).toUint128(); 48 : : 49 : : // since the debt ceiling does not take into account the interest accrued, it might happen that amount 50 : : // repaid > debt in isolation mode - 51 : 4 : if (isolationModeTotalDebt <= isolatedDebtRepaid) { - 52 : 2 : reservesData[isolationModeCollateralAddress].isolationModeTotalDebt = 0; - 53 : 2 : emit IsolationModeTotalDebtUpdated(isolationModeCollateralAddress, 0); + 51 : 2 : if (isolationModeTotalDebt <= isolatedDebtRepaid) { + 52 : 1 : reservesData[isolationModeCollateralAddress].isolationModeTotalDebt = 0; + 53 : 1 : emit IsolationModeTotalDebtUpdated(isolationModeCollateralAddress, 0); 54 : : } else { - 55 : 3 : uint256 nextIsolationModeTotalDebt = reservesData[isolationModeCollateralAddress] + 55 : 1 : uint256 nextIsolationModeTotalDebt = reservesData[isolationModeCollateralAddress] 56 : : .isolationModeTotalDebt = isolationModeTotalDebt - isolatedDebtRepaid; - 57 : 2 : emit IsolationModeTotalDebtUpdated( + 57 : 1 : emit IsolationModeTotalDebtUpdated( 58 : : isolationModeCollateralAddress, 59 : : nextIsolationModeTotalDebt 60 : : ); @@ -140,8 +140,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func-c.html b/report/protocol/libraries/logic/LiquidationLogic.sol.func-c.html similarity index 56% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func-c.html rename to report/protocol/libraries/logic/LiquidationLogic.sol.func-c.html index 0e8460fb..82970336 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/LiquidationLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/LiquidationLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,70 +53,63 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - LiquidationLogic.sol (source / functions)top level - protocol/libraries/logic - LiquidationLogic.sol (source / functions) Coveragelcov.info.p Lines:95.5 %888498.6 %7473
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7766
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + @@ -124,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
LiquidationLogic._liquidateATokensLiquidationLogic._liquidateATokens 3
LiquidationLogic._burnCollateralATokensLiquidationLogic._burnCollateralATokens60098008
LiquidationLogic._burnDebtTokensLiquidationLogic._burnDebtTokens60128011
LiquidationLogic._getConfigurationDataLiquidationLogic._calculateAvailableCollateralToLiquidate601212021
LiquidationLogic._calculateAvailableCollateralToLiquidateLiquidationLogic._calculateDebt902314501
LiquidationLogic._calculateDebtLiquidationLogic.executeLiquidationCall11292
LiquidationLogic.executeLiquidationCall1129214501
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func.html b/report/protocol/libraries/logic/LiquidationLogic.sol.func.html similarity index 56% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func.html rename to report/protocol/libraries/logic/LiquidationLogic.sol.func.html index a3d162f6..99073430 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.func.html +++ b/report/protocol/libraries/logic/LiquidationLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/LiquidationLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,70 +53,63 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - LiquidationLogic.sol (source / functions)top level - protocol/libraries/logic - LiquidationLogic.sol (source / functions) Coveragelcov.info.p Lines:95.5 %888498.6 %7473
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7766
0 0
- + - + - + - + - + - + - + - + - + - + - - - - - - - - + - + - + @@ -124,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
LiquidationLogic._burnCollateralATokensLiquidationLogic._burnCollateralATokens60098008
LiquidationLogic._burnDebtTokensLiquidationLogic._burnDebtTokens60128011
LiquidationLogic._calculateAvailableCollateralToLiquidateLiquidationLogic._calculateAvailableCollateralToLiquidate902312021
LiquidationLogic._calculateDebtLiquidationLogic._calculateDebt1129214501
LiquidationLogic._getConfigurationData6012
LiquidationLogic._liquidateATokensLiquidationLogic._liquidateATokens 3
LiquidationLogic.executeLiquidationCallLiquidationLogic.executeLiquidationCall1129214501
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.gcov.html b/report/protocol/libraries/logic/LiquidationLogic.sol.gcov.html similarity index 76% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.gcov.html rename to report/protocol/libraries/logic/LiquidationLogic.sol.gcov.html index 67f052b3..59de0f5b 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/LiquidationLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/LiquidationLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/LiquidationLogic.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - LiquidationLogic.sol (source / functions)top level - protocol/libraries/logic - LiquidationLogic.sol (source / functions) Coveragelcov.info.p Lines:95.5 %888498.6 %7473
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7766
0 0
@@ -76,527 +76,459 @@ 5 : : import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; 6 : : import {PercentageMath} from '../../libraries/math/PercentageMath.sol'; 7 : : import {WadRayMath} from '../../libraries/math/WadRayMath.sol'; - 8 : : import {Helpers} from '../../libraries/helpers/Helpers.sol'; - 9 : : import {DataTypes} from '../../libraries/types/DataTypes.sol'; - 10 : : import {ReserveLogic} from './ReserveLogic.sol'; - 11 : : import {ValidationLogic} from './ValidationLogic.sol'; - 12 : : import {GenericLogic} from './GenericLogic.sol'; - 13 : : import {IsolationModeLogic} from './IsolationModeLogic.sol'; - 14 : : import {EModeLogic} from './EModeLogic.sol'; - 15 : : import {UserConfiguration} from '../../libraries/configuration/UserConfiguration.sol'; - 16 : : import {ReserveConfiguration} from '../../libraries/configuration/ReserveConfiguration.sol'; + 8 : : import {DataTypes} from '../../libraries/types/DataTypes.sol'; + 9 : : import {ReserveLogic} from './ReserveLogic.sol'; + 10 : : import {ValidationLogic} from './ValidationLogic.sol'; + 11 : : import {GenericLogic} from './GenericLogic.sol'; + 12 : : import {IsolationModeLogic} from './IsolationModeLogic.sol'; + 13 : : import {EModeLogic} from './EModeLogic.sol'; + 14 : : import {UserConfiguration} from '../../libraries/configuration/UserConfiguration.sol'; + 15 : : import {ReserveConfiguration} from '../../libraries/configuration/ReserveConfiguration.sol'; + 16 : : import {EModeConfiguration} from '../../libraries/configuration/EModeConfiguration.sol'; 17 : : import {IAToken} from '../../../interfaces/IAToken.sol'; - 18 : : import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; - 19 : : import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; - 20 : : import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; - 21 : : - 22 : : /** - 23 : : * @title LiquidationLogic library - 24 : : * @author Aave - 25 : : * @notice Implements actions involving management of collateral in the protocol, the main one being the liquidations - 26 : : */ - 27 : : library LiquidationLogic { - 28 : : using WadRayMath for uint256; - 29 : : using PercentageMath for uint256; - 30 : : using ReserveLogic for DataTypes.ReserveCache; - 31 : : using ReserveLogic for DataTypes.ReserveData; - 32 : : using UserConfiguration for DataTypes.UserConfigurationMap; - 33 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 34 : : using GPv2SafeERC20 for IERC20; - 35 : : - 36 : : // See `IPool` for descriptions - 37 : : event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); - 38 : : event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); - 39 : : event LiquidationCall( - 40 : : address indexed collateralAsset, - 41 : : address indexed debtAsset, - 42 : : address indexed user, - 43 : : uint256 debtToCover, - 44 : : uint256 liquidatedCollateralAmount, - 45 : : address liquidator, - 46 : : bool receiveAToken - 47 : : ); - 48 : : - 49 : : /** - 50 : : * @dev Default percentage of borrower's debt to be repaid in a liquidation. - 51 : : * @dev Percentage applied when the users health factor is above `CLOSE_FACTOR_HF_THRESHOLD` - 52 : : * Expressed in bps, a value of 0.5e4 results in 50.00% - 53 : : */ - 54 : : uint256 internal constant DEFAULT_LIQUIDATION_CLOSE_FACTOR = 0.5e4; - 55 : : - 56 : : /** - 57 : : * @dev Maximum percentage of borrower's debt to be repaid in a liquidation - 58 : : * @dev Percentage applied when the users health factor is below `CLOSE_FACTOR_HF_THRESHOLD` - 59 : : * Expressed in bps, a value of 1e4 results in 100.00% - 60 : : */ - 61 : : uint256 public constant MAX_LIQUIDATION_CLOSE_FACTOR = 1e4; - 62 : : - 63 : : /** - 64 : : * @dev This constant represents below which health factor value it is possible to liquidate - 65 : : * an amount of debt corresponding to `MAX_LIQUIDATION_CLOSE_FACTOR`. - 66 : : * A value of 0.95e18 results in 0.95 - 67 : : */ - 68 : : uint256 public constant CLOSE_FACTOR_HF_THRESHOLD = 0.95e18; - 69 : : - 70 : : struct LiquidationCallLocalVars { - 71 : : uint256 userCollateralBalance; - 72 : : uint256 userVariableDebt; - 73 : : uint256 userTotalDebt; - 74 : : uint256 actualDebtToLiquidate; - 75 : : uint256 actualCollateralToLiquidate; - 76 : : uint256 liquidationBonus; - 77 : : uint256 healthFactor; - 78 : : uint256 liquidationProtocolFeeAmount; - 79 : : address collateralPriceSource; - 80 : : address debtPriceSource; - 81 : : IAToken collateralAToken; - 82 : : DataTypes.ReserveCache debtReserveCache; - 83 : : } - 84 : : - 85 : : /** - 86 : : * @notice Function to liquidate a position if its Health Factor drops below 1. The caller (liquidator) - 87 : : * covers `debtToCover` amount of debt of the user getting liquidated, and receives - 88 : : * a proportional amount of the `collateralAsset` plus a bonus to cover market risk - 89 : : * @dev Emits the `LiquidationCall()` event - 90 : : * @param reservesData The state of all the reserves - 91 : : * @param reservesList The addresses of all the active reserves - 92 : : * @param usersConfig The users configuration mapping that track the supplied/borrowed assets - 93 : : * @param eModeCategories The configuration of all the efficiency mode categories - 94 : : * @param params The additional parameters needed to execute the liquidation function - 95 : : */ - 96 : 11292 : function executeLiquidationCall( - 97 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 98 : : mapping(uint256 => address) storage reservesList, - 99 : : mapping(address => DataTypes.UserConfigurationMap) storage usersConfig, - 100 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 101 : : DataTypes.ExecuteLiquidationCallParams memory params - 102 : : ) external { - 103 : 22584 : LiquidationCallLocalVars memory vars; - 104 : : - 105 : 22584 : DataTypes.ReserveData storage collateralReserve = reservesData[params.collateralAsset]; - 106 : 22584 : DataTypes.ReserveData storage debtReserve = reservesData[params.debtAsset]; - 107 : 22584 : DataTypes.UserConfigurationMap storage userConfig = usersConfig[params.user]; - 108 : 22584 : vars.debtReserveCache = debtReserve.cache(); - 109 : 22584 : debtReserve.updateState(vars.debtReserveCache); - 110 : : - 111 : 22584 : (, , , , vars.healthFactor, ) = GenericLogic.calculateUserAccountData( - 112 : : reservesData, - 113 : : reservesList, - 114 : : eModeCategories, - 115 : : DataTypes.CalculateUserAccountDataParams({ - 116 : : userConfig: userConfig, - 117 : : reservesCount: params.reservesCount, - 118 : : user: params.user, - 119 : : oracle: params.priceOracle, - 120 : : userEModeCategory: params.userEModeCategory - 121 : : }) - 122 : : ); - 123 : : - 124 : 22584 : (vars.userVariableDebt, vars.userTotalDebt, vars.actualDebtToLiquidate) = _calculateDebt( - 125 : : vars.debtReserveCache, - 126 : : params, - 127 : : vars.healthFactor - 128 : : ); - 129 : : - 130 : 22584 : ValidationLogic.validateLiquidationCall( - 131 : : userConfig, - 132 : : collateralReserve, - 133 : : debtReserve, - 134 : : DataTypes.ValidateLiquidationCallParams({ - 135 : : debtReserveCache: vars.debtReserveCache, - 136 : : totalDebt: vars.userTotalDebt, - 137 : : healthFactor: vars.healthFactor, - 138 : : priceOracleSentinel: params.priceOracleSentinel - 139 : : }) - 140 : : ); - 141 : : - 142 : 12024 : ( - 143 : : vars.collateralAToken, - 144 : : vars.collateralPriceSource, - 145 : : vars.debtPriceSource, - 146 : : vars.liquidationBonus - 147 : : ) = _getConfigurationData(eModeCategories, collateralReserve, params); - 148 : : - 149 : 12024 : vars.userCollateralBalance = vars.collateralAToken.balanceOf(params.user); + 18 : : import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; + 19 : : import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; + 20 : : + 21 : : /** + 22 : : * @title LiquidationLogic library + 23 : : * @author Aave + 24 : : * @notice Implements actions involving management of collateral in the protocol, the main one being the liquidations + 25 : : */ + 26 : : library LiquidationLogic { + 27 : : using WadRayMath for uint256; + 28 : : using PercentageMath for uint256; + 29 : : using ReserveLogic for DataTypes.ReserveCache; + 30 : : using ReserveLogic for DataTypes.ReserveData; + 31 : : using UserConfiguration for DataTypes.UserConfigurationMap; + 32 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 33 : : using GPv2SafeERC20 for IERC20; + 34 : : + 35 : : // See `IPool` for descriptions + 36 : : event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); + 37 : : event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); + 38 : : event LiquidationCall( + 39 : : address indexed collateralAsset, + 40 : : address indexed debtAsset, + 41 : : address indexed user, + 42 : : uint256 debtToCover, + 43 : : uint256 liquidatedCollateralAmount, + 44 : : address liquidator, + 45 : : bool receiveAToken + 46 : : ); + 47 : : + 48 : : /** + 49 : : * @dev Default percentage of borrower's debt to be repaid in a liquidation. + 50 : : * @dev Percentage applied when the users health factor is above `CLOSE_FACTOR_HF_THRESHOLD` + 51 : : * Expressed in bps, a value of 0.5e4 results in 50.00% + 52 : : */ + 53 : : uint256 internal constant DEFAULT_LIQUIDATION_CLOSE_FACTOR = 0.5e4; + 54 : : + 55 : : /** + 56 : : * @dev Maximum percentage of borrower's debt to be repaid in a liquidation + 57 : : * @dev Percentage applied when the users health factor is below `CLOSE_FACTOR_HF_THRESHOLD` + 58 : : * Expressed in bps, a value of 1e4 results in 100.00% + 59 : : */ + 60 : : uint256 public constant MAX_LIQUIDATION_CLOSE_FACTOR = 1e4; + 61 : : + 62 : : /** + 63 : : * @dev This constant represents below which health factor value it is possible to liquidate + 64 : : * an amount of debt corresponding to `MAX_LIQUIDATION_CLOSE_FACTOR`. + 65 : : * A value of 0.95e18 results in 0.95 + 66 : : */ + 67 : : uint256 public constant CLOSE_FACTOR_HF_THRESHOLD = 0.95e18; + 68 : : + 69 : : struct LiquidationCallLocalVars { + 70 : : uint256 userCollateralBalance; + 71 : : uint256 userTotalDebt; + 72 : : uint256 actualDebtToLiquidate; + 73 : : uint256 actualCollateralToLiquidate; + 74 : : uint256 liquidationBonus; + 75 : : uint256 healthFactor; + 76 : : uint256 liquidationProtocolFeeAmount; + 77 : : IAToken collateralAToken; + 78 : : DataTypes.ReserveCache debtReserveCache; + 79 : : } + 80 : : + 81 : : /** + 82 : : * @notice Function to liquidate a position if its Health Factor drops below 1. The caller (liquidator) + 83 : : * covers `debtToCover` amount of debt of the user getting liquidated, and receives + 84 : : * a proportional amount of the `collateralAsset` plus a bonus to cover market risk + 85 : : * @dev Emits the `LiquidationCall()` event + 86 : : * @param reservesData The state of all the reserves + 87 : : * @param reservesList The addresses of all the active reserves + 88 : : * @param usersConfig The users configuration mapping that track the supplied/borrowed assets + 89 : : * @param eModeCategories The configuration of all the efficiency mode categories + 90 : : * @param params The additional parameters needed to execute the liquidation function + 91 : : */ + 92 : : function executeLiquidationCall( + 93 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 94 : : mapping(uint256 => address) storage reservesList, + 95 : : mapping(address => DataTypes.UserConfigurationMap) storage usersConfig, + 96 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 97 : : DataTypes.ExecuteLiquidationCallParams memory params + 98 : : ) external { + 99 : 14501 : LiquidationCallLocalVars memory vars; + 100 : : + 101 : 14501 : DataTypes.ReserveData storage collateralReserve = reservesData[params.collateralAsset]; + 102 : 14501 : DataTypes.ReserveData storage debtReserve = reservesData[params.debtAsset]; + 103 : 14501 : DataTypes.UserConfigurationMap storage userConfig = usersConfig[params.user]; + 104 : 14501 : vars.debtReserveCache = debtReserve.cache(); + 105 : 14501 : debtReserve.updateState(vars.debtReserveCache); + 106 : : + 107 : 14501 : (, , , , vars.healthFactor, ) = GenericLogic.calculateUserAccountData( + 108 : : reservesData, + 109 : : reservesList, + 110 : : eModeCategories, + 111 : : DataTypes.CalculateUserAccountDataParams({ + 112 : : userConfig: userConfig, + 113 : : reservesCount: params.reservesCount, + 114 : : user: params.user, + 115 : : oracle: params.priceOracle, + 116 : : userEModeCategory: params.userEModeCategory + 117 : : }) + 118 : : ); + 119 : : + 120 : 14501 : (vars.userTotalDebt, vars.actualDebtToLiquidate) = _calculateDebt( + 121 : : vars.debtReserveCache, + 122 : : params, + 123 : : vars.healthFactor + 124 : : ); + 125 : : + 126 : 14501 : ValidationLogic.validateLiquidationCall( + 127 : : userConfig, + 128 : : collateralReserve, + 129 : : debtReserve, + 130 : : DataTypes.ValidateLiquidationCallParams({ + 131 : : debtReserveCache: vars.debtReserveCache, + 132 : : totalDebt: vars.userTotalDebt, + 133 : : healthFactor: vars.healthFactor, + 134 : : priceOracleSentinel: params.priceOracleSentinel + 135 : : }) + 136 : : ); + 137 : : + 138 : 8011 : vars.collateralAToken = IAToken(collateralReserve.aTokenAddress); + 139 : : if ( + 140 : 8011 : params.userEModeCategory != 0 && + 141 : 1001 : EModeConfiguration.isReserveEnabledOnBitmap( + 142 : : eModeCategories[params.userEModeCategory].collateralBitmap, + 143 : : collateralReserve.id + 144 : : ) + 145 : : ) { + 146 : 1001 : vars.liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; + 147 : : } else { + 148 : 7010 : vars.liquidationBonus = collateralReserve.configuration.getLiquidationBonus(); + 149 : : } 150 : : - 151 : 12024 : ( - 152 : : vars.actualCollateralToLiquidate, - 153 : : vars.actualDebtToLiquidate, - 154 : : vars.liquidationProtocolFeeAmount - 155 : : ) = _calculateAvailableCollateralToLiquidate( - 156 : : collateralReserve, - 157 : : vars.debtReserveCache, - 158 : : vars.collateralPriceSource, - 159 : : vars.debtPriceSource, - 160 : : vars.actualDebtToLiquidate, - 161 : : vars.userCollateralBalance, - 162 : : vars.liquidationBonus, - 163 : : IPriceOracleGetter(params.priceOracle) - 164 : : ); - 165 : : - 166 : 12024 : if (vars.userTotalDebt == vars.actualDebtToLiquidate) { - 167 : 4 : userConfig.setBorrowing(debtReserve.id, false); - 168 : : } - 169 : : - 170 : : // If the collateral being liquidated is equal to the user balance, - 171 : : // we set the currency as not being used as collateral anymore - 172 : : if ( - 173 : 18036 : vars.actualCollateralToLiquidate + vars.liquidationProtocolFeeAmount == - 174 : : vars.userCollateralBalance - 175 : : ) { - 176 : 12 : userConfig.setUsingAsCollateral(collateralReserve.id, false); - 177 : 12 : emit ReserveUsedAsCollateralDisabled(params.collateralAsset, params.user); - 178 : : } - 179 : : - 180 : 12024 : _burnDebtTokens(params, vars); + 151 : 8011 : vars.userCollateralBalance = vars.collateralAToken.balanceOf(params.user); + 152 : : + 153 : 8011 : ( + 154 : : vars.actualCollateralToLiquidate, + 155 : : vars.actualDebtToLiquidate, + 156 : : vars.liquidationProtocolFeeAmount + 157 : : ) = _calculateAvailableCollateralToLiquidate( + 158 : : collateralReserve, + 159 : : vars.debtReserveCache, + 160 : : params.collateralAsset, + 161 : : params.debtAsset, + 162 : : vars.actualDebtToLiquidate, + 163 : : vars.userCollateralBalance, + 164 : : vars.liquidationBonus, + 165 : : IPriceOracleGetter(params.priceOracle) + 166 : : ); + 167 : : + 168 : 8011 : if (vars.userTotalDebt == vars.actualDebtToLiquidate) { + 169 : 2 : userConfig.setBorrowing(debtReserve.id, false); + 170 : : } + 171 : : + 172 : : // If the collateral being liquidated is equal to the user balance, + 173 : : // we set the currency as not being used as collateral anymore + 174 : : if ( + 175 : 8011 : vars.actualCollateralToLiquidate + vars.liquidationProtocolFeeAmount == + 176 : : vars.userCollateralBalance + 177 : : ) { + 178 : 1006 : userConfig.setUsingAsCollateral(collateralReserve.id, false); + 179 : 1006 : emit ReserveUsedAsCollateralDisabled(params.collateralAsset, params.user); + 180 : : } 181 : : - 182 : 12024 : debtReserve.updateInterestRatesAndVirtualBalance( - 183 : : vars.debtReserveCache, - 184 : : params.debtAsset, - 185 : : vars.actualDebtToLiquidate, - 186 : : 0 - 187 : : ); - 188 : : - 189 : 12024 : IsolationModeLogic.updateIsolatedDebtIfIsolated( - 190 : : reservesData, - 191 : : reservesList, - 192 : : userConfig, - 193 : : vars.debtReserveCache, - 194 : : vars.actualDebtToLiquidate - 195 : : ); - 196 : : - 197 : 6012 : if (params.receiveAToken) { - 198 : 6 : _liquidateATokens(reservesData, reservesList, usersConfig, collateralReserve, params, vars); - 199 : : } else { - 200 : 12018 : _burnCollateralATokens(collateralReserve, params, vars); - 201 : : } - 202 : : - 203 : : // Transfer fee to treasury if it is non-zero - 204 : 12024 : if (vars.liquidationProtocolFeeAmount != 0) { - 205 : 18033 : uint256 liquidityIndex = collateralReserve.getNormalizedIncome(); - 206 : 18033 : uint256 scaledDownLiquidationProtocolFee = vars.liquidationProtocolFeeAmount.rayDiv( - 207 : : liquidityIndex - 208 : : ); - 209 : 18033 : uint256 scaledDownUserBalance = vars.collateralAToken.scaledBalanceOf(params.user); - 210 : : // To avoid trying to send more aTokens than available on balance, due to 1 wei imprecision - 211 : 12022 : if (scaledDownLiquidationProtocolFee > scaledDownUserBalance) { - 212 : 0 : vars.liquidationProtocolFeeAmount = scaledDownUserBalance.rayMul(liquidityIndex); - 213 : : } - 214 : 12022 : vars.collateralAToken.transferOnLiquidation( - 215 : : params.user, - 216 : : vars.collateralAToken.RESERVE_TREASURY_ADDRESS(), - 217 : : vars.liquidationProtocolFeeAmount - 218 : : ); - 219 : : } - 220 : : - 221 : : // Transfers the debt asset being repaid to the aToken, where the liquidity is kept - 222 : 12024 : IERC20(params.debtAsset).safeTransferFrom( - 223 : : msg.sender, - 224 : : vars.debtReserveCache.aTokenAddress, - 225 : : vars.actualDebtToLiquidate - 226 : : ); - 227 : : - 228 : 12024 : IAToken(vars.debtReserveCache.aTokenAddress).handleRepayment( - 229 : : msg.sender, - 230 : : params.user, - 231 : : vars.actualDebtToLiquidate - 232 : : ); - 233 : : - 234 : 12024 : emit LiquidationCall( - 235 : : params.collateralAsset, - 236 : : params.debtAsset, - 237 : : params.user, - 238 : : vars.actualDebtToLiquidate, - 239 : : vars.actualCollateralToLiquidate, - 240 : : msg.sender, - 241 : : params.receiveAToken - 242 : : ); - 243 : : } - 244 : : - 245 : : /** - 246 : : * @notice Burns the collateral aTokens and transfers the underlying to the liquidator. - 247 : : * @dev The function also updates the state and the interest rate of the collateral reserve. - 248 : : * @param collateralReserve The data of the collateral reserve - 249 : : * @param params The additional parameters needed to execute the liquidation function - 250 : : * @param vars The executeLiquidationCall() function local vars - 251 : : */ - 252 : 6009 : function _burnCollateralATokens( - 253 : : DataTypes.ReserveData storage collateralReserve, - 254 : : DataTypes.ExecuteLiquidationCallParams memory params, - 255 : : LiquidationCallLocalVars memory vars - 256 : : ) internal { - 257 : 18027 : DataTypes.ReserveCache memory collateralReserveCache = collateralReserve.cache(); - 258 : 12018 : collateralReserve.updateState(collateralReserveCache); - 259 : 12018 : collateralReserve.updateInterestRatesAndVirtualBalance( - 260 : : collateralReserveCache, - 261 : : params.collateralAsset, - 262 : : 0, - 263 : : vars.actualCollateralToLiquidate - 264 : : ); - 265 : : - 266 : : // Burn the equivalent amount of aToken, sending the underlying to the liquidator - 267 : 12018 : vars.collateralAToken.burn( - 268 : : params.user, - 269 : : msg.sender, - 270 : : vars.actualCollateralToLiquidate, - 271 : : collateralReserveCache.nextLiquidityIndex - 272 : : ); - 273 : : } - 274 : : - 275 : : /** - 276 : : * @notice Liquidates the user aTokens by transferring them to the liquidator. - 277 : : * @dev The function also checks the state of the liquidator and activates the aToken as collateral - 278 : : * as in standard transfers if the isolation mode constraints are respected. - 279 : : * @param reservesData The state of all the reserves - 280 : : * @param reservesList The addresses of all the active reserves - 281 : : * @param usersConfig The users configuration mapping that track the supplied/borrowed assets - 282 : : * @param collateralReserve The data of the collateral reserve - 283 : : * @param params The additional parameters needed to execute the liquidation function - 284 : : * @param vars The executeLiquidationCall() function local vars - 285 : : */ - 286 : 3 : function _liquidateATokens( - 287 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 288 : : mapping(uint256 => address) storage reservesList, - 289 : : mapping(address => DataTypes.UserConfigurationMap) storage usersConfig, - 290 : : DataTypes.ReserveData storage collateralReserve, - 291 : : DataTypes.ExecuteLiquidationCallParams memory params, - 292 : : LiquidationCallLocalVars memory vars - 293 : : ) internal { - 294 : 9 : uint256 liquidatorPreviousATokenBalance = IERC20(vars.collateralAToken).balanceOf(msg.sender); - 295 : 6 : vars.collateralAToken.transferOnLiquidation( - 296 : : params.user, - 297 : : msg.sender, - 298 : : vars.actualCollateralToLiquidate - 299 : : ); - 300 : : - 301 : 6 : if (liquidatorPreviousATokenBalance == 0) { - 302 : 6 : DataTypes.UserConfigurationMap storage liquidatorConfig = usersConfig[msg.sender]; - 303 : : if ( - 304 : 6 : ValidationLogic.validateAutomaticUseAsCollateral( - 305 : : reservesData, - 306 : : reservesList, - 307 : : liquidatorConfig, - 308 : : collateralReserve.configuration, - 309 : : collateralReserve.aTokenAddress - 310 : : ) - 311 : : ) { - 312 : 6 : liquidatorConfig.setUsingAsCollateral(collateralReserve.id, true); - 313 : 6 : emit ReserveUsedAsCollateralEnabled(params.collateralAsset, msg.sender); - 314 : : } - 315 : : } - 316 : : } - 317 : : - 318 : : /** - 319 : : * @notice Burns the debt tokens of the user up to the amount being repaid by the liquidator. - 320 : : * @dev The function alters the `debtReserveCache` state in `vars` to update the debt related data. - 321 : : * @param params The additional parameters needed to execute the liquidation function - 322 : : * @param vars the executeLiquidationCall() function local vars - 323 : : */ - 324 : 6012 : function _burnDebtTokens( - 325 : : DataTypes.ExecuteLiquidationCallParams memory params, - 326 : : LiquidationCallLocalVars memory vars - 327 : : ) internal { - 328 : 12024 : if (vars.userVariableDebt >= vars.actualDebtToLiquidate) { - 329 : 12024 : vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( - 330 : : vars.debtReserveCache.variableDebtTokenAddress - 331 : : ).burn( - 332 : : params.user, - 333 : : vars.actualDebtToLiquidate, - 334 : : vars.debtReserveCache.nextVariableBorrowIndex - 335 : : ); - 336 : : } else { - 337 : : // If the user doesn't have variable debt, no need to try to burn variable debt tokens - 338 : 0 : if (vars.userVariableDebt != 0) { - 339 : 0 : vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( - 340 : : vars.debtReserveCache.variableDebtTokenAddress - 341 : : ).burn(params.user, vars.userVariableDebt, vars.debtReserveCache.nextVariableBorrowIndex); - 342 : : } - 343 : 0 : ( - 344 : : vars.debtReserveCache.nextTotalStableDebt, - 345 : : vars.debtReserveCache.nextAvgStableBorrowRate - 346 : : ) = IStableDebtToken(vars.debtReserveCache.stableDebtTokenAddress).burn( - 347 : : params.user, - 348 : : vars.actualDebtToLiquidate - vars.userVariableDebt - 349 : : ); - 350 : : } - 351 : : } - 352 : : - 353 : : /** - 354 : : * @notice Calculates the total debt of the user and the actual amount to liquidate depending on the health factor - 355 : : * and corresponding close factor. - 356 : : * @dev If the Health Factor is below CLOSE_FACTOR_HF_THRESHOLD, the close factor is increased to MAX_LIQUIDATION_CLOSE_FACTOR - 357 : : * @param debtReserveCache The reserve cache data object of the debt reserve - 358 : : * @param params The additional parameters needed to execute the liquidation function - 359 : : * @param healthFactor The health factor of the position - 360 : : * @return The variable debt of the user - 361 : : * @return The total debt of the user - 362 : : * @return The actual debt to liquidate as a function of the closeFactor - 363 : : */ - 364 : 11292 : function _calculateDebt( - 365 : : DataTypes.ReserveCache memory debtReserveCache, - 366 : : DataTypes.ExecuteLiquidationCallParams memory params, - 367 : : uint256 healthFactor - 368 : : ) internal view returns (uint256, uint256, uint256) { - 369 : 33876 : (uint256 userStableDebt, uint256 userVariableDebt) = Helpers.getUserCurrentDebt( - 370 : : params.user, - 371 : : debtReserveCache - 372 : : ); - 373 : : - 374 : 33876 : uint256 userTotalDebt = userStableDebt + userVariableDebt; - 375 : : - 376 : 33876 : uint256 closeFactor = healthFactor > CLOSE_FACTOR_HF_THRESHOLD - 377 : : ? DEFAULT_LIQUIDATION_CLOSE_FACTOR - 378 : : : MAX_LIQUIDATION_CLOSE_FACTOR; - 379 : : - 380 : 33876 : uint256 maxLiquidatableDebt = userTotalDebt.percentMul(closeFactor); - 381 : : - 382 : 33876 : uint256 actualDebtToLiquidate = params.debtToCover > maxLiquidatableDebt - 383 : : ? maxLiquidatableDebt - 384 : : : params.debtToCover; - 385 : : - 386 : 22584 : return (userVariableDebt, userTotalDebt, actualDebtToLiquidate); - 387 : : } - 388 : : - 389 : : /** - 390 : : * @notice Returns the configuration data for the debt and the collateral reserves. - 391 : : * @param eModeCategories The configuration of all the efficiency mode categories - 392 : : * @param collateralReserve The data of the collateral reserve - 393 : : * @param params The additional parameters needed to execute the liquidation function - 394 : : * @return The collateral aToken - 395 : : * @return The address to use as price source for the collateral - 396 : : * @return The address to use as price source for the debt - 397 : : * @return The liquidation bonus to apply to the collateral + 182 : 8011 : _burnDebtTokens(params, vars); + 183 : : + 184 : 8011 : debtReserve.updateInterestRatesAndVirtualBalance( + 185 : : vars.debtReserveCache, + 186 : : params.debtAsset, + 187 : : vars.actualDebtToLiquidate, + 188 : : 0 + 189 : : ); + 190 : : + 191 : 8011 : IsolationModeLogic.updateIsolatedDebtIfIsolated( + 192 : : reservesData, + 193 : : reservesList, + 194 : : userConfig, + 195 : : vars.debtReserveCache, + 196 : : vars.actualDebtToLiquidate + 197 : : ); + 198 : : + 199 : 8011 : if (params.receiveAToken) { + 200 : 3 : _liquidateATokens(reservesData, reservesList, usersConfig, collateralReserve, params, vars); + 201 : : } else { + 202 : 8008 : _burnCollateralATokens(collateralReserve, params, vars); + 203 : : } + 204 : : + 205 : : // Transfer fee to treasury if it is non-zero + 206 : 8011 : if (vars.liquidationProtocolFeeAmount != 0) { + 207 : 8010 : uint256 liquidityIndex = collateralReserve.getNormalizedIncome(); + 208 : 8010 : uint256 scaledDownLiquidationProtocolFee = vars.liquidationProtocolFeeAmount.rayDiv( + 209 : : liquidityIndex + 210 : : ); + 211 : 8010 : uint256 scaledDownUserBalance = vars.collateralAToken.scaledBalanceOf(params.user); + 212 : : // To avoid trying to send more aTokens than available on balance, due to 1 wei imprecision + 213 : 8010 : if (scaledDownLiquidationProtocolFee > scaledDownUserBalance) { + 214 : 0 : vars.liquidationProtocolFeeAmount = scaledDownUserBalance.rayMul(liquidityIndex); + 215 : : } + 216 : 8010 : vars.collateralAToken.transferOnLiquidation( + 217 : : params.user, + 218 : : vars.collateralAToken.RESERVE_TREASURY_ADDRESS(), + 219 : : vars.liquidationProtocolFeeAmount + 220 : : ); + 221 : : } + 222 : : + 223 : : // Transfers the debt asset being repaid to the aToken, where the liquidity is kept + 224 : 8011 : IERC20(params.debtAsset).safeTransferFrom( + 225 : : msg.sender, + 226 : : vars.debtReserveCache.aTokenAddress, + 227 : : vars.actualDebtToLiquidate + 228 : : ); + 229 : : + 230 : 8011 : IAToken(vars.debtReserveCache.aTokenAddress).handleRepayment( + 231 : : msg.sender, + 232 : : params.user, + 233 : : vars.actualDebtToLiquidate + 234 : : ); + 235 : : + 236 : 8011 : emit LiquidationCall( + 237 : : params.collateralAsset, + 238 : : params.debtAsset, + 239 : : params.user, + 240 : : vars.actualDebtToLiquidate, + 241 : : vars.actualCollateralToLiquidate, + 242 : : msg.sender, + 243 : : params.receiveAToken + 244 : : ); + 245 : : } + 246 : : + 247 : : /** + 248 : : * @notice Burns the collateral aTokens and transfers the underlying to the liquidator. + 249 : : * @dev The function also updates the state and the interest rate of the collateral reserve. + 250 : : * @param collateralReserve The data of the collateral reserve + 251 : : * @param params The additional parameters needed to execute the liquidation function + 252 : : * @param vars The executeLiquidationCall() function local vars + 253 : : */ + 254 : : function _burnCollateralATokens( + 255 : : DataTypes.ReserveData storage collateralReserve, + 256 : : DataTypes.ExecuteLiquidationCallParams memory params, + 257 : : LiquidationCallLocalVars memory vars + 258 : : ) internal { + 259 : 8008 : DataTypes.ReserveCache memory collateralReserveCache = collateralReserve.cache(); + 260 : 8008 : collateralReserve.updateState(collateralReserveCache); + 261 : 8008 : collateralReserve.updateInterestRatesAndVirtualBalance( + 262 : : collateralReserveCache, + 263 : : params.collateralAsset, + 264 : : 0, + 265 : : vars.actualCollateralToLiquidate + 266 : : ); + 267 : : + 268 : : // Burn the equivalent amount of aToken, sending the underlying to the liquidator + 269 : 8008 : vars.collateralAToken.burn( + 270 : : params.user, + 271 : : msg.sender, + 272 : : vars.actualCollateralToLiquidate, + 273 : : collateralReserveCache.nextLiquidityIndex + 274 : : ); + 275 : : } + 276 : : + 277 : : /** + 278 : : * @notice Liquidates the user aTokens by transferring them to the liquidator. + 279 : : * @dev The function also checks the state of the liquidator and activates the aToken as collateral + 280 : : * as in standard transfers if the isolation mode constraints are respected. + 281 : : * @param reservesData The state of all the reserves + 282 : : * @param reservesList The addresses of all the active reserves + 283 : : * @param usersConfig The users configuration mapping that track the supplied/borrowed assets + 284 : : * @param collateralReserve The data of the collateral reserve + 285 : : * @param params The additional parameters needed to execute the liquidation function + 286 : : * @param vars The executeLiquidationCall() function local vars + 287 : : */ + 288 : : function _liquidateATokens( + 289 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 290 : : mapping(uint256 => address) storage reservesList, + 291 : : mapping(address => DataTypes.UserConfigurationMap) storage usersConfig, + 292 : : DataTypes.ReserveData storage collateralReserve, + 293 : : DataTypes.ExecuteLiquidationCallParams memory params, + 294 : : LiquidationCallLocalVars memory vars + 295 : : ) internal { + 296 : 3 : uint256 liquidatorPreviousATokenBalance = IERC20(vars.collateralAToken).balanceOf(msg.sender); + 297 : 3 : vars.collateralAToken.transferOnLiquidation( + 298 : : params.user, + 299 : : msg.sender, + 300 : : vars.actualCollateralToLiquidate + 301 : : ); + 302 : : + 303 : 3 : if (liquidatorPreviousATokenBalance == 0) { + 304 : 3 : DataTypes.UserConfigurationMap storage liquidatorConfig = usersConfig[msg.sender]; + 305 : : if ( + 306 : 3 : ValidationLogic.validateAutomaticUseAsCollateral( + 307 : : reservesData, + 308 : : reservesList, + 309 : : liquidatorConfig, + 310 : : collateralReserve.configuration, + 311 : : collateralReserve.aTokenAddress + 312 : : ) + 313 : : ) { + 314 : 3 : liquidatorConfig.setUsingAsCollateral(collateralReserve.id, true); + 315 : 3 : emit ReserveUsedAsCollateralEnabled(params.collateralAsset, msg.sender); + 316 : : } + 317 : : } + 318 : : } + 319 : : + 320 : : /** + 321 : : * @notice Burns the debt tokens of the user up to the amount being repaid by the liquidator. + 322 : : * @dev The function alters the `debtReserveCache` state in `vars` to update the debt related data. + 323 : : * @param params The additional parameters needed to execute the liquidation function + 324 : : * @param vars the executeLiquidationCall() function local vars + 325 : : */ + 326 : : function _burnDebtTokens( + 327 : : DataTypes.ExecuteLiquidationCallParams memory params, + 328 : : LiquidationCallLocalVars memory vars + 329 : : ) internal { + 330 : 8011 : vars.debtReserveCache.nextScaledVariableDebt = IVariableDebtToken( + 331 : : vars.debtReserveCache.variableDebtTokenAddress + 332 : : ).burn(params.user, vars.actualDebtToLiquidate, vars.debtReserveCache.nextVariableBorrowIndex); + 333 : : } + 334 : : + 335 : : /** + 336 : : * @notice Calculates the total debt of the user and the actual amount to liquidate depending on the health factor + 337 : : * and corresponding close factor. + 338 : : * @dev If the Health Factor is below CLOSE_FACTOR_HF_THRESHOLD, the close factor is increased to MAX_LIQUIDATION_CLOSE_FACTOR + 339 : : * @param debtReserveCache The reserve cache data object of the debt reserve + 340 : : * @param params The additional parameters needed to execute the liquidation function + 341 : : * @param healthFactor The health factor of the position + 342 : : * @return The total debt of the user + 343 : : * @return The actual debt to liquidate as a function of the closeFactor + 344 : : */ + 345 : : function _calculateDebt( + 346 : : DataTypes.ReserveCache memory debtReserveCache, + 347 : : DataTypes.ExecuteLiquidationCallParams memory params, + 348 : : uint256 healthFactor + 349 : : ) internal view returns (uint256, uint256) { + 350 : 14501 : uint256 userVariableDebt = IERC20(debtReserveCache.variableDebtTokenAddress).balanceOf( + 351 : : params.user + 352 : : ); + 353 : : + 354 : 14501 : uint256 closeFactor = healthFactor > CLOSE_FACTOR_HF_THRESHOLD + 355 : : ? DEFAULT_LIQUIDATION_CLOSE_FACTOR + 356 : : : MAX_LIQUIDATION_CLOSE_FACTOR; + 357 : : + 358 : 14501 : uint256 maxLiquidatableDebt = userVariableDebt.percentMul(closeFactor); + 359 : : + 360 : 14501 : uint256 actualDebtToLiquidate = params.debtToCover > maxLiquidatableDebt + 361 : : ? maxLiquidatableDebt + 362 : : : params.debtToCover; + 363 : : + 364 : 14501 : return (userVariableDebt, actualDebtToLiquidate); + 365 : : } + 366 : : + 367 : : struct AvailableCollateralToLiquidateLocalVars { + 368 : : uint256 collateralPrice; + 369 : : uint256 debtAssetPrice; + 370 : : uint256 maxCollateralToLiquidate; + 371 : : uint256 baseCollateral; + 372 : : uint256 bonusCollateral; + 373 : : uint256 debtAssetDecimals; + 374 : : uint256 collateralDecimals; + 375 : : uint256 collateralAssetUnit; + 376 : : uint256 debtAssetUnit; + 377 : : uint256 collateralAmount; + 378 : : uint256 debtAmountNeeded; + 379 : : uint256 liquidationProtocolFeePercentage; + 380 : : uint256 liquidationProtocolFee; + 381 : : } + 382 : : + 383 : : /** + 384 : : * @notice Calculates how much of a specific collateral can be liquidated, given + 385 : : * a certain amount of debt asset. + 386 : : * @dev This function needs to be called after all the checks to validate the liquidation have been performed, + 387 : : * otherwise it might fail. + 388 : : * @param collateralReserve The data of the collateral reserve + 389 : : * @param debtReserveCache The cached data of the debt reserve + 390 : : * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation + 391 : : * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation + 392 : : * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover + 393 : : * @param userCollateralBalance The collateral balance for the specific `collateralAsset` of the user being liquidated + 394 : : * @param liquidationBonus The collateral bonus percentage to receive as result of the liquidation + 395 : : * @return The maximum amount that is possible to liquidate given all the liquidation constraints (user balance, close factor) + 396 : : * @return The amount to repay with the liquidation + 397 : : * @return The fee taken from the liquidation bonus amount to be paid to the protocol 398 : : */ - 399 : 6012 : function _getConfigurationData( - 400 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 401 : : DataTypes.ReserveData storage collateralReserve, - 402 : : DataTypes.ExecuteLiquidationCallParams memory params - 403 : : ) internal view returns (IAToken, address, address, uint256) { - 404 : 18036 : IAToken collateralAToken = IAToken(collateralReserve.aTokenAddress); - 405 : 18036 : uint256 liquidationBonus = collateralReserve.configuration.getLiquidationBonus(); - 406 : : - 407 : 12024 : address collateralPriceSource = params.collateralAsset; - 408 : 12024 : address debtPriceSource = params.debtAsset; - 409 : : - 410 : 12024 : if (params.userEModeCategory != 0) { - 411 : 4 : address eModePriceSource = eModeCategories[params.userEModeCategory].priceSource; - 412 : : - 413 : : if ( - 414 : 4 : EModeLogic.isInEModeCategory( - 415 : : params.userEModeCategory, - 416 : : collateralReserve.configuration.getEModeCategory() - 417 : : ) - 418 : : ) { - 419 : 4 : liquidationBonus = eModeCategories[params.userEModeCategory].liquidationBonus; - 420 : : - 421 : 6 : if (eModePriceSource != address(0)) { - 422 : 2 : collateralPriceSource = eModePriceSource; - 423 : : } - 424 : : } + 399 : : function _calculateAvailableCollateralToLiquidate( + 400 : : DataTypes.ReserveData storage collateralReserve, + 401 : : DataTypes.ReserveCache memory debtReserveCache, + 402 : : address collateralAsset, + 403 : : address debtAsset, + 404 : : uint256 debtToCover, + 405 : : uint256 userCollateralBalance, + 406 : : uint256 liquidationBonus, + 407 : : IPriceOracleGetter oracle + 408 : : ) internal view returns (uint256, uint256, uint256) { + 409 : 12021 : AvailableCollateralToLiquidateLocalVars memory vars; + 410 : : + 411 : 12021 : vars.collateralPrice = oracle.getAssetPrice(collateralAsset); + 412 : 12021 : vars.debtAssetPrice = oracle.getAssetPrice(debtAsset); + 413 : : + 414 : 12021 : vars.collateralDecimals = collateralReserve.configuration.getDecimals(); + 415 : 12021 : vars.debtAssetDecimals = debtReserveCache.reserveConfiguration.getDecimals(); + 416 : : + 417 : : unchecked { + 418 : 12021 : vars.collateralAssetUnit = 10 ** vars.collateralDecimals; + 419 : 12021 : vars.debtAssetUnit = 10 ** vars.debtAssetDecimals; + 420 : : } + 421 : : + 422 : 12021 : vars.liquidationProtocolFeePercentage = collateralReserve + 423 : : .configuration + 424 : : .getLiquidationProtocolFee(); 425 : : - 426 : : // when in eMode, debt will always be in the same eMode category, can skip matching category check - 427 : 6 : if (eModePriceSource != address(0)) { - 428 : 2 : debtPriceSource = eModePriceSource; - 429 : : } - 430 : : } - 431 : : - 432 : 12024 : return (collateralAToken, collateralPriceSource, debtPriceSource, liquidationBonus); - 433 : : } - 434 : : - 435 : : struct AvailableCollateralToLiquidateLocalVars { - 436 : : uint256 collateralPrice; - 437 : : uint256 debtAssetPrice; - 438 : : uint256 maxCollateralToLiquidate; - 439 : : uint256 baseCollateral; - 440 : : uint256 bonusCollateral; - 441 : : uint256 debtAssetDecimals; - 442 : : uint256 collateralDecimals; - 443 : : uint256 collateralAssetUnit; - 444 : : uint256 debtAssetUnit; - 445 : : uint256 collateralAmount; - 446 : : uint256 debtAmountNeeded; - 447 : : uint256 liquidationProtocolFeePercentage; - 448 : : uint256 liquidationProtocolFee; - 449 : : } + 426 : : // This is the base collateral to liquidate based on the given debt to cover + 427 : 12021 : vars.baseCollateral = + 428 : : ((vars.debtAssetPrice * debtToCover * vars.collateralAssetUnit)) / + 429 : : (vars.collateralPrice * vars.debtAssetUnit); + 430 : : + 431 : 12021 : vars.maxCollateralToLiquidate = vars.baseCollateral.percentMul(liquidationBonus); + 432 : : + 433 : 12021 : if (vars.maxCollateralToLiquidate > userCollateralBalance) { + 434 : 1011 : vars.collateralAmount = userCollateralBalance; + 435 : 1011 : vars.debtAmountNeeded = ((vars.collateralPrice * vars.collateralAmount * vars.debtAssetUnit) / + 436 : : (vars.debtAssetPrice * vars.collateralAssetUnit)).percentDiv(liquidationBonus); + 437 : : } else { + 438 : 11010 : vars.collateralAmount = vars.maxCollateralToLiquidate; + 439 : 11010 : vars.debtAmountNeeded = debtToCover; + 440 : : } + 441 : : + 442 : 12021 : if (vars.liquidationProtocolFeePercentage != 0) { + 443 : 12019 : vars.bonusCollateral = + 444 : : vars.collateralAmount - + 445 : : vars.collateralAmount.percentDiv(liquidationBonus); + 446 : : + 447 : 12019 : vars.liquidationProtocolFee = vars.bonusCollateral.percentMul( + 448 : : vars.liquidationProtocolFeePercentage + 449 : : ); 450 : : - 451 : : /** - 452 : : * @notice Calculates how much of a specific collateral can be liquidated, given - 453 : : * a certain amount of debt asset. - 454 : : * @dev This function needs to be called after all the checks to validate the liquidation have been performed, - 455 : : * otherwise it might fail. - 456 : : * @param collateralReserve The data of the collateral reserve - 457 : : * @param debtReserveCache The cached data of the debt reserve - 458 : : * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation - 459 : : * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation - 460 : : * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover - 461 : : * @param userCollateralBalance The collateral balance for the specific `collateralAsset` of the user being liquidated - 462 : : * @param liquidationBonus The collateral bonus percentage to receive as result of the liquidation - 463 : : * @return The maximum amount that is possible to liquidate given all the liquidation constraints (user balance, close factor) - 464 : : * @return The amount to repay with the liquidation - 465 : : * @return The fee taken from the liquidation bonus amount to be paid to the protocol - 466 : : */ - 467 : 9023 : function _calculateAvailableCollateralToLiquidate( - 468 : : DataTypes.ReserveData storage collateralReserve, - 469 : : DataTypes.ReserveCache memory debtReserveCache, - 470 : : address collateralAsset, - 471 : : address debtAsset, - 472 : : uint256 debtToCover, - 473 : : uint256 userCollateralBalance, - 474 : : uint256 liquidationBonus, - 475 : : IPriceOracleGetter oracle - 476 : : ) internal view returns (uint256, uint256, uint256) { - 477 : 18046 : AvailableCollateralToLiquidateLocalVars memory vars; - 478 : : - 479 : 18046 : vars.collateralPrice = oracle.getAssetPrice(collateralAsset); - 480 : 18046 : vars.debtAssetPrice = oracle.getAssetPrice(debtAsset); - 481 : : - 482 : 18046 : vars.collateralDecimals = collateralReserve.configuration.getDecimals(); - 483 : 18046 : vars.debtAssetDecimals = debtReserveCache.reserveConfiguration.getDecimals(); - 484 : : - 485 : : unchecked { - 486 : 18046 : vars.collateralAssetUnit = 10 ** vars.collateralDecimals; - 487 : 18046 : vars.debtAssetUnit = 10 ** vars.debtAssetDecimals; - 488 : : } - 489 : : - 490 : 18046 : vars.liquidationProtocolFeePercentage = collateralReserve - 491 : : .configuration - 492 : : .getLiquidationProtocolFee(); - 493 : : - 494 : : // This is the base collateral to liquidate based on the given debt to cover - 495 : 18046 : vars.baseCollateral = - 496 : : ((vars.debtAssetPrice * debtToCover * vars.collateralAssetUnit)) / - 497 : : (vars.collateralPrice * vars.debtAssetUnit); - 498 : : - 499 : 18046 : vars.maxCollateralToLiquidate = vars.baseCollateral.percentMul(liquidationBonus); - 500 : : - 501 : 18046 : if (vars.maxCollateralToLiquidate > userCollateralBalance) { - 502 : 22 : vars.collateralAmount = userCollateralBalance; - 503 : 22 : vars.debtAmountNeeded = ((vars.collateralPrice * vars.collateralAmount * vars.debtAssetUnit) / - 504 : : (vars.debtAssetPrice * vars.collateralAssetUnit)).percentDiv(liquidationBonus); - 505 : : } else { - 506 : 18024 : vars.collateralAmount = vars.maxCollateralToLiquidate; - 507 : 18024 : vars.debtAmountNeeded = debtToCover; - 508 : : } - 509 : : - 510 : 18046 : if (vars.liquidationProtocolFeePercentage != 0) { - 511 : 18042 : vars.bonusCollateral = - 512 : : vars.collateralAmount - - 513 : : vars.collateralAmount.percentDiv(liquidationBonus); - 514 : : - 515 : 18042 : vars.liquidationProtocolFee = vars.bonusCollateral.percentMul( - 516 : : vars.liquidationProtocolFeePercentage - 517 : : ); - 518 : : - 519 : 18042 : return ( - 520 : : vars.collateralAmount - vars.liquidationProtocolFee, - 521 : : vars.debtAmountNeeded, - 522 : : vars.liquidationProtocolFee - 523 : : ); - 524 : : } else { - 525 : 4 : return (vars.collateralAmount, vars.debtAmountNeeded, 0); - 526 : : } - 527 : : } - 528 : : } + 451 : 12019 : return ( + 452 : : vars.collateralAmount - vars.liquidationProtocolFee, + 453 : : vars.debtAmountNeeded, + 454 : : vars.liquidationProtocolFee + 455 : : ); + 456 : : } else { + 457 : 2 : return (vars.collateralAmount, vars.debtAmountNeeded, 0); + 458 : : } + 459 : : } + 460 : : } @@ -604,8 +536,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func-c.html b/report/protocol/libraries/logic/PoolLogic.sol.func-c.html similarity index 66% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func-c.html rename to report/protocol/libraries/logic/PoolLogic.sol.func-c.html index dfb17312..3fcf8767 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/PoolLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/PoolLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,70 +53,70 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - PoolLogic.sol (source / functions)top level - protocol/libraries/logic - PoolLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + @@ -124,8 +124,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolLogic.executeMintToTreasuryPoolLogic.executeMintToTreasury 4
PoolLogic.executeDropReservePoolLogic.executeDropReserve 9
PoolLogic.executeResetIsolationModeTotalDebtPoolLogic.executeResetIsolationModeTotalDebt17511951
PoolLogic.executeRescueTokensPoolLogic.executeRescueTokens 2000
PoolLogic.executeInitReservePoolLogic.executeGetUserAccountData288910015
PoolLogic.executeGetUserAccountDataPoolLogic.executeSetLiquidationGracePeriod301312412
PoolLogic.executeSetLiquidationGracePeriodPoolLogic.executeInitReserve9028166023
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func.html b/report/protocol/libraries/logic/PoolLogic.sol.func.html similarity index 66% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func.html rename to report/protocol/libraries/logic/PoolLogic.sol.func.html index 6cd89e2d..63ec4fd8 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.func.html +++ b/report/protocol/libraries/logic/PoolLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/PoolLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,70 +53,70 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - PoolLogic.sol (source / functions)top level - protocol/libraries/logic - PoolLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + - + - + - + - + - + - + - + - + @@ -124,8 +124,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolLogic.executeDropReservePoolLogic.executeDropReserve 9
PoolLogic.executeGetUserAccountDataPoolLogic.executeGetUserAccountData301310015
PoolLogic.executeInitReserve2889166023
PoolLogic.executeMintToTreasuryPoolLogic.executeMintToTreasury 4
PoolLogic.executeRescueTokensPoolLogic.executeRescueTokens 2000
PoolLogic.executeResetIsolationModeTotalDebtPoolLogic.executeResetIsolationModeTotalDebt17511951
PoolLogic.executeSetLiquidationGracePeriodPoolLogic.executeSetLiquidationGracePeriod902812412
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.gcov.html b/report/protocol/libraries/logic/PoolLogic.sol.gcov.html similarity index 86% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.gcov.html rename to report/protocol/libraries/logic/PoolLogic.sol.gcov.html index 1b87cbfe..bc54127d 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/PoolLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/PoolLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/PoolLogic.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - PoolLogic.sol (source / functions)top level - protocol/libraries/logic - PoolLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -106,171 +106,170 @@ 35 : : * @param params Additional parameters needed for initiation 36 : : * @return true if appended, false if inserted at existing empty spot 37 : : */ - 38 : 2889 : function executeInitReserve( + 38 : : function executeInitReserve( 39 : : mapping(address => DataTypes.ReserveData) storage reservesData, 40 : : mapping(uint256 => address) storage reservesList, 41 : : DataTypes.InitReserveParams memory params 42 : : ) external returns (bool) { - 43 : 5778 : require(Address.isContract(params.asset), Errors.NOT_CONTRACT); - 44 : 5778 : reservesData[params.asset].init( + 43 : 166023 : require(Address.isContract(params.asset), Errors.NOT_CONTRACT); + 44 : 166023 : reservesData[params.asset].init( 45 : : params.aTokenAddress, - 46 : : params.stableDebtAddress, - 47 : : params.variableDebtAddress, - 48 : : params.interestRateStrategyAddress - 49 : : ); - 50 : : - 51 : 11552 : bool reserveAlreadyAdded = reservesData[params.asset].id != 0 || - 52 : 5776 : reservesList[0] == params.asset; - 53 : 5776 : require(!reserveAlreadyAdded, Errors.RESERVE_ALREADY_ADDED); - 54 : : - 55 : 34740 : for (uint16 i = 0; i < params.reservesCount; i++) { - 56 : 39117 : if (reservesList[i] == address(0)) { - 57 : 2 : reservesData[params.asset].id = i; - 58 : 2 : reservesList[i] = params.asset; - 59 : 2 : return false; - 60 : : } - 61 : : } - 62 : : - 63 : 5774 : require(params.reservesCount < params.maxNumberReserves, Errors.NO_MORE_RESERVES_ALLOWED); - 64 : 5770 : reservesData[params.asset].id = params.reservesCount; - 65 : 5770 : reservesList[params.reservesCount] = params.asset; - 66 : 5770 : return true; - 67 : : } - 68 : : - 69 : : /** - 70 : : * @notice Rescue and transfer tokens locked in this contract - 71 : : * @param token The address of the token - 72 : : * @param to The address of the recipient - 73 : : * @param amount The amount of token to transfer - 74 : : */ - 75 : 2000 : function executeRescueTokens(address token, address to, uint256 amount) external { - 76 : 4000 : IERC20(token).safeTransfer(to, amount); - 77 : : } - 78 : : - 79 : : /** - 80 : : * @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens - 81 : : * @param reservesData The state of all the reserves - 82 : : * @param assets The list of reserves for which the minting needs to be executed - 83 : : */ - 84 : 4 : function executeMintToTreasury( - 85 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 86 : : address[] calldata assets - 87 : : ) external { - 88 : 24 : for (uint256 i = 0; i < assets.length; i++) { - 89 : 12 : address assetAddress = assets[i]; - 90 : : - 91 : 12 : DataTypes.ReserveData storage reserve = reservesData[assetAddress]; - 92 : : - 93 : : // this cover both inactive reserves and invalid reserves since the flag will be 0 for both - 94 : 12 : if (!reserve.configuration.getActive()) { - 95 : 4 : continue; - 96 : : } - 97 : : - 98 : 8 : uint256 accruedToTreasury = reserve.accruedToTreasury; - 99 : : - 100 : 8 : if (accruedToTreasury != 0) { - 101 : 8 : reserve.accruedToTreasury = 0; - 102 : 12 : uint256 normalizedIncome = reserve.getNormalizedIncome(); - 103 : 12 : uint256 amountToMint = accruedToTreasury.rayMul(normalizedIncome); - 104 : 8 : IAToken(reserve.aTokenAddress).mintToTreasury(amountToMint, normalizedIncome); - 105 : : - 106 : 8 : emit MintedToTreasury(assetAddress, amountToMint); - 107 : : } - 108 : : } - 109 : : } - 110 : : - 111 : : /** - 112 : : * @notice Resets the isolation mode total debt of the given asset to zero - 113 : : * @dev It requires the given asset has zero debt ceiling - 114 : : * @param reservesData The state of all the reserves - 115 : : * @param asset The address of the underlying asset to reset the isolationModeTotalDebt - 116 : : */ - 117 : 1751 : function executeResetIsolationModeTotalDebt( - 118 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 119 : : address asset - 120 : : ) external { - 121 : 3502 : require(reservesData[asset].configuration.getDebtCeiling() == 0, Errors.DEBT_CEILING_NOT_ZERO); - 122 : 3502 : reservesData[asset].isolationModeTotalDebt = 0; - 123 : 3502 : emit IsolationModeTotalDebtUpdated(asset, 0); - 124 : : } - 125 : : - 126 : : /** - 127 : : * @notice Sets the liquidation grace period of the asset - 128 : : * @param reservesData The state of all the reserves - 129 : : * @param asset The address of the underlying asset to set the liquidationGracePeriod - 130 : : * @param until Timestamp when the liquidation grace period will end - 131 : : */ - 132 : 9028 : function executeSetLiquidationGracePeriod( - 133 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 134 : : address asset, - 135 : : uint40 until - 136 : : ) external { - 137 : 18056 : reservesData[asset].liquidationGracePeriodUntil = until; - 138 : : } - 139 : : - 140 : : /** - 141 : : * @notice Drop a reserve - 142 : : * @param reservesData The state of all the reserves - 143 : : * @param reservesList The addresses of all the active reserves - 144 : : * @param asset The address of the underlying asset of the reserve - 145 : : */ - 146 : 9 : function executeDropReserve( - 147 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 148 : : mapping(uint256 => address) storage reservesList, - 149 : : address asset - 150 : : ) external { - 151 : 18 : DataTypes.ReserveData storage reserve = reservesData[asset]; - 152 : 18 : ValidationLogic.validateDropReserve(reservesList, reserve, asset); - 153 : 10 : reservesList[reservesData[asset].id] = address(0); - 154 : 10 : delete reservesData[asset]; - 155 : : } - 156 : : - 157 : : /** - 158 : : * @notice Returns the user account data across all the reserves - 159 : : * @param reservesData The state of all the reserves - 160 : : * @param reservesList The addresses of all the active reserves - 161 : : * @param eModeCategories The configuration of all the efficiency mode categories - 162 : : * @param params Additional params needed for the calculation - 163 : : * @return totalCollateralBase The total collateral of the user in the base currency used by the price feed - 164 : : * @return totalDebtBase The total debt of the user in the base currency used by the price feed - 165 : : * @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed - 166 : : * @return currentLiquidationThreshold The liquidation threshold of the user - 167 : : * @return ltv The loan to value of The user - 168 : : * @return healthFactor The current health factor of the user - 169 : : */ - 170 : 3013 : function executeGetUserAccountData( - 171 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 172 : : mapping(uint256 => address) storage reservesList, - 173 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 174 : : DataTypes.CalculateUserAccountDataParams memory params - 175 : : ) - 176 : : external - 177 : : view - 178 : : returns ( - 179 : : uint256 totalCollateralBase, - 180 : : uint256 totalDebtBase, - 181 : : uint256 availableBorrowsBase, - 182 : : uint256 currentLiquidationThreshold, - 183 : : uint256 ltv, - 184 : : uint256 healthFactor - 185 : : ) - 186 : : { - 187 : 6026 : ( - 188 : : totalCollateralBase, - 189 : : totalDebtBase, - 190 : : ltv, - 191 : : currentLiquidationThreshold, - 192 : : healthFactor, - 193 : : - 194 : : ) = GenericLogic.calculateUserAccountData(reservesData, reservesList, eModeCategories, params); - 195 : : - 196 : 6026 : availableBorrowsBase = GenericLogic.calculateAvailableBorrows( - 197 : : totalCollateralBase, - 198 : : totalDebtBase, - 199 : : ltv - 200 : : ); - 201 : : } - 202 : : } + 46 : : params.variableDebtAddress, + 47 : : params.interestRateStrategyAddress + 48 : : ); + 49 : : + 50 : 166022 : bool reserveAlreadyAdded = reservesData[params.asset].id != 0 || + 51 : 166022 : reservesList[0] == params.asset; + 52 : 166022 : require(!reserveAlreadyAdded, Errors.RESERVE_ALREADY_ADDED); + 53 : : + 54 : 166022 : for (uint16 i = 0; i < params.reservesCount; i++) { + 55 : 9608022 : if (reservesList[i] == address(0)) { + 56 : 1 : reservesData[params.asset].id = i; + 57 : 1 : reservesList[i] = params.asset; + 58 : 1 : return false; + 59 : : } + 60 : : } + 61 : : + 62 : 166021 : require(params.reservesCount < params.maxNumberReserves, Errors.NO_MORE_RESERVES_ALLOWED); + 63 : 165020 : reservesData[params.asset].id = params.reservesCount; + 64 : 165020 : reservesList[params.reservesCount] = params.asset; + 65 : 165020 : return true; + 66 : : } + 67 : : + 68 : : /** + 69 : : * @notice Rescue and transfer tokens locked in this contract + 70 : : * @param token The address of the token + 71 : : * @param to The address of the recipient + 72 : : * @param amount The amount of token to transfer + 73 : : */ + 74 : : function executeRescueTokens(address token, address to, uint256 amount) external { + 75 : 2000 : IERC20(token).safeTransfer(to, amount); + 76 : : } + 77 : : + 78 : : /** + 79 : : * @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens + 80 : : * @param reservesData The state of all the reserves + 81 : : * @param assets The list of reserves for which the minting needs to be executed + 82 : : */ + 83 : : function executeMintToTreasury( + 84 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 85 : : address[] calldata assets + 86 : : ) external { + 87 : 4 : for (uint256 i = 0; i < assets.length; i++) { + 88 : 6 : address assetAddress = assets[i]; + 89 : : + 90 : 6 : DataTypes.ReserveData storage reserve = reservesData[assetAddress]; + 91 : : + 92 : : // this cover both inactive reserves and invalid reserves since the flag will be 0 for both + 93 : 6 : if (!reserve.configuration.getActive()) { + 94 : 2 : continue; + 95 : : } + 96 : : + 97 : 4 : uint256 accruedToTreasury = reserve.accruedToTreasury; + 98 : : + 99 : 4 : if (accruedToTreasury != 0) { + 100 : 4 : reserve.accruedToTreasury = 0; + 101 : 4 : uint256 normalizedIncome = reserve.getNormalizedIncome(); + 102 : 4 : uint256 amountToMint = accruedToTreasury.rayMul(normalizedIncome); + 103 : 4 : IAToken(reserve.aTokenAddress).mintToTreasury(amountToMint, normalizedIncome); + 104 : : + 105 : 4 : emit MintedToTreasury(assetAddress, amountToMint); + 106 : : } + 107 : : } + 108 : : } + 109 : : + 110 : : /** + 111 : : * @notice Resets the isolation mode total debt of the given asset to zero + 112 : : * @dev It requires the given asset has zero debt ceiling + 113 : : * @param reservesData The state of all the reserves + 114 : : * @param asset The address of the underlying asset to reset the isolationModeTotalDebt + 115 : : */ + 116 : : function executeResetIsolationModeTotalDebt( + 117 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 118 : : address asset + 119 : : ) external { + 120 : 1951 : require(reservesData[asset].configuration.getDebtCeiling() == 0, Errors.DEBT_CEILING_NOT_ZERO); + 121 : 1951 : reservesData[asset].isolationModeTotalDebt = 0; + 122 : 1951 : emit IsolationModeTotalDebtUpdated(asset, 0); + 123 : : } + 124 : : + 125 : : /** + 126 : : * @notice Sets the liquidation grace period of the asset + 127 : : * @param reservesData The state of all the reserves + 128 : : * @param asset The address of the underlying asset to set the liquidationGracePeriod + 129 : : * @param until Timestamp when the liquidation grace period will end + 130 : : */ + 131 : : function executeSetLiquidationGracePeriod( + 132 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 133 : : address asset, + 134 : : uint40 until + 135 : : ) external { + 136 : 12412 : reservesData[asset].liquidationGracePeriodUntil = until; + 137 : : } + 138 : : + 139 : : /** + 140 : : * @notice Drop a reserve + 141 : : * @param reservesData The state of all the reserves + 142 : : * @param reservesList The addresses of all the active reserves + 143 : : * @param asset The address of the underlying asset of the reserve + 144 : : */ + 145 : : function executeDropReserve( + 146 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 147 : : mapping(uint256 => address) storage reservesList, + 148 : : address asset + 149 : : ) external { + 150 : 9 : DataTypes.ReserveData storage reserve = reservesData[asset]; + 151 : 9 : ValidationLogic.validateDropReserve(reservesList, reserve, asset); + 152 : 5 : reservesList[reservesData[asset].id] = address(0); + 153 : 5 : delete reservesData[asset]; + 154 : : } + 155 : : + 156 : : /** + 157 : : * @notice Returns the user account data across all the reserves + 158 : : * @param reservesData The state of all the reserves + 159 : : * @param reservesList The addresses of all the active reserves + 160 : : * @param eModeCategories The configuration of all the efficiency mode categories + 161 : : * @param params Additional params needed for the calculation + 162 : : * @return totalCollateralBase The total collateral of the user in the base currency used by the price feed + 163 : : * @return totalDebtBase The total debt of the user in the base currency used by the price feed + 164 : : * @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed + 165 : : * @return currentLiquidationThreshold The liquidation threshold of the user + 166 : : * @return ltv The loan to value of The user + 167 : : * @return healthFactor The current health factor of the user + 168 : : */ + 169 : : function executeGetUserAccountData( + 170 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 171 : : mapping(uint256 => address) storage reservesList, + 172 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 173 : : DataTypes.CalculateUserAccountDataParams memory params + 174 : : ) + 175 : : external + 176 : : view + 177 : : returns ( + 178 : : uint256 totalCollateralBase, + 179 : : uint256 totalDebtBase, + 180 : : uint256 availableBorrowsBase, + 181 : : uint256 currentLiquidationThreshold, + 182 : : uint256 ltv, + 183 : : uint256 healthFactor + 184 : : ) + 185 : : { + 186 : 10015 : ( + 187 : : totalCollateralBase, + 188 : : totalDebtBase, + 189 : : ltv, + 190 : : currentLiquidationThreshold, + 191 : : healthFactor, + 192 : : + 193 : : ) = GenericLogic.calculateUserAccountData(reservesData, reservesList, eModeCategories, params); + 194 : : + 195 : 10015 : availableBorrowsBase = GenericLogic.calculateAvailableBorrows( + 196 : : totalCollateralBase, + 197 : : totalDebtBase, + 198 : : ltv + 199 : : ); + 200 : : } + 201 : : } @@ -278,8 +277,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func-c.html b/report/protocol/libraries/logic/SupplyLogic.sol.func-c.html similarity index 68% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func-c.html rename to report/protocol/libraries/logic/SupplyLogic.sol.func-c.html index 452c1606..f464f30d 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/SupplyLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/SupplyLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - SupplyLogic.sol (source / functions)top level - protocol/libraries/logic - SupplyLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + @@ -81,21 +81,21 @@ - + - + - + @@ -103,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
SupplyLogic.executeWithdraw452045
SupplyLogic.executeFinalizeTransfer103617042
SupplyLogic.executeSupply1358244515
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func.html b/report/protocol/libraries/logic/SupplyLogic.sol.func.html similarity index 68% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func.html rename to report/protocol/libraries/logic/SupplyLogic.sol.func.html index 039c5115..88a637ef 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.func.html +++ b/report/protocol/libraries/logic/SupplyLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/SupplyLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - SupplyLogic.sol (source / functions)top level - protocol/libraries/logic - SupplyLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -95,7 +95,7 @@ - + @@ -103,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
SupplyLogic.executeFinalizeTransfer103617042
SupplyLogic.executeSupply1358244515
SupplyLogic.executeWithdraw452045
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.gcov.html b/report/protocol/libraries/logic/SupplyLogic.sol.gcov.html similarity index 88% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.gcov.html rename to report/protocol/libraries/logic/SupplyLogic.sol.gcov.html index 5d94b67a..c4930385 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/SupplyLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/SupplyLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/SupplyLogic.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - SupplyLogic.sol (source / functions)top level - protocol/libraries/logic - SupplyLogic.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -120,33 +120,33 @@ 49 : : * @param userConfig The user configuration mapping that tracks the supplied/borrowed assets 50 : : * @param params The additional parameters needed to execute the supply function 51 : : */ - 52 : 13582 : function executeSupply( + 52 : : function executeSupply( 53 : : mapping(address => DataTypes.ReserveData) storage reservesData, 54 : : mapping(uint256 => address) storage reservesList, 55 : : DataTypes.UserConfigurationMap storage userConfig, 56 : : DataTypes.ExecuteSupplyParams memory params 57 : : ) external { - 58 : 27164 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; - 59 : 40746 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 58 : 44515 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; + 59 : 44515 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); 60 : : - 61 : 27164 : reserve.updateState(reserveCache); + 61 : 44515 : reserve.updateState(reserveCache); 62 : : - 63 : 27164 : ValidationLogic.validateSupply(reserveCache, reserve, params.amount, params.onBehalfOf); + 63 : 44515 : ValidationLogic.validateSupply(reserveCache, reserve, params.amount, params.onBehalfOf); 64 : : - 65 : 27148 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, params.amount, 0); + 65 : 44507 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, params.amount, 0); 66 : : - 67 : 27146 : IERC20(params.asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, params.amount); + 67 : 44506 : IERC20(params.asset).safeTransferFrom(msg.sender, reserveCache.aTokenAddress, params.amount); 68 : : - 69 : 37719 : bool isFirstSupply = IAToken(reserveCache.aTokenAddress).mint( + 69 : 43506 : bool isFirstSupply = IAToken(reserveCache.aTokenAddress).mint( 70 : : msg.sender, 71 : : params.onBehalfOf, 72 : : params.amount, 73 : : reserveCache.nextLiquidityIndex 74 : : ); 75 : : - 76 : 12573 : if (isFirstSupply) { + 76 : 43506 : if (isFirstSupply) { 77 : : if ( - 78 : 25094 : ValidationLogic.validateAutomaticUseAsCollateral( + 78 : 43501 : ValidationLogic.validateAutomaticUseAsCollateral( 79 : : reservesData, 80 : : reservesList, 81 : : userConfig, @@ -154,12 +154,12 @@ 83 : : reserveCache.aTokenAddress 84 : : ) 85 : : ) { - 86 : 25068 : userConfig.setUsingAsCollateral(reserve.id, true); - 87 : 25068 : emit ReserveUsedAsCollateralEnabled(params.asset, params.onBehalfOf); + 86 : 43488 : userConfig.setUsingAsCollateral(reserve.id, true); + 87 : 43488 : emit ReserveUsedAsCollateralEnabled(params.asset, params.onBehalfOf); 88 : : } 89 : : } 90 : : - 91 : 25146 : emit Supply(params.asset, msg.sender, params.onBehalfOf, params.amount, params.referralCode); + 91 : 43506 : emit Supply(params.asset, msg.sender, params.onBehalfOf, params.amount, params.referralCode); 92 : : } 93 : : 94 : : /** @@ -174,50 +174,50 @@ 103 : : * @param params The additional parameters needed to execute the withdraw function 104 : : * @return The actual amount withdrawn 105 : : */ - 106 : 45 : function executeWithdraw( + 106 : : function executeWithdraw( 107 : : mapping(address => DataTypes.ReserveData) storage reservesData, 108 : : mapping(uint256 => address) storage reservesList, 109 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, 110 : : DataTypes.UserConfigurationMap storage userConfig, 111 : : DataTypes.ExecuteWithdrawParams memory params 112 : : ) external returns (uint256) { - 113 : 90 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; - 114 : 135 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 113 : 2045 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; + 114 : 2045 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); 115 : : - 116 : 90 : require(params.to != reserveCache.aTokenAddress, Errors.WITHDRAW_TO_ATOKEN); + 116 : 2045 : require(params.to != reserveCache.aTokenAddress, Errors.WITHDRAW_TO_ATOKEN); 117 : : - 118 : 88 : reserve.updateState(reserveCache); + 118 : 2044 : reserve.updateState(reserveCache); 119 : : - 120 : 132 : uint256 userBalance = IAToken(reserveCache.aTokenAddress).scaledBalanceOf(msg.sender).rayMul( + 120 : 2044 : uint256 userBalance = IAToken(reserveCache.aTokenAddress).scaledBalanceOf(msg.sender).rayMul( 121 : : reserveCache.nextLiquidityIndex 122 : : ); 123 : : - 124 : 88 : uint256 amountToWithdraw = params.amount; + 124 : 2044 : uint256 amountToWithdraw = params.amount; 125 : : - 126 : 88 : if (params.amount == type(uint256).max) { - 127 : 10 : amountToWithdraw = userBalance; + 126 : 2044 : if (params.amount == type(uint256).max) { + 127 : 5 : amountToWithdraw = userBalance; 128 : : } 129 : : - 130 : 88 : ValidationLogic.validateWithdraw(reserveCache, amountToWithdraw, userBalance); + 130 : 2044 : ValidationLogic.validateWithdraw(reserveCache, amountToWithdraw, userBalance); 131 : : - 132 : 80 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, 0, amountToWithdraw); + 132 : 2040 : reserve.updateInterestRatesAndVirtualBalance(reserveCache, params.asset, 0, amountToWithdraw); 133 : : - 134 : 111 : bool isCollateral = userConfig.isUsingAsCollateral(reserve.id); + 134 : 2037 : bool isCollateral = userConfig.isUsingAsCollateral(reserve.id); 135 : : - 136 : 110 : if (isCollateral && amountToWithdraw == userBalance) { - 137 : 60 : userConfig.setUsingAsCollateral(reserve.id, false); - 138 : 60 : emit ReserveUsedAsCollateralDisabled(params.asset, msg.sender); + 136 : 2037 : if (isCollateral && amountToWithdraw == userBalance) { + 137 : 2030 : userConfig.setUsingAsCollateral(reserve.id, false); + 138 : 2030 : emit ReserveUsedAsCollateralDisabled(params.asset, msg.sender); 139 : : } 140 : : - 141 : 74 : IAToken(reserveCache.aTokenAddress).burn( + 141 : 2037 : IAToken(reserveCache.aTokenAddress).burn( 142 : : msg.sender, 143 : : params.to, 144 : : amountToWithdraw, 145 : : reserveCache.nextLiquidityIndex 146 : : ); 147 : : - 148 : 110 : if (isCollateral && userConfig.isBorrowingAny()) { - 149 : 2 : ValidationLogic.validateHFAndLtv( + 148 : 2037 : if (isCollateral && userConfig.isBorrowingAny()) { + 149 : 1 : ValidationLogic.validateHFAndLtv( 150 : : reservesData, 151 : : reservesList, 152 : : eModeCategories, @@ -230,9 +230,9 @@ 159 : : ); 160 : : } 161 : : - 162 : 72 : emit Withdraw(params.asset, msg.sender, params.to, amountToWithdraw); + 162 : 2036 : emit Withdraw(params.asset, msg.sender, params.to, amountToWithdraw); 163 : : - 164 : 72 : return amountToWithdraw; + 164 : 2036 : return amountToWithdraw; 165 : : } 166 : : 167 : : /** @@ -247,26 +247,26 @@ 176 : : * @param usersConfig The users configuration mapping that track the supplied/borrowed assets 177 : : * @param params The additional parameters needed to execute the finalizeTransfer function 178 : : */ - 179 : 1036 : function executeFinalizeTransfer( + 179 : : function executeFinalizeTransfer( 180 : : mapping(address => DataTypes.ReserveData) storage reservesData, 181 : : mapping(uint256 => address) storage reservesList, 182 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, 183 : : mapping(address => DataTypes.UserConfigurationMap) storage usersConfig, 184 : : DataTypes.FinalizeTransferParams memory params 185 : : ) external { - 186 : 2072 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; + 186 : 17042 : DataTypes.ReserveData storage reserve = reservesData[params.asset]; 187 : : - 188 : 2072 : ValidationLogic.validateTransfer(reserve); + 188 : 17042 : ValidationLogic.validateTransfer(reserve); 189 : : - 190 : 2072 : uint256 reserveId = reserve.id; - 191 : 3108 : uint256 scaledAmount = params.amount.rayDiv(reserve.getNormalizedIncome()); + 190 : 17042 : uint256 reserveId = reserve.id; + 191 : 17042 : uint256 scaledAmount = params.amount.rayDiv(reserve.getNormalizedIncome()); 192 : : - 193 : 4142 : if (params.from != params.to && scaledAmount != 0) { - 194 : 1558 : DataTypes.UserConfigurationMap storage fromConfig = usersConfig[params.from]; + 193 : 17042 : if (params.from != params.to && scaledAmount != 0) { + 194 : 16898 : DataTypes.UserConfigurationMap storage fromConfig = usersConfig[params.from]; 195 : : - 196 : 1558 : if (fromConfig.isUsingAsCollateral(reserveId)) { - 197 : 1558 : if (fromConfig.isBorrowingAny()) { - 198 : 12 : ValidationLogic.validateHFAndLtv( + 196 : 16898 : if (fromConfig.isUsingAsCollateral(reserveId)) { + 197 : 16898 : if (fromConfig.isBorrowingAny()) { + 198 : 6 : ValidationLogic.validateHFAndLtv( 199 : : reservesData, 200 : : reservesList, 201 : : eModeCategories, @@ -278,16 +278,16 @@ 207 : : params.fromEModeCategory 208 : : ); 209 : : } - 210 : 1556 : if (params.balanceFromBefore == params.amount) { - 211 : 14 : fromConfig.setUsingAsCollateral(reserveId, false); - 212 : 14 : emit ReserveUsedAsCollateralDisabled(params.asset, params.from); + 210 : 16897 : if (params.balanceFromBefore == params.amount) { + 211 : 15013 : fromConfig.setUsingAsCollateral(reserveId, false); + 212 : 15013 : emit ReserveUsedAsCollateralDisabled(params.asset, params.from); 213 : : } 214 : : } 215 : : - 216 : 1556 : if (params.balanceToBefore == 0) { - 217 : 1548 : DataTypes.UserConfigurationMap storage toConfig = usersConfig[params.to]; + 216 : 16897 : if (params.balanceToBefore == 0) { + 217 : 15893 : DataTypes.UserConfigurationMap storage toConfig = usersConfig[params.to]; 218 : : if ( - 219 : 1548 : ValidationLogic.validateAutomaticUseAsCollateral( + 219 : 15893 : ValidationLogic.validateAutomaticUseAsCollateral( 220 : : reservesData, 221 : : reservesList, 222 : : toConfig, @@ -295,8 +295,8 @@ 224 : : reserve.aTokenAddress 225 : : ) 226 : : ) { - 227 : 1548 : toConfig.setUsingAsCollateral(reserveId, true); - 228 : 1548 : emit ReserveUsedAsCollateralEnabled(params.asset, params.to); + 227 : 15893 : toConfig.setUsingAsCollateral(reserveId, true); + 228 : 15893 : emit ReserveUsedAsCollateralEnabled(params.asset, params.to); 229 : : } 230 : : } 231 : : } @@ -318,7 +318,7 @@ 247 : : * @param priceOracle The address of the price oracle 248 : : * @param userEModeCategory The eMode category chosen by the user 249 : : */ - 250 : 43 : function executeUseReserveAsCollateral( + 250 : : function executeUseReserveAsCollateral( 251 : : mapping(address => DataTypes.ReserveData) storage reservesData, 252 : : mapping(uint256 => address) storage reservesList, 253 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, @@ -329,17 +329,17 @@ 258 : : address priceOracle, 259 : : uint8 userEModeCategory 260 : : ) external { - 261 : 86 : DataTypes.ReserveData storage reserve = reservesData[asset]; - 262 : 129 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 261 : 43 : DataTypes.ReserveData storage reserve = reservesData[asset]; + 262 : 43 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); 263 : : - 264 : 129 : uint256 userBalance = IERC20(reserveCache.aTokenAddress).balanceOf(msg.sender); + 264 : 43 : uint256 userBalance = IERC20(reserveCache.aTokenAddress).balanceOf(msg.sender); 265 : : - 266 : 86 : ValidationLogic.validateSetUseReserveAsCollateral(reserveCache, userBalance); + 266 : 43 : ValidationLogic.validateSetUseReserveAsCollateral(reserveCache, userBalance); 267 : : - 268 : 113 : if (useAsCollateral == userConfig.isUsingAsCollateral(reserve.id)) return; + 268 : 37 : if (useAsCollateral == userConfig.isUsingAsCollateral(reserve.id)) return; 269 : : 270 : 35 : if (useAsCollateral) { - 271 : 38 : require( + 271 : 19 : require( 272 : : ValidationLogic.validateUseAsCollateral( 273 : : reservesData, 274 : : reservesList, @@ -349,11 +349,11 @@ 278 : : Errors.USER_IN_ISOLATION_MODE_OR_LTV_ZERO 279 : : ); 280 : : - 281 : 30 : userConfig.setUsingAsCollateral(reserve.id, true); - 282 : 30 : emit ReserveUsedAsCollateralEnabled(asset, msg.sender); + 281 : 15 : userConfig.setUsingAsCollateral(reserve.id, true); + 282 : 15 : emit ReserveUsedAsCollateralEnabled(asset, msg.sender); 283 : : } else { - 284 : 32 : userConfig.setUsingAsCollateral(reserve.id, false); - 285 : 32 : ValidationLogic.validateHFAndLtv( + 284 : 16 : userConfig.setUsingAsCollateral(reserve.id, false); + 285 : 16 : ValidationLogic.validateHFAndLtv( 286 : : reservesData, 287 : : reservesList, 288 : : eModeCategories, @@ -365,7 +365,7 @@ 294 : : userEModeCategory 295 : : ); 296 : : - 297 : 28 : emit ReserveUsedAsCollateralDisabled(asset, msg.sender); + 297 : 14 : emit ReserveUsedAsCollateralDisabled(asset, msg.sender); 298 : : } 299 : : } 300 : : } @@ -376,8 +376,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func-c.html b/report/protocol/libraries/logic/ValidationLogic.sol.func-c.html similarity index 57% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func-c.html rename to report/protocol/libraries/logic/ValidationLogic.sol.func-c.html index 1c7aa134..ecc963ea 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func-c.html +++ b/report/protocol/libraries/logic/ValidationLogic.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/ValidationLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,140 +53,126 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ValidationLogic.sol (source / functions)top level - protocol/libraries/logic - ValidationLogic.sol (source / functions) Coverage Lines: 100.0 %132132110110
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %17171515
0 0
- + - + - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -194,8 +180,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ValidationLogic.validateRebalanceStableBorrowRate5
ValidationLogic.validateSwapRateMode8
ValidationLogic.validateDropReserveValidationLogic.validateDropReserve 9
ValidationLogic.validateFlashloanValidationLogic.validateFlashloanSimple1023
ValidationLogic.validateSetUserEModeValidationLogic.validateHFAndLtv1723
ValidationLogic.validateFlashloanSimpleValidationLogic.validateSetUseReserveAsCollateral2143
ValidationLogic.validateHFAndLtvValidationLogic.validateFlashloan231011
ValidationLogic.validateHealthFactorValidationLogic.validateWithdraw272044
ValidationLogic.validateSetUseReserveAsCollateralValidationLogic.validateRepay435030
ValidationLogic.validateWithdrawValidationLogic.validateHealthFactor448637
ValidationLogic.validateTransferValidationLogic.validateSetUserEMode10369617
ValidationLogic.validateRepayValidationLogic.validateLiquidationCall502914501
ValidationLogic.validateBorrowValidationLogic.validateBorrow911716110
ValidationLogic.validateLiquidationCallValidationLogic.validateTransfer1129217042
ValidationLogic.validateAutomaticUseAsCollateralValidationLogic.validateSupply1333144531
ValidationLogic.validateUseAsCollateralValidationLogic.validateAutomaticUseAsCollateral1333859404
ValidationLogic.validateSupplyValidationLogic.validateUseAsCollateral1359859411
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func.html b/report/protocol/libraries/logic/ValidationLogic.sol.func.html similarity index 57% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func.html rename to report/protocol/libraries/logic/ValidationLogic.sol.func.html index 7319ff08..8e7a3e8d 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.func.html +++ b/report/protocol/libraries/logic/ValidationLogic.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol - functions - + LCOV - lcov.info.p - protocol/libraries/logic/ValidationLogic.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,140 +53,126 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ValidationLogic.sol (source / functions)top level - protocol/libraries/logic - ValidationLogic.sol (source / functions) Coverage Lines: 100.0 %132132110110
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %17171515
0 0
- + - + - + - + - + - + - + - + - + - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + - + - + - + - + - + - + @@ -194,8 +180,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ValidationLogic.validateAutomaticUseAsCollateralValidationLogic.validateAutomaticUseAsCollateral1333159404
ValidationLogic.validateBorrowValidationLogic.validateBorrow911716110
ValidationLogic.validateDropReserveValidationLogic.validateDropReserve 9
ValidationLogic.validateFlashloanValidationLogic.validateFlashloan101011
ValidationLogic.validateFlashloanSimple21
ValidationLogic.validateHFAndLtvValidationLogic.validateFlashloanSimple 23
ValidationLogic.validateHealthFactorValidationLogic.validateHFAndLtv2723
ValidationLogic.validateLiquidationCallValidationLogic.validateHealthFactor112928637
ValidationLogic.validateRebalanceStableBorrowRateValidationLogic.validateLiquidationCall514501
ValidationLogic.validateRepayValidationLogic.validateRepay50295030
ValidationLogic.validateSetUseReserveAsCollateralValidationLogic.validateSetUseReserveAsCollateral 43
ValidationLogic.validateSetUserEModeValidationLogic.validateSetUserEMode179617
ValidationLogic.validateSupply13598
ValidationLogic.validateSwapRateMode844531
ValidationLogic.validateTransferValidationLogic.validateTransfer103617042
ValidationLogic.validateUseAsCollateralValidationLogic.validateUseAsCollateral1333859411
ValidationLogic.validateWithdrawValidationLogic.validateWithdraw442044
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.gcov.html b/report/protocol/libraries/logic/ValidationLogic.sol.gcov.html similarity index 71% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.gcov.html rename to report/protocol/libraries/logic/ValidationLogic.sol.gcov.html index d7f1dd6f..02916898 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol.gcov.html +++ b/report/protocol/libraries/logic/ValidationLogic.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/ValidationLogic.sol - + LCOV - lcov.info.p - protocol/libraries/logic/ValidationLogic.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - ValidationLogic.sol (source / functions)top level - protocol/libraries/logic - ValidationLogic.sol (source / functions) Coverage Lines: 100.0 %132132110110
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %17171515
0 0
@@ -76,15 +76,15 @@ 5 : : import {Address} from '../../../dependencies/openzeppelin/contracts/Address.sol'; 6 : : import {GPv2SafeERC20} from '../../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; 7 : : import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; - 8 : : import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; - 9 : : import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol'; - 10 : : import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; - 11 : : import {IAToken} from '../../../interfaces/IAToken.sol'; - 12 : : import {IPriceOracleSentinel} from '../../../interfaces/IPriceOracleSentinel.sol'; - 13 : : import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; - 14 : : import {IAccessControl} from '../../../dependencies/openzeppelin/contracts/IAccessControl.sol'; - 15 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; - 16 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; + 8 : : import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol'; + 9 : : import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; + 10 : : import {IAToken} from '../../../interfaces/IAToken.sol'; + 11 : : import {IPriceOracleSentinel} from '../../../interfaces/IPriceOracleSentinel.sol'; + 12 : : import {IPoolAddressesProvider} from '../../../interfaces/IPoolAddressesProvider.sol'; + 13 : : import {IAccessControl} from '../../../dependencies/openzeppelin/contracts/IAccessControl.sol'; + 14 : : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; + 15 : : import {UserConfiguration} from '../configuration/UserConfiguration.sol'; + 16 : : import {EModeConfiguration} from '../configuration/EModeConfiguration.sol'; 17 : : import {Errors} from '../helpers/Errors.sol'; 18 : : import {WadRayMath} from '../math/WadRayMath.sol'; 19 : : import {PercentageMath} from '../math/PercentageMath.sol'; @@ -134,715 +134,583 @@ 63 : : * @param reserveCache The cached data of the reserve 64 : : * @param amount The amount to be supplied 65 : : */ - 66 : 13598 : function validateSupply( + 66 : : function validateSupply( 67 : : DataTypes.ReserveCache memory reserveCache, 68 : : DataTypes.ReserveData storage reserve, 69 : : uint256 amount, 70 : : address onBehalfOf 71 : : ) internal view { - 72 : 27196 : require(amount != 0, Errors.INVALID_AMOUNT); + 72 : 44531 : require(amount != 0, Errors.INVALID_AMOUNT); 73 : : - 74 : 40791 : (bool isActive, bool isFrozen, , , bool isPaused) = reserveCache - 75 : : .reserveConfiguration - 76 : : .getFlags(); - 77 : 27194 : require(isActive, Errors.RESERVE_INACTIVE); - 78 : 27192 : require(!isPaused, Errors.RESERVE_PAUSED); - 79 : 27190 : require(!isFrozen, Errors.RESERVE_FROZEN); - 80 : 27188 : require(onBehalfOf != reserveCache.aTokenAddress, Errors.SUPPLY_TO_ATOKEN); - 81 : : - 82 : 40779 : uint256 supplyCap = reserveCache.reserveConfiguration.getSupplyCap(); - 83 : 27186 : require( - 84 : : supplyCap == 0 || - 85 : : ((IAToken(reserveCache.aTokenAddress).scaledTotalSupply() + - 86 : : uint256(reserve.accruedToTreasury)).rayMul(reserveCache.nextLiquidityIndex) + amount) <= - 87 : : supplyCap * (10 ** reserveCache.reserveConfiguration.getDecimals()), - 88 : : Errors.SUPPLY_CAP_EXCEEDED - 89 : : ); - 90 : : } - 91 : : - 92 : : /** - 93 : : * @notice Validates a withdraw action. - 94 : : * @param reserveCache The cached data of the reserve - 95 : : * @param amount The amount to be withdrawn - 96 : : * @param userBalance The balance of the user - 97 : : */ - 98 : 44 : function validateWithdraw( - 99 : : DataTypes.ReserveCache memory reserveCache, - 100 : : uint256 amount, - 101 : : uint256 userBalance - 102 : : ) internal pure { - 103 : 88 : require(amount != 0, Errors.INVALID_AMOUNT); - 104 : 86 : require(amount <= userBalance, Errors.NOT_ENOUGH_AVAILABLE_USER_BALANCE); - 105 : : - 106 : 126 : (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); - 107 : 84 : require(isActive, Errors.RESERVE_INACTIVE); - 108 : 82 : require(!isPaused, Errors.RESERVE_PAUSED); - 109 : : } - 110 : : - 111 : : struct ValidateBorrowLocalVars { - 112 : : uint256 currentLtv; - 113 : : uint256 collateralNeededInBaseCurrency; - 114 : : uint256 userCollateralInBaseCurrency; - 115 : : uint256 userDebtInBaseCurrency; - 116 : : uint256 availableLiquidity; - 117 : : uint256 healthFactor; - 118 : : uint256 totalDebt; - 119 : : uint256 totalSupplyVariableDebt; - 120 : : uint256 reserveDecimals; - 121 : : uint256 borrowCap; - 122 : : uint256 amountInBaseCurrency; - 123 : : uint256 assetUnit; - 124 : : address eModePriceSource; - 125 : : address siloedBorrowingAddress; - 126 : : bool isActive; - 127 : : bool isFrozen; - 128 : : bool isPaused; - 129 : : bool borrowingEnabled; - 130 : : bool stableRateBorrowingEnabled; - 131 : : bool siloedBorrowingEnabled; - 132 : : } - 133 : : - 134 : : /** - 135 : : * @notice Validates a borrow action. - 136 : : * @param reservesData The state of all the reserves - 137 : : * @param reservesList The addresses of all the active reserves - 138 : : * @param eModeCategories The configuration of all the efficiency mode categories - 139 : : * @param params Additional params needed for the validation - 140 : : */ - 141 : 9117 : function validateBorrow( - 142 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 143 : : mapping(uint256 => address) storage reservesList, - 144 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 145 : : DataTypes.ValidateBorrowParams memory params - 146 : : ) internal view { - 147 : 18234 : require(params.amount != 0, Errors.INVALID_AMOUNT); - 148 : : - 149 : 18232 : ValidateBorrowLocalVars memory vars; - 150 : : - 151 : 18232 : ( - 152 : : vars.isActive, - 153 : : vars.isFrozen, - 154 : : vars.borrowingEnabled, - 155 : : vars.stableRateBorrowingEnabled, - 156 : : vars.isPaused - 157 : : ) = params.reserveCache.reserveConfiguration.getFlags(); - 158 : : - 159 : 18232 : require(vars.isActive, Errors.RESERVE_INACTIVE); - 160 : 18230 : require(!vars.isPaused, Errors.RESERVE_PAUSED); - 161 : 18228 : require(!vars.isFrozen, Errors.RESERVE_FROZEN); - 162 : 18226 : require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); - 163 : 18226 : require( - 164 : : IERC20(params.reserveCache.aTokenAddress).totalSupply() >= params.amount, - 165 : : Errors.INVALID_AMOUNT + 74 : 44530 : (bool isActive, bool isFrozen, , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + 75 : 44530 : require(isActive, Errors.RESERVE_INACTIVE); + 76 : 44529 : require(!isPaused, Errors.RESERVE_PAUSED); + 77 : 44528 : require(!isFrozen, Errors.RESERVE_FROZEN); + 78 : 44527 : require(onBehalfOf != reserveCache.aTokenAddress, Errors.SUPPLY_TO_ATOKEN); + 79 : : + 80 : 44526 : uint256 supplyCap = reserveCache.reserveConfiguration.getSupplyCap(); + 81 : 44526 : require( + 82 : : supplyCap == 0 || + 83 : : ((IAToken(reserveCache.aTokenAddress).scaledTotalSupply() + + 84 : : uint256(reserve.accruedToTreasury)).rayMul(reserveCache.nextLiquidityIndex) + amount) <= + 85 : : supplyCap * (10 ** reserveCache.reserveConfiguration.getDecimals()), + 86 : : Errors.SUPPLY_CAP_EXCEEDED + 87 : : ); + 88 : : } + 89 : : + 90 : : /** + 91 : : * @notice Validates a withdraw action. + 92 : : * @param reserveCache The cached data of the reserve + 93 : : * @param amount The amount to be withdrawn + 94 : : * @param userBalance The balance of the user + 95 : : */ + 96 : : function validateWithdraw( + 97 : : DataTypes.ReserveCache memory reserveCache, + 98 : : uint256 amount, + 99 : : uint256 userBalance + 100 : : ) internal pure { + 101 : 2044 : require(amount != 0, Errors.INVALID_AMOUNT); + 102 : 2043 : require(amount <= userBalance, Errors.NOT_ENOUGH_AVAILABLE_USER_BALANCE); + 103 : : + 104 : 2042 : (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + 105 : 2042 : require(isActive, Errors.RESERVE_INACTIVE); + 106 : 2041 : require(!isPaused, Errors.RESERVE_PAUSED); + 107 : : } + 108 : : + 109 : : struct ValidateBorrowLocalVars { + 110 : : uint256 currentLtv; + 111 : : uint256 collateralNeededInBaseCurrency; + 112 : : uint256 userCollateralInBaseCurrency; + 113 : : uint256 userDebtInBaseCurrency; + 114 : : uint256 availableLiquidity; + 115 : : uint256 healthFactor; + 116 : : uint256 totalDebt; + 117 : : uint256 totalSupplyVariableDebt; + 118 : : uint256 reserveDecimals; + 119 : : uint256 borrowCap; + 120 : : uint256 amountInBaseCurrency; + 121 : : uint256 assetUnit; + 122 : : address siloedBorrowingAddress; + 123 : : bool isActive; + 124 : : bool isFrozen; + 125 : : bool isPaused; + 126 : : bool borrowingEnabled; + 127 : : bool siloedBorrowingEnabled; + 128 : : } + 129 : : + 130 : : /** + 131 : : * @notice Validates a borrow action. + 132 : : * @param reservesData The state of all the reserves + 133 : : * @param reservesList The addresses of all the active reserves + 134 : : * @param eModeCategories The configuration of all the efficiency mode categories + 135 : : * @param params Additional params needed for the validation + 136 : : */ + 137 : : function validateBorrow( + 138 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 139 : : mapping(uint256 => address) storage reservesList, + 140 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 141 : : DataTypes.ValidateBorrowParams memory params + 142 : : ) internal view { + 143 : 16110 : require(params.amount != 0, Errors.INVALID_AMOUNT); + 144 : : + 145 : 16109 : ValidateBorrowLocalVars memory vars; + 146 : : + 147 : 16109 : (vars.isActive, vars.isFrozen, vars.borrowingEnabled, vars.isPaused) = params + 148 : : .reserveCache + 149 : : .reserveConfiguration + 150 : : .getFlags(); + 151 : : + 152 : 16109 : require(vars.isActive, Errors.RESERVE_INACTIVE); + 153 : 16108 : require(!vars.isPaused, Errors.RESERVE_PAUSED); + 154 : 16107 : require(!vars.isFrozen, Errors.RESERVE_FROZEN); + 155 : 16106 : require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED); + 156 : 15106 : require( + 157 : : !params.reserveCache.reserveConfiguration.getIsVirtualAccActive() || + 158 : : IERC20(params.reserveCache.aTokenAddress).totalSupply() >= params.amount, + 159 : : Errors.INVALID_AMOUNT + 160 : : ); + 161 : : + 162 : 15105 : require( + 163 : : params.priceOracleSentinel == address(0) || + 164 : : IPriceOracleSentinel(params.priceOracleSentinel).isBorrowAllowed(), + 165 : : Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED 166 : : ); 167 : : - 168 : 18224 : require( - 169 : : params.priceOracleSentinel == address(0) || - 170 : : IPriceOracleSentinel(params.priceOracleSentinel).isBorrowAllowed(), - 171 : : Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED + 168 : : //validate interest rate mode + 169 : 15104 : require( + 170 : : params.interestRateMode == DataTypes.InterestRateMode.VARIABLE, + 171 : : Errors.INVALID_INTEREST_RATE_MODE_SELECTED 172 : : ); 173 : : - 174 : : //validate interest rate mode - 175 : 18222 : require( - 176 : : params.interestRateMode == DataTypes.InterestRateMode.VARIABLE || - 177 : : params.interestRateMode == DataTypes.InterestRateMode.STABLE, - 178 : : Errors.INVALID_INTEREST_RATE_MODE_SELECTED - 179 : : ); - 180 : : - 181 : 18220 : vars.reserveDecimals = params.reserveCache.reserveConfiguration.getDecimals(); - 182 : 18220 : vars.borrowCap = params.reserveCache.reserveConfiguration.getBorrowCap(); - 183 : : unchecked { - 184 : 18220 : vars.assetUnit = 10 ** vars.reserveDecimals; - 185 : : } + 174 : 15102 : vars.reserveDecimals = params.reserveCache.reserveConfiguration.getDecimals(); + 175 : 15102 : vars.borrowCap = params.reserveCache.reserveConfiguration.getBorrowCap(); + 176 : : unchecked { + 177 : 15102 : vars.assetUnit = 10 ** vars.reserveDecimals; + 178 : : } + 179 : : + 180 : 15102 : if (vars.borrowCap != 0) { + 181 : 7 : vars.totalSupplyVariableDebt = params.reserveCache.currScaledVariableDebt.rayMul( + 182 : : params.reserveCache.nextVariableBorrowIndex + 183 : : ); + 184 : : + 185 : 7 : vars.totalDebt = vars.totalSupplyVariableDebt + params.amount; 186 : : - 187 : 18220 : if (vars.borrowCap != 0) { - 188 : 14 : vars.totalSupplyVariableDebt = params.reserveCache.currScaledVariableDebt.rayMul( - 189 : : params.reserveCache.nextVariableBorrowIndex - 190 : : ); + 187 : : unchecked { + 188 : 7 : require(vars.totalDebt <= vars.borrowCap * vars.assetUnit, Errors.BORROW_CAP_EXCEEDED); + 189 : : } + 190 : : } 191 : : - 192 : 14 : vars.totalDebt = - 193 : : params.reserveCache.currTotalStableDebt + - 194 : : vars.totalSupplyVariableDebt + - 195 : : params.amount; - 196 : : - 197 : : unchecked { - 198 : 14 : require(vars.totalDebt <= vars.borrowCap * vars.assetUnit, Errors.BORROW_CAP_EXCEEDED); - 199 : : } - 200 : : } - 201 : : - 202 : 9107 : if (params.isolationModeActive) { - 203 : : // check that the asset being borrowed is borrowable in isolation mode AND - 204 : : // the total exposure is no bigger than the collateral debt ceiling - 205 : 22 : require( - 206 : : params.reserveCache.reserveConfiguration.getBorrowableInIsolation(), - 207 : : Errors.ASSET_NOT_BORROWABLE_IN_ISOLATION - 208 : : ); + 192 : 15099 : if (params.isolationModeActive) { + 193 : : // check that the asset being borrowed is borrowable in isolation mode AND + 194 : : // the total exposure is no bigger than the collateral debt ceiling + 195 : 11 : require( + 196 : : params.reserveCache.reserveConfiguration.getBorrowableInIsolation(), + 197 : : Errors.ASSET_NOT_BORROWABLE_IN_ISOLATION + 198 : : ); + 199 : : + 200 : 10 : require( + 201 : : reservesData[params.isolationModeCollateralAddress].isolationModeTotalDebt + + 202 : : (params.amount / + 203 : : 10 ** (vars.reserveDecimals - ReserveConfiguration.DEBT_CEILING_DECIMALS)) + 204 : : .toUint128() <= + 205 : : params.isolationModeDebtCeiling, + 206 : : Errors.DEBT_CEILING_EXCEEDED + 207 : : ); + 208 : : } 209 : : - 210 : 20 : require( - 211 : : reservesData[params.isolationModeCollateralAddress].isolationModeTotalDebt + - 212 : : (params.amount / - 213 : : 10 ** (vars.reserveDecimals - ReserveConfiguration.DEBT_CEILING_DECIMALS)) - 214 : : .toUint128() <= - 215 : : params.isolationModeDebtCeiling, - 216 : : Errors.DEBT_CEILING_EXCEEDED + 210 : 15096 : if (params.userEModeCategory != 0) { + 211 : 4006 : require( + 212 : : EModeConfiguration.isReserveEnabledOnBitmap( + 213 : : eModeCategories[params.userEModeCategory].borrowableBitmap, + 214 : : reservesData[params.asset].id + 215 : : ), + 216 : : Errors.NOT_BORROWABLE_IN_EMODE 217 : : ); 218 : : } 219 : : - 220 : 18208 : if (params.userEModeCategory != 0) { - 221 : 14 : require( - 222 : : params.reserveCache.reserveConfiguration.getEModeCategory() == params.userEModeCategory, - 223 : : Errors.INCONSISTENT_EMODE_CATEGORY - 224 : : ); - 225 : 12 : vars.eModePriceSource = eModeCategories[params.userEModeCategory].priceSource; - 226 : : } - 227 : : - 228 : 18206 : ( - 229 : : vars.userCollateralInBaseCurrency, - 230 : : vars.userDebtInBaseCurrency, - 231 : : vars.currentLtv, - 232 : : , - 233 : : vars.healthFactor, - 234 : : - 235 : : ) = GenericLogic.calculateUserAccountData( - 236 : : reservesData, - 237 : : reservesList, - 238 : : eModeCategories, - 239 : : DataTypes.CalculateUserAccountDataParams({ - 240 : : userConfig: params.userConfig, - 241 : : reservesCount: params.reservesCount, - 242 : : user: params.userAddress, - 243 : : oracle: params.oracle, - 244 : : userEModeCategory: params.userEModeCategory - 245 : : }) + 220 : 15095 : ( + 221 : : vars.userCollateralInBaseCurrency, + 222 : : vars.userDebtInBaseCurrency, + 223 : : vars.currentLtv, + 224 : : , + 225 : : vars.healthFactor, + 226 : : + 227 : : ) = GenericLogic.calculateUserAccountData( + 228 : : reservesData, + 229 : : reservesList, + 230 : : eModeCategories, + 231 : : DataTypes.CalculateUserAccountDataParams({ + 232 : : userConfig: params.userConfig, + 233 : : reservesCount: params.reservesCount, + 234 : : user: params.userAddress, + 235 : : oracle: params.oracle, + 236 : : userEModeCategory: params.userEModeCategory + 237 : : }) + 238 : : ); + 239 : : + 240 : 15095 : require(vars.userCollateralInBaseCurrency != 0, Errors.COLLATERAL_BALANCE_IS_ZERO); + 241 : 15094 : require(vars.currentLtv != 0, Errors.LTV_VALIDATION_FAILED); + 242 : : + 243 : 15094 : require( + 244 : : vars.healthFactor > HEALTH_FACTOR_LIQUIDATION_THRESHOLD, + 245 : : Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD 246 : : ); 247 : : - 248 : 18206 : require(vars.userCollateralInBaseCurrency != 0, Errors.COLLATERAL_BALANCE_IS_ZERO); - 249 : 18204 : require(vars.currentLtv != 0, Errors.LTV_VALIDATION_FAILED); - 250 : : - 251 : 18204 : require( - 252 : : vars.healthFactor > HEALTH_FACTOR_LIQUIDATION_THRESHOLD, - 253 : : Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD - 254 : : ); - 255 : : - 256 : 18202 : vars.amountInBaseCurrency = - 257 : : IPriceOracleGetter(params.oracle).getAssetPrice( - 258 : : vars.eModePriceSource != address(0) ? vars.eModePriceSource : params.asset - 259 : : ) * - 260 : : params.amount; - 261 : : unchecked { - 262 : 18202 : vars.amountInBaseCurrency /= vars.assetUnit; - 263 : : } - 264 : : - 265 : : //add the current already borrowed amount to the amount requested to calculate the total collateral needed. - 266 : 18202 : vars.collateralNeededInBaseCurrency = (vars.userDebtInBaseCurrency + vars.amountInBaseCurrency) - 267 : : .percentDiv(vars.currentLtv); //LTV is calculated in percentage + 248 : 15093 : vars.amountInBaseCurrency = + 249 : : IPriceOracleGetter(params.oracle).getAssetPrice(params.asset) * + 250 : : params.amount; + 251 : : unchecked { + 252 : 15093 : vars.amountInBaseCurrency /= vars.assetUnit; + 253 : : } + 254 : : + 255 : : //add the current already borrowed amount to the amount requested to calculate the total collateral needed. + 256 : 15093 : vars.collateralNeededInBaseCurrency = (vars.userDebtInBaseCurrency + vars.amountInBaseCurrency) + 257 : : .percentDiv(vars.currentLtv); //LTV is calculated in percentage + 258 : : + 259 : 15093 : require( + 260 : : vars.collateralNeededInBaseCurrency <= vars.userCollateralInBaseCurrency, + 261 : : Errors.COLLATERAL_CANNOT_COVER_NEW_BORROW + 262 : : ); + 263 : : + 264 : 15092 : if (params.userConfig.isBorrowingAny()) { + 265 : 7 : (vars.siloedBorrowingEnabled, vars.siloedBorrowingAddress) = params + 266 : : .userConfig + 267 : : .getSiloedBorrowingState(reservesData, reservesList); 268 : : - 269 : 18202 : require( - 270 : : vars.collateralNeededInBaseCurrency <= vars.userCollateralInBaseCurrency, - 271 : : Errors.COLLATERAL_CANNOT_COVER_NEW_BORROW - 272 : : ); - 273 : : - 274 : : /** - 275 : : * Following conditions need to be met if the user is borrowing at a stable rate: - 276 : : * 1. Reserve must be enabled for stable rate borrowing - 277 : : * 2. Users cannot borrow from the reserve if their collateral is (mostly) the same currency - 278 : : * they are borrowing, to prevent abuses. - 279 : : * 3. Users will be able to borrow only a portion of the total available liquidity - 280 : : */ - 281 : : - 282 : 18200 : if (params.interestRateMode == DataTypes.InterestRateMode.STABLE) { - 283 : : //check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve - 284 : : - 285 : 8 : require(vars.stableRateBorrowingEnabled, Errors.STABLE_BORROWING_NOT_ENABLED); - 286 : : - 287 : 6 : require( - 288 : : !params.userConfig.isUsingAsCollateral(reservesData[params.asset].id) || - 289 : : params.reserveCache.reserveConfiguration.getLtv() == 0 || - 290 : : params.amount > IERC20(params.reserveCache.aTokenAddress).balanceOf(params.userAddress), - 291 : : Errors.COLLATERAL_SAME_AS_BORROWING_CURRENCY - 292 : : ); - 293 : : - 294 : 4 : vars.availableLiquidity = reservesData[params.asset].virtualUnderlyingBalance; - 295 : : - 296 : : //calculate the max available loan size in stable rate mode as a percentage of the - 297 : : //available liquidity - 298 : 6 : uint256 maxLoanSizeStable = vars.availableLiquidity.percentMul(params.maxStableLoanPercent); - 299 : : - 300 : 4 : require(params.amount <= maxLoanSizeStable, Errors.AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE); - 301 : : } - 302 : : - 303 : 18194 : if (params.userConfig.isBorrowingAny()) { - 304 : 14 : (vars.siloedBorrowingEnabled, vars.siloedBorrowingAddress) = params - 305 : : .userConfig - 306 : : .getSiloedBorrowingState(reservesData, reservesList); + 269 : 7 : if (vars.siloedBorrowingEnabled) { + 270 : 1 : require(vars.siloedBorrowingAddress == params.asset, Errors.SILOED_BORROWING_VIOLATION); + 271 : : } else { + 272 : 6 : require( + 273 : : !params.reserveCache.reserveConfiguration.getSiloedBorrowing(), + 274 : : Errors.SILOED_BORROWING_VIOLATION + 275 : : ); + 276 : : } + 277 : : } + 278 : : } + 279 : : + 280 : : /** + 281 : : * @notice Validates a repay action. + 282 : : * @param reserveCache The cached data of the reserve + 283 : : * @param amountSent The amount sent for the repayment. Can be an actual value or uint(-1) + 284 : : * @param onBehalfOf The address of the user msg.sender is repaying for + 285 : : * @param debt The borrow balance of the user + 286 : : */ + 287 : : function validateRepay( + 288 : : DataTypes.ReserveCache memory reserveCache, + 289 : : uint256 amountSent, + 290 : : DataTypes.InterestRateMode interestRateMode, + 291 : : address onBehalfOf, + 292 : : uint256 debt + 293 : : ) internal view { + 294 : 5030 : require(amountSent != 0, Errors.INVALID_AMOUNT); + 295 : 5029 : require( + 296 : : interestRateMode == DataTypes.InterestRateMode.VARIABLE, + 297 : : Errors.INVALID_INTEREST_RATE_MODE_SELECTED + 298 : : ); + 299 : 5028 : require( + 300 : : amountSent != type(uint256).max || msg.sender == onBehalfOf, + 301 : : Errors.NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF + 302 : : ); + 303 : : + 304 : 5027 : (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + 305 : 5027 : require(isActive, Errors.RESERVE_INACTIVE); + 306 : 5026 : require(!isPaused, Errors.RESERVE_PAUSED); 307 : : - 308 : 7 : if (vars.siloedBorrowingEnabled) { - 309 : 2 : require(vars.siloedBorrowingAddress == params.asset, Errors.SILOED_BORROWING_VIOLATION); - 310 : : } else { - 311 : 12 : require( - 312 : : !params.reserveCache.reserveConfiguration.getSiloedBorrowing(), - 313 : : Errors.SILOED_BORROWING_VIOLATION - 314 : : ); - 315 : : } - 316 : : } - 317 : : } - 318 : : - 319 : : /** - 320 : : * @notice Validates a repay action. - 321 : : * @param reserveCache The cached data of the reserve - 322 : : * @param amountSent The amount sent for the repayment. Can be an actual value or uint(-1) - 323 : : * @param interestRateMode The interest rate mode of the debt being repaid - 324 : : * @param onBehalfOf The address of the user msg.sender is repaying for - 325 : : * @param stableDebt The borrow balance of the user - 326 : : * @param variableDebt The borrow balance of the user - 327 : : */ - 328 : 5029 : function validateRepay( - 329 : : DataTypes.ReserveCache memory reserveCache, - 330 : : uint256 amountSent, - 331 : : DataTypes.InterestRateMode interestRateMode, - 332 : : address onBehalfOf, - 333 : : uint256 stableDebt, - 334 : : uint256 variableDebt - 335 : : ) internal view { - 336 : 10058 : require(amountSent != 0, Errors.INVALID_AMOUNT); - 337 : 10056 : require( - 338 : : amountSent != type(uint256).max || msg.sender == onBehalfOf, - 339 : : Errors.NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF - 340 : : ); - 341 : : - 342 : 15081 : (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); - 343 : 10054 : require(isActive, Errors.RESERVE_INACTIVE); - 344 : 10052 : require(!isPaused, Errors.RESERVE_PAUSED); - 345 : : - 346 : 10050 : require( - 347 : : (stableDebt != 0 && interestRateMode == DataTypes.InterestRateMode.STABLE) || - 348 : : (variableDebt != 0 && interestRateMode == DataTypes.InterestRateMode.VARIABLE), - 349 : : Errors.NO_DEBT_OF_SELECTED_TYPE - 350 : : ); - 351 : : } - 352 : : - 353 : : /** - 354 : : * @notice Validates a swap of borrow rate mode. - 355 : : * @param reserve The reserve state on which the user is swapping the rate - 356 : : * @param reserveCache The cached data of the reserve - 357 : : * @param userConfig The user reserves configuration - 358 : : * @param stableDebt The stable debt of the user - 359 : : * @param variableDebt The variable debt of the user - 360 : : * @param currentRateMode The rate mode of the debt being swapped - 361 : : */ - 362 : 8 : function validateSwapRateMode( - 363 : : DataTypes.ReserveData storage reserve, - 364 : : DataTypes.ReserveCache memory reserveCache, - 365 : : DataTypes.UserConfigurationMap storage userConfig, - 366 : : uint256 stableDebt, - 367 : : uint256 variableDebt, - 368 : : DataTypes.InterestRateMode currentRateMode - 369 : : ) internal view { - 370 : 24 : (bool isActive, , , bool stableRateEnabled, bool isPaused) = reserveCache - 371 : : .reserveConfiguration - 372 : : .getFlags(); - 373 : 16 : require(isActive, Errors.RESERVE_INACTIVE); - 374 : 14 : require(!isPaused, Errors.RESERVE_PAUSED); - 375 : : - 376 : 12 : if (currentRateMode == DataTypes.InterestRateMode.STABLE) { - 377 : 2 : require(stableDebt != 0, Errors.NO_OUTSTANDING_STABLE_DEBT); - 378 : 10 : } else if (currentRateMode == DataTypes.InterestRateMode.VARIABLE) { - 379 : 8 : require(variableDebt != 0, Errors.NO_OUTSTANDING_VARIABLE_DEBT); - 380 : : /** - 381 : : * user wants to swap to stable, before swapping we need to ensure that - 382 : : * 1. stable borrow rate is enabled on the reserve - 383 : : * 2. user is not trying to abuse the reserve by supplying - 384 : : * more collateral than he is borrowing, artificially lowering - 385 : : * the interest rate, borrowing at variable, and switching to stable - 386 : : */ - 387 : 6 : require(stableRateEnabled, Errors.STABLE_BORROWING_NOT_ENABLED); + 308 : 5025 : require(debt != 0, Errors.NO_DEBT_OF_SELECTED_TYPE); + 309 : : } + 310 : : + 311 : : /** + 312 : : * @notice Validates the action of setting an asset as collateral. + 313 : : * @param reserveCache The cached data of the reserve + 314 : : * @param userBalance The balance of the user + 315 : : */ + 316 : : function validateSetUseReserveAsCollateral( + 317 : : DataTypes.ReserveCache memory reserveCache, + 318 : : uint256 userBalance + 319 : : ) internal pure { + 320 : 43 : require(userBalance != 0, Errors.UNDERLYING_BALANCE_ZERO); + 321 : : + 322 : 41 : (bool isActive, , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); + 323 : 41 : require(isActive, Errors.RESERVE_INACTIVE); + 324 : 39 : require(!isPaused, Errors.RESERVE_PAUSED); + 325 : : } + 326 : : + 327 : : /** + 328 : : * @notice Validates a flashloan action. + 329 : : * @param reservesData The state of all the reserves + 330 : : * @param assets The assets being flash-borrowed + 331 : : * @param amounts The amounts for each asset being borrowed + 332 : : */ + 333 : : function validateFlashloan( + 334 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 335 : : address[] memory assets, + 336 : : uint256[] memory amounts + 337 : : ) internal view { + 338 : 1011 : require(assets.length == amounts.length, Errors.INCONSISTENT_FLASHLOAN_PARAMS); + 339 : 1011 : for (uint256 i = 0; i < assets.length; i++) { + 340 : 1012 : for (uint256 j = i + 1; j < assets.length; j++) { + 341 : 1001 : require(assets[i] != assets[j], Errors.INCONSISTENT_FLASHLOAN_PARAMS); + 342 : : } + 343 : 12 : validateFlashloanSimple(reservesData[assets[i]], amounts[i]); + 344 : : } + 345 : : } + 346 : : + 347 : : /** + 348 : : * @notice Validates a flashloan action. + 349 : : * @param reserve The state of the reserve + 350 : : */ + 351 : : function validateFlashloanSimple( + 352 : : DataTypes.ReserveData storage reserve, + 353 : : uint256 amount + 354 : : ) internal view { + 355 : 23 : DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration; + 356 : 23 : require(!configuration.getPaused(), Errors.RESERVE_PAUSED); + 357 : 22 : require(configuration.getActive(), Errors.RESERVE_INACTIVE); + 358 : 21 : require(configuration.getFlashLoanEnabled(), Errors.FLASHLOAN_DISABLED); + 359 : 20 : require( + 360 : : !configuration.getIsVirtualAccActive() || + 361 : : IERC20(reserve.aTokenAddress).totalSupply() >= amount, + 362 : : Errors.INVALID_AMOUNT + 363 : : ); + 364 : : } + 365 : : + 366 : : struct ValidateLiquidationCallLocalVars { + 367 : : bool collateralReserveActive; + 368 : : bool collateralReservePaused; + 369 : : bool principalReserveActive; + 370 : : bool principalReservePaused; + 371 : : bool isCollateralEnabled; + 372 : : } + 373 : : + 374 : : /** + 375 : : * @notice Validates the liquidation action. + 376 : : * @param userConfig The user configuration mapping + 377 : : * @param collateralReserve The reserve data of the collateral + 378 : : * @param debtReserve The reserve data of the debt + 379 : : * @param params Additional parameters needed for the validation + 380 : : */ + 381 : : function validateLiquidationCall( + 382 : : DataTypes.UserConfigurationMap storage userConfig, + 383 : : DataTypes.ReserveData storage collateralReserve, + 384 : : DataTypes.ReserveData storage debtReserve, + 385 : : DataTypes.ValidateLiquidationCallParams memory params + 386 : : ) internal view { + 387 : 14501 : ValidateLiquidationCallLocalVars memory vars; 388 : : - 389 : 6 : require( - 390 : : !userConfig.isUsingAsCollateral(reserve.id) || - 391 : : reserveCache.reserveConfiguration.getLtv() == 0 || - 392 : : stableDebt + variableDebt > IERC20(reserveCache.aTokenAddress).balanceOf(msg.sender), - 393 : : Errors.COLLATERAL_SAME_AS_BORROWING_CURRENCY - 394 : : ); - 395 : : } else { - 396 : 2 : revert(Errors.INVALID_INTEREST_RATE_MODE_SELECTED); - 397 : : } - 398 : : } - 399 : : - 400 : : /** - 401 : : * @notice Validates a stable borrow rate rebalance action. - 402 : : * @dev Rebalancing is accepted when depositors are earning <= 90% of their earnings in pure supply/demand market (variable rate only) - 403 : : * For this to be the case, there has to be quite large stable debt with an interest rate below the current variable rate. - 404 : : * @param reserve The reserve state on which the user is getting rebalanced - 405 : : * @param reserveCache The cached state of the reserve - 406 : : * @param reserveAddress The address of the reserve - 407 : : */ - 408 : 5 : function validateRebalanceStableBorrowRate( - 409 : : DataTypes.ReserveData storage reserve, - 410 : : DataTypes.ReserveCache memory reserveCache, - 411 : : address reserveAddress - 412 : : ) internal view { - 413 : 15 : (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); - 414 : 10 : require(isActive, Errors.RESERVE_INACTIVE); - 415 : 8 : require(!isPaused, Errors.RESERVE_PAUSED); - 416 : : - 417 : 12 : uint256 totalDebt = IERC20(reserveCache.stableDebtTokenAddress).totalSupply() + - 418 : 6 : IERC20(reserveCache.variableDebtTokenAddress).totalSupply(); - 419 : : - 420 : 9 : (uint256 liquidityRateVariableDebtOnly, , ) = IReserveInterestRateStrategy( - 421 : : reserve.interestRateStrategyAddress - 422 : : ).calculateInterestRates( - 423 : : DataTypes.CalculateInterestRatesParams({ - 424 : : unbacked: reserve.unbacked, - 425 : : liquidityAdded: 0, - 426 : : liquidityTaken: 0, - 427 : : totalStableDebt: 0, - 428 : : totalVariableDebt: totalDebt, - 429 : : averageStableBorrowRate: 0, - 430 : : reserveFactor: reserveCache.reserveFactor, - 431 : : reserve: reserveAddress, - 432 : : usingVirtualBalance: reserve.configuration.getIsVirtualAccActive(), - 433 : : virtualUnderlyingBalance: reserve.virtualUnderlyingBalance - 434 : : }) - 435 : : ); - 436 : : - 437 : 6 : require( - 438 : : reserveCache.currLiquidityRate <= - 439 : : liquidityRateVariableDebtOnly.percentMul(REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD), - 440 : : Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET - 441 : : ); - 442 : : } - 443 : : - 444 : : /** - 445 : : * @notice Validates the action of setting an asset as collateral. - 446 : : * @param reserveCache The cached data of the reserve - 447 : : * @param userBalance The balance of the user - 448 : : */ - 449 : 43 : function validateSetUseReserveAsCollateral( - 450 : : DataTypes.ReserveCache memory reserveCache, - 451 : : uint256 userBalance - 452 : : ) internal pure { - 453 : 86 : require(userBalance != 0, Errors.UNDERLYING_BALANCE_ZERO); - 454 : : - 455 : 123 : (bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlags(); - 456 : 82 : require(isActive, Errors.RESERVE_INACTIVE); - 457 : 78 : require(!isPaused, Errors.RESERVE_PAUSED); - 458 : : } - 459 : : - 460 : : /** - 461 : : * @notice Validates a flashloan action. - 462 : : * @param reservesData The state of all the reserves - 463 : : * @param assets The assets being flash-borrowed - 464 : : * @param amounts The amounts for each asset being borrowed - 465 : : */ - 466 : 10 : function validateFlashloan( - 467 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 468 : : address[] memory assets, - 469 : : uint256[] memory amounts - 470 : : ) internal view { - 471 : 20 : require(assets.length == amounts.length, Errors.INCONSISTENT_FLASHLOAN_PARAMS); - 472 : 44 : for (uint256 i = 0; i < assets.length; i++) { - 473 : 22 : validateFlashloanSimple(reservesData[assets[i]], amounts[i]); - 474 : : } - 475 : : } - 476 : : - 477 : : /** - 478 : : * @notice Validates a flashloan action. - 479 : : * @param reserve The state of the reserve - 480 : : */ - 481 : 21 : function validateFlashloanSimple( - 482 : : DataTypes.ReserveData storage reserve, - 483 : : uint256 amount - 484 : : ) internal view { - 485 : 42 : DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration; - 486 : 42 : require(!configuration.getPaused(), Errors.RESERVE_PAUSED); - 487 : 40 : require(configuration.getActive(), Errors.RESERVE_INACTIVE); - 488 : 38 : require(configuration.getFlashLoanEnabled(), Errors.FLASHLOAN_DISABLED); - 489 : 36 : require(IERC20(reserve.aTokenAddress).totalSupply() >= amount, Errors.INVALID_AMOUNT); - 490 : : } - 491 : : - 492 : : struct ValidateLiquidationCallLocalVars { - 493 : : bool collateralReserveActive; - 494 : : bool collateralReservePaused; - 495 : : bool principalReserveActive; - 496 : : bool principalReservePaused; - 497 : : bool isCollateralEnabled; - 498 : : } - 499 : : - 500 : : /** - 501 : : * @notice Validates the liquidation action. - 502 : : * @param userConfig The user configuration mapping - 503 : : * @param collateralReserve The reserve data of the collateral - 504 : : * @param debtReserve The reserve data of the debt - 505 : : * @param params Additional parameters needed for the validation - 506 : : */ - 507 : 11292 : function validateLiquidationCall( - 508 : : DataTypes.UserConfigurationMap storage userConfig, - 509 : : DataTypes.ReserveData storage collateralReserve, - 510 : : DataTypes.ReserveData storage debtReserve, - 511 : : DataTypes.ValidateLiquidationCallParams memory params - 512 : : ) internal view { - 513 : 22584 : ValidateLiquidationCallLocalVars memory vars; - 514 : : - 515 : 22584 : (vars.collateralReserveActive, , , , vars.collateralReservePaused) = collateralReserve - 516 : : .configuration - 517 : : .getFlags(); - 518 : : - 519 : 22584 : (vars.principalReserveActive, , , , vars.principalReservePaused) = params - 520 : : .debtReserveCache - 521 : : .reserveConfiguration - 522 : : .getFlags(); - 523 : : - 524 : 22584 : require(vars.collateralReserveActive && vars.principalReserveActive, Errors.RESERVE_INACTIVE); - 525 : 22582 : require(!vars.collateralReservePaused && !vars.principalReservePaused, Errors.RESERVE_PAUSED); - 526 : : - 527 : 22580 : require( - 528 : : params.priceOracleSentinel == address(0) || - 529 : : params.healthFactor < MINIMUM_HEALTH_FACTOR_LIQUIDATION_THRESHOLD || - 530 : : IPriceOracleSentinel(params.priceOracleSentinel).isLiquidationAllowed(), - 531 : : Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED - 532 : : ); - 533 : : - 534 : 22578 : require( - 535 : : collateralReserve.liquidationGracePeriodUntil < uint40(block.timestamp) && - 536 : : debtReserve.liquidationGracePeriodUntil < uint40(block.timestamp), - 537 : : Errors.LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED - 538 : : ); - 539 : : - 540 : 12030 : require( - 541 : : params.healthFactor < HEALTH_FACTOR_LIQUIDATION_THRESHOLD, - 542 : : Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD - 543 : : ); - 544 : : - 545 : 12028 : vars.isCollateralEnabled = - 546 : : collateralReserve.configuration.getLiquidationThreshold() != 0 && - 547 : : userConfig.isUsingAsCollateral(collateralReserve.id); - 548 : : - 549 : : //if collateral isn't enabled as collateral by user, it cannot be liquidated - 550 : 12028 : require(vars.isCollateralEnabled, Errors.COLLATERAL_CANNOT_BE_LIQUIDATED); - 551 : 12026 : require(params.totalDebt != 0, Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER); - 552 : : } - 553 : : - 554 : : /** - 555 : : * @notice Validates the health factor of a user. - 556 : : * @param reservesData The state of all the reserves - 557 : : * @param reservesList The addresses of all the active reserves - 558 : : * @param eModeCategories The configuration of all the efficiency mode categories - 559 : : * @param userConfig The state of the user for the specific reserve - 560 : : * @param user The user to validate health factor of - 561 : : * @param userEModeCategory The users active efficiency mode category - 562 : : * @param reservesCount The number of available reserves - 563 : : * @param oracle The price oracle - 564 : : */ - 565 : 27 : function validateHealthFactor( - 566 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 567 : : mapping(uint256 => address) storage reservesList, - 568 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 569 : : DataTypes.UserConfigurationMap memory userConfig, - 570 : : address user, - 571 : : uint8 userEModeCategory, - 572 : : uint256 reservesCount, - 573 : : address oracle - 574 : : ) internal view returns (uint256, bool) { - 575 : 81 : (, , , , uint256 healthFactor, bool hasZeroLtvCollateral) = GenericLogic - 576 : : .calculateUserAccountData( - 577 : : reservesData, - 578 : : reservesList, - 579 : : eModeCategories, - 580 : : DataTypes.CalculateUserAccountDataParams({ - 581 : : userConfig: userConfig, - 582 : : reservesCount: reservesCount, - 583 : : user: user, - 584 : : oracle: oracle, - 585 : : userEModeCategory: userEModeCategory - 586 : : }) - 587 : : ); - 588 : : - 589 : 54 : require( - 590 : : healthFactor >= HEALTH_FACTOR_LIQUIDATION_THRESHOLD, - 591 : : Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD - 592 : : ); - 593 : : - 594 : 42 : return (healthFactor, hasZeroLtvCollateral); - 595 : : } - 596 : : - 597 : : /** - 598 : : * @notice Validates the health factor of a user and the ltv of the asset being withdrawn. - 599 : : * @param reservesData The state of all the reserves - 600 : : * @param reservesList The addresses of all the active reserves - 601 : : * @param eModeCategories The configuration of all the efficiency mode categories - 602 : : * @param userConfig The state of the user for the specific reserve - 603 : : * @param asset The asset for which the ltv will be validated - 604 : : * @param from The user from which the aTokens are being transferred - 605 : : * @param reservesCount The number of available reserves - 606 : : * @param oracle The price oracle - 607 : : * @param userEModeCategory The users active efficiency mode category - 608 : : */ - 609 : 23 : function validateHFAndLtv( - 610 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 611 : : mapping(uint256 => address) storage reservesList, - 612 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 613 : : DataTypes.UserConfigurationMap memory userConfig, - 614 : : address asset, - 615 : : address from, - 616 : : uint256 reservesCount, - 617 : : address oracle, - 618 : : uint8 userEModeCategory - 619 : : ) internal view { - 620 : 46 : DataTypes.ReserveData memory reserve = reservesData[asset]; - 621 : : - 622 : 69 : (, bool hasZeroLtvCollateral) = validateHealthFactor( - 623 : : reservesData, - 624 : : reservesList, - 625 : : eModeCategories, - 626 : : userConfig, - 627 : : from, - 628 : : userEModeCategory, - 629 : : reservesCount, - 630 : : oracle - 631 : : ); - 632 : : - 633 : 38 : require( - 634 : : !hasZeroLtvCollateral || reserve.configuration.getLtv() == 0, - 635 : : Errors.LTV_VALIDATION_FAILED - 636 : : ); - 637 : : } - 638 : : - 639 : : /** - 640 : : * @notice Validates a transfer action. - 641 : : * @param reserve The reserve object - 642 : : */ - 643 : 1036 : function validateTransfer(DataTypes.ReserveData storage reserve) internal view { - 644 : 2072 : require(!reserve.configuration.getPaused(), Errors.RESERVE_PAUSED); - 645 : : } - 646 : : - 647 : : /** - 648 : : * @notice Validates a drop reserve action. - 649 : : * @param reservesList The addresses of all the active reserves - 650 : : * @param reserve The reserve object - 651 : : * @param asset The address of the reserve's underlying asset - 652 : : */ - 653 : 9 : function validateDropReserve( - 654 : : mapping(uint256 => address) storage reservesList, - 655 : : DataTypes.ReserveData storage reserve, - 656 : : address asset - 657 : : ) internal view { - 658 : 18 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); - 659 : 16 : require(reserve.id != 0 || reservesList[0] == asset, Errors.ASSET_NOT_LISTED); - 660 : 14 : require(IERC20(reserve.stableDebtTokenAddress).totalSupply() == 0, Errors.STABLE_DEBT_NOT_ZERO); - 661 : 14 : require( - 662 : : IERC20(reserve.variableDebtTokenAddress).totalSupply() == 0, - 663 : : Errors.VARIABLE_DEBT_SUPPLY_NOT_ZERO - 664 : : ); - 665 : 12 : require( - 666 : : IERC20(reserve.aTokenAddress).totalSupply() == 0 && reserve.accruedToTreasury == 0, - 667 : : Errors.UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO - 668 : : ); - 669 : : } - 670 : : - 671 : : /** - 672 : : * @notice Validates the action of setting efficiency mode. - 673 : : * @param reservesData The state of all the reserves - 674 : : * @param reservesList The addresses of all the active reserves - 675 : : * @param eModeCategories a mapping storing configurations for all efficiency mode categories - 676 : : * @param userConfig the user configuration - 677 : : * @param reservesCount The total number of valid reserves - 678 : : * @param categoryId The id of the category - 679 : : */ - 680 : 17 : function validateSetUserEMode( - 681 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 682 : : mapping(uint256 => address) storage reservesList, - 683 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, - 684 : : DataTypes.UserConfigurationMap memory userConfig, - 685 : : uint256 reservesCount, - 686 : : uint8 categoryId - 687 : : ) internal view { - 688 : : // category is invalid if the liq threshold is not set - 689 : 34 : require( - 690 : : categoryId == 0 || eModeCategories[categoryId].liquidationThreshold != 0, - 691 : : Errors.INCONSISTENT_EMODE_CATEGORY - 692 : : ); - 693 : : - 694 : : // eMode can always be enabled if the user hasn't supplied anything - 695 : 34 : if (userConfig.isEmpty()) { - 696 : 34 : return; - 697 : : } - 698 : : - 699 : : // if user is trying to set another category than default we require that - 700 : : // either the user is not borrowing, or it's borrowing assets of categoryId - 701 : 8 : if (categoryId != 0) { - 702 : : unchecked { - 703 : 14 : for (uint256 i = 0; i < reservesCount; i++) { - 704 : 12 : if (userConfig.isBorrowing(i)) { - 705 : 4 : DataTypes.ReserveConfigurationMap memory configuration = reservesData[reservesList[i]] - 706 : : .configuration; - 707 : 4 : require( - 708 : : configuration.getEModeCategory() == categoryId, - 709 : : Errors.INCONSISTENT_EMODE_CATEGORY - 710 : : ); - 711 : : } - 712 : : } - 713 : : } - 714 : : } - 715 : : } - 716 : : - 717 : : /** - 718 : : * @notice Validates the action of activating the asset as collateral. - 719 : : * @dev Only possible if the asset has non-zero LTV and the user is not in isolation mode - 720 : : * @param reservesData The state of all the reserves - 721 : : * @param reservesList The addresses of all the active reserves - 722 : : * @param userConfig the user configuration - 723 : : * @param reserveConfig The reserve configuration - 724 : : * @return True if the asset can be activated as collateral, false otherwise - 725 : : */ - 726 : 13338 : function validateUseAsCollateral( - 727 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 728 : : mapping(uint256 => address) storage reservesList, - 729 : : DataTypes.UserConfigurationMap storage userConfig, - 730 : : DataTypes.ReserveConfigurationMap memory reserveConfig - 731 : : ) internal view returns (bool) { - 732 : 40014 : if (reserveConfig.getLtv() == 0) { - 733 : 6 : return false; - 734 : : } - 735 : 26670 : if (!userConfig.isUsingAsCollateralAny()) { - 736 : 24510 : return true; - 737 : : } - 738 : 3240 : (bool isolationModeActive, , ) = userConfig.getIsolationModeState(reservesData, reservesList); - 739 : : - 740 : 2160 : return (!isolationModeActive && reserveConfig.getDebtCeiling() == 0); - 741 : : } - 742 : : - 743 : : /** - 744 : : * @notice Validates if an asset should be automatically activated as collateral in the following actions: supply, - 745 : : * transfer, mint unbacked, and liquidate - 746 : : * @dev This is used to ensure that isolated assets are not enabled as collateral automatically - 747 : : * @param reservesData The state of all the reserves - 748 : : * @param reservesList The addresses of all the active reserves - 749 : : * @param userConfig the user configuration - 750 : : * @param reserveConfig The reserve configuration - 751 : : * @return True if the asset can be activated as collateral, false otherwise - 752 : : */ - 753 : 13331 : function validateAutomaticUseAsCollateral( - 754 : : mapping(address => DataTypes.ReserveData) storage reservesData, - 755 : : mapping(uint256 => address) storage reservesList, - 756 : : DataTypes.UserConfigurationMap storage userConfig, - 757 : : DataTypes.ReserveConfigurationMap memory reserveConfig, - 758 : : address aTokenAddress - 759 : : ) internal view returns (bool) { - 760 : 39993 : if (reserveConfig.getDebtCeiling() != 0) { - 761 : : // ensures only the ISOLATED_COLLATERAL_SUPPLIER_ROLE can enable collateral as side-effect of an action - 762 : 36 : IPoolAddressesProvider addressesProvider = IncentivizedERC20(aTokenAddress) - 763 : : .POOL() - 764 : : .ADDRESSES_PROVIDER(); - 765 : : if ( - 766 : 24 : !IAccessControl(addressesProvider.getACLManager()).hasRole( - 767 : : ISOLATED_COLLATERAL_SUPPLIER_ROLE, - 768 : : msg.sender - 769 : : ) - 770 : 24 : ) return false; - 771 : : } - 772 : 39957 : return validateUseAsCollateral(reservesData, reservesList, userConfig, reserveConfig); - 773 : : } - 774 : : } + 389 : 14501 : (vars.collateralReserveActive, , , vars.collateralReservePaused) = collateralReserve + 390 : : .configuration + 391 : : .getFlags(); + 392 : : + 393 : 14501 : (vars.principalReserveActive, , , vars.principalReservePaused) = params + 394 : : .debtReserveCache + 395 : : .reserveConfiguration + 396 : : .getFlags(); + 397 : : + 398 : 14501 : require(vars.collateralReserveActive && vars.principalReserveActive, Errors.RESERVE_INACTIVE); + 399 : 14500 : require(!vars.collateralReservePaused && !vars.principalReservePaused, Errors.RESERVE_PAUSED); + 400 : : + 401 : 14499 : require( + 402 : : params.priceOracleSentinel == address(0) || + 403 : : params.healthFactor < MINIMUM_HEALTH_FACTOR_LIQUIDATION_THRESHOLD || + 404 : : IPriceOracleSentinel(params.priceOracleSentinel).isLiquidationAllowed(), + 405 : : Errors.PRICE_ORACLE_SENTINEL_CHECK_FAILED + 406 : : ); + 407 : : + 408 : 14498 : require( + 409 : : collateralReserve.liquidationGracePeriodUntil < uint40(block.timestamp) && + 410 : : debtReserve.liquidationGracePeriodUntil < uint40(block.timestamp), + 411 : : Errors.LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED + 412 : : ); + 413 : : + 414 : 8014 : require( + 415 : : params.healthFactor < HEALTH_FACTOR_LIQUIDATION_THRESHOLD, + 416 : : Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD + 417 : : ); + 418 : : + 419 : 8013 : vars.isCollateralEnabled = + 420 : : collateralReserve.configuration.getLiquidationThreshold() != 0 && + 421 : : userConfig.isUsingAsCollateral(collateralReserve.id); + 422 : : + 423 : : //if collateral isn't enabled as collateral by user, it cannot be liquidated + 424 : 8013 : require(vars.isCollateralEnabled, Errors.COLLATERAL_CANNOT_BE_LIQUIDATED); + 425 : 8012 : require(params.totalDebt != 0, Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER); + 426 : : } + 427 : : + 428 : : /** + 429 : : * @notice Validates the health factor of a user. + 430 : : * @param reservesData The state of all the reserves + 431 : : * @param reservesList The addresses of all the active reserves + 432 : : * @param eModeCategories The configuration of all the efficiency mode categories + 433 : : * @param userConfig The state of the user for the specific reserve + 434 : : * @param user The user to validate health factor of + 435 : : * @param userEModeCategory The users active efficiency mode category + 436 : : * @param reservesCount The number of available reserves + 437 : : * @param oracle The price oracle + 438 : : */ + 439 : : function validateHealthFactor( + 440 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 441 : : mapping(uint256 => address) storage reservesList, + 442 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 443 : : DataTypes.UserConfigurationMap memory userConfig, + 444 : : address user, + 445 : : uint8 userEModeCategory, + 446 : : uint256 reservesCount, + 447 : : address oracle + 448 : : ) internal view returns (uint256, bool) { + 449 : 8637 : (, , , , uint256 healthFactor, bool hasZeroLtvCollateral) = GenericLogic + 450 : : .calculateUserAccountData( + 451 : : reservesData, + 452 : : reservesList, + 453 : : eModeCategories, + 454 : : DataTypes.CalculateUserAccountDataParams({ + 455 : : userConfig: userConfig, + 456 : : reservesCount: reservesCount, + 457 : : user: user, + 458 : : oracle: oracle, + 459 : : userEModeCategory: userEModeCategory + 460 : : }) + 461 : : ); + 462 : : + 463 : 8637 : require( + 464 : : healthFactor >= HEALTH_FACTOR_LIQUIDATION_THRESHOLD, + 465 : : Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD + 466 : : ); + 467 : : + 468 : 7631 : return (healthFactor, hasZeroLtvCollateral); + 469 : : } + 470 : : + 471 : : /** + 472 : : * @notice Validates the health factor of a user and the ltv of the asset being withdrawn. + 473 : : * @param reservesData The state of all the reserves + 474 : : * @param reservesList The addresses of all the active reserves + 475 : : * @param eModeCategories The configuration of all the efficiency mode categories + 476 : : * @param userConfig The state of the user for the specific reserve + 477 : : * @param asset The asset for which the ltv will be validated + 478 : : * @param from The user from which the aTokens are being transferred + 479 : : * @param reservesCount The number of available reserves + 480 : : * @param oracle The price oracle + 481 : : * @param userEModeCategory The users active efficiency mode category + 482 : : */ + 483 : : function validateHFAndLtv( + 484 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 485 : : mapping(uint256 => address) storage reservesList, + 486 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 487 : : DataTypes.UserConfigurationMap memory userConfig, + 488 : : address asset, + 489 : : address from, + 490 : : uint256 reservesCount, + 491 : : address oracle, + 492 : : uint8 userEModeCategory + 493 : : ) internal view { + 494 : 23 : DataTypes.ReserveData memory reserve = reservesData[asset]; + 495 : : + 496 : 23 : (, bool hasZeroLtvCollateral) = validateHealthFactor( + 497 : : reservesData, + 498 : : reservesList, + 499 : : eModeCategories, + 500 : : userConfig, + 501 : : from, + 502 : : userEModeCategory, + 503 : : reservesCount, + 504 : : oracle + 505 : : ); + 506 : : + 507 : 19 : require( + 508 : : !hasZeroLtvCollateral || reserve.configuration.getLtv() == 0, + 509 : : Errors.LTV_VALIDATION_FAILED + 510 : : ); + 511 : : } + 512 : : + 513 : : /** + 514 : : * @notice Validates a transfer action. + 515 : : * @param reserve The reserve object + 516 : : */ + 517 : : function validateTransfer(DataTypes.ReserveData storage reserve) internal view { + 518 : 17042 : require(!reserve.configuration.getPaused(), Errors.RESERVE_PAUSED); + 519 : : } + 520 : : + 521 : : /** + 522 : : * @notice Validates a drop reserve action. + 523 : : * @param reservesList The addresses of all the active reserves + 524 : : * @param reserve The reserve object + 525 : : * @param asset The address of the reserve's underlying asset + 526 : : */ + 527 : : function validateDropReserve( + 528 : : mapping(uint256 => address) storage reservesList, + 529 : : DataTypes.ReserveData storage reserve, + 530 : : address asset + 531 : : ) internal view { + 532 : 9 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 533 : 8 : require(reserve.id != 0 || reservesList[0] == asset, Errors.ASSET_NOT_LISTED); + 534 : 7 : require( + 535 : : IERC20(reserve.variableDebtTokenAddress).totalSupply() == 0, + 536 : : Errors.VARIABLE_DEBT_SUPPLY_NOT_ZERO + 537 : : ); + 538 : 6 : require( + 539 : : IERC20(reserve.aTokenAddress).totalSupply() == 0 && reserve.accruedToTreasury == 0, + 540 : : Errors.UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO + 541 : : ); + 542 : : } + 543 : : + 544 : : /** + 545 : : * @notice Validates the action of setting efficiency mode. + 546 : : * @param eModeCategories a mapping storing configurations for all efficiency mode categories + 547 : : * @param userConfig the user configuration + 548 : : * @param reservesCount The total number of valid reserves + 549 : : * @param categoryId The id of the category + 550 : : */ + 551 : : function validateSetUserEMode( + 552 : : mapping(uint8 => DataTypes.EModeCategory) storage eModeCategories, + 553 : : DataTypes.UserConfigurationMap memory userConfig, + 554 : : uint256 reservesCount, + 555 : : uint8 categoryId + 556 : : ) internal view { + 557 : 9617 : DataTypes.EModeCategory storage eModeCategory = eModeCategories[categoryId]; + 558 : : // category is invalid if the liq threshold is not set + 559 : 9617 : require( + 560 : : categoryId == 0 || eModeCategory.liquidationThreshold != 0, + 561 : : Errors.INCONSISTENT_EMODE_CATEGORY + 562 : : ); + 563 : : + 564 : : // eMode can always be enabled if the user hasn't supplied anything + 565 : 9616 : if (userConfig.isEmpty()) { + 566 : 6611 : return; + 567 : : } + 568 : : + 569 : : // if user is trying to set another category than default we require that + 570 : : // either the user is not borrowing, or it's borrowing assets of categoryId + 571 : 3005 : if (categoryId != 0) { + 572 : : unchecked { + 573 : 3002 : for (uint256 i = 0; i < reservesCount; i++) { + 574 : 8006 : if (userConfig.isBorrowing(i)) { + 575 : 3002 : require( + 576 : : EModeConfiguration.isReserveEnabledOnBitmap(eModeCategory.borrowableBitmap, i), + 577 : : Errors.NOT_BORROWABLE_IN_EMODE + 578 : : ); + 579 : : } + 580 : : } + 581 : : } + 582 : : } + 583 : : } + 584 : : + 585 : : /** + 586 : : * @notice Validates the action of activating the asset as collateral. + 587 : : * @dev Only possible if the asset has non-zero LTV and the user is not in isolation mode + 588 : : * @param reservesData The state of all the reserves + 589 : : * @param reservesList The addresses of all the active reserves + 590 : : * @param userConfig the user configuration + 591 : : * @param reserveConfig The reserve configuration + 592 : : * @return True if the asset can be activated as collateral, false otherwise + 593 : : */ + 594 : : function validateUseAsCollateral( + 595 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 596 : : mapping(uint256 => address) storage reservesList, + 597 : : DataTypes.UserConfigurationMap storage userConfig, + 598 : : DataTypes.ReserveConfigurationMap memory reserveConfig + 599 : : ) internal view returns (bool) { + 600 : 59411 : if (reserveConfig.getLtv() == 0) { + 601 : 3 : return false; + 602 : : } + 603 : 59408 : if (!userConfig.isUsingAsCollateralAny()) { + 604 : 58324 : return true; + 605 : : } + 606 : 1084 : (bool isolationModeActive, , ) = userConfig.getIsolationModeState(reservesData, reservesList); + 607 : : + 608 : 1084 : return (!isolationModeActive && reserveConfig.getDebtCeiling() == 0); + 609 : : } + 610 : : + 611 : : /** + 612 : : * @notice Validates if an asset should be automatically activated as collateral in the following actions: supply, + 613 : : * transfer, mint unbacked, and liquidate + 614 : : * @dev This is used to ensure that isolated assets are not enabled as collateral automatically + 615 : : * @param reservesData The state of all the reserves + 616 : : * @param reservesList The addresses of all the active reserves + 617 : : * @param userConfig the user configuration + 618 : : * @param reserveConfig The reserve configuration + 619 : : * @return True if the asset can be activated as collateral, false otherwise + 620 : : */ + 621 : : function validateAutomaticUseAsCollateral( + 622 : : mapping(address => DataTypes.ReserveData) storage reservesData, + 623 : : mapping(uint256 => address) storage reservesList, + 624 : : DataTypes.UserConfigurationMap storage userConfig, + 625 : : DataTypes.ReserveConfigurationMap memory reserveConfig, + 626 : : address aTokenAddress + 627 : : ) internal view returns (bool) { + 628 : 59404 : if (reserveConfig.getDebtCeiling() != 0) { + 629 : : // ensures only the ISOLATED_COLLATERAL_SUPPLIER_ROLE can enable collateral as side-effect of an action + 630 : 12 : IPoolAddressesProvider addressesProvider = IncentivizedERC20(aTokenAddress) + 631 : : .POOL() + 632 : : .ADDRESSES_PROVIDER(); + 633 : : if ( + 634 : 12 : !IAccessControl(addressesProvider.getACLManager()).hasRole( + 635 : : ISOLATED_COLLATERAL_SUPPLIER_ROLE, + 636 : : msg.sender + 637 : : ) + 638 : 12 : ) return false; + 639 : : } + 640 : 59392 : return validateUseAsCollateral(reservesData, reservesList, userConfig, reserveConfig); + 641 : : } + 642 : : } @@ -850,8 +718,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-b.html b/report/protocol/libraries/logic/index-sort-b.html similarity index 60% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-b.html rename to report/protocol/libraries/logic/index-sort-b.html index d508c1da..f602334f 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-b.html +++ b/report/protocol/libraries/logic/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - + LCOV - lcov.info.p - protocol/libraries/logic + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logictop level - protocol/libraries/logic Coveragelcov.info.p Lines:97.9 %57656499.8 %493492
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %64645454
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - BorrowLogic.sol + BorrowLogic.sol -
88.1%88.1%
+
100.0%
- 88.1 % - 67 - 59 + 100.0 % + 41 + 41 - 100.0 % - 4 - 4 + 2 + 2 - BridgeLogic.sol + BridgeLogic.sol -
100.0%
+
100.0%
100.0 % 28 @@ -126,54 +126,54 @@ 2 - CalldataLogic.sol + CalldataLogic.sol -
100.0%
+
100.0%
100.0 % - 72 - 72 + 62 + 62 - 100.0 % - 10 - 10 + 8 + 8 - ConfiguratorLogic.sol + ConfiguratorLogic.sol -
100.0%
+
100.0%
100.0 % - 33 - 33 + 29 + 29 - 100.0 % - 6 - 6 + 5 + 5 - EModeLogic.sol + EModeLogic.sol -
100.0%
+
100.0%
100.0 % - 12 - 12 + 5 + 5 - 100.0 % - 3 - 3 + 1 + 1 - FlashLoanLogic.sol + FlashLoanLogic.sol -
100.0%
+
100.0%
100.0 % 38 @@ -186,9 +186,9 @@ 3 - IsolationModeLogic.sol + IsolationModeLogic.sol -
100.0%
+
100.0%
100.0 % 9 @@ -201,24 +201,24 @@ 1 - LiquidationLogic.sol + LiquidationLogic.sol -
95.5%95.5%
+
98.6%98.6%
- 95.5 % - 88 - 84 + 98.6 % + 74 + 73 - 100.0 % - 7 - 7 + 6 + 6 - PoolLogic.sol + PoolLogic.sol -
100.0%
+
100.0%
100.0 % 37 @@ -231,9 +231,9 @@ 7 - SupplyLogic.sol + SupplyLogic.sol -
100.0%
+
100.0%
100.0 % 60 @@ -246,27 +246,27 @@ 4 - ValidationLogic.sol + ValidationLogic.sol -
100.0%
+
100.0%
100.0 % - 132 - 132 + 110 + 110 - 100.0 % - 17 - 17 + 15 + 15

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-f.html b/report/protocol/libraries/logic/index-sort-f.html similarity index 60% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-f.html rename to report/protocol/libraries/logic/index-sort-f.html index 6975312e..d083a5b9 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-f.html +++ b/report/protocol/libraries/logic/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - + LCOV - lcov.info.p - protocol/libraries/logic + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logictop level - protocol/libraries/logic Coveragelcov.info.p Lines:97.9 %57656499.8 %493492
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %64645454
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,13 +96,13 @@ Hit - IsolationModeLogic.sol + EModeLogic.sol -
100.0%
+
100.0%
100.0 % - 9 - 9 + 5 + 5 - @@ -111,69 +111,69 @@ 1 - BridgeLogic.sol + IsolationModeLogic.sol -
100.0%
+
100.0%
100.0 % - 28 - 28 + 9 + 9 - 100.0 % - 2 - 2 + 1 + 1 - EModeLogic.sol + BorrowLogic.sol -
100.0%
+
100.0%
100.0 % - 12 - 12 + 41 + 41 - 100.0 % - 3 - 3 + 2 + 2 - FlashLoanLogic.sol + BridgeLogic.sol -
100.0%
+
100.0%
100.0 % - 38 - 38 + 28 + 28 - 100.0 % - 3 - 3 + 2 + 2 - BorrowLogic.sol + FlashLoanLogic.sol -
88.1%88.1%
+
100.0%
- 88.1 % - 67 - 59 + 100.0 % + 38 + 38 - 100.0 % - 4 - 4 + 3 + 3 - SupplyLogic.sol + SupplyLogic.sol -
100.0%
+
100.0%
100.0 % 60 @@ -186,39 +186,39 @@ 4 - ConfiguratorLogic.sol + ConfiguratorLogic.sol -
100.0%
+
100.0%
100.0 % - 33 - 33 + 29 + 29 - 100.0 % - 6 - 6 + 5 + 5 - LiquidationLogic.sol + LiquidationLogic.sol -
95.5%95.5%
+
98.6%98.6%
- 95.5 % - 88 - 84 + 98.6 % + 74 + 73 - 100.0 % - 7 - 7 + 6 + 6 - PoolLogic.sol + PoolLogic.sol -
100.0%
+
100.0%
100.0 % 37 @@ -231,42 +231,42 @@ 7 - CalldataLogic.sol + CalldataLogic.sol -
100.0%
+
100.0%
100.0 % - 72 - 72 + 62 + 62 - 100.0 % - 10 - 10 + 8 + 8 - ValidationLogic.sol + ValidationLogic.sol -
100.0%
+
100.0%
100.0 % - 132 - 132 + 110 + 110 - 100.0 % - 17 - 17 + 15 + 15

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-l.html b/report/protocol/libraries/logic/index-sort-l.html similarity index 60% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-l.html rename to report/protocol/libraries/logic/index-sort-l.html index fe96817d..408cb650 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index-sort-l.html +++ b/report/protocol/libraries/logic/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - + LCOV - lcov.info.p - protocol/libraries/logic + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logictop level - protocol/libraries/logic Coveragelcov.info.p Lines:97.9 %57656499.8 %493492
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %64645454
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,39 +96,39 @@ Hit - BorrowLogic.sol + LiquidationLogic.sol -
88.1%88.1%
+
98.6%98.6%
- 88.1 % - 67 - 59 + 98.6 % + 74 + 73 - 100.0 % - 4 - 4 + 6 + 6 - LiquidationLogic.sol + EModeLogic.sol -
95.5%95.5%
+
100.0%
- 95.5 % - 88 - 84 + 100.0 % + 5 + 5 - 100.0 % - 7 - 7 + 1 + 1 - IsolationModeLogic.sol + IsolationModeLogic.sol -
100.0%
+
100.0%
100.0 % 9 @@ -141,24 +141,9 @@ 1 - EModeLogic.sol + BridgeLogic.sol -
100.0%
- - 100.0 % - 12 - 12 - - - - - 100.0 % - 3 - 3 - - - BridgeLogic.sol - -
100.0%
+
100.0%
100.0 % 28 @@ -171,24 +156,24 @@ 2 - ConfiguratorLogic.sol + ConfiguratorLogic.sol -
100.0%
+
100.0%
100.0 % - 33 - 33 + 29 + 29 - 100.0 % - 6 - 6 + 5 + 5 - PoolLogic.sol + PoolLogic.sol -
100.0%
+
100.0%
100.0 % 37 @@ -201,9 +186,9 @@ 7 - FlashLoanLogic.sol + FlashLoanLogic.sol -
100.0%
+
100.0%
100.0 % 38 @@ -216,9 +201,24 @@ 3 - SupplyLogic.sol + BorrowLogic.sol + +
100.0%
+ + 100.0 % + 41 + 41 + - + + + 100.0 % + 2 + 2 + + + SupplyLogic.sol -
100.0%
+
100.0%
100.0 % 60 @@ -231,42 +231,42 @@ 4 - CalldataLogic.sol + CalldataLogic.sol -
100.0%
+
100.0%
100.0 % - 72 - 72 + 62 + 62 - 100.0 % - 10 - 10 + 8 + 8 - ValidationLogic.sol + ValidationLogic.sol -
100.0%
+
100.0%
100.0 % - 132 - 132 + 110 + 110 - 100.0 % - 17 - 17 + 15 + 15

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index.html b/report/protocol/libraries/logic/index.html similarity index 60% rename from report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index.html rename to report/protocol/libraries/logic/index.html index 61e0232b..750492df 100644 --- a/report/core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/index.html +++ b/report/protocol/libraries/logic/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic - + LCOV - lcov.info.p - protocol/libraries/logic + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logictop level - protocol/libraries/logic Coveragelcov.info.p Lines:97.9 %57656499.8 %493492
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %64645454
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - BorrowLogic.sol + BorrowLogic.sol -
88.1%88.1%
+
100.0%
- 88.1 % - 67 - 59 + 100.0 % + 41 + 41 - 100.0 % - 4 - 4 + 2 + 2 - BridgeLogic.sol + BridgeLogic.sol -
100.0%
+
100.0%
100.0 % 28 @@ -126,54 +126,54 @@ 2 - CalldataLogic.sol + CalldataLogic.sol -
100.0%
+
100.0%
100.0 % - 72 - 72 + 62 + 62 - 100.0 % - 10 - 10 + 8 + 8 - ConfiguratorLogic.sol + ConfiguratorLogic.sol -
100.0%
+
100.0%
100.0 % - 33 - 33 + 29 + 29 - 100.0 % - 6 - 6 + 5 + 5 - EModeLogic.sol + EModeLogic.sol -
100.0%
+
100.0%
100.0 % - 12 - 12 + 5 + 5 - 100.0 % - 3 - 3 + 1 + 1 - FlashLoanLogic.sol + FlashLoanLogic.sol -
100.0%
+
100.0%
100.0 % 38 @@ -186,9 +186,9 @@ 3 - IsolationModeLogic.sol + IsolationModeLogic.sol -
100.0%
+
100.0%
100.0 % 9 @@ -201,24 +201,24 @@ 1 - LiquidationLogic.sol + LiquidationLogic.sol -
95.5%95.5%
+
98.6%98.6%
- 95.5 % - 88 - 84 + 98.6 % + 74 + 73 - 100.0 % - 7 - 7 + 6 + 6 - PoolLogic.sol + PoolLogic.sol -
100.0%
+
100.0%
100.0 % 37 @@ -231,9 +231,9 @@ 7 - SupplyLogic.sol + SupplyLogic.sol -
100.0%
+
100.0%
100.0 % 60 @@ -246,27 +246,27 @@ 4 - ValidationLogic.sol + ValidationLogic.sol -
100.0%
+
100.0%
100.0 % - 132 - 132 + 110 + 110 - 100.0 % - 17 - 17 + 15 + 15

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func-c.html b/report/protocol/libraries/math/MathUtils.sol.func-c.html similarity index 66% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func-c.html rename to report/protocol/libraries/math/MathUtils.sol.func-c.html index 64f7e490..4000a122 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func-c.html +++ b/report/protocol/libraries/math/MathUtils.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/MathUtils.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - MathUtils.sol (source / functions)top level - protocol/libraries/math - MathUtils.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
MathUtils.calculateLinearInterest1976221122
MathUtils.calculateCompoundedInterest3947727028
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func.html b/report/protocol/libraries/math/MathUtils.sol.func.html similarity index 66% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func.html rename to report/protocol/libraries/math/MathUtils.sol.func.html index 2618d9a6..07920843 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.func.html +++ b/report/protocol/libraries/math/MathUtils.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/MathUtils.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - MathUtils.sol (source / functions)top level - protocol/libraries/math - MathUtils.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
MathUtils.calculateCompoundedInterest3947727028
MathUtils.calculateLinearInterest1976221122
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.gcov.html b/report/protocol/libraries/math/MathUtils.sol.gcov.html similarity index 84% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.gcov.html rename to report/protocol/libraries/math/MathUtils.sol.gcov.html index 0bd46234..998460ce 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol.gcov.html +++ b/report/protocol/libraries/math/MathUtils.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/MathUtils.sol - + LCOV - lcov.info.p - protocol/libraries/math/MathUtils.sol + - + - +
LCOV - code coverage report
- + @@ -37,7 +37,7 @@ - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - MathUtils.sol (source / functions)top level - protocol/libraries/math - MathUtils.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -91,17 +91,17 @@ 20 : : * @param lastUpdateTimestamp The timestamp of the last update of the interest 21 : : * @return The interest rate linearly accumulated during the timeDelta, in ray 22 : : */ - 23 : 19762 : function calculateLinearInterest( + 23 : : function calculateLinearInterest( 24 : : uint256 rate, 25 : : uint40 lastUpdateTimestamp 26 : : ) internal view returns (uint256) { 27 : : //solium-disable-next-line - 28 : 59286 : uint256 result = rate * (block.timestamp - uint256(lastUpdateTimestamp)); + 28 : 21122 : uint256 result = rate * (block.timestamp - uint256(lastUpdateTimestamp)); 29 : : unchecked { - 30 : 39524 : result = result / SECONDS_PER_YEAR; + 30 : 21122 : result = result / SECONDS_PER_YEAR; 31 : : } 32 : : - 33 : 59286 : return WadRayMath.RAY + result; + 33 : 21122 : return WadRayMath.RAY + result; 34 : : } 35 : : 36 : : /** @@ -118,41 +118,41 @@ 47 : : * @param lastUpdateTimestamp The timestamp of the last update of the interest 48 : : * @return The interest rate compounded during the timeDelta, in ray 49 : : */ - 50 : 39477 : function calculateCompoundedInterest( + 50 : : function calculateCompoundedInterest( 51 : : uint256 rate, 52 : : uint40 lastUpdateTimestamp, 53 : : uint256 currentTimestamp 54 : : ) internal pure returns (uint256) { 55 : : //solium-disable-next-line - 56 : 104820 : uint256 exp = currentTimestamp - uint256(lastUpdateTimestamp); + 56 : 13515 : uint256 exp = currentTimestamp - uint256(lastUpdateTimestamp); 57 : : - 58 : 52410 : if (exp == 0) { - 59 : 2 : return WadRayMath.RAY; + 58 : 13515 : if (exp == 0) { + 59 : 1 : return WadRayMath.RAY; 60 : : } 61 : : - 62 : 52408 : uint256 expMinusOne; - 63 : 52408 : uint256 expMinusTwo; - 64 : 52408 : uint256 basePowerTwo; - 65 : 52408 : uint256 basePowerThree; + 62 : 13514 : uint256 expMinusOne; + 63 : 13514 : uint256 expMinusTwo; + 64 : 13514 : uint256 basePowerTwo; + 65 : 13514 : uint256 basePowerThree; 66 : : unchecked { - 67 : 52408 : expMinusOne = exp - 1; + 67 : 13514 : expMinusOne = exp - 1; 68 : : - 69 : 52408 : expMinusTwo = exp > 2 ? exp - 2 : 0; + 69 : 13514 : expMinusTwo = exp > 2 ? exp - 2 : 0; 70 : : - 71 : 52408 : basePowerTwo = rate.rayMul(rate) / (SECONDS_PER_YEAR * SECONDS_PER_YEAR); - 72 : 52408 : basePowerThree = basePowerTwo.rayMul(rate) / SECONDS_PER_YEAR; + 71 : 13514 : basePowerTwo = rate.rayMul(rate) / (SECONDS_PER_YEAR * SECONDS_PER_YEAR); + 72 : 13514 : basePowerThree = basePowerTwo.rayMul(rate) / SECONDS_PER_YEAR; 73 : : } 74 : : - 75 : 104816 : uint256 secondTerm = exp * expMinusOne * basePowerTwo; + 75 : 13514 : uint256 secondTerm = exp * expMinusOne * basePowerTwo; 76 : : unchecked { - 77 : 52408 : secondTerm /= 2; + 77 : 13514 : secondTerm /= 2; 78 : : } - 79 : 131020 : uint256 thirdTerm = exp * expMinusOne * expMinusTwo * basePowerThree; + 79 : 13514 : uint256 thirdTerm = exp * expMinusOne * expMinusTwo * basePowerThree; 80 : : unchecked { - 81 : 52408 : thirdTerm /= 6; + 81 : 13514 : thirdTerm /= 6; 82 : : } 83 : : - 84 : 157224 : return WadRayMath.RAY + (rate * exp) / SECONDS_PER_YEAR + secondTerm + thirdTerm; + 84 : 13514 : return WadRayMath.RAY + (rate * exp) / SECONDS_PER_YEAR + secondTerm + thirdTerm; 85 : : } 86 : : 87 : : /** @@ -165,7 +165,7 @@ 94 : : uint256 rate, 95 : : uint40 lastUpdateTimestamp 96 : : ) internal view returns (uint256) { - 97 : 39816 : return calculateCompoundedInterest(rate, lastUpdateTimestamp, block.timestamp); + 97 : 13513 : return calculateCompoundedInterest(rate, lastUpdateTimestamp, block.timestamp); 98 : : } 99 : : } @@ -175,8 +175,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func-c.html b/report/protocol/libraries/math/PercentageMath.sol.func-c.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func-c.html rename to report/protocol/libraries/math/PercentageMath.sol.func-c.html index 5361ea87..c249258b 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func-c.html +++ b/report/protocol/libraries/math/PercentageMath.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/PercentageMath.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - PercentageMath.sol (source / functions)top level - protocol/libraries/math - PercentageMath.sol (source / functions) Coverage Lines: 100.0 %4466
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PercentageMath.percentDiv1913630126
PercentageMath.percentMul100989158440
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func.html b/report/protocol/libraries/math/PercentageMath.sol.func.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func.html rename to report/protocol/libraries/math/PercentageMath.sol.func.html index ab030e28..1695ad80 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.func.html +++ b/report/protocol/libraries/math/PercentageMath.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/PercentageMath.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - PercentageMath.sol (source / functions)top level - protocol/libraries/math - PercentageMath.sol (source / functions) Coverage Lines: 100.0 %4466
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -89,8 +89,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PercentageMath.percentDiv1913630126
PercentageMath.percentMul100989158440
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.gcov.html b/report/protocol/libraries/math/PercentageMath.sol.gcov.html similarity index 84% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.gcov.html rename to report/protocol/libraries/math/PercentageMath.sol.gcov.html index f7058a46..65415a84 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol.gcov.html +++ b/report/protocol/libraries/math/PercentageMath.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/PercentageMath.sol - + LCOV - lcov.info.p - protocol/libraries/math/PercentageMath.sol + - + - +
LCOV - code coverage report
- + @@ -32,12 +32,12 @@ - - + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - PercentageMath.sol (source / functions)top level - protocol/libraries/math - PercentageMath.sol (source / functions) Coverage Lines: 100.0 %4466
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -93,19 +93,19 @@ 22 : : * @param percentage The percentage of the value to be calculated 23 : : * @return result value percentmul percentage 24 : : */ - 25 : 100989 : function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256 result) { + 25 : : function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256 result) { 26 : : // to avoid overflow, value <= (type(uint256).max - HALF_PERCENTAGE_FACTOR) / percentage 27 : : assembly { - 28 : 100989 : if iszero( + 28 : 158440 : if iszero( 29 : : or( 30 : : iszero(percentage), 31 : : iszero(gt(value, div(sub(not(0), HALF_PERCENTAGE_FACTOR), percentage))) 32 : : ) 33 : : ) { - 34 : : revert(0, 0) + 34 : 303 : revert(0, 0) 35 : : } 36 : : - 37 : 201340 : result := div(add(mul(value, percentage), HALF_PERCENTAGE_FACTOR), PERCENTAGE_FACTOR) + 37 : 158137 : result := div(add(mul(value, percentage), HALF_PERCENTAGE_FACTOR), PERCENTAGE_FACTOR) 38 : : } 39 : : } 40 : : @@ -116,17 +116,17 @@ 45 : : * @param percentage The percentage of the value to be calculated 46 : : * @return result value percentdiv percentage 47 : : */ - 48 : 19136 : function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256 result) { + 48 : : function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256 result) { 49 : : // to avoid overflow, value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR 50 : : assembly { - 51 : 19136 : if or( + 51 : 30126 : if or( 52 : : iszero(percentage), 53 : : iszero(iszero(gt(value, div(sub(not(0), div(percentage, 2)), PERCENTAGE_FACTOR)))) 54 : : ) { - 55 : : revert(0, 0) + 55 : 74 : revert(0, 0) 56 : : } 57 : : - 58 : 37888 : result := div(add(mul(value, PERCENTAGE_FACTOR), div(percentage, 2)), percentage) + 58 : 30052 : result := div(add(mul(value, PERCENTAGE_FACTOR), div(percentage, 2)), percentage) 59 : : } 60 : : } 61 : : } @@ -137,8 +137,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func-c.html b/report/protocol/libraries/math/WadRayMath.sol.func-c.html similarity index 67% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func-c.html rename to report/protocol/libraries/math/WadRayMath.sol.func-c.html index a02ca863..aa6c47cb 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func-c.html +++ b/report/protocol/libraries/math/WadRayMath.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/WadRayMath.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - WadRayMath.sol (source / functions)top level - protocol/libraries/math - WadRayMath.sol (source / functions) Coveragelcov.info.p Lines:100.0 %131389.5 %1917
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + @@ -79,37 +79,37 @@ - + - + - + - + - + - + - + - + @@ -117,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
WadRayMath.rayToWadWadRayMath.wadToRay20031945
WadRayMath.wadDivWadRayMath.rayToWad153252003
WadRayMath.wadToRayWadRayMath.wadDiv7713123533
WadRayMath.rayDiv173648280644
WadRayMath.rayMul479205719133
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func.html b/report/protocol/libraries/math/WadRayMath.sol.func.html similarity index 67% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func.html rename to report/protocol/libraries/math/WadRayMath.sol.func.html index 820bd34b..88a84a37 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.func.html +++ b/report/protocol/libraries/math/WadRayMath.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol - functions - + LCOV - lcov.info.p - protocol/libraries/math/WadRayMath.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,35 +53,35 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - WadRayMath.sol (source / functions)top level - protocol/libraries/math - WadRayMath.sol (source / functions) Coveragelcov.info.p Lines:100.0 %131389.5 %1917
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
- + - + - + - + @@ -95,7 +95,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -117,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
WadRayMath.rayDiv173648280644
WadRayMath.rayMul479205719133
WadRayMath.wadDiv1532523533
WadRayMath.wadToRay771311945
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.gcov.html b/report/protocol/libraries/math/WadRayMath.sol.gcov.html similarity index 83% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.gcov.html rename to report/protocol/libraries/math/WadRayMath.sol.gcov.html index 78bbe0d7..1aab3e38 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol.gcov.html +++ b/report/protocol/libraries/math/WadRayMath.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/WadRayMath.sol - + LCOV - lcov.info.p - protocol/libraries/math/WadRayMath.sol + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - WadRayMath.sol (source / functions)top level - protocol/libraries/math - WadRayMath.sol (source / functions) Coveragelcov.info.p Lines:100.0 %131389.5 %1917
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -97,14 +97,14 @@ 26 : : * @param b Wad 27 : : * @return c = a*b, in wad 28 : : */ - 29 : 1006 : function wadMul(uint256 a, uint256 b) internal pure returns (uint256 c) { + 29 : : function wadMul(uint256 a, uint256 b) internal pure returns (uint256 c) { 30 : : // to avoid overflow, a <= (type(uint256).max - HALF_WAD) / b 31 : : assembly { - 32 : 1006 : if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_WAD), b))))) { - 33 : : revert(0, 0) + 32 : 1006 : if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_WAD), b))))) { + 33 : 314 : revert(0, 0) 34 : : } 35 : : - 36 : 1382 : c := div(add(mul(a, b), HALF_WAD), WAD) + 36 : 692 : c := div(add(mul(a, b), HALF_WAD), WAD) 37 : : } 38 : : } 39 : : @@ -115,14 +115,14 @@ 44 : : * @param b Wad 45 : : * @return c = a/b, in wad 46 : : */ - 47 : 15325 : function wadDiv(uint256 a, uint256 b) internal pure returns (uint256 c) { + 47 : : function wadDiv(uint256 a, uint256 b) internal pure returns (uint256 c) { 48 : : // to avoid overflow, a <= (type(uint256).max - halfB) / WAD 49 : : assembly { - 50 : 15325 : if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), WAD))))) { - 51 : : revert(0, 0) + 50 : 23533 : if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), WAD))))) { + 51 : 169 : revert(0, 0) 52 : : } 53 : : - 54 : 30170 : c := div(add(mul(a, WAD), div(b, 2)), b) + 54 : 23364 : c := div(add(mul(a, WAD), div(b, 2)), b) 55 : : } 56 : : } 57 : : @@ -133,14 +133,14 @@ 62 : : * @param b Ray 63 : : * @return c = a raymul b 64 : : */ - 65 : 479205 : function rayMul(uint256 a, uint256 b) internal pure returns (uint256 c) { + 65 : : function rayMul(uint256 a, uint256 b) internal pure returns (uint256 c) { 66 : : // to avoid overflow, a <= (type(uint256).max - HALF_RAY) / b 67 : : assembly { - 68 : 479205 : if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_RAY), b))))) { - 69 : : revert(0, 0) + 68 : 719133 : if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_RAY), b))))) { + 69 : 0 : revert(0, 0) 70 : : } 71 : : - 72 : 958410 : c := div(add(mul(a, b), HALF_RAY), RAY) + 72 : 719133 : c := div(add(mul(a, b), HALF_RAY), RAY) 73 : : } 74 : : } 75 : : @@ -151,14 +151,14 @@ 80 : : * @param b Ray 81 : : * @return c = a raydiv b 82 : : */ - 83 : 173648 : function rayDiv(uint256 a, uint256 b) internal pure returns (uint256 c) { + 83 : : function rayDiv(uint256 a, uint256 b) internal pure returns (uint256 c) { 84 : : // to avoid overflow, a <= (type(uint256).max - halfB) / RAY 85 : : assembly { - 86 : 173648 : if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), RAY))))) { - 87 : : revert(0, 0) + 86 : 280644 : if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), RAY))))) { + 87 : 0 : revert(0, 0) 88 : : } 89 : : - 90 : 347296 : c := div(add(mul(a, RAY), div(b, 2)), b) + 90 : 280644 : c := div(add(mul(a, RAY), div(b, 2)), b) 91 : : } 92 : : } 93 : : @@ -168,12 +168,12 @@ 97 : : * @param a Ray 98 : : * @return b = a converted to wad, rounded half up to the nearest wad 99 : : */ - 100 : 2003 : function rayToWad(uint256 a) internal pure returns (uint256 b) { + 100 : : function rayToWad(uint256 a) internal pure returns (uint256 b) { 101 : : assembly { - 102 : 4006 : b := div(a, WAD_RAY_RATIO) - 103 : : let remainder := mod(a, WAD_RAY_RATIO) + 102 : 2003 : b := div(a, WAD_RAY_RATIO) + 103 : 2003 : let remainder := mod(a, WAD_RAY_RATIO) 104 : 2003 : if iszero(lt(remainder, div(WAD_RAY_RATIO, 2))) { - 105 : 576 : b := add(b, 1) + 105 : 558 : b := add(b, 1) 106 : : } 107 : : } 108 : : } @@ -184,13 +184,13 @@ 113 : : * @param a Wad 114 : : * @return b = a converted in ray 115 : : */ - 116 : 77131 : function wadToRay(uint256 a) internal pure returns (uint256 b) { + 116 : : function wadToRay(uint256 a) internal pure returns (uint256 b) { 117 : : // to avoid overflow, b/WAD_RAY_RATIO == a 118 : : assembly { - 119 : 154262 : b := mul(a, WAD_RAY_RATIO) + 119 : 1945 : b := mul(a, WAD_RAY_RATIO) 120 : : - 121 : 77131 : if iszero(eq(div(b, WAD_RAY_RATIO), a)) { - 122 : : revert(0, 0) + 121 : 1945 : if iszero(eq(div(b, WAD_RAY_RATIO), a)) { + 122 : 112 : revert(0, 0) 123 : : } 124 : : } 125 : : } @@ -202,8 +202,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-b.html b/report/protocol/libraries/math/index-sort-b.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-b.html rename to report/protocol/libraries/math/index-sort-b.html index 71bac976..5eaa5eb6 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-b.html +++ b/report/protocol/libraries/math/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - + LCOV - lcov.info.p - protocol/libraries/math + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/mathtop level - protocol/libraries/math Coveragelcov.info.p Lines:100.0 %373795.6 %4543
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - MathUtils.sol + MathUtils.sol -
100.0%
+
100.0%
100.0 % 20 @@ -111,13 +111,13 @@ 2 - PercentageMath.sol + PercentageMath.sol -
100.0%
+
100.0%
100.0 % - 4 - 4 + 6 + 6 - @@ -126,13 +126,13 @@ 2 - WadRayMath.sol + WadRayMath.sol -
100.0%
+
89.5%89.5%
- 100.0 % - 13 - 13 + 89.5 % + 19 + 17 - @@ -145,8 +145,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-f.html b/report/protocol/libraries/math/index-sort-f.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-f.html rename to report/protocol/libraries/math/index-sort-f.html index cb969e10..196574ae 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-f.html +++ b/report/protocol/libraries/math/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - + LCOV - lcov.info.p - protocol/libraries/math + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/mathtop level - protocol/libraries/math Coveragelcov.info.p Lines:100.0 %373795.6 %4543
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - MathUtils.sol + MathUtils.sol -
100.0%
+
100.0%
100.0 % 20 @@ -111,13 +111,13 @@ 2 - PercentageMath.sol + PercentageMath.sol -
100.0%
+
100.0%
100.0 % - 4 - 4 + 6 + 6 - @@ -126,13 +126,13 @@ 2 - WadRayMath.sol + WadRayMath.sol -
100.0%
+
89.5%89.5%
- 100.0 % - 13 - 13 + 89.5 % + 19 + 17 - @@ -145,8 +145,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-l.html b/report/protocol/libraries/math/index-sort-l.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-l.html rename to report/protocol/libraries/math/index-sort-l.html index 5a3881c2..3b7d6d76 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index-sort-l.html +++ b/report/protocol/libraries/math/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - + LCOV - lcov.info.p - protocol/libraries/math + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/mathtop level - protocol/libraries/math Coveragelcov.info.p Lines:100.0 %373795.6 %4543
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,39 +96,39 @@ Hit - PercentageMath.sol + WadRayMath.sol -
100.0%
+
89.5%89.5%
- 100.0 % - 4 - 4 + 89.5 % + 19 + 17 - 100.0 % - 2 - 2 + 6 + 6 - WadRayMath.sol + PercentageMath.sol -
100.0%
+
100.0%
100.0 % - 13 - 13 + 6 + 6 - 100.0 % - 6 - 6 + 2 + 2 - MathUtils.sol + MathUtils.sol -
100.0%
+
100.0%
100.0 % 20 @@ -145,8 +145,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index.html b/report/protocol/libraries/math/index.html similarity index 64% rename from report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index.html rename to report/protocol/libraries/math/index.html index fb38af2f..fb57a734 100644 --- a/report/core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math/index.html +++ b/report/protocol/libraries/math/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/math - + LCOV - lcov.info.p - protocol/libraries/math + - + - +
LCOV - code coverage report
- + @@ -31,13 +31,13 @@ - - - + + + - + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/libraries/math/src/core/contracts/protocol/libraries/mathtop level - protocol/libraries/math Coveragelcov.info.p Lines:100.0 %373795.6 %4543
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - MathUtils.sol + MathUtils.sol -
100.0%
+
100.0%
100.0 % 20 @@ -111,13 +111,13 @@ 2 - PercentageMath.sol + PercentageMath.sol -
100.0%
+
100.0%
100.0 % - 4 - 4 + 6 + 6 - @@ -126,13 +126,13 @@ 2 - WadRayMath.sol + WadRayMath.sol -
100.0%
+
89.5%89.5%
- 100.0 % - 13 - 13 + 89.5 % + 19 + 17 - @@ -145,8 +145,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func-c.html b/report/protocol/pool/L2Pool.sol.func-c.html similarity index 66% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func-c.html rename to report/protocol/pool/L2Pool.sol.func-c.html index bd46015b..fdaff8d1 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func-c.html +++ b/report/protocol/pool/L2Pool.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol - functions - + LCOV - lcov.info.p - protocol/pool/L2Pool.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,33 +53,26 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - L2Pool.sol (source / functions)top level - protocol/pool - L2Pool.sol (source / functions) Coverage Lines: 100.0 %24242020
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %111199
0 0
- + - + - - - - - - - - + @@ -100,14 +93,7 @@ - - - - - - - - + @@ -152,8 +138,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
L2Pool.liquidationCall1
L2Pool.rebalanceStableBorrowRateL2Pool.liquidationCall 1
L2Pool.setUserUseReserveAsCollateral1
L2Pool.swapBorrowRateModeL2Pool.setUserUseReserveAsCollateral 1
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func.html b/report/protocol/pool/L2Pool.sol.func.html similarity index 66% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func.html rename to report/protocol/pool/L2Pool.sol.func.html index 5cb0e702..5d8dfdfa 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.func.html +++ b/report/protocol/pool/L2Pool.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol - functions - + LCOV - lcov.info.p - protocol/pool/L2Pool.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - L2Pool.sol (source / functions)top level - protocol/pool - L2Pool.sol (source / functions) Coverage Lines: 100.0 %24242020
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %111199
0 0
- + - + @@ -79,14 +79,7 @@ - - - - - - - - + @@ -114,7 +107,7 @@ - + @@ -133,13 +126,6 @@ - - - - - - - @@ -152,8 +138,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
L2Pool.liquidationCall1
L2Pool.rebalanceStableBorrowRateL2Pool.liquidationCall 1
L2Pool.setUserUseReserveAsCollateralL2Pool.setUserUseReserveAsCollateral 11000
L2Pool.swapBorrowRateMode1
L2Pool.withdraw
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.gcov.html b/report/protocol/pool/L2Pool.sol.gcov.html similarity index 66% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.gcov.html rename to report/protocol/pool/L2Pool.sol.gcov.html index 5ba63d60..6ce0cf48 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol.gcov.html +++ b/report/protocol/pool/L2Pool.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/L2Pool.sol - + LCOV - lcov.info.p - protocol/pool/L2Pool.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - L2Pool.sol (source / functions)top level - protocol/pool - L2Pool.sol (source / functions) Coverage Lines: 100.0 %24242020
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %111199
0 0
@@ -85,110 +85,92 @@ 14 : : */ 15 : : abstract contract L2Pool is Pool, IL2Pool { 16 : : /// @inheritdoc IL2Pool - 17 : 7 : function supply(bytes32 args) external override { - 18 : 21 : (address asset, uint256 amount, uint16 referralCode) = CalldataLogic.decodeSupplyParams( + 17 : : function supply(bytes32 args) external override { + 18 : 7 : (address asset, uint256 amount, uint16 referralCode) = CalldataLogic.decodeSupplyParams( 19 : : _reservesList, 20 : : args 21 : : ); 22 : : - 23 : 14 : supply(asset, amount, msg.sender, referralCode); + 23 : 7 : supply(asset, amount, msg.sender, referralCode); 24 : : } 25 : : 26 : : /// @inheritdoc IL2Pool - 27 : 1000 : function supplyWithPermit(bytes32 args, bytes32 r, bytes32 s) external override { - 28 : 3000 : (address asset, uint256 amount, uint16 referralCode, uint256 deadline, uint8 v) = CalldataLogic + 27 : : function supplyWithPermit(bytes32 args, bytes32 r, bytes32 s) external override { + 28 : 1000 : (address asset, uint256 amount, uint16 referralCode, uint256 deadline, uint8 v) = CalldataLogic 29 : : .decodeSupplyWithPermitParams(_reservesList, args); 30 : : - 31 : 2000 : supplyWithPermit(asset, amount, msg.sender, referralCode, deadline, v, r, s); + 31 : 1000 : supplyWithPermit(asset, amount, msg.sender, referralCode, deadline, v, r, s); 32 : : } 33 : : 34 : : /// @inheritdoc IL2Pool - 35 : 2 : function withdraw(bytes32 args) external override returns (uint256) { - 36 : 6 : (address asset, uint256 amount) = CalldataLogic.decodeWithdrawParams(_reservesList, args); + 35 : : function withdraw(bytes32 args) external override returns (uint256) { + 36 : 2 : (address asset, uint256 amount) = CalldataLogic.decodeWithdrawParams(_reservesList, args); 37 : : - 38 : 6 : return withdraw(asset, amount, msg.sender); + 38 : 2 : return withdraw(asset, amount, msg.sender); 39 : : } 40 : : 41 : : /// @inheritdoc IL2Pool - 42 : 3 : function borrow(bytes32 args) external override { - 43 : 9 : (address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode) = CalldataLogic + 42 : : function borrow(bytes32 args) external override { + 43 : 3 : (address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode) = CalldataLogic 44 : : .decodeBorrowParams(_reservesList, args); 45 : : - 46 : 6 : borrow(asset, amount, interestRateMode, referralCode, msg.sender); + 46 : 3 : borrow(asset, amount, interestRateMode, referralCode, msg.sender); 47 : : } 48 : : 49 : : /// @inheritdoc IL2Pool - 50 : 1 : function repay(bytes32 args) external override returns (uint256) { - 51 : 3 : (address asset, uint256 amount, uint256 interestRateMode) = CalldataLogic.decodeRepayParams( + 50 : : function repay(bytes32 args) external override returns (uint256) { + 51 : 1 : (address asset, uint256 amount, uint256 interestRateMode) = CalldataLogic.decodeRepayParams( 52 : : _reservesList, 53 : : args 54 : : ); 55 : : - 56 : 3 : return repay(asset, amount, interestRateMode, msg.sender); + 56 : 1 : return repay(asset, amount, interestRateMode, msg.sender); 57 : : } 58 : : 59 : : /// @inheritdoc IL2Pool - 60 : 1000 : function repayWithPermit(bytes32 args, bytes32 r, bytes32 s) external override returns (uint256) { - 61 : 2000 : ( + 60 : : function repayWithPermit(bytes32 args, bytes32 r, bytes32 s) external override returns (uint256) { + 61 : 1000 : ( 62 : : address asset, 63 : : uint256 amount, 64 : : uint256 interestRateMode, 65 : : uint256 deadline, 66 : : uint8 v - 67 : 2000 : ) = CalldataLogic.decodeRepayWithPermitParams(_reservesList, args); + 67 : 1000 : ) = CalldataLogic.decodeRepayWithPermitParams(_reservesList, args); 68 : : - 69 : 3000 : return repayWithPermit(asset, amount, interestRateMode, msg.sender, deadline, v, r, s); + 69 : 1000 : return repayWithPermit(asset, amount, interestRateMode, msg.sender, deadline, v, r, s); 70 : : } 71 : : 72 : : /// @inheritdoc IL2Pool - 73 : 1 : function repayWithATokens(bytes32 args) external override returns (uint256) { - 74 : 3 : (address asset, uint256 amount, uint256 interestRateMode) = CalldataLogic.decodeRepayParams( + 73 : : function repayWithATokens(bytes32 args) external override returns (uint256) { + 74 : 1 : (address asset, uint256 amount, uint256 interestRateMode) = CalldataLogic.decodeRepayParams( 75 : : _reservesList, 76 : : args 77 : : ); 78 : : - 79 : 3 : return repayWithATokens(asset, amount, interestRateMode); + 79 : 1 : return repayWithATokens(asset, amount, interestRateMode); 80 : : } 81 : : 82 : : /// @inheritdoc IL2Pool - 83 : 1 : function swapBorrowRateMode(bytes32 args) external override { - 84 : 3 : (address asset, uint256 interestRateMode) = CalldataLogic.decodeSwapBorrowRateModeParams( + 83 : : function setUserUseReserveAsCollateral(bytes32 args) external override { + 84 : 1 : (address asset, bool useAsCollateral) = CalldataLogic.decodeSetUserUseReserveAsCollateralParams( 85 : : _reservesList, 86 : : args 87 : : ); - 88 : 2 : swapBorrowRateMode(asset, interestRateMode); + 88 : 1 : setUserUseReserveAsCollateral(asset, useAsCollateral); 89 : : } 90 : : 91 : : /// @inheritdoc IL2Pool - 92 : 1 : function rebalanceStableBorrowRate(bytes32 args) external override { - 93 : 3 : (address asset, address user) = CalldataLogic.decodeRebalanceStableBorrowRateParams( - 94 : : _reservesList, - 95 : : args - 96 : : ); - 97 : 2 : rebalanceStableBorrowRate(asset, user); - 98 : : } - 99 : : - 100 : : /// @inheritdoc IL2Pool - 101 : 1 : function setUserUseReserveAsCollateral(bytes32 args) external override { - 102 : 3 : (address asset, bool useAsCollateral) = CalldataLogic.decodeSetUserUseReserveAsCollateralParams( - 103 : : _reservesList, - 104 : : args - 105 : : ); - 106 : 2 : setUserUseReserveAsCollateral(asset, useAsCollateral); - 107 : : } - 108 : : - 109 : : /// @inheritdoc IL2Pool - 110 : 1 : function liquidationCall(bytes32 args1, bytes32 args2) external override { - 111 : 2 : ( - 112 : : address collateralAsset, - 113 : : address debtAsset, - 114 : : address user, - 115 : : uint256 debtToCover, - 116 : : bool receiveAToken - 117 : 2 : ) = CalldataLogic.decodeLiquidationCallParams(_reservesList, args1, args2); - 118 : 2 : liquidationCall(collateralAsset, debtAsset, user, debtToCover, receiveAToken); - 119 : : } - 120 : : } + 92 : : function liquidationCall(bytes32 args1, bytes32 args2) external override { + 93 : 1 : ( + 94 : : address collateralAsset, + 95 : : address debtAsset, + 96 : : address user, + 97 : : uint256 debtToCover, + 98 : : bool receiveAToken + 99 : 1 : ) = CalldataLogic.decodeLiquidationCallParams(_reservesList, args1, args2); + 100 : 1 : liquidationCall(collateralAsset, debtAsset, user, debtToCover, receiveAToken); + 101 : : } + 102 : : } @@ -196,8 +178,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func-c.html b/report/protocol/pool/Pool.sol.func-c.html similarity index 62% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func-c.html rename to report/protocol/pool/Pool.sol.func-c.html index 25ce9a96..8a0cf110 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func-c.html +++ b/report/protocol/pool/Pool.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol - functions - + LCOV - lcov.info.p - protocol/pool/Pool.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,448 +53,490 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - Pool.sol (source / functions)top level - protocol/pool - Pool.sol (source / functions) Coveragelcov.info.p Lines:99.1 %10810798.3 %121119
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:98.4 %6160100.0 %6767
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -502,8 +544,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
Pool.swapToVariablePool.getReserveAddressById01
Pool.getReserveAddressByIdPool.getBorrowLogic12
Pool.getReservesCountPool.getBridgeLogic12
Pool.getBorrowLogicPool.getEModeLogic 2
Pool.getBridgeLogicPool.getFlashLoanLogic 2
Pool.getEModeLogicPool.getLiquidationLogic 2
Pool.getFlashLoanLogicPool.getPoolLogic 2
Pool.getLiquidationLogicPool.getReservesCount 2
Pool.getPoolLogicPool.getSupplyLogic 2
Pool.getSupplyLogicPool.getEModeCategoryData23
Pool.MAX_NUMBER_RESERVESPool.mintToTreasury34
Pool.MAX_STABLE_RATE_BORROW_SIZE_PERCENTPool.backUnbacked39
Pool.mintToTreasuryPool.flashLoanSimple411
Pool.rebalanceStableBorrowRatePool.mintUnbacked417
Pool.getReserveDataExtendedPool.onlyBridge617
Pool.swapBorrowRateModePool.repay723
Pool.backUnbackedPool.BRIDGE_PROTOCOL_FEE925
Pool.flashLoanPool.getEModeCategoryLabel1025
Pool.flashLoanSimplePool._onlyBridge1026
Pool.depositPool.setUserUseReserveAsCollateral1742
Pool.mintUnbackedPool.1744
Pool.setUserEModePool.getEModeCategoryCollateralConfig17110
Pool.repayPool.repayWithATokens221005
Pool.BRIDGE_PROTOCOL_FEEPool.flashLoan251011
Pool._onlyBridgePool.FLASHLOAN_PREMIUM_TO_PROTOCOL261365
Pool.setUserUseReserveAsCollateralPool.FLASHLOAN_PREMIUM_TOTAL421368
Pool.withdrawPool.syncIndexesState431994
Pool.getEModeCategoryDataPool.syncRatesState461994
Pool.repayWithATokensPool._onlyPoolAdmin10052000
Pool.finalizeTransferPool.onlyPoolAdmin10362000
Pool.FLASHLOAN_PREMIUM_TO_PROTOCOLPool.rescueTokens12152000
Pool.FLASHLOAN_PREMIUM_TOTALPool.MAX_NUMBER_RESERVES12182002
Pool.syncIndexesStatePool.dropReserve17512007
Pool.syncRatesStatePool.updateBridgeProtocolFee17512013
Pool._onlyPoolAdminPool.withdraw20002043
Pool.rescueTokensPool.repayWithPermit20003000
Pool.dropReservePool.supplyWithPermit20073000
Pool.updateBridgeProtocolFeePool.updateFlashloanPremiums20133362
Pool.configureEModeCategoryPool.resetIsolationModeTotalDebt20273951
Pool.repayWithPermitPool.getUserEMode30005016
Pool.supplyWithPermitPool.getReserveDataExtended30006011
Pool.onlyPoolConfigurator6046
Pool.setReserveInterestRateStrategyAddress6046
Pool.configureEModeCategoryBorrowableBitmap7010
Pool.getUserConfiguration7029
Pool.getEModeCategoryBorrowableBitmap7035
Pool.getVirtualUnderlyingBalance8111
Pool.getUserEModePool.getLiquidationGracePeriod30128756
Pool.getUserAccountDataPool.getUserAccountData301310015
Pool.updateFlashloanPremiumsPool.setUserEMode321210023
Pool.resetIsolationModeTotalDebtPool.configureEModeCategoryCollateralBitmap375110039
Pool.getLiquidationGracePeriodPool.getEModeCategoryCollateralBitmap551210064
Pool.setReserveInterestRateStrategyAddressPool.configureEModeCategory600612029
Pool.getUserConfigurationPool.liquidationCall603014500
Pool.getVirtualUnderlyingBalancePool.getReservesList603016076
Pool.getReservesListPool.borrow604316105
Pool.initReservePool.setLiquidationGracePeriod688216412
Pool.borrowPool.finalizeTransfer911317042
Pool.supplyPool.deposit955820025
Pool.liquidationCallPool.supply1129120483
Pool.setLiquidationGracePeriodPool.getReserveNormalizedVariableDebt1302829583
Pool.getReserveDataPool.getReserveData2220483030
Pool.getReserveNormalizedVariableDebtPool.getReserveNormalizedIncome25218115423
Pool.getReserveNormalizedIncomePool.getConfiguration31404162047
Pool.setConfigurationPool.initReserve38058170016
Pool.getConfigurationPool.setConfiguration41450210599
Pool._onlyPoolConfiguratorPool._onlyPoolConfigurator80486447472
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func.html b/report/protocol/pool/Pool.sol.func.html similarity index 62% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func.html rename to report/protocol/pool/Pool.sol.func.html index ca1ea3f4..7757b8f3 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.func.html +++ b/report/protocol/pool/Pool.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol - functions - + LCOV - lcov.info.p - protocol/pool/Pool.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,448 +53,490 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - Pool.sol (source / functions)top level - protocol/pool - Pool.sol (source / functions) Coveragelcov.info.p Lines:99.1 %10810798.3 %121119
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:98.4 %6160100.0 %6767
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -502,8 +544,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
Pool.BRIDGE_PROTOCOL_FEEPool.2544
Pool.FLASHLOAN_PREMIUM_TOTALPool.BRIDGE_PROTOCOL_FEE121825
Pool.FLASHLOAN_PREMIUM_TO_PROTOCOLPool.FLASHLOAN_PREMIUM_TOTAL12151368
Pool.MAX_NUMBER_RESERVESPool.FLASHLOAN_PREMIUM_TO_PROTOCOL31365
Pool.MAX_STABLE_RATE_BORROW_SIZE_PERCENTPool.MAX_NUMBER_RESERVES32002
Pool._onlyBridgePool._onlyBridge 26
Pool._onlyPoolAdminPool._onlyPoolAdmin 2000
Pool._onlyPoolConfiguratorPool._onlyPoolConfigurator80486447472
Pool.backUnbackedPool.backUnbacked 9
Pool.borrowPool.borrow911316105
Pool.configureEModeCategoryPool.configureEModeCategory202712029
Pool.depositPool.configureEModeCategoryBorrowableBitmap177010
Pool.configureEModeCategoryCollateralBitmap10039
Pool.dropReservePool.deposit20025
Pool.dropReserve 2007
Pool.finalizeTransferPool.finalizeTransfer103617042
Pool.flashLoanPool.flashLoan101011
Pool.flashLoanSimplePool.flashLoanSimple1011
Pool.getBorrowLogicPool.getBorrowLogic 2
Pool.getBridgeLogicPool.getBridgeLogic 2
Pool.getConfigurationPool.getConfiguration41450162047
Pool.getEModeCategoryDataPool.getEModeCategoryBorrowableBitmap467035
Pool.getEModeLogicPool.getEModeCategoryCollateralBitmap10064
Pool.getEModeCategoryCollateralConfig110
Pool.getEModeCategoryData3
Pool.getEModeCategoryLabel25
Pool.getEModeLogic 2
Pool.getFlashLoanLogicPool.getFlashLoanLogic 2
Pool.getLiquidationGracePeriodPool.getLiquidationGracePeriod55128756
Pool.getLiquidationLogicPool.getLiquidationLogic 2
Pool.getPoolLogicPool.getPoolLogic 2
Pool.getReserveAddressByIdPool.getReserveAddressById 1
Pool.getReserveDataPool.getReserveData2220483030
Pool.getReserveDataExtendedPool.getReserveDataExtended66011
Pool.getReserveNormalizedIncomePool.getReserveNormalizedIncome31404115423
Pool.getReserveNormalizedVariableDebtPool.getReserveNormalizedVariableDebt2521829583
Pool.getReservesCountPool.getReservesCount12
Pool.getReservesListPool.getReservesList604316076
Pool.getSupplyLogicPool.getSupplyLogic 2
Pool.getUserAccountDataPool.getUserAccountData301310015
Pool.getUserConfigurationPool.getUserConfiguration60307029
Pool.getUserEModePool.getUserEMode30125016
Pool.getVirtualUnderlyingBalancePool.getVirtualUnderlyingBalance60308111
Pool.initReservePool.initReserve6882170016
Pool.liquidationCallPool.liquidationCall1129114500
Pool.mintToTreasuryPool.mintToTreasury 4
Pool.mintUnbackedPool.mintUnbacked 17
Pool.rebalanceStableBorrowRatePool.onlyBridge417
Pool.repayPool.onlyPoolAdmin222000
Pool.repayWithATokensPool.onlyPoolConfigurator10056046
Pool.repayWithPermitPool.repay300023
Pool.rescueTokensPool.repayWithATokens20001005
Pool.resetIsolationModeTotalDebtPool.repayWithPermit37513000
Pool.setConfigurationPool.rescueTokens380582000
Pool.setLiquidationGracePeriodPool.resetIsolationModeTotalDebt130283951
Pool.setReserveInterestRateStrategyAddressPool.setConfiguration6006210599
Pool.setUserEModePool.setLiquidationGracePeriod1716412
Pool.setUserUseReserveAsCollateralPool.setReserveInterestRateStrategyAddress426046
Pool.supplyPool.setUserEMode955810023
Pool.supplyWithPermitPool.setUserUseReserveAsCollateral300042
Pool.swapBorrowRateModePool.supply720483
Pool.swapToVariablePool.supplyWithPermit03000
Pool.syncIndexesStatePool.syncIndexesState17511994
Pool.syncRatesStatePool.syncRatesState17511994
Pool.updateBridgeProtocolFeePool.updateBridgeProtocolFee 2013
Pool.updateFlashloanPremiumsPool.updateFlashloanPremiums32123362
Pool.withdrawPool.withdraw432043
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.gcov.html b/report/protocol/pool/Pool.sol.gcov.html similarity index 83% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.gcov.html rename to report/protocol/pool/Pool.sol.gcov.html index c53efd0f..af32c91e 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol.gcov.html +++ b/report/protocol/pool/Pool.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/Pool.sol - + LCOV - lcov.info.p - protocol/pool/Pool.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - Pool.sol (source / functions)top level - protocol/pool - Pool.sol (source / functions) Coveragelcov.info.p Lines:99.1 %10810798.3 %121119
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:98.4 %6160100.0 %6767
0 0
@@ -72,7 +72,7 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; + 4 : : import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; 5 : : import {Errors} from '../libraries/helpers/Errors.sol'; 6 : : import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; 7 : : import {PoolLogic} from '../libraries/logic/PoolLogic.sol'; @@ -99,824 +99,843 @@ 28 : : * # Withdraw 29 : : * # Borrow 30 : : * # Repay - 31 : : * # Swap their loans between variable and stable rate - 32 : : * # Enable/disable their supplied assets as collateral rebalance stable rate borrow positions - 33 : : * # Liquidate positions - 34 : : * # Execute Flash Loans - 35 : : * @dev To be covered by a proxy contract, owned by the PoolAddressesProvider of the specific market - 36 : : * @dev All admin functions are callable by the PoolConfigurator contract defined also in the - 37 : : * PoolAddressesProvider - 38 : : */ - 39 : : abstract contract Pool is VersionedInitializable, PoolStorage, IPool { - 40 : : using ReserveLogic for DataTypes.ReserveData; - 41 : : - 42 : : IPoolAddressesProvider public immutable ADDRESSES_PROVIDER; - 43 : : - 44 : : /** - 45 : : * @dev Only pool configurator can call functions marked by this modifier. - 46 : : */ - 47 : : modifier onlyPoolConfigurator() { - 48 : : _onlyPoolConfigurator(); - 49 : : _; - 50 : : } - 51 : : - 52 : : /** - 53 : : * @dev Only pool admin can call functions marked by this modifier. - 54 : : */ - 55 : : modifier onlyPoolAdmin() { - 56 : : _onlyPoolAdmin(); - 57 : : _; - 58 : : } - 59 : : - 60 : : /** - 61 : : * @dev Only bridge can call functions marked by this modifier. - 62 : : */ - 63 : : modifier onlyBridge() { - 64 : : _onlyBridge(); - 65 : : _; - 66 : : } - 67 : : - 68 : 80486 : function _onlyPoolConfigurator() internal view virtual { - 69 : 160972 : require( - 70 : : ADDRESSES_PROVIDER.getPoolConfigurator() == msg.sender, - 71 : : Errors.CALLER_NOT_POOL_CONFIGURATOR - 72 : : ); - 73 : : } - 74 : : - 75 : 2000 : function _onlyPoolAdmin() internal view virtual { - 76 : 4000 : require( - 77 : : IACLManager(ADDRESSES_PROVIDER.getACLManager()).isPoolAdmin(msg.sender), - 78 : : Errors.CALLER_NOT_POOL_ADMIN - 79 : : ); - 80 : : } - 81 : : - 82 : 26 : function _onlyBridge() internal view virtual { - 83 : 52 : require( - 84 : : IACLManager(ADDRESSES_PROVIDER.getACLManager()).isBridge(msg.sender), - 85 : : Errors.CALLER_NOT_BRIDGE - 86 : : ); - 87 : : } - 88 : : - 89 : : /** - 90 : : * @dev Constructor. - 91 : : * @param provider The address of the PoolAddressesProvider contract - 92 : : */ - 93 : : constructor(IPoolAddressesProvider provider) { - 94 : : ADDRESSES_PROVIDER = provider; - 95 : : } - 96 : : - 97 : : /** - 98 : : * @notice Initializes the Pool. - 99 : : * @dev Function is invoked by the proxy contract when the Pool contract is added to the - 100 : : * PoolAddressesProvider of the market. - 101 : : * @dev Caching the address of the PoolAddressesProvider in order to reduce gas consumption on subsequent operations - 102 : : * @param provider The address of the PoolAddressesProvider - 103 : : */ - 104 : : function initialize(IPoolAddressesProvider provider) external virtual; - 105 : : - 106 : : /// @inheritdoc IPool - 107 : 17 : function mintUnbacked( - 108 : : address asset, - 109 : : uint256 amount, - 110 : : address onBehalfOf, - 111 : : uint16 referralCode - 112 : : ) external virtual override onlyBridge { - 113 : 32 : BridgeLogic.executeMintUnbacked( - 114 : : _reserves, - 115 : : _reservesList, - 116 : : _usersConfig[onBehalfOf], - 117 : : asset, - 118 : : amount, - 119 : : onBehalfOf, - 120 : : referralCode - 121 : : ); - 122 : : } - 123 : : - 124 : : /// @inheritdoc IPool - 125 : 9 : function backUnbacked( - 126 : : address asset, - 127 : : uint256 amount, - 128 : : uint256 fee - 129 : : ) external virtual override onlyBridge returns (uint256) { - 130 : 18 : return - 131 : 18 : BridgeLogic.executeBackUnbacked(_reserves[asset], asset, amount, fee, _bridgeProtocolFee); - 132 : : } - 133 : : - 134 : : /// @inheritdoc IPool - 135 : 9558 : function supply( - 136 : : address asset, - 137 : : uint256 amount, - 138 : : address onBehalfOf, - 139 : : uint16 referralCode - 140 : : ) public virtual override { - 141 : 19130 : SupplyLogic.executeSupply( - 142 : : _reserves, - 143 : : _reservesList, - 144 : : _usersConfig[onBehalfOf], - 145 : : DataTypes.ExecuteSupplyParams({ - 146 : : asset: asset, - 147 : : amount: amount, - 148 : : onBehalfOf: onBehalfOf, - 149 : : referralCode: referralCode - 150 : : }) - 151 : : ); - 152 : : } - 153 : : - 154 : : /// @inheritdoc IPool - 155 : 3000 : function supplyWithPermit( - 156 : : address asset, - 157 : : uint256 amount, - 158 : : address onBehalfOf, - 159 : : uint16 referralCode, - 160 : : uint256 deadline, - 161 : : uint8 permitV, - 162 : : bytes32 permitR, - 163 : : bytes32 permitS - 164 : : ) public virtual override { - 165 : : try - 166 : 8000 : IERC20WithPermit(asset).permit( - 167 : : msg.sender, - 168 : : address(this), - 169 : : amount, - 170 : : deadline, - 171 : : permitV, - 172 : : permitR, - 173 : : permitS - 174 : : ) - 175 : : {} catch {} - 176 : 8000 : SupplyLogic.executeSupply( - 177 : : _reserves, - 178 : : _reservesList, - 179 : : _usersConfig[onBehalfOf], - 180 : : DataTypes.ExecuteSupplyParams({ - 181 : : asset: asset, - 182 : : amount: amount, - 183 : : onBehalfOf: onBehalfOf, - 184 : : referralCode: referralCode - 185 : : }) - 186 : : ); - 187 : : } - 188 : : - 189 : : /// @inheritdoc IPool - 190 : 43 : function withdraw( - 191 : : address asset, - 192 : : uint256 amount, - 193 : : address to - 194 : : ) public virtual override returns (uint256) { - 195 : 90 : return - 196 : 90 : SupplyLogic.executeWithdraw( - 197 : : _reserves, - 198 : : _reservesList, - 199 : : _eModeCategories, - 200 : : _usersConfig[msg.sender], - 201 : : DataTypes.ExecuteWithdrawParams({ - 202 : : asset: asset, - 203 : : amount: amount, - 204 : : to: to, - 205 : : reservesCount: _reservesCount, - 206 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), - 207 : : userEModeCategory: _usersEModeCategory[msg.sender] - 208 : : }) - 209 : : ); - 210 : : } - 211 : : - 212 : : /// @inheritdoc IPool - 213 : 9113 : function borrow( - 214 : : address asset, - 215 : : uint256 amount, - 216 : : uint256 interestRateMode, - 217 : : uint16 referralCode, - 218 : : address onBehalfOf - 219 : : ) public virtual override { - 220 : 18232 : BorrowLogic.executeBorrow( - 221 : : _reserves, - 222 : : _reservesList, - 223 : : _eModeCategories, - 224 : : _usersConfig[onBehalfOf], - 225 : : DataTypes.ExecuteBorrowParams({ - 226 : : asset: asset, - 227 : : user: msg.sender, - 228 : : onBehalfOf: onBehalfOf, - 229 : : amount: amount, - 230 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), - 231 : : referralCode: referralCode, - 232 : : releaseUnderlying: true, - 233 : : maxStableRateBorrowSizePercent: _maxStableRateBorrowSizePercent, - 234 : : reservesCount: _reservesCount, - 235 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), - 236 : : userEModeCategory: _usersEModeCategory[onBehalfOf], - 237 : : priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel() - 238 : : }) - 239 : : ); - 240 : : } - 241 : : - 242 : : /// @inheritdoc IPool - 243 : 22 : function repay( - 244 : : address asset, - 245 : : uint256 amount, - 246 : : uint256 interestRateMode, - 247 : : address onBehalfOf - 248 : : ) public virtual override returns (uint256) { - 249 : 46 : return - 250 : 46 : BorrowLogic.executeRepay( - 251 : : _reserves, - 252 : : _reservesList, - 253 : : _usersConfig[onBehalfOf], - 254 : : DataTypes.ExecuteRepayParams({ - 255 : : asset: asset, - 256 : : amount: amount, - 257 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), - 258 : : onBehalfOf: onBehalfOf, - 259 : : useATokens: false - 260 : : }) - 261 : : ); - 262 : : } - 263 : : - 264 : : /// @inheritdoc IPool - 265 : 3000 : function repayWithPermit( - 266 : : address asset, - 267 : : uint256 amount, - 268 : : uint256 interestRateMode, - 269 : : address onBehalfOf, - 270 : : uint256 deadline, - 271 : : uint8 permitV, - 272 : : bytes32 permitR, - 273 : : bytes32 permitS - 274 : : ) public virtual override returns (uint256) { - 275 : : try - 276 : 8000 : IERC20WithPermit(asset).permit( - 277 : : msg.sender, - 278 : : address(this), - 279 : : amount, - 280 : : deadline, - 281 : : permitV, - 282 : : permitR, - 283 : : permitS - 284 : : ) - 285 : : {} catch {} - 286 : : - 287 : : { - 288 : 12000 : DataTypes.ExecuteRepayParams memory params = DataTypes.ExecuteRepayParams({ - 289 : : asset: asset, - 290 : : amount: amount, - 291 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), - 292 : : onBehalfOf: onBehalfOf, - 293 : : useATokens: false - 294 : : }); - 295 : 12000 : return BorrowLogic.executeRepay(_reserves, _reservesList, _usersConfig[onBehalfOf], params); - 296 : : } - 297 : : } - 298 : : - 299 : : /// @inheritdoc IPool - 300 : 1005 : function repayWithATokens( - 301 : : address asset, - 302 : : uint256 amount, - 303 : : uint256 interestRateMode - 304 : : ) public virtual override returns (uint256) { - 305 : 2012 : return - 306 : 2012 : BorrowLogic.executeRepay( - 307 : : _reserves, - 308 : : _reservesList, - 309 : : _usersConfig[msg.sender], - 310 : : DataTypes.ExecuteRepayParams({ - 311 : : asset: asset, - 312 : : amount: amount, - 313 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), - 314 : : onBehalfOf: msg.sender, - 315 : : useATokens: true - 316 : : }) - 317 : : ); - 318 : : } - 319 : : - 320 : : /// @inheritdoc IPool - 321 : 7 : function swapBorrowRateMode(address asset, uint256 interestRateMode) public virtual override { - 322 : 16 : BorrowLogic.executeSwapBorrowRateMode( - 323 : : _reserves[asset], - 324 : : _usersConfig[msg.sender], - 325 : : asset, - 326 : : msg.sender, - 327 : : DataTypes.InterestRateMode(interestRateMode) - 328 : : ); - 329 : : } - 330 : : - 331 : : /// @inheritdoc IPool - 332 : 0 : function swapToVariable(address asset, address user) public virtual override { - 333 : 0 : BorrowLogic.executeSwapBorrowRateMode( - 334 : : _reserves[asset], - 335 : : _usersConfig[user], - 336 : : asset, - 337 : : user, - 338 : : DataTypes.InterestRateMode.STABLE - 339 : : ); - 340 : : } - 341 : : - 342 : : /// @inheritdoc IPool - 343 : 4 : function rebalanceStableBorrowRate(address asset, address user) public virtual override { - 344 : 10 : BorrowLogic.executeRebalanceStableBorrowRate(_reserves[asset], asset, user); - 345 : : } - 346 : : - 347 : : /// @inheritdoc IPool - 348 : 42 : function setUserUseReserveAsCollateral( - 349 : : address asset, - 350 : : bool useAsCollateral - 351 : : ) public virtual override { - 352 : 86 : SupplyLogic.executeUseReserveAsCollateral( - 353 : : _reserves, - 354 : : _reservesList, - 355 : : _eModeCategories, - 356 : : _usersConfig[msg.sender], - 357 : : asset, - 358 : : useAsCollateral, - 359 : : _reservesCount, - 360 : : ADDRESSES_PROVIDER.getPriceOracle(), - 361 : : _usersEModeCategory[msg.sender] - 362 : : ); - 363 : : } - 364 : : - 365 : : /// @inheritdoc IPool - 366 : 11291 : function liquidationCall( - 367 : : address collateralAsset, - 368 : : address debtAsset, - 369 : : address user, - 370 : : uint256 debtToCover, - 371 : : bool receiveAToken + 31 : : * # Enable/disable their supplied assets as collateral + 32 : : * # Liquidate positions + 33 : : * # Execute Flash Loans + 34 : : * @dev To be covered by a proxy contract, owned by the PoolAddressesProvider of the specific market + 35 : : * @dev All admin functions are callable by the PoolConfigurator contract defined also in the + 36 : : * PoolAddressesProvider + 37 : : */ + 38 : : abstract contract Pool is VersionedInitializable, PoolStorage, IPool { + 39 : : using ReserveLogic for DataTypes.ReserveData; + 40 : : + 41 : : IPoolAddressesProvider public immutable ADDRESSES_PROVIDER; + 42 : : + 43 : : /** + 44 : : * @dev Only pool configurator can call functions marked by this modifier. + 45 : : */ + 46 : : modifier onlyPoolConfigurator() { + 47 : 6046 : _onlyPoolConfigurator(); + 48 : : _; + 49 : : } + 50 : : + 51 : : /** + 52 : : * @dev Only pool admin can call functions marked by this modifier. + 53 : : */ + 54 : : modifier onlyPoolAdmin() { + 55 : 2000 : _onlyPoolAdmin(); + 56 : : _; + 57 : : } + 58 : : + 59 : : /** + 60 : : * @dev Only bridge can call functions marked by this modifier. + 61 : : */ + 62 : : modifier onlyBridge() { + 63 : 17 : _onlyBridge(); + 64 : : _; + 65 : : } + 66 : : + 67 : : function _onlyPoolConfigurator() internal view virtual { + 68 : 447472 : require( + 69 : : ADDRESSES_PROVIDER.getPoolConfigurator() == msg.sender, + 70 : : Errors.CALLER_NOT_POOL_CONFIGURATOR + 71 : : ); + 72 : : } + 73 : : + 74 : : function _onlyPoolAdmin() internal view virtual { + 75 : 2000 : require( + 76 : : IACLManager(ADDRESSES_PROVIDER.getACLManager()).isPoolAdmin(msg.sender), + 77 : : Errors.CALLER_NOT_POOL_ADMIN + 78 : : ); + 79 : : } + 80 : : + 81 : : function _onlyBridge() internal view virtual { + 82 : 26 : require( + 83 : : IACLManager(ADDRESSES_PROVIDER.getACLManager()).isBridge(msg.sender), + 84 : : Errors.CALLER_NOT_BRIDGE + 85 : : ); + 86 : : } + 87 : : + 88 : : /** + 89 : : * @dev Constructor. + 90 : : * @param provider The address of the PoolAddressesProvider contract + 91 : : */ + 92 : : constructor(IPoolAddressesProvider provider) { + 93 : 44 : ADDRESSES_PROVIDER = provider; + 94 : : } + 95 : : + 96 : : /** + 97 : : * @notice Initializes the Pool. + 98 : : * @dev Function is invoked by the proxy contract when the Pool contract is added to the + 99 : : * PoolAddressesProvider of the market. + 100 : : * @dev Caching the address of the PoolAddressesProvider in order to reduce gas consumption on subsequent operations + 101 : : * @param provider The address of the PoolAddressesProvider + 102 : : */ + 103 : : function initialize(IPoolAddressesProvider provider) external virtual; + 104 : : + 105 : : /// @inheritdoc IPool + 106 : : function mintUnbacked( + 107 : : address asset, + 108 : : uint256 amount, + 109 : : address onBehalfOf, + 110 : : uint16 referralCode + 111 : : ) external virtual override onlyBridge { + 112 : 16 : BridgeLogic.executeMintUnbacked( + 113 : : _reserves, + 114 : : _reservesList, + 115 : : _usersConfig[onBehalfOf], + 116 : : asset, + 117 : : amount, + 118 : : onBehalfOf, + 119 : : referralCode + 120 : : ); + 121 : : } + 122 : : + 123 : : /// @inheritdoc IPool + 124 : : function backUnbacked( + 125 : : address asset, + 126 : : uint256 amount, + 127 : : uint256 fee + 128 : : ) external virtual override onlyBridge returns (uint256) { + 129 : 9 : return + 130 : 9 : BridgeLogic.executeBackUnbacked(_reserves[asset], asset, amount, fee, _bridgeProtocolFee); + 131 : : } + 132 : : + 133 : : /// @inheritdoc IPool + 134 : : function supply( + 135 : : address asset, + 136 : : uint256 amount, + 137 : : address onBehalfOf, + 138 : : uint16 referralCode + 139 : : ) public virtual override { + 140 : 20490 : SupplyLogic.executeSupply( + 141 : : _reserves, + 142 : : _reservesList, + 143 : : _usersConfig[onBehalfOf], + 144 : : DataTypes.ExecuteSupplyParams({ + 145 : : asset: asset, + 146 : : amount: amount, + 147 : : onBehalfOf: onBehalfOf, + 148 : : referralCode: referralCode + 149 : : }) + 150 : : ); + 151 : : } + 152 : : + 153 : : /// @inheritdoc IPool + 154 : : function supplyWithPermit( + 155 : : address asset, + 156 : : uint256 amount, + 157 : : address onBehalfOf, + 158 : : uint16 referralCode, + 159 : : uint256 deadline, + 160 : : uint8 permitV, + 161 : : bytes32 permitR, + 162 : : bytes32 permitS + 163 : : ) public virtual override { + 164 : : try + 165 : 4000 : IERC20WithPermit(asset).permit( + 166 : : msg.sender, + 167 : : address(this), + 168 : : amount, + 169 : : deadline, + 170 : : permitV, + 171 : : permitR, + 172 : : permitS + 173 : : ) + 174 : 0 : {} catch {} + 175 : 4000 : SupplyLogic.executeSupply( + 176 : : _reserves, + 177 : : _reservesList, + 178 : : _usersConfig[onBehalfOf], + 179 : : DataTypes.ExecuteSupplyParams({ + 180 : : asset: asset, + 181 : : amount: amount, + 182 : : onBehalfOf: onBehalfOf, + 183 : : referralCode: referralCode + 184 : : }) + 185 : : ); + 186 : : } + 187 : : + 188 : : /// @inheritdoc IPool + 189 : : function withdraw( + 190 : : address asset, + 191 : : uint256 amount, + 192 : : address to + 193 : : ) public virtual override returns (uint256) { + 194 : 2045 : return + 195 : 2045 : SupplyLogic.executeWithdraw( + 196 : : _reserves, + 197 : : _reservesList, + 198 : : _eModeCategories, + 199 : : _usersConfig[msg.sender], + 200 : : DataTypes.ExecuteWithdrawParams({ + 201 : : asset: asset, + 202 : : amount: amount, + 203 : : to: to, + 204 : : reservesCount: _reservesCount, + 205 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), + 206 : : userEModeCategory: _usersEModeCategory[msg.sender] + 207 : : }) + 208 : : ); + 209 : : } + 210 : : + 211 : : /// @inheritdoc IPool + 212 : : function borrow( + 213 : : address asset, + 214 : : uint256 amount, + 215 : : uint256 interestRateMode, + 216 : : uint16 referralCode, + 217 : : address onBehalfOf + 218 : : ) public virtual override { + 219 : 16108 : BorrowLogic.executeBorrow( + 220 : : _reserves, + 221 : : _reservesList, + 222 : : _eModeCategories, + 223 : : _usersConfig[onBehalfOf], + 224 : : DataTypes.ExecuteBorrowParams({ + 225 : : asset: asset, + 226 : : user: msg.sender, + 227 : : onBehalfOf: onBehalfOf, + 228 : : amount: amount, + 229 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), + 230 : : referralCode: referralCode, + 231 : : releaseUnderlying: true, + 232 : : reservesCount: _reservesCount, + 233 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), + 234 : : userEModeCategory: _usersEModeCategory[onBehalfOf], + 235 : : priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel() + 236 : : }) + 237 : : ); + 238 : : } + 239 : : + 240 : : /// @inheritdoc IPool + 241 : : function repay( + 242 : : address asset, + 243 : : uint256 amount, + 244 : : uint256 interestRateMode, + 245 : : address onBehalfOf + 246 : : ) public virtual override returns (uint256) { + 247 : 24 : return + 248 : 24 : BorrowLogic.executeRepay( + 249 : : _reserves, + 250 : : _reservesList, + 251 : : _usersConfig[onBehalfOf], + 252 : : DataTypes.ExecuteRepayParams({ + 253 : : asset: asset, + 254 : : amount: amount, + 255 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), + 256 : : onBehalfOf: onBehalfOf, + 257 : : useATokens: false + 258 : : }) + 259 : : ); + 260 : : } + 261 : : + 262 : : /// @inheritdoc IPool + 263 : : function repayWithPermit( + 264 : : address asset, + 265 : : uint256 amount, + 266 : : uint256 interestRateMode, + 267 : : address onBehalfOf, + 268 : : uint256 deadline, + 269 : : uint8 permitV, + 270 : : bytes32 permitR, + 271 : : bytes32 permitS + 272 : : ) public virtual override returns (uint256) { + 273 : : try + 274 : 4000 : IERC20WithPermit(asset).permit( + 275 : : msg.sender, + 276 : : address(this), + 277 : : amount, + 278 : : deadline, + 279 : : permitV, + 280 : : permitR, + 281 : : permitS + 282 : : ) + 283 : 0 : {} catch {} + 284 : : + 285 : : { + 286 : 4000 : DataTypes.ExecuteRepayParams memory params = DataTypes.ExecuteRepayParams({ + 287 : : asset: asset, + 288 : : amount: amount, + 289 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), + 290 : : onBehalfOf: onBehalfOf, + 291 : : useATokens: false + 292 : : }); + 293 : 4000 : return BorrowLogic.executeRepay(_reserves, _reservesList, _usersConfig[onBehalfOf], params); + 294 : : } + 295 : : } + 296 : : + 297 : : /// @inheritdoc IPool + 298 : : function repayWithATokens( + 299 : : address asset, + 300 : : uint256 amount, + 301 : : uint256 interestRateMode + 302 : : ) public virtual override returns (uint256) { + 303 : 1006 : return + 304 : 1006 : BorrowLogic.executeRepay( + 305 : : _reserves, + 306 : : _reservesList, + 307 : : _usersConfig[msg.sender], + 308 : : DataTypes.ExecuteRepayParams({ + 309 : : asset: asset, + 310 : : amount: amount, + 311 : : interestRateMode: DataTypes.InterestRateMode(interestRateMode), + 312 : : onBehalfOf: msg.sender, + 313 : : useATokens: true + 314 : : }) + 315 : : ); + 316 : : } + 317 : : + 318 : : /// @inheritdoc IPool + 319 : : function setUserUseReserveAsCollateral( + 320 : : address asset, + 321 : : bool useAsCollateral + 322 : : ) public virtual override { + 323 : 43 : SupplyLogic.executeUseReserveAsCollateral( + 324 : : _reserves, + 325 : : _reservesList, + 326 : : _eModeCategories, + 327 : : _usersConfig[msg.sender], + 328 : : asset, + 329 : : useAsCollateral, + 330 : : _reservesCount, + 331 : : ADDRESSES_PROVIDER.getPriceOracle(), + 332 : : _usersEModeCategory[msg.sender] + 333 : : ); + 334 : : } + 335 : : + 336 : : /// @inheritdoc IPool + 337 : : function liquidationCall( + 338 : : address collateralAsset, + 339 : : address debtAsset, + 340 : : address user, + 341 : : uint256 debtToCover, + 342 : : bool receiveAToken + 343 : : ) public virtual override { + 344 : 14501 : LiquidationLogic.executeLiquidationCall( + 345 : : _reserves, + 346 : : _reservesList, + 347 : : _usersConfig, + 348 : : _eModeCategories, + 349 : : DataTypes.ExecuteLiquidationCallParams({ + 350 : : reservesCount: _reservesCount, + 351 : : debtToCover: debtToCover, + 352 : : collateralAsset: collateralAsset, + 353 : : debtAsset: debtAsset, + 354 : : user: user, + 355 : : receiveAToken: receiveAToken, + 356 : : priceOracle: ADDRESSES_PROVIDER.getPriceOracle(), + 357 : : userEModeCategory: _usersEModeCategory[user], + 358 : : priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel() + 359 : : }) + 360 : : ); + 361 : : } + 362 : : + 363 : : /// @inheritdoc IPool + 364 : : function flashLoan( + 365 : : address receiverAddress, + 366 : : address[] calldata assets, + 367 : : uint256[] calldata amounts, + 368 : : uint256[] calldata interestRateModes, + 369 : : address onBehalfOf, + 370 : : bytes calldata params, + 371 : : uint16 referralCode 372 : : ) public virtual override { - 373 : 22584 : LiquidationLogic.executeLiquidationCall( - 374 : : _reserves, - 375 : : _reservesList, - 376 : : _usersConfig, - 377 : : _eModeCategories, - 378 : : DataTypes.ExecuteLiquidationCallParams({ - 379 : : reservesCount: _reservesCount, - 380 : : debtToCover: debtToCover, - 381 : : collateralAsset: collateralAsset, - 382 : : debtAsset: debtAsset, - 383 : : user: user, - 384 : : receiveAToken: receiveAToken, - 385 : : priceOracle: ADDRESSES_PROVIDER.getPriceOracle(), - 386 : : userEModeCategory: _usersEModeCategory[user], - 387 : : priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel() - 388 : : }) - 389 : : ); - 390 : : } + 373 : 1011 : DataTypes.FlashloanParams memory flashParams = DataTypes.FlashloanParams({ + 374 : : receiverAddress: receiverAddress, + 375 : : assets: assets, + 376 : : amounts: amounts, + 377 : : interestRateModes: interestRateModes, + 378 : : onBehalfOf: onBehalfOf, + 379 : : params: params, + 380 : : referralCode: referralCode, + 381 : : flashLoanPremiumToProtocol: _flashLoanPremiumToProtocol, + 382 : : flashLoanPremiumTotal: _flashLoanPremiumTotal, + 383 : : reservesCount: _reservesCount, + 384 : : addressesProvider: address(ADDRESSES_PROVIDER), + 385 : : pool: address(this), + 386 : : userEModeCategory: _usersEModeCategory[onBehalfOf], + 387 : : isAuthorizedFlashBorrower: IACLManager(ADDRESSES_PROVIDER.getACLManager()).isFlashBorrower( + 388 : : msg.sender + 389 : : ) + 390 : : }); 391 : : - 392 : : /// @inheritdoc IPool - 393 : 10 : function flashLoan( - 394 : : address receiverAddress, - 395 : : address[] calldata assets, - 396 : : uint256[] calldata amounts, - 397 : : uint256[] calldata interestRateModes, - 398 : : address onBehalfOf, - 399 : : bytes calldata params, - 400 : : uint16 referralCode - 401 : : ) public virtual override { - 402 : 30 : DataTypes.FlashloanParams memory flashParams = DataTypes.FlashloanParams({ - 403 : : receiverAddress: receiverAddress, - 404 : : assets: assets, - 405 : : amounts: amounts, - 406 : : interestRateModes: interestRateModes, - 407 : : onBehalfOf: onBehalfOf, - 408 : : params: params, - 409 : : referralCode: referralCode, - 410 : : flashLoanPremiumToProtocol: _flashLoanPremiumToProtocol, - 411 : : flashLoanPremiumTotal: _flashLoanPremiumTotal, - 412 : : maxStableRateBorrowSizePercent: _maxStableRateBorrowSizePercent, - 413 : : reservesCount: _reservesCount, - 414 : : addressesProvider: address(ADDRESSES_PROVIDER), - 415 : : pool: address(this), - 416 : : userEModeCategory: _usersEModeCategory[onBehalfOf], - 417 : : isAuthorizedFlashBorrower: IACLManager(ADDRESSES_PROVIDER.getACLManager()).isFlashBorrower( - 418 : : msg.sender - 419 : : ) - 420 : : }); - 421 : : - 422 : 20 : FlashLoanLogic.executeFlashLoan( - 423 : : _reserves, - 424 : : _reservesList, - 425 : : _eModeCategories, - 426 : : _usersConfig[onBehalfOf], - 427 : : flashParams - 428 : : ); - 429 : : } - 430 : : - 431 : : /// @inheritdoc IPool - 432 : 10 : function flashLoanSimple( - 433 : : address receiverAddress, - 434 : : address asset, - 435 : : uint256 amount, - 436 : : bytes calldata params, - 437 : : uint16 referralCode - 438 : : ) public virtual override { - 439 : 30 : DataTypes.FlashloanSimpleParams memory flashParams = DataTypes.FlashloanSimpleParams({ - 440 : : receiverAddress: receiverAddress, - 441 : : asset: asset, - 442 : : amount: amount, - 443 : : params: params, - 444 : : referralCode: referralCode, - 445 : : flashLoanPremiumToProtocol: _flashLoanPremiumToProtocol, - 446 : : flashLoanPremiumTotal: _flashLoanPremiumTotal - 447 : : }); - 448 : 20 : FlashLoanLogic.executeFlashLoanSimple(_reserves[asset], flashParams); - 449 : : } - 450 : : - 451 : : /// @inheritdoc IPool - 452 : 4 : function mintToTreasury(address[] calldata assets) external virtual override { - 453 : 8 : PoolLogic.executeMintToTreasury(_reserves, assets); + 392 : 1011 : FlashLoanLogic.executeFlashLoan( + 393 : : _reserves, + 394 : : _reservesList, + 395 : : _eModeCategories, + 396 : : _usersConfig[onBehalfOf], + 397 : : flashParams + 398 : : ); + 399 : : } + 400 : : + 401 : : /// @inheritdoc IPool + 402 : : function flashLoanSimple( + 403 : : address receiverAddress, + 404 : : address asset, + 405 : : uint256 amount, + 406 : : bytes calldata params, + 407 : : uint16 referralCode + 408 : : ) public virtual override { + 409 : 11 : DataTypes.FlashloanSimpleParams memory flashParams = DataTypes.FlashloanSimpleParams({ + 410 : : receiverAddress: receiverAddress, + 411 : : asset: asset, + 412 : : amount: amount, + 413 : : params: params, + 414 : : referralCode: referralCode, + 415 : : flashLoanPremiumToProtocol: _flashLoanPremiumToProtocol, + 416 : : flashLoanPremiumTotal: _flashLoanPremiumTotal + 417 : : }); + 418 : 11 : FlashLoanLogic.executeFlashLoanSimple(_reserves[asset], flashParams); + 419 : : } + 420 : : + 421 : : /// @inheritdoc IPool + 422 : : function mintToTreasury(address[] calldata assets) external virtual override { + 423 : 4 : PoolLogic.executeMintToTreasury(_reserves, assets); + 424 : : } + 425 : : + 426 : : /// @inheritdoc IPool + 427 : : function getReserveDataExtended( + 428 : : address asset + 429 : : ) external view returns (DataTypes.ReserveData memory) { + 430 : 6011 : return _reserves[asset]; + 431 : : } + 432 : : + 433 : : /// @inheritdoc IPool + 434 : : function getReserveData( + 435 : : address asset + 436 : : ) external view virtual override returns (DataTypes.ReserveDataLegacy memory) { + 437 : 83030 : DataTypes.ReserveData memory reserve = _reserves[asset]; + 438 : 83030 : DataTypes.ReserveDataLegacy memory res; + 439 : : + 440 : 83030 : res.configuration = reserve.configuration; + 441 : 83030 : res.liquidityIndex = reserve.liquidityIndex; + 442 : 83030 : res.currentLiquidityRate = reserve.currentLiquidityRate; + 443 : 83030 : res.variableBorrowIndex = reserve.variableBorrowIndex; + 444 : 83030 : res.currentVariableBorrowRate = reserve.currentVariableBorrowRate; + 445 : 83030 : res.lastUpdateTimestamp = reserve.lastUpdateTimestamp; + 446 : 83030 : res.id = reserve.id; + 447 : 83030 : res.aTokenAddress = reserve.aTokenAddress; + 448 : 83030 : res.variableDebtTokenAddress = reserve.variableDebtTokenAddress; + 449 : 83030 : res.interestRateStrategyAddress = reserve.interestRateStrategyAddress; + 450 : 83030 : res.accruedToTreasury = reserve.accruedToTreasury; + 451 : 83030 : res.unbacked = reserve.unbacked; + 452 : 83030 : res.isolationModeTotalDebt = reserve.isolationModeTotalDebt; + 453 : 83030 : return res; 454 : : } 455 : : 456 : : /// @inheritdoc IPool - 457 : 6 : function getReserveDataExtended( + 457 : : function getVirtualUnderlyingBalance( 458 : : address asset - 459 : : ) external view returns (DataTypes.ReserveData memory) { - 460 : 12 : return _reserves[asset]; + 459 : : ) external view virtual override returns (uint128) { + 460 : 8111 : return _reserves[asset].virtualUnderlyingBalance; 461 : : } 462 : : 463 : : /// @inheritdoc IPool - 464 : 22204 : function getReserveData( - 465 : : address asset - 466 : : ) external view virtual override returns (DataTypes.ReserveDataLegacy memory) { - 467 : 44408 : DataTypes.ReserveData memory reserve = _reserves[asset]; - 468 : 44408 : DataTypes.ReserveDataLegacy memory res; - 469 : : - 470 : 44408 : res.configuration = reserve.configuration; - 471 : 44408 : res.liquidityIndex = reserve.liquidityIndex; - 472 : 44408 : res.currentLiquidityRate = reserve.currentLiquidityRate; - 473 : 44408 : res.variableBorrowIndex = reserve.variableBorrowIndex; - 474 : 44408 : res.currentVariableBorrowRate = reserve.currentVariableBorrowRate; - 475 : 44408 : res.currentStableBorrowRate = reserve.currentStableBorrowRate; - 476 : 44408 : res.lastUpdateTimestamp = reserve.lastUpdateTimestamp; - 477 : 44408 : res.id = reserve.id; - 478 : 44408 : res.aTokenAddress = reserve.aTokenAddress; - 479 : 44408 : res.stableDebtTokenAddress = reserve.stableDebtTokenAddress; - 480 : 44408 : res.variableDebtTokenAddress = reserve.variableDebtTokenAddress; - 481 : 44408 : res.interestRateStrategyAddress = reserve.interestRateStrategyAddress; - 482 : 44408 : res.accruedToTreasury = reserve.accruedToTreasury; - 483 : 44408 : res.unbacked = reserve.unbacked; - 484 : 44408 : res.isolationModeTotalDebt = reserve.isolationModeTotalDebt; - 485 : 44408 : return res; - 486 : : } - 487 : : - 488 : : /// @inheritdoc IPool - 489 : 6030 : function getVirtualUnderlyingBalance( - 490 : : address asset - 491 : : ) external view virtual override returns (uint128) { - 492 : 12060 : return _reserves[asset].virtualUnderlyingBalance; + 464 : : function getUserAccountData( + 465 : : address user + 466 : : ) + 467 : : external + 468 : : view + 469 : : virtual + 470 : : override + 471 : : returns ( + 472 : : uint256 totalCollateralBase, + 473 : : uint256 totalDebtBase, + 474 : : uint256 availableBorrowsBase, + 475 : : uint256 currentLiquidationThreshold, + 476 : : uint256 ltv, + 477 : : uint256 healthFactor + 478 : : ) + 479 : : { + 480 : 10015 : return + 481 : 10015 : PoolLogic.executeGetUserAccountData( + 482 : : _reserves, + 483 : : _reservesList, + 484 : : _eModeCategories, + 485 : : DataTypes.CalculateUserAccountDataParams({ + 486 : : userConfig: _usersConfig[user], + 487 : : reservesCount: _reservesCount, + 488 : : user: user, + 489 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), + 490 : : userEModeCategory: _usersEModeCategory[user] + 491 : : }) + 492 : : ); 493 : : } 494 : : 495 : : /// @inheritdoc IPool - 496 : 3013 : function getUserAccountData( - 497 : : address user - 498 : : ) - 499 : : external - 500 : : view - 501 : : virtual - 502 : : override - 503 : : returns ( - 504 : : uint256 totalCollateralBase, - 505 : : uint256 totalDebtBase, - 506 : : uint256 availableBorrowsBase, - 507 : : uint256 currentLiquidationThreshold, - 508 : : uint256 ltv, - 509 : : uint256 healthFactor - 510 : : ) - 511 : : { - 512 : 6026 : return - 513 : 6026 : PoolLogic.executeGetUserAccountData( - 514 : : _reserves, - 515 : : _reservesList, - 516 : : _eModeCategories, - 517 : : DataTypes.CalculateUserAccountDataParams({ - 518 : : userConfig: _usersConfig[user], - 519 : : reservesCount: _reservesCount, - 520 : : user: user, - 521 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), - 522 : : userEModeCategory: _usersEModeCategory[user] - 523 : : }) - 524 : : ); - 525 : : } - 526 : : - 527 : : /// @inheritdoc IPool - 528 : 41450 : function getConfiguration( - 529 : : address asset - 530 : : ) external view virtual override returns (DataTypes.ReserveConfigurationMap memory) { - 531 : 82900 : return _reserves[asset].configuration; - 532 : : } - 533 : : - 534 : : /// @inheritdoc IPool - 535 : 6030 : function getUserConfiguration( - 536 : : address user - 537 : : ) external view virtual override returns (DataTypes.UserConfigurationMap memory) { - 538 : 12060 : return _usersConfig[user]; - 539 : : } - 540 : : - 541 : : /// @inheritdoc IPool - 542 : 31404 : function getReserveNormalizedIncome( - 543 : : address asset - 544 : : ) external view virtual override returns (uint256) { - 545 : 94212 : return _reserves[asset].getNormalizedIncome(); - 546 : : } - 547 : : - 548 : : /// @inheritdoc IPool - 549 : 25218 : function getReserveNormalizedVariableDebt( - 550 : : address asset - 551 : : ) external view virtual override returns (uint256) { - 552 : 75654 : return _reserves[asset].getNormalizedDebt(); - 553 : : } - 554 : : - 555 : : /// @inheritdoc IPool - 556 : 6043 : function getReservesList() external view virtual override returns (address[] memory) { - 557 : 12086 : uint256 reservesListCount = _reservesCount; - 558 : 12086 : uint256 droppedReservesCount = 0; - 559 : 18129 : address[] memory reservesList = new address[](reservesListCount); - 560 : : - 561 : 56395 : for (uint256 i = 0; i < reservesListCount; i++) { - 562 : 57399 : if (_reservesList[i] != address(0)) { - 563 : 38264 : reservesList[i - droppedReservesCount] = _reservesList[i]; - 564 : : } else { - 565 : 2 : droppedReservesCount++; - 566 : : } - 567 : : } + 496 : : function getConfiguration( + 497 : : address asset + 498 : : ) external view virtual override returns (DataTypes.ReserveConfigurationMap memory) { + 499 : 162047 : return _reserves[asset].configuration; + 500 : : } + 501 : : + 502 : : /// @inheritdoc IPool + 503 : : function getUserConfiguration( + 504 : : address user + 505 : : ) external view virtual override returns (DataTypes.UserConfigurationMap memory) { + 506 : 7029 : return _usersConfig[user]; + 507 : : } + 508 : : + 509 : : /// @inheritdoc IPool + 510 : : function getReserveNormalizedIncome( + 511 : : address asset + 512 : : ) external view virtual override returns (uint256) { + 513 : 115423 : return _reserves[asset].getNormalizedIncome(); + 514 : : } + 515 : : + 516 : : /// @inheritdoc IPool + 517 : : function getReserveNormalizedVariableDebt( + 518 : : address asset + 519 : : ) external view virtual override returns (uint256) { + 520 : 29583 : return _reserves[asset].getNormalizedDebt(); + 521 : : } + 522 : : + 523 : : /// @inheritdoc IPool + 524 : : function getReservesList() external view virtual override returns (address[] memory) { + 525 : 16076 : uint256 reservesListCount = _reservesCount; + 526 : 16076 : uint256 droppedReservesCount = 0; + 527 : 16076 : address[] memory reservesList = new address[](reservesListCount); + 528 : : + 529 : 16076 : for (uint256 i = 0; i < reservesListCount; i++) { + 530 : 82300 : if (_reservesList[i] != address(0)) { + 531 : 82299 : reservesList[i - droppedReservesCount] = _reservesList[i]; + 532 : : } else { + 533 : 1 : droppedReservesCount++; + 534 : : } + 535 : : } + 536 : : + 537 : : // Reduces the length of the reserves array by `droppedReservesCount` + 538 : : assembly { + 539 : 16076 : mstore(reservesList, sub(reservesListCount, droppedReservesCount)) + 540 : : } + 541 : 16076 : return reservesList; + 542 : : } + 543 : : + 544 : : /// @inheritdoc IPool + 545 : : function getReservesCount() external view virtual override returns (uint256) { + 546 : 2 : return _reservesCount; + 547 : : } + 548 : : + 549 : : /// @inheritdoc IPool + 550 : : function getReserveAddressById(uint16 id) external view returns (address) { + 551 : 1 : return _reservesList[id]; + 552 : : } + 553 : : + 554 : : /// @inheritdoc IPool + 555 : : function BRIDGE_PROTOCOL_FEE() public view virtual override returns (uint256) { + 556 : 25 : return _bridgeProtocolFee; + 557 : : } + 558 : : + 559 : : /// @inheritdoc IPool + 560 : : function FLASHLOAN_PREMIUM_TOTAL() public view virtual override returns (uint128) { + 561 : 1368 : return _flashLoanPremiumTotal; + 562 : : } + 563 : : + 564 : : /// @inheritdoc IPool + 565 : : function FLASHLOAN_PREMIUM_TO_PROTOCOL() public view virtual override returns (uint128) { + 566 : 1365 : return _flashLoanPremiumToProtocol; + 567 : : } 568 : : - 569 : : // Reduces the length of the reserves array by `droppedReservesCount` - 570 : : assembly { - 571 : : mstore(reservesList, sub(reservesListCount, droppedReservesCount)) - 572 : : } - 573 : 12086 : return reservesList; - 574 : : } - 575 : : - 576 : : /// @inheritdoc IPool - 577 : 1 : function getReservesCount() external view virtual override returns (uint256) { - 578 : 2 : return _reservesCount; - 579 : : } - 580 : : - 581 : : /// @inheritdoc IPool - 582 : 1 : function getReserveAddressById(uint16 id) external view returns (address) { - 583 : 2 : return _reservesList[id]; - 584 : : } - 585 : : - 586 : : /// @inheritdoc IPool - 587 : 3 : function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view virtual override returns (uint256) { - 588 : 6 : return _maxStableRateBorrowSizePercent; - 589 : : } - 590 : : - 591 : : /// @inheritdoc IPool - 592 : 25 : function BRIDGE_PROTOCOL_FEE() public view virtual override returns (uint256) { - 593 : 50 : return _bridgeProtocolFee; - 594 : : } - 595 : : - 596 : : /// @inheritdoc IPool - 597 : 1218 : function FLASHLOAN_PREMIUM_TOTAL() public view virtual override returns (uint128) { - 598 : 2436 : return _flashLoanPremiumTotal; - 599 : : } - 600 : : - 601 : : /// @inheritdoc IPool - 602 : 1215 : function FLASHLOAN_PREMIUM_TO_PROTOCOL() public view virtual override returns (uint128) { - 603 : 2430 : return _flashLoanPremiumToProtocol; - 604 : : } - 605 : : - 606 : : /// @inheritdoc IPool - 607 : 3 : function MAX_NUMBER_RESERVES() public view virtual override returns (uint16) { - 608 : 5770 : return ReserveConfiguration.MAX_RESERVES_COUNT; - 609 : : } - 610 : : - 611 : : /// @inheritdoc IPool - 612 : 1036 : function finalizeTransfer( - 613 : : address asset, - 614 : : address from, - 615 : : address to, - 616 : : uint256 amount, - 617 : : uint256 balanceFromBefore, - 618 : : uint256 balanceToBefore - 619 : : ) external virtual override { - 620 : 2072 : require(msg.sender == _reserves[asset].aTokenAddress, Errors.CALLER_NOT_ATOKEN); - 621 : 2072 : SupplyLogic.executeFinalizeTransfer( - 622 : : _reserves, - 623 : : _reservesList, - 624 : : _eModeCategories, - 625 : : _usersConfig, - 626 : : DataTypes.FinalizeTransferParams({ - 627 : : asset: asset, - 628 : : from: from, - 629 : : to: to, - 630 : : amount: amount, - 631 : : balanceFromBefore: balanceFromBefore, - 632 : : balanceToBefore: balanceToBefore, - 633 : : reservesCount: _reservesCount, - 634 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), - 635 : : fromEModeCategory: _usersEModeCategory[from] - 636 : : }) - 637 : : ); - 638 : : } - 639 : : - 640 : : /// @inheritdoc IPool - 641 : 6882 : function initReserve( - 642 : : address asset, - 643 : : address aTokenAddress, - 644 : : address stableDebtAddress, - 645 : : address variableDebtAddress, - 646 : : address interestRateStrategyAddress - 647 : : ) external virtual override onlyPoolConfigurator { - 648 : : if ( - 649 : 5764 : PoolLogic.executeInitReserve( - 650 : : _reserves, - 651 : : _reservesList, - 652 : : DataTypes.InitReserveParams({ - 653 : : asset: asset, - 654 : : aTokenAddress: aTokenAddress, - 655 : : stableDebtAddress: stableDebtAddress, - 656 : : variableDebtAddress: variableDebtAddress, - 657 : : interestRateStrategyAddress: interestRateStrategyAddress, - 658 : : reservesCount: _reservesCount, - 659 : : maxNumberReserves: MAX_NUMBER_RESERVES() - 660 : : }) - 661 : : ) - 662 : : ) { - 663 : 5762 : _reservesCount++; - 664 : : } - 665 : : } - 666 : : - 667 : : /// @inheritdoc IPool - 668 : 2007 : function dropReserve(address asset) external virtual override onlyPoolConfigurator { - 669 : 14 : PoolLogic.executeDropReserve(_reserves, _reservesList, asset); - 670 : : } - 671 : : - 672 : : /// @inheritdoc IPool - 673 : 6006 : function setReserveInterestRateStrategyAddress( - 674 : : address asset, - 675 : : address rateStrategyAddress - 676 : : ) external virtual override onlyPoolConfigurator { - 677 : 8012 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); - 678 : 4012 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); - 679 : : - 680 : 12 : _reserves[asset].interestRateStrategyAddress = rateStrategyAddress; - 681 : : } - 682 : : - 683 : : /// @inheritdoc IPool - 684 : 1751 : function syncIndexesState(address asset) external virtual override onlyPoolConfigurator { - 685 : 3502 : DataTypes.ReserveData storage reserve = _reserves[asset]; - 686 : 5253 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 687 : : - 688 : 3502 : reserve.updateState(reserveCache); - 689 : : } - 690 : : - 691 : : /// @inheritdoc IPool - 692 : 1751 : function syncRatesState(address asset) external virtual override onlyPoolConfigurator { - 693 : 3502 : DataTypes.ReserveData storage reserve = _reserves[asset]; - 694 : 5253 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); - 695 : : - 696 : 3502 : ReserveLogic.updateInterestRatesAndVirtualBalance(reserve, reserveCache, asset, 0, 0); + 569 : : /// @inheritdoc IPool + 570 : : function MAX_NUMBER_RESERVES() public view virtual override returns (uint16) { + 571 : 168018 : return ReserveConfiguration.MAX_RESERVES_COUNT; + 572 : : } + 573 : : + 574 : : /// @inheritdoc IPool + 575 : : function finalizeTransfer( + 576 : : address asset, + 577 : : address from, + 578 : : address to, + 579 : : uint256 amount, + 580 : : uint256 balanceFromBefore, + 581 : : uint256 balanceToBefore + 582 : : ) external virtual override { + 583 : 17042 : require(msg.sender == _reserves[asset].aTokenAddress, Errors.CALLER_NOT_ATOKEN); + 584 : 17042 : SupplyLogic.executeFinalizeTransfer( + 585 : : _reserves, + 586 : : _reservesList, + 587 : : _eModeCategories, + 588 : : _usersConfig, + 589 : : DataTypes.FinalizeTransferParams({ + 590 : : asset: asset, + 591 : : from: from, + 592 : : to: to, + 593 : : amount: amount, + 594 : : balanceFromBefore: balanceFromBefore, + 595 : : balanceToBefore: balanceToBefore, + 596 : : reservesCount: _reservesCount, + 597 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), + 598 : : fromEModeCategory: _usersEModeCategory[from] + 599 : : }) + 600 : : ); + 601 : : } + 602 : : + 603 : : /// @inheritdoc IPool + 604 : : function initReserve( + 605 : : address asset, + 606 : : address aTokenAddress, + 607 : : address variableDebtAddress, + 608 : : address interestRateStrategyAddress + 609 : : ) external virtual override onlyPoolConfigurator { + 610 : : if ( + 611 : 166016 : PoolLogic.executeInitReserve( + 612 : : _reserves, + 613 : : _reservesList, + 614 : : DataTypes.InitReserveParams({ + 615 : : asset: asset, + 616 : : aTokenAddress: aTokenAddress, + 617 : : variableDebtAddress: variableDebtAddress, + 618 : : interestRateStrategyAddress: interestRateStrategyAddress, + 619 : : reservesCount: _reservesCount, + 620 : : maxNumberReserves: MAX_NUMBER_RESERVES() + 621 : : }) + 622 : : ) + 623 : : ) { + 624 : 165016 : _reservesCount++; + 625 : : } + 626 : : } + 627 : : + 628 : : /// @inheritdoc IPool + 629 : : function dropReserve(address asset) external virtual override onlyPoolConfigurator { + 630 : 7 : PoolLogic.executeDropReserve(_reserves, _reservesList, asset); + 631 : : } + 632 : : + 633 : : /// @inheritdoc IPool + 634 : : function setReserveInterestRateStrategyAddress( + 635 : : address asset, + 636 : : address rateStrategyAddress + 637 : : ) external virtual override onlyPoolConfigurator { + 638 : 4046 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 639 : 2046 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); + 640 : : + 641 : 46 : _reserves[asset].interestRateStrategyAddress = rateStrategyAddress; + 642 : : } + 643 : : + 644 : : /// @inheritdoc IPool + 645 : : function syncIndexesState(address asset) external virtual override onlyPoolConfigurator { + 646 : 1994 : DataTypes.ReserveData storage reserve = _reserves[asset]; + 647 : 1994 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 648 : : + 649 : 1994 : reserve.updateState(reserveCache); + 650 : : } + 651 : : + 652 : : /// @inheritdoc IPool + 653 : : function syncRatesState(address asset) external virtual override onlyPoolConfigurator { + 654 : 1994 : DataTypes.ReserveData storage reserve = _reserves[asset]; + 655 : 1994 : DataTypes.ReserveCache memory reserveCache = reserve.cache(); + 656 : : + 657 : 1994 : ReserveLogic.updateInterestRatesAndVirtualBalance(reserve, reserveCache, asset, 0, 0); + 658 : : } + 659 : : + 660 : : /// @inheritdoc IPool + 661 : : function setConfiguration( + 662 : : address asset, + 663 : : DataTypes.ReserveConfigurationMap calldata configuration + 664 : : ) external virtual override onlyPoolConfigurator { + 665 : 208599 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 666 : 208599 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); + 667 : 208599 : _reserves[asset].configuration = configuration; + 668 : : } + 669 : : + 670 : : /// @inheritdoc IPool + 671 : : function updateBridgeProtocolFee( + 672 : : uint256 protocolFee + 673 : : ) external virtual override onlyPoolConfigurator { + 674 : 13 : _bridgeProtocolFee = protocolFee; + 675 : : } + 676 : : + 677 : : /// @inheritdoc IPool + 678 : : function updateFlashloanPremiums( + 679 : : uint128 flashLoanPremiumTotal, + 680 : : uint128 flashLoanPremiumToProtocol + 681 : : ) external virtual override onlyPoolConfigurator { + 682 : 1362 : _flashLoanPremiumTotal = flashLoanPremiumTotal; + 683 : 1362 : _flashLoanPremiumToProtocol = flashLoanPremiumToProtocol; + 684 : : } + 685 : : + 686 : : /// @inheritdoc IPool + 687 : : function configureEModeCategory( + 688 : : uint8 id, + 689 : : DataTypes.EModeCategoryBaseConfiguration memory category + 690 : : ) external virtual override onlyPoolConfigurator { + 691 : : // category 0 is reserved for volatile heterogeneous assets and it's always disabled + 692 : 10029 : require(id != 0, Errors.EMODE_CATEGORY_RESERVED); + 693 : 10029 : _eModeCategories[id].ltv = category.ltv; + 694 : 10029 : _eModeCategories[id].liquidationThreshold = category.liquidationThreshold; + 695 : 10029 : _eModeCategories[id].liquidationBonus = category.liquidationBonus; + 696 : 10029 : _eModeCategories[id].label = category.label; 697 : : } 698 : : 699 : : /// @inheritdoc IPool - 700 : 38058 : function setConfiguration( - 701 : : address asset, - 702 : : DataTypes.ReserveConfigurationMap calldata configuration + 700 : : function configureEModeCategoryCollateralBitmap( + 701 : : uint8 id, + 702 : : uint128 collateralBitmap 703 : : ) external virtual override onlyPoolConfigurator { - 704 : 72116 : require(asset != address(0), Errors.ZERO_ADDRESS_NOT_VALID); - 705 : 72116 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); - 706 : 72116 : _reserves[asset].configuration = configuration; + 704 : : // category 0 is reserved for volatile heterogeneous assets and it's always disabled + 705 : 10039 : require(id != 0, Errors.EMODE_CATEGORY_RESERVED); + 706 : 10039 : _eModeCategories[id].collateralBitmap = collateralBitmap; 707 : : } 708 : : 709 : : /// @inheritdoc IPool - 710 : 2013 : function updateBridgeProtocolFee( - 711 : : uint256 protocolFee - 712 : : ) external virtual override onlyPoolConfigurator { - 713 : 26 : _bridgeProtocolFee = protocolFee; - 714 : : } - 715 : : - 716 : : /// @inheritdoc IPool - 717 : 3212 : function updateFlashloanPremiums( - 718 : : uint128 flashLoanPremiumTotal, - 719 : : uint128 flashLoanPremiumToProtocol - 720 : : ) external virtual override onlyPoolConfigurator { - 721 : 2424 : _flashLoanPremiumTotal = flashLoanPremiumTotal; - 722 : 2424 : _flashLoanPremiumToProtocol = flashLoanPremiumToProtocol; - 723 : : } - 724 : : - 725 : : /// @inheritdoc IPool - 726 : 2027 : function configureEModeCategory( - 727 : : uint8 id, - 728 : : DataTypes.EModeCategory memory category - 729 : : ) external virtual override onlyPoolConfigurator { - 730 : : // category 0 is reserved for volatile heterogeneous assets and it's always disabled - 731 : 54 : require(id != 0, Errors.EMODE_CATEGORY_RESERVED); - 732 : 54 : _eModeCategories[id] = category; - 733 : : } - 734 : : - 735 : : /// @inheritdoc IPool - 736 : 46 : function getEModeCategoryData( - 737 : : uint8 id - 738 : : ) external view virtual override returns (DataTypes.EModeCategory memory) { - 739 : 92 : return _eModeCategories[id]; - 740 : : } - 741 : : - 742 : : /// @inheritdoc IPool - 743 : 17 : function setUserEMode(uint8 categoryId) external virtual override { - 744 : 34 : EModeLogic.executeSetUserEMode( - 745 : : _reserves, - 746 : : _reservesList, - 747 : : _eModeCategories, - 748 : : _usersEModeCategory, - 749 : : _usersConfig[msg.sender], - 750 : : DataTypes.ExecuteSetUserEModeParams({ - 751 : : reservesCount: _reservesCount, - 752 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), - 753 : : categoryId: categoryId - 754 : : }) - 755 : : ); - 756 : : } - 757 : : - 758 : : /// @inheritdoc IPool - 759 : 3012 : function getUserEMode(address user) external view virtual override returns (uint256) { - 760 : 6024 : return _usersEModeCategory[user]; - 761 : : } - 762 : : - 763 : : /// @inheritdoc IPool - 764 : 3751 : function resetIsolationModeTotalDebt( - 765 : : address asset - 766 : : ) external virtual override onlyPoolConfigurator { - 767 : 3502 : PoolLogic.executeResetIsolationModeTotalDebt(_reserves, asset); - 768 : : } - 769 : : - 770 : : /// @inheritdoc IPool - 771 : 5512 : function getLiquidationGracePeriod(address asset) external virtual override returns (uint40) { - 772 : 11024 : return _reserves[asset].liquidationGracePeriodUntil; - 773 : : } - 774 : : - 775 : : /// @inheritdoc IPool - 776 : 13028 : function setLiquidationGracePeriod( - 777 : : address asset, - 778 : : uint40 until - 779 : : ) external virtual override onlyPoolConfigurator { - 780 : 22056 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); - 781 : 18056 : PoolLogic.executeSetLiquidationGracePeriod(_reserves, asset, until); - 782 : : } - 783 : : - 784 : : /// @inheritdoc IPool - 785 : 2000 : function rescueTokens( - 786 : : address token, - 787 : : address to, - 788 : : uint256 amount - 789 : : ) external virtual override onlyPoolAdmin { - 790 : 4000 : PoolLogic.executeRescueTokens(token, to, amount); - 791 : : } - 792 : : - 793 : : /// @inheritdoc IPool - 794 : : /// @dev Deprecated: maintained for compatibility purposes - 795 : 17 : function deposit( + 710 : : function configureEModeCategoryBorrowableBitmap( + 711 : : uint8 id, + 712 : : uint128 borrowableBitmap + 713 : : ) external virtual override onlyPoolConfigurator { + 714 : : // category 0 is reserved for volatile heterogeneous assets and it's always disabled + 715 : 7010 : require(id != 0, Errors.EMODE_CATEGORY_RESERVED); + 716 : 7010 : _eModeCategories[id].borrowableBitmap = borrowableBitmap; + 717 : : } + 718 : : + 719 : : /// @inheritdoc IPool + 720 : : function getEModeCategoryData( + 721 : : uint8 id + 722 : : ) external view virtual override returns (DataTypes.EModeCategoryLegacy memory) { + 723 : 3 : DataTypes.EModeCategory memory category = _eModeCategories[id]; + 724 : 3 : return + 725 : : DataTypes.EModeCategoryLegacy({ + 726 : : ltv: category.ltv, + 727 : : liquidationThreshold: category.liquidationThreshold, + 728 : : liquidationBonus: category.liquidationBonus, + 729 : : priceSource: address(0), + 730 : : label: category.label + 731 : : }); + 732 : : } + 733 : : + 734 : : /// @inheritdoc IPool + 735 : : function getEModeCategoryCollateralConfig( + 736 : : uint8 id + 737 : : ) external view returns (DataTypes.CollateralConfig memory) { + 738 : 110 : return + 739 : : DataTypes.CollateralConfig({ + 740 : : ltv: _eModeCategories[id].ltv, + 741 : : liquidationThreshold: _eModeCategories[id].liquidationThreshold, + 742 : : liquidationBonus: _eModeCategories[id].liquidationBonus + 743 : : }); + 744 : : } + 745 : : + 746 : : /// @inheritdoc IPool + 747 : : function getEModeCategoryLabel(uint8 id) external view returns (string memory) { + 748 : 25 : return _eModeCategories[id].label; + 749 : : } + 750 : : + 751 : : /// @inheritdoc IPool + 752 : : function getEModeCategoryCollateralBitmap(uint8 id) external view returns (uint128) { + 753 : 10064 : return _eModeCategories[id].collateralBitmap; + 754 : : } + 755 : : + 756 : : /// @inheritdoc IPool + 757 : : function getEModeCategoryBorrowableBitmap(uint8 id) external view returns (uint128) { + 758 : 7035 : return _eModeCategories[id].borrowableBitmap; + 759 : : } + 760 : : + 761 : : /// @inheritdoc IPool + 762 : : function setUserEMode(uint8 categoryId) external virtual override { + 763 : 10023 : EModeLogic.executeSetUserEMode( + 764 : : _reserves, + 765 : : _reservesList, + 766 : : _eModeCategories, + 767 : : _usersEModeCategory, + 768 : : _usersConfig[msg.sender], + 769 : : DataTypes.ExecuteSetUserEModeParams({ + 770 : : reservesCount: _reservesCount, + 771 : : oracle: ADDRESSES_PROVIDER.getPriceOracle(), + 772 : : categoryId: categoryId + 773 : : }) + 774 : : ); + 775 : : } + 776 : : + 777 : : /// @inheritdoc IPool + 778 : : function getUserEMode(address user) external view virtual override returns (uint256) { + 779 : 5016 : return _usersEModeCategory[user]; + 780 : : } + 781 : : + 782 : : /// @inheritdoc IPool + 783 : : function resetIsolationModeTotalDebt( + 784 : : address asset + 785 : : ) external virtual override onlyPoolConfigurator { + 786 : 1951 : PoolLogic.executeResetIsolationModeTotalDebt(_reserves, asset); + 787 : : } + 788 : : + 789 : : /// @inheritdoc IPool + 790 : : function getLiquidationGracePeriod(address asset) external virtual override returns (uint40) { + 791 : 8756 : return _reserves[asset].liquidationGracePeriodUntil; + 792 : : } + 793 : : + 794 : : /// @inheritdoc IPool + 795 : : function setLiquidationGracePeriod( 796 : : address asset, - 797 : : uint256 amount, - 798 : : address onBehalfOf, - 799 : : uint16 referralCode - 800 : : ) external virtual override { - 801 : 34 : SupplyLogic.executeSupply( - 802 : : _reserves, - 803 : : _reservesList, - 804 : : _usersConfig[onBehalfOf], - 805 : : DataTypes.ExecuteSupplyParams({ - 806 : : asset: asset, - 807 : : amount: amount, - 808 : : onBehalfOf: onBehalfOf, - 809 : : referralCode: referralCode - 810 : : }) - 811 : : ); - 812 : : } - 813 : : - 814 : : /// @inheritdoc IPool - 815 : 2 : function getFlashLoanLogic() external pure returns (address) { - 816 : 6 : return address(FlashLoanLogic); - 817 : : } - 818 : : - 819 : : /// @inheritdoc IPool - 820 : 2 : function getBorrowLogic() external pure returns (address) { - 821 : 6 : return address(BorrowLogic); - 822 : : } - 823 : : - 824 : : /// @inheritdoc IPool - 825 : 2 : function getBridgeLogic() external pure returns (address) { - 826 : 6 : return address(BridgeLogic); - 827 : : } - 828 : : - 829 : : /// @inheritdoc IPool - 830 : 2 : function getEModeLogic() external pure returns (address) { - 831 : 6 : return address(EModeLogic); - 832 : : } - 833 : : - 834 : : /// @inheritdoc IPool - 835 : 2 : function getLiquidationLogic() external pure returns (address) { - 836 : 6 : return address(LiquidationLogic); - 837 : : } - 838 : : - 839 : : /// @inheritdoc IPool - 840 : 2 : function getPoolLogic() external pure returns (address) { - 841 : 6 : return address(PoolLogic); - 842 : : } - 843 : : - 844 : : /// @inheritdoc IPool - 845 : 2 : function getSupplyLogic() external pure returns (address) { - 846 : 6 : return address(SupplyLogic); - 847 : : } - 848 : : } + 797 : : uint40 until + 798 : : ) external virtual override onlyPoolConfigurator { + 799 : 14412 : require(_reserves[asset].id != 0 || _reservesList[0] == asset, Errors.ASSET_NOT_LISTED); + 800 : 12412 : PoolLogic.executeSetLiquidationGracePeriod(_reserves, asset, until); + 801 : : } + 802 : : + 803 : : /// @inheritdoc IPool + 804 : : function rescueTokens( + 805 : : address token, + 806 : : address to, + 807 : : uint256 amount + 808 : : ) external virtual override onlyPoolAdmin { + 809 : 2000 : PoolLogic.executeRescueTokens(token, to, amount); + 810 : : } + 811 : : + 812 : : /// @inheritdoc IPool + 813 : : /// @dev Deprecated: maintained for compatibility purposes + 814 : : function deposit( + 815 : : address asset, + 816 : : uint256 amount, + 817 : : address onBehalfOf, + 818 : : uint16 referralCode + 819 : : ) external virtual override { + 820 : 20025 : SupplyLogic.executeSupply( + 821 : : _reserves, + 822 : : _reservesList, + 823 : : _usersConfig[onBehalfOf], + 824 : : DataTypes.ExecuteSupplyParams({ + 825 : : asset: asset, + 826 : : amount: amount, + 827 : : onBehalfOf: onBehalfOf, + 828 : : referralCode: referralCode + 829 : : }) + 830 : : ); + 831 : : } + 832 : : + 833 : : /// @inheritdoc IPool + 834 : : function getFlashLoanLogic() external pure returns (address) { + 835 : 2 : return address(FlashLoanLogic); + 836 : : } + 837 : : + 838 : : /// @inheritdoc IPool + 839 : : function getBorrowLogic() external pure returns (address) { + 840 : 2 : return address(BorrowLogic); + 841 : : } + 842 : : + 843 : : /// @inheritdoc IPool + 844 : : function getBridgeLogic() external pure returns (address) { + 845 : 2 : return address(BridgeLogic); + 846 : : } + 847 : : + 848 : : /// @inheritdoc IPool + 849 : : function getEModeLogic() external pure returns (address) { + 850 : 2 : return address(EModeLogic); + 851 : : } + 852 : : + 853 : : /// @inheritdoc IPool + 854 : : function getLiquidationLogic() external pure returns (address) { + 855 : 2 : return address(LiquidationLogic); + 856 : : } + 857 : : + 858 : : /// @inheritdoc IPool + 859 : : function getPoolLogic() external pure returns (address) { + 860 : 2 : return address(PoolLogic); + 861 : : } + 862 : : + 863 : : /// @inheritdoc IPool + 864 : : function getSupplyLogic() external pure returns (address) { + 865 : 2 : return address(SupplyLogic); + 866 : : } + 867 : : } @@ -924,8 +943,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func-c.html b/report/protocol/pool/PoolConfigurator.sol.func-c.html similarity index 56% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func-c.html rename to report/protocol/pool/PoolConfigurator.sol.func-c.html index 0246f91c..b8fd358e 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func-c.html +++ b/report/protocol/pool/PoolConfigurator.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol - functions - + LCOV - lcov.info.p - protocol/pool/PoolConfigurator.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,294 +53,322 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - PoolConfigurator.sol (source / functions)top level - protocol/pool - PoolConfigurator.sol (source / functions) Coveragelcov.info.p Lines:96.8 %100.0 %190 190184
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:94.9 %3937100.0 %4343
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + @@ -348,8 +376,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolConfigurator._onlyEmergencyAdminPoolConfigurator.getConfiguratorLogic01
PoolConfigurator.setReserveInterestRateDataPoolConfigurator._checkNoBorrowers03
PoolConfigurator.getConfiguratorLogicPoolConfigurator.setUnbackedMintCap17
PoolConfigurator.updateATokenPoolConfigurator.updateBridgeProtocolFee214
PoolConfigurator.updateStableDebtTokenPoolConfigurator._updateInterestRateStrategy246
PoolConfigurator.updateVariableDebtTokenPoolConfigurator.updateAToken21001
PoolConfigurator._checkNoBorrowersPoolConfigurator.updateVariableDebtToken31001
PoolConfigurator._updateInterestRateStrategyPoolConfigurator.setReserveInterestRateData41002
PoolConfigurator.setReserveInterestRateStrategyAddressPoolConfigurator.dropReserve51005
PoolConfigurator.dropReservePoolConfigurator.setReserveActive61011
PoolConfigurator.setUnbackedMintCapPoolConfigurator.setReserveInterestRateStrategyAddress71044
PoolConfigurator.setReserveActivePoolConfigurator.onlyPoolAdmin141682
PoolConfigurator.updateBridgeProtocolFeePoolConfigurator.updateFlashloanPremiumToProtocol141682
PoolConfigurator.setEModeCategoryPoolConfigurator.updateFlashloanPremiumTotal381682
PoolConfigurator.updateFlashloanPremiumToProtocolPoolConfigurator.setSiloedBorrowing6081949
PoolConfigurator.updateFlashloanPremiumTotalPoolConfigurator.setLiquidationProtocolFee6081954
PoolConfigurator._onlyRiskOrPoolOrEmergencyAdminsPoolConfigurator.setBorrowableInIsolation10111959
PoolConfigurator.setReserveFreezePoolConfigurator.disableLiquidationGracePeriod10112001
PoolConfigurator._onlyPoolAdminPoolConfigurator.onlyEmergencyOrPoolAdmin12562003
PoolConfigurator.setReserveFactorPoolConfigurator.setReserveFactor17492949
PoolConfigurator.setReserveFlashLoaningPoolConfigurator.setBorrowCap17492957
PoolConfigurator.setSiloedBorrowingPoolConfigurator.setDebtCeiling17492964
PoolConfigurator.setReserveBorrowingPoolConfigurator._checkNoSuppliers17512971
PoolConfigurator.setLiquidationProtocolFeePoolConfigurator.getPendingLtv17543003
PoolConfigurator.setBorrowCapPoolConfigurator._onlyRiskOrPoolOrEmergencyAdmins17593014
PoolConfigurator.setBorrowableInIsolationPoolConfigurator.onlyRiskOrPoolOrEmergencyAdmins17593014
PoolConfigurator.setSupplyCapPoolConfigurator.setReserveFreeze17623014
PoolConfigurator.setDebtCeilingPoolConfigurator.setReserveFlashLoaning17653948
PoolConfigurator._checkNoSuppliersPoolConfigurator.setSupplyCap17743963
PoolConfigurator.setAssetEModeCategoryPoolConfigurator.setPoolPause17864003
PoolConfigurator.setReserveStableRateBorrowingPoolConfigurator.setReserveBorrowing19335947
PoolConfigurator.getPendingLtvPoolConfigurator.onlyRiskOrPoolAdmins20037010
PoolConfigurator._onlyAssetListingOrPoolAdminsPoolConfigurator.setAssetBorrowableInEMode25927010
PoolConfigurator.initReservesPoolConfigurator._onlyPoolAdmin25927396
PoolConfigurator.setPoolPausePoolConfigurator._onlyAssetListingOrPoolAdmins30038651
PoolConfigurator.initReserves8651
PoolConfigurator.onlyAssetListingOrPoolAdmins8651
PoolConfigurator.configureReserveAsCollateral10952
PoolConfigurator.setEModeCategory11035
PoolConfigurator.configureReserveAsCollateralPoolConfigurator.setAssetCollateralInEMode475711039
PoolConfigurator.setReservePausePoolConfigurator.setReservePause889114013
PoolConfigurator._onlyPoolOrEmergencyAdminPoolConfigurator._onlyPoolOrEmergencyAdmin1490324030
PoolConfigurator._onlyRiskOrPoolAdminsPoolConfigurator._onlyRiskOrPoolAdmins2432370679
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func.html b/report/protocol/pool/PoolConfigurator.sol.func.html similarity index 56% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func.html rename to report/protocol/pool/PoolConfigurator.sol.func.html index 3bc91cd2..5bdd150a 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.func.html +++ b/report/protocol/pool/PoolConfigurator.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol - functions - + LCOV - lcov.info.p - protocol/pool/PoolConfigurator.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,294 +53,322 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - PoolConfigurator.sol (source / functions)top level - protocol/pool - PoolConfigurator.sol (source / functions) Coveragelcov.info.p Lines:96.8 %100.0 %190 190184
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:94.9 %3937100.0 %4343
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + + + - + - + - + - + - + - + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + + + + + + + + + + + + - + - + - + - + - + - + @@ -348,8 +376,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
PoolConfigurator._checkNoBorrowersPoolConfigurator._checkNoBorrowers 3
PoolConfigurator._checkNoSuppliersPoolConfigurator._checkNoSuppliers17742971
PoolConfigurator._onlyAssetListingOrPoolAdminsPoolConfigurator._onlyAssetListingOrPoolAdmins25928651
PoolConfigurator._onlyEmergencyAdminPoolConfigurator._onlyPoolAdmin07396
PoolConfigurator._onlyPoolAdminPoolConfigurator._onlyPoolOrEmergencyAdmin125624030
PoolConfigurator._onlyPoolOrEmergencyAdminPoolConfigurator._onlyRiskOrPoolAdmins1490370679
PoolConfigurator._onlyRiskOrPoolAdminsPoolConfigurator._onlyRiskOrPoolOrEmergencyAdmins243233014
PoolConfigurator._onlyRiskOrPoolOrEmergencyAdminsPoolConfigurator._updateInterestRateStrategy101146
PoolConfigurator._updateInterestRateStrategyPoolConfigurator.configureReserveAsCollateral410952
PoolConfigurator.configureReserveAsCollateralPoolConfigurator.disableLiquidationGracePeriod47572001
PoolConfigurator.dropReservePoolConfigurator.dropReserve61005
PoolConfigurator.getConfiguratorLogicPoolConfigurator.getConfiguratorLogic 1
PoolConfigurator.getPendingLtvPoolConfigurator.getPendingLtv20033003
PoolConfigurator.initReservesPoolConfigurator.initReserves25928651
PoolConfigurator.setAssetEModeCategoryPoolConfigurator.onlyAssetListingOrPoolAdmins17868651
PoolConfigurator.setBorrowCapPoolConfigurator.onlyEmergencyOrPoolAdmin17592003
PoolConfigurator.setBorrowableInIsolationPoolConfigurator.onlyPoolAdmin17591682
PoolConfigurator.setDebtCeilingPoolConfigurator.onlyRiskOrPoolAdmins17657010
PoolConfigurator.setEModeCategoryPoolConfigurator.onlyRiskOrPoolOrEmergencyAdmins383014
PoolConfigurator.setLiquidationProtocolFeePoolConfigurator.setAssetBorrowableInEMode17547010
PoolConfigurator.setPoolPausePoolConfigurator.setAssetCollateralInEMode300311039
PoolConfigurator.setReserveActivePoolConfigurator.setBorrowCap295714
PoolConfigurator.setBorrowableInIsolation1959
PoolConfigurator.setReserveBorrowingPoolConfigurator.setDebtCeiling17512964
PoolConfigurator.setReserveFactorPoolConfigurator.setEModeCategory174911035
PoolConfigurator.setReserveFlashLoaningPoolConfigurator.setLiquidationProtocolFee17491954
PoolConfigurator.setReserveFreezePoolConfigurator.setPoolPause4003
PoolConfigurator.setReserveActive 1011
PoolConfigurator.setReserveInterestRateDataPoolConfigurator.setReserveBorrowing05947
PoolConfigurator.setReserveInterestRateStrategyAddressPoolConfigurator.setReserveFactor52949
PoolConfigurator.setReservePausePoolConfigurator.setReserveFlashLoaning88913948
PoolConfigurator.setReserveStableRateBorrowingPoolConfigurator.setReserveFreeze19333014
PoolConfigurator.setSiloedBorrowingPoolConfigurator.setReserveInterestRateData17491002
PoolConfigurator.setSupplyCapPoolConfigurator.setReserveInterestRateStrategyAddress17621044
PoolConfigurator.setUnbackedMintCapPoolConfigurator.setReservePause714013
PoolConfigurator.updateATokenPoolConfigurator.setSiloedBorrowing21949
PoolConfigurator.updateBridgeProtocolFeePoolConfigurator.setSupplyCap143963
PoolConfigurator.updateFlashloanPremiumToProtocolPoolConfigurator.setUnbackedMintCap7608
PoolConfigurator.updateAToken1001
PoolConfigurator.updateBridgeProtocolFee14
PoolConfigurator.updateFlashloanPremiumTotalPoolConfigurator.updateFlashloanPremiumToProtocol6081682
PoolConfigurator.updateStableDebtTokenPoolConfigurator.updateFlashloanPremiumTotal21682
PoolConfigurator.updateVariableDebtTokenPoolConfigurator.updateVariableDebtToken21001
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.gcov.html b/report/protocol/pool/PoolConfigurator.sol.gcov.html similarity index 75% rename from report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.gcov.html rename to report/protocol/pool/PoolConfigurator.sol.gcov.html index 39285c10..4e0e3977 100644 --- a/report/core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol.gcov.html +++ b/report/protocol/pool/PoolConfigurator.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/pool/src/core/contracts/protocol/pool/PoolConfigurator.sol - + LCOV - lcov.info.p - protocol/pool/PoolConfigurator.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/pool/src/core/contracts/protocol/pool - PoolConfigurator.sol (source / functions)top level - protocol/pool - PoolConfigurator.sol (source / functions) Coveragelcov.info.p Lines:96.8 %100.0 %190 190184
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:94.9 %3937100.0 %4343
0 0
@@ -72,36 +72,36 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; + 4 : : import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; 5 : : import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; - 6 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; - 7 : : import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; - 8 : : import {Errors} from '../libraries/helpers/Errors.sol'; - 9 : : import {PercentageMath} from '../libraries/math/PercentageMath.sol'; - 10 : : import {DataTypes} from '../libraries/types/DataTypes.sol'; - 11 : : import {ConfiguratorLogic} from '../libraries/logic/ConfiguratorLogic.sol'; - 12 : : import {ConfiguratorInputTypes} from '../libraries/types/ConfiguratorInputTypes.sol'; - 13 : : import {IPoolConfigurator} from '../../interfaces/IPoolConfigurator.sol'; - 14 : : import {IPool} from '../../interfaces/IPool.sol'; - 15 : : import {IACLManager} from '../../interfaces/IACLManager.sol'; - 16 : : import {IPoolDataProvider} from '../../interfaces/IPoolDataProvider.sol'; - 17 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; - 18 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 19 : : - 20 : : /** - 21 : : * @title PoolConfigurator - 22 : : * @author Aave - 23 : : * @dev Implements the configuration methods for the Aave protocol - 24 : : */ - 25 : : abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator { - 26 : : using PercentageMath for uint256; - 27 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - 28 : : - 29 : : IPoolAddressesProvider internal _addressesProvider; - 30 : : IPool internal _pool; - 31 : : - 32 : : mapping(address => uint256) internal _pendingLtv; - 33 : : mapping(address => bool) internal _isPendingLtvSet; + 6 : : import {EModeConfiguration} from '../libraries/configuration/EModeConfiguration.sol'; + 7 : : import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; + 8 : : import {IDefaultInterestRateStrategyV2} from '../../interfaces/IDefaultInterestRateStrategyV2.sol'; + 9 : : import {Errors} from '../libraries/helpers/Errors.sol'; + 10 : : import {PercentageMath} from '../libraries/math/PercentageMath.sol'; + 11 : : import {DataTypes} from '../libraries/types/DataTypes.sol'; + 12 : : import {ConfiguratorLogic} from '../libraries/logic/ConfiguratorLogic.sol'; + 13 : : import {ConfiguratorInputTypes} from '../libraries/types/ConfiguratorInputTypes.sol'; + 14 : : import {IPoolConfigurator} from '../../interfaces/IPoolConfigurator.sol'; + 15 : : import {IPool} from '../../interfaces/IPool.sol'; + 16 : : import {IACLManager} from '../../interfaces/IACLManager.sol'; + 17 : : import {IPoolDataProvider} from '../../interfaces/IPoolDataProvider.sol'; + 18 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; + 19 : : import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 20 : : + 21 : : /** + 22 : : * @title PoolConfigurator + 23 : : * @author Aave + 24 : : * @dev Implements the configuration methods for the Aave protocol + 25 : : */ + 26 : : abstract contract PoolConfigurator is VersionedInitializable, IPoolConfigurator { + 27 : : using PercentageMath for uint256; + 28 : : using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + 29 : : + 30 : : IPoolAddressesProvider internal _addressesProvider; + 31 : : IPool internal _pool; + 32 : : + 33 : : mapping(address => uint256) internal _pendingLtv; 34 : : 35 : : uint40 public constant MAX_GRACE_PERIOD = 4 hours; 36 : : @@ -109,610 +109,596 @@ 38 : : * @dev Only pool admin can call functions marked by this modifier. 39 : : */ 40 : : modifier onlyPoolAdmin() { - 41 : : _onlyPoolAdmin(); + 41 : 1682 : _onlyPoolAdmin(); 42 : : _; 43 : : } 44 : : 45 : : /** - 46 : : * @dev Only emergency admin can call functions marked by this modifier. + 46 : : * @dev Only emergency or pool admin can call functions marked by this modifier. 47 : : */ - 48 : : modifier onlyEmergencyAdmin() { - 49 : : _onlyEmergencyAdmin(); + 48 : : modifier onlyEmergencyOrPoolAdmin() { + 49 : 2003 : _onlyPoolOrEmergencyAdmin(); 50 : : _; 51 : : } 52 : : 53 : : /** - 54 : : * @dev Only emergency or pool admin can call functions marked by this modifier. + 54 : : * @dev Only asset listing or pool admin can call functions marked by this modifier. 55 : : */ - 56 : : modifier onlyEmergencyOrPoolAdmin() { - 57 : : _onlyPoolOrEmergencyAdmin(); + 56 : : modifier onlyAssetListingOrPoolAdmins() { + 57 : 8651 : _onlyAssetListingOrPoolAdmins(); 58 : : _; 59 : : } 60 : : 61 : : /** - 62 : : * @dev Only asset listing or pool admin can call functions marked by this modifier. + 62 : : * @dev Only risk or pool admin can call functions marked by this modifier. 63 : : */ - 64 : : modifier onlyAssetListingOrPoolAdmins() { - 65 : : _onlyAssetListingOrPoolAdmins(); + 64 : : modifier onlyRiskOrPoolAdmins() { + 65 : 7010 : _onlyRiskOrPoolAdmins(); 66 : : _; 67 : : } 68 : : 69 : : /** - 70 : : * @dev Only risk or pool admin can call functions marked by this modifier. + 70 : : * @dev Only risk, pool or emergency admin can call functions marked by this modifier. 71 : : */ - 72 : : modifier onlyRiskOrPoolAdmins() { - 73 : : _onlyRiskOrPoolAdmins(); + 72 : : modifier onlyRiskOrPoolOrEmergencyAdmins() { + 73 : 3014 : _onlyRiskOrPoolOrEmergencyAdmins(); 74 : : _; 75 : : } 76 : : - 77 : : /** - 78 : : * @dev Only risk, pool or emergency admin can call functions marked by this modifier. - 79 : : */ - 80 : : modifier onlyRiskOrPoolOrEmergencyAdmins() { - 81 : : _onlyRiskOrPoolOrEmergencyAdmins(); - 82 : : _; - 83 : : } + 77 : : function initialize(IPoolAddressesProvider provider) public virtual; + 78 : : + 79 : : /// @inheritdoc IPoolConfigurator + 80 : : function initReserves( + 81 : : ConfiguratorInputTypes.InitReserveInput[] calldata input + 82 : : ) external override onlyAssetListingOrPoolAdmins { + 83 : 7651 : IPool cachedPool = _pool; 84 : : - 85 : : function initialize(IPoolAddressesProvider provider) public virtual; - 86 : : - 87 : : /// @inheritdoc IPoolConfigurator - 88 : 2592 : function initReserves( - 89 : : ConfiguratorInputTypes.InitReserveInput[] calldata input - 90 : : ) external override onlyAssetListingOrPoolAdmins { - 91 : 5182 : IPool cachedPool = _pool; - 92 : 13535 : for (uint256 i = 0; i < input.length; i++) { - 93 : 7764 : require(IERC20Detailed(input[i].underlyingAsset).decimals() > 5, Errors.INVALID_DECIMALS); + 85 : 7651 : for (uint256 i = 0; i < input.length; i++) { + 86 : 167016 : ConfiguratorLogic.executeInitReserve(cachedPool, input[i]); + 87 : 165016 : emit ReserveInterestRateDataChanged( + 88 : : input[i].underlyingAsset, + 89 : : input[i].interestRateStrategyAddress, + 90 : : input[i].interestRateData + 91 : : ); + 92 : : } + 93 : : } 94 : : - 95 : 5764 : ConfiguratorLogic.executeInitReserve(cachedPool, input[i]); - 96 : 5762 : emit ReserveInterestRateDataChanged( - 97 : : input[i].underlyingAsset, - 98 : : input[i].interestRateStrategyAddress, - 99 : : input[i].interestRateData - 100 : : ); - 101 : : } - 102 : : } - 103 : : - 104 : : /// @inheritdoc IPoolConfigurator - 105 : 6 : function dropReserve(address asset) external override onlyPoolAdmin { - 106 : 10 : _pool.dropReserve(asset); - 107 : 2 : emit ReserveDropped(asset); - 108 : : } - 109 : : - 110 : : /// @inheritdoc IPoolConfigurator - 111 : 2 : function updateAToken( - 112 : : ConfiguratorInputTypes.UpdateATokenInput calldata input - 113 : : ) external override onlyPoolAdmin { - 114 : 2 : ConfiguratorLogic.executeUpdateAToken(_pool, input); - 115 : : } - 116 : : - 117 : : /// @inheritdoc IPoolConfigurator - 118 : 2 : function updateStableDebtToken( - 119 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - 120 : : ) external override onlyPoolAdmin { - 121 : 2 : ConfiguratorLogic.executeUpdateStableDebtToken(_pool, input); - 122 : : } - 123 : : - 124 : : /// @inheritdoc IPoolConfigurator - 125 : 2 : function updateVariableDebtToken( - 126 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input - 127 : : ) external override onlyPoolAdmin { - 128 : 2 : ConfiguratorLogic.executeUpdateVariableDebtToken(_pool, input); - 129 : : } - 130 : : - 131 : : /// @inheritdoc IPoolConfigurator - 132 : 1751 : function setReserveBorrowing(address asset, bool enabled) external override onlyRiskOrPoolAdmins { - 133 : 5250 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 134 : 3500 : if (!enabled) { - 135 : 4 : require(!currentConfig.getStableRateBorrowingEnabled(), Errors.STABLE_BORROWING_ENABLED); - 136 : : } - 137 : 3500 : currentConfig.setBorrowingEnabled(enabled); - 138 : 3500 : _pool.setConfiguration(asset, currentConfig); - 139 : 3500 : emit ReserveBorrowing(asset, enabled); - 140 : : } + 95 : : /// @inheritdoc IPoolConfigurator + 96 : : function dropReserve(address asset) external override onlyPoolAdmin { + 97 : 5 : _pool.dropReserve(asset); + 98 : 1 : emit ReserveDropped(asset); + 99 : : } + 100 : : + 101 : : /// @inheritdoc IPoolConfigurator + 102 : : function updateAToken( + 103 : : ConfiguratorInputTypes.UpdateATokenInput calldata input + 104 : : ) external override onlyPoolAdmin { + 105 : 1 : ConfiguratorLogic.executeUpdateAToken(_pool, input); + 106 : : } + 107 : : + 108 : : /// @inheritdoc IPoolConfigurator + 109 : : function updateVariableDebtToken( + 110 : : ConfiguratorInputTypes.UpdateDebtTokenInput calldata input + 111 : : ) external override onlyPoolAdmin { + 112 : 1 : ConfiguratorLogic.executeUpdateVariableDebtToken(_pool, input); + 113 : : } + 114 : : + 115 : : /// @inheritdoc IPoolConfigurator + 116 : : function setReserveBorrowing(address asset, bool enabled) external override onlyRiskOrPoolAdmins { + 117 : 4947 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 118 : 4947 : currentConfig.setBorrowingEnabled(enabled); + 119 : 4947 : _pool.setConfiguration(asset, currentConfig); + 120 : 4947 : emit ReserveBorrowing(asset, enabled); + 121 : : } + 122 : : + 123 : : /// @inheritdoc IPoolConfigurator + 124 : : function configureReserveAsCollateral( + 125 : : address asset, + 126 : : uint256 ltv, + 127 : : uint256 liquidationThreshold, + 128 : : uint256 liquidationBonus + 129 : : ) external override onlyRiskOrPoolAdmins { + 130 : : //validation of the parameters: the LTV can + 131 : : //only be lower or equal than the liquidation threshold + 132 : : //(otherwise a loan against the asset would cause instantaneous liquidation) + 133 : 9952 : require(ltv <= liquidationThreshold, Errors.INVALID_RESERVE_PARAMS); + 134 : : + 135 : 7952 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 136 : : + 137 : 7952 : if (liquidationThreshold != 0) { + 138 : : //liquidation bonus must be bigger than 100.00%, otherwise the liquidator would receive less + 139 : : //collateral than needed to cover the debt + 140 : 6951 : require(liquidationBonus > PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_RESERVE_PARAMS); 141 : : - 142 : : /// @inheritdoc IPoolConfigurator - 143 : 4757 : function configureReserveAsCollateral( - 144 : : address asset, - 145 : : uint256 ltv, - 146 : : uint256 liquidationThreshold, - 147 : : uint256 liquidationBonus - 148 : : ) external override onlyRiskOrPoolAdmins { - 149 : : //validation of the parameters: the LTV can - 150 : : //only be lower or equal than the liquidation threshold - 151 : : //(otherwise a loan against the asset would cause instantaneous liquidation) - 152 : 9512 : require(ltv <= liquidationThreshold, Errors.INVALID_RESERVE_PARAMS); - 153 : : - 154 : 14262 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 142 : : //if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment + 143 : : //a loan is taken there is enough collateral available to cover the liquidation bonus + 144 : 5951 : require( + 145 : : liquidationThreshold.percentMul(liquidationBonus) <= PercentageMath.PERCENTAGE_FACTOR, + 146 : : Errors.INVALID_RESERVE_PARAMS + 147 : : ); + 148 : : } else { + 149 : 1001 : require(liquidationBonus == 0, Errors.INVALID_RESERVE_PARAMS); + 150 : : //if the liquidation threshold is being set to 0, + 151 : : // the reserve is being disabled as collateral. To do so, + 152 : : //we need to ensure no liquidity is supplied + 153 : 1001 : _checkNoSuppliers(asset); + 154 : : } 155 : : - 156 : 9508 : if (liquidationThreshold != 0) { - 157 : : //liquidation bonus must be bigger than 100.00%, otherwise the liquidator would receive less - 158 : : //collateral than needed to cover the debt - 159 : 9504 : require(liquidationBonus > PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_RESERVE_PARAMS); - 160 : : - 161 : : //if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment - 162 : : //a loan is taken there is enough collateral available to cover the liquidation bonus - 163 : 9502 : require( - 164 : : liquidationThreshold.percentMul(liquidationBonus) <= PercentageMath.PERCENTAGE_FACTOR, - 165 : : Errors.INVALID_RESERVE_PARAMS - 166 : : ); - 167 : : } else { - 168 : 4 : require(liquidationBonus == 0, Errors.INVALID_RESERVE_PARAMS); - 169 : : //if the liquidation threshold is being set to 0, - 170 : : // the reserve is being disabled as collateral. To do so, - 171 : : //we need to ensure no liquidity is supplied - 172 : 4 : _checkNoSuppliers(asset); - 173 : : } + 156 : 4952 : uint256 newLtv = ltv; + 157 : : + 158 : 4952 : if (currentConfig.getFrozen()) { + 159 : 1000 : _pendingLtv[asset] = ltv; + 160 : 1000 : newLtv = 0; + 161 : : + 162 : 1000 : emit PendingLtvChanged(asset, ltv); + 163 : : } else { + 164 : 3952 : currentConfig.setLtv(ltv); + 165 : : } + 166 : : + 167 : 4952 : currentConfig.setLiquidationThreshold(liquidationThreshold); + 168 : 4952 : currentConfig.setLiquidationBonus(liquidationBonus); + 169 : : + 170 : 4952 : _pool.setConfiguration(asset, currentConfig); + 171 : : + 172 : 4952 : emit CollateralConfigurationChanged(asset, newLtv, liquidationThreshold, liquidationBonus); + 173 : : } 174 : : - 175 : 9502 : if (currentConfig.getFrozen()) { - 176 : 2000 : _pendingLtv[asset] = ltv; - 177 : 2000 : _isPendingLtvSet[asset] = true; - 178 : : - 179 : 2000 : emit PendingLtvChanged(asset, ltv); - 180 : : } else { - 181 : 7502 : currentConfig.setLtv(ltv); - 182 : : } - 183 : : - 184 : 9502 : currentConfig.setLiquidationThreshold(liquidationThreshold); - 185 : 9502 : currentConfig.setLiquidationBonus(liquidationBonus); + 175 : : /// @inheritdoc IPoolConfigurator + 176 : : function setReserveFlashLoaning( + 177 : : address asset, + 178 : : bool enabled + 179 : : ) external override onlyRiskOrPoolAdmins { + 180 : 3948 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 181 : : + 182 : 3948 : currentConfig.setFlashLoanEnabled(enabled); + 183 : 3948 : _pool.setConfiguration(asset, currentConfig); + 184 : 3948 : emit ReserveFlashLoaning(asset, enabled); + 185 : : } 186 : : - 187 : 9502 : _pool.setConfiguration(asset, currentConfig); - 188 : : - 189 : 9502 : emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus); - 190 : : } - 191 : : - 192 : : /// @inheritdoc IPoolConfigurator - 193 : 1933 : function setReserveStableRateBorrowing( - 194 : : address asset, - 195 : : bool enabled - 196 : : ) external override onlyRiskOrPoolAdmins { - 197 : 5796 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 198 : 1932 : if (enabled) { - 199 : 368 : require(currentConfig.getBorrowingEnabled(), Errors.BORROWING_NOT_ENABLED); - 200 : : } - 201 : 3862 : currentConfig.setStableRateBorrowingEnabled(enabled); - 202 : 3862 : _pool.setConfiguration(asset, currentConfig); - 203 : 3862 : emit ReserveStableRateBorrowing(asset, enabled); - 204 : : } - 205 : : - 206 : : /// @inheritdoc IPoolConfigurator - 207 : 1749 : function setReserveFlashLoaning( - 208 : : address asset, - 209 : : bool enabled - 210 : : ) external override onlyRiskOrPoolAdmins { - 211 : 5247 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 212 : : - 213 : 3498 : currentConfig.setFlashLoanEnabled(enabled); - 214 : 3498 : _pool.setConfiguration(asset, currentConfig); - 215 : 3498 : emit ReserveFlashLoaning(asset, enabled); - 216 : : } - 217 : : - 218 : : /// @inheritdoc IPoolConfigurator - 219 : 14 : function setReserveActive(address asset, bool active) external override onlyPoolAdmin { - 220 : 38 : if (!active) _checkNoSuppliers(asset); - 221 : 36 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 222 : 24 : currentConfig.setActive(active); - 223 : 24 : _pool.setConfiguration(asset, currentConfig); - 224 : 24 : emit ReserveActive(asset, active); - 225 : : } - 226 : : - 227 : : /// @inheritdoc IPoolConfigurator - 228 : 1011 : function setReserveFreeze( - 229 : : address asset, - 230 : : bool freeze - 231 : : ) external override onlyRiskOrPoolOrEmergencyAdmins { - 232 : 3030 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 233 : 2020 : currentConfig.setFrozen(freeze); - 234 : : - 235 : 1010 : if (freeze) { - 236 : 2016 : _pendingLtv[asset] = currentConfig.getLtv(); - 237 : 2016 : _isPendingLtvSet[asset] = true; - 238 : 2016 : currentConfig.setLtv(0); - 239 : : - 240 : 2016 : emit PendingLtvChanged(asset, currentConfig.getLtv()); - 241 : 2 : } else if (_isPendingLtvSet[asset]) { - 242 : 2 : uint256 ltv = _pendingLtv[asset]; - 243 : 2 : currentConfig.setLtv(ltv); - 244 : : - 245 : 2 : delete _pendingLtv[asset]; - 246 : 2 : delete _isPendingLtvSet[asset]; - 247 : : - 248 : 2 : emit PendingLtvRemoved(asset); - 249 : : } - 250 : : - 251 : 2020 : _pool.setConfiguration(asset, currentConfig); - 252 : 2020 : emit ReserveFrozen(asset, freeze); - 253 : : } - 254 : : - 255 : : /// @inheritdoc IPoolConfigurator - 256 : 1759 : function setBorrowableInIsolation( - 257 : : address asset, - 258 : : bool borrowable - 259 : : ) external override onlyRiskOrPoolAdmins { - 260 : 5277 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 261 : 3518 : currentConfig.setBorrowableInIsolation(borrowable); - 262 : 3518 : _pool.setConfiguration(asset, currentConfig); - 263 : 3518 : emit BorrowableInIsolationChanged(asset, borrowable); - 264 : : } - 265 : : - 266 : : /// @inheritdoc IPoolConfigurator - 267 : 8891 : function setReservePause( - 268 : : address asset, - 269 : : bool paused, - 270 : : uint40 gracePeriod - 271 : : ) public override onlyEmergencyOrPoolAdmin { - 272 : : // Only setting grace period if the transition is paused -> unpaused - 273 : 35582 : if (!paused && gracePeriod != 0) { - 274 : 16056 : require(gracePeriod <= MAX_GRACE_PERIOD, Errors.INVALID_GRACE_PERIOD); + 187 : : /// @inheritdoc IPoolConfigurator + 188 : : function setReserveActive(address asset, bool active) external override onlyPoolAdmin { + 189 : 11 : if (!active) _checkNoSuppliers(asset); + 190 : 10 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 191 : 10 : currentConfig.setActive(active); + 192 : 10 : _pool.setConfiguration(asset, currentConfig); + 193 : 10 : emit ReserveActive(asset, active); + 194 : : } + 195 : : + 196 : : /// @inheritdoc IPoolConfigurator + 197 : : function setReserveFreeze( + 198 : : address asset, + 199 : : bool freeze + 200 : : ) external override onlyRiskOrPoolOrEmergencyAdmins { + 201 : 2014 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 202 : : + 203 : 2014 : require(freeze != currentConfig.getFrozen(), Errors.INVALID_FREEZE_STATE); + 204 : : + 205 : 2012 : currentConfig.setFrozen(freeze); + 206 : : + 207 : 2012 : uint256 ltvSet; + 208 : 2012 : uint256 pendingLtvSet; + 209 : : + 210 : 2012 : if (freeze) { + 211 : 1010 : pendingLtvSet = currentConfig.getLtv(); + 212 : 1010 : _pendingLtv[asset] = pendingLtvSet; + 213 : 1010 : currentConfig.setLtv(0); + 214 : : } else { + 215 : 1002 : ltvSet = _pendingLtv[asset]; + 216 : 1002 : currentConfig.setLtv(ltvSet); + 217 : 1002 : delete _pendingLtv[asset]; + 218 : : } + 219 : : + 220 : 2012 : emit PendingLtvChanged(asset, pendingLtvSet); + 221 : 2012 : emit CollateralConfigurationChanged( + 222 : : asset, + 223 : : ltvSet, + 224 : : currentConfig.getLiquidationThreshold(), + 225 : : currentConfig.getLiquidationBonus() + 226 : : ); + 227 : : + 228 : 2012 : _pool.setConfiguration(asset, currentConfig); + 229 : 2012 : emit ReserveFrozen(asset, freeze); + 230 : : } + 231 : : + 232 : : /// @inheritdoc IPoolConfigurator + 233 : : function setBorrowableInIsolation( + 234 : : address asset, + 235 : : bool borrowable + 236 : : ) external override onlyRiskOrPoolAdmins { + 237 : 1959 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 238 : 1959 : currentConfig.setBorrowableInIsolation(borrowable); + 239 : 1959 : _pool.setConfiguration(asset, currentConfig); + 240 : 1959 : emit BorrowableInIsolationChanged(asset, borrowable); + 241 : : } + 242 : : + 243 : : /// @inheritdoc IPoolConfigurator + 244 : : function setReservePause( + 245 : : address asset, + 246 : : bool paused, + 247 : : uint40 gracePeriod + 248 : : ) public override onlyEmergencyOrPoolAdmin { + 249 : 14022 : if (!paused && gracePeriod != 0) { + 250 : 10411 : require(gracePeriod <= MAX_GRACE_PERIOD, Errors.INVALID_GRACE_PERIOD); + 251 : : + 252 : 9411 : uint40 until = uint40(block.timestamp) + gracePeriod; + 253 : 9411 : _pool.setLiquidationGracePeriod(asset, until); + 254 : 9411 : emit LiquidationGracePeriodChanged(asset, until); + 255 : : } + 256 : : + 257 : 13022 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 258 : 13022 : currentConfig.setPaused(paused); + 259 : 13022 : _pool.setConfiguration(asset, currentConfig); + 260 : 13022 : emit ReservePaused(asset, paused); + 261 : : } + 262 : : + 263 : : /// @inheritdoc IPoolConfigurator + 264 : : function setReservePause(address asset, bool paused) external override onlyEmergencyOrPoolAdmin { + 265 : 1001 : setReservePause(asset, paused, 0); + 266 : : } + 267 : : + 268 : : /// @inheritdoc IPoolConfigurator + 269 : : function disableLiquidationGracePeriod(address asset) external override onlyEmergencyOrPoolAdmin { + 270 : : // set the liquidation grace period in the past to disable liquidation grace period + 271 : 1001 : _pool.setLiquidationGracePeriod(asset, 0); + 272 : : + 273 : 1001 : emit LiquidationGracePeriodDisabled(asset); + 274 : : } 275 : : - 276 : 28112 : uint40 until = uint40(block.timestamp) + gracePeriod; - 277 : 14056 : _pool.setLiquidationGracePeriod(asset, until); - 278 : 14056 : emit LiquidationGracePeriodChanged(asset, until); - 279 : : } - 280 : : - 281 : 23700 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 282 : 15800 : currentConfig.setPaused(paused); - 283 : 15800 : _pool.setConfiguration(asset, currentConfig); - 284 : 15800 : emit ReservePaused(asset, paused); - 285 : : } - 286 : : - 287 : : /// @inheritdoc IPoolConfigurator - 288 : : function setReservePause(address asset, bool paused) public override onlyEmergencyOrPoolAdmin { - 289 : 0 : setReservePause(asset, paused, 0); - 290 : : } - 291 : : - 292 : : /// @inheritdoc IPoolConfigurator - 293 : 1749 : function setReserveFactor( - 294 : : address asset, - 295 : : uint256 newReserveFactor - 296 : : ) external override onlyRiskOrPoolAdmins { - 297 : 3496 : require(newReserveFactor <= PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_RESERVE_FACTOR); - 298 : : - 299 : 3494 : _pool.syncIndexesState(asset); + 276 : : /// @inheritdoc IPoolConfigurator + 277 : : function setReserveFactor( + 278 : : address asset, + 279 : : uint256 newReserveFactor + 280 : : ) external override onlyRiskOrPoolAdmins { + 281 : 1949 : require(newReserveFactor <= PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_RESERVE_FACTOR); + 282 : : + 283 : 1948 : _pool.syncIndexesState(asset); + 284 : : + 285 : 1948 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 286 : 1948 : uint256 oldReserveFactor = currentConfig.getReserveFactor(); + 287 : 1948 : currentConfig.setReserveFactor(newReserveFactor); + 288 : 1948 : _pool.setConfiguration(asset, currentConfig); + 289 : 1948 : emit ReserveFactorChanged(asset, oldReserveFactor, newReserveFactor); + 290 : : + 291 : 1948 : _pool.syncRatesState(asset); + 292 : : } + 293 : : + 294 : : /// @inheritdoc IPoolConfigurator + 295 : : function setDebtCeiling( + 296 : : address asset, + 297 : : uint256 newDebtCeiling + 298 : : ) external override onlyRiskOrPoolAdmins { + 299 : 1964 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); 300 : : - 301 : 5241 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 302 : 5241 : uint256 oldReserveFactor = currentConfig.getReserveFactor(); - 303 : 3494 : currentConfig.setReserveFactor(newReserveFactor); - 304 : 3494 : _pool.setConfiguration(asset, currentConfig); - 305 : 3494 : emit ReserveFactorChanged(asset, oldReserveFactor, newReserveFactor); - 306 : : - 307 : 3494 : _pool.syncRatesState(asset); - 308 : : } - 309 : : - 310 : : /// @inheritdoc IPoolConfigurator - 311 : 1765 : function setDebtCeiling( - 312 : : address asset, - 313 : : uint256 newDebtCeiling - 314 : : ) external override onlyRiskOrPoolAdmins { - 315 : 5292 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 316 : : - 317 : 5292 : uint256 oldDebtCeiling = currentConfig.getDebtCeiling(); - 318 : 8819 : if (currentConfig.getLiquidationThreshold() != 0 && oldDebtCeiling == 0) { - 319 : 3520 : _checkNoSuppliers(asset); - 320 : : } - 321 : 3526 : currentConfig.setDebtCeiling(newDebtCeiling); - 322 : 3526 : _pool.setConfiguration(asset, currentConfig); - 323 : : - 324 : 3526 : if (newDebtCeiling == 0) { - 325 : 3498 : _pool.resetIsolationModeTotalDebt(asset); - 326 : : } - 327 : : - 328 : 3526 : emit DebtCeilingChanged(asset, oldDebtCeiling, newDebtCeiling); - 329 : : } + 301 : 1964 : uint256 oldDebtCeiling = currentConfig.getDebtCeiling(); + 302 : 1964 : if (currentConfig.getLiquidationThreshold() != 0 && oldDebtCeiling == 0) { + 303 : 1960 : _checkNoSuppliers(asset); + 304 : : } + 305 : 1963 : currentConfig.setDebtCeiling(newDebtCeiling); + 306 : 1963 : _pool.setConfiguration(asset, currentConfig); + 307 : : + 308 : 1963 : if (newDebtCeiling == 0) { + 309 : 1949 : _pool.resetIsolationModeTotalDebt(asset); + 310 : : } + 311 : : + 312 : 1963 : emit DebtCeilingChanged(asset, oldDebtCeiling, newDebtCeiling); + 313 : : } + 314 : : + 315 : : /// @inheritdoc IPoolConfigurator + 316 : : function setSiloedBorrowing( + 317 : : address asset, + 318 : : bool newSiloed + 319 : : ) external override onlyRiskOrPoolAdmins { + 320 : 1949 : if (newSiloed) { + 321 : 3 : _checkNoBorrowers(asset); + 322 : : } + 323 : 1948 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 324 : : + 325 : 1948 : bool oldSiloed = currentConfig.getSiloedBorrowing(); + 326 : : + 327 : 1948 : currentConfig.setSiloedBorrowing(newSiloed); + 328 : : + 329 : 1948 : _pool.setConfiguration(asset, currentConfig); 330 : : - 331 : : /// @inheritdoc IPoolConfigurator - 332 : 1749 : function setSiloedBorrowing( - 333 : : address asset, - 334 : : bool newSiloed - 335 : : ) external override onlyRiskOrPoolAdmins { - 336 : 1749 : if (newSiloed) { - 337 : 6 : _checkNoBorrowers(asset); - 338 : : } - 339 : 5244 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 340 : : - 341 : 5244 : bool oldSiloed = currentConfig.getSiloedBorrowing(); - 342 : : - 343 : 3496 : currentConfig.setSiloedBorrowing(newSiloed); - 344 : : - 345 : 3496 : _pool.setConfiguration(asset, currentConfig); - 346 : : - 347 : 3496 : emit SiloedBorrowingChanged(asset, oldSiloed, newSiloed); - 348 : : } - 349 : : - 350 : : /// @inheritdoc IPoolConfigurator - 351 : 1759 : function setBorrowCap( - 352 : : address asset, - 353 : : uint256 newBorrowCap - 354 : : ) external override onlyRiskOrPoolAdmins { - 355 : 5271 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 356 : 5271 : uint256 oldBorrowCap = currentConfig.getBorrowCap(); - 357 : 3514 : currentConfig.setBorrowCap(newBorrowCap); - 358 : 3512 : _pool.setConfiguration(asset, currentConfig); - 359 : 3512 : emit BorrowCapChanged(asset, oldBorrowCap, newBorrowCap); - 360 : : } - 361 : : - 362 : : /// @inheritdoc IPoolConfigurator - 363 : 1762 : function setSupplyCap( - 364 : : address asset, - 365 : : uint256 newSupplyCap - 366 : : ) external override onlyRiskOrPoolAdmins { - 367 : 5280 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 368 : 5280 : uint256 oldSupplyCap = currentConfig.getSupplyCap(); - 369 : 3520 : currentConfig.setSupplyCap(newSupplyCap); - 370 : 3518 : _pool.setConfiguration(asset, currentConfig); - 371 : 3518 : emit SupplyCapChanged(asset, oldSupplyCap, newSupplyCap); - 372 : : } - 373 : : - 374 : : /// @inheritdoc IPoolConfigurator - 375 : 1754 : function setLiquidationProtocolFee( - 376 : : address asset, - 377 : : uint256 newFee + 331 : 1948 : emit SiloedBorrowingChanged(asset, oldSiloed, newSiloed); + 332 : : } + 333 : : + 334 : : /// @inheritdoc IPoolConfigurator + 335 : : function setBorrowCap( + 336 : : address asset, + 337 : : uint256 newBorrowCap + 338 : : ) external override onlyRiskOrPoolAdmins { + 339 : 1956 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 340 : 1956 : uint256 oldBorrowCap = currentConfig.getBorrowCap(); + 341 : 1956 : currentConfig.setBorrowCap(newBorrowCap); + 342 : 1955 : _pool.setConfiguration(asset, currentConfig); + 343 : 1955 : emit BorrowCapChanged(asset, oldBorrowCap, newBorrowCap); + 344 : : } + 345 : : + 346 : : /// @inheritdoc IPoolConfigurator + 347 : : function setSupplyCap( + 348 : : address asset, + 349 : : uint256 newSupplyCap + 350 : : ) external override onlyRiskOrPoolAdmins { + 351 : 2962 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 352 : 2962 : uint256 oldSupplyCap = currentConfig.getSupplyCap(); + 353 : 2962 : currentConfig.setSupplyCap(newSupplyCap); + 354 : 2961 : _pool.setConfiguration(asset, currentConfig); + 355 : 2961 : emit SupplyCapChanged(asset, oldSupplyCap, newSupplyCap); + 356 : : } + 357 : : + 358 : : /// @inheritdoc IPoolConfigurator + 359 : : function setLiquidationProtocolFee( + 360 : : address asset, + 361 : : uint256 newFee + 362 : : ) external override onlyRiskOrPoolAdmins { + 363 : 1953 : require(newFee <= PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_LIQUIDATION_PROTOCOL_FEE); + 364 : 1951 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 365 : 1951 : uint256 oldFee = currentConfig.getLiquidationProtocolFee(); + 366 : 1951 : currentConfig.setLiquidationProtocolFee(newFee); + 367 : 1951 : _pool.setConfiguration(asset, currentConfig); + 368 : 1951 : emit LiquidationProtocolFeeChanged(asset, oldFee, newFee); + 369 : : } + 370 : : + 371 : : /// @inheritdoc IPoolConfigurator + 372 : : function setEModeCategory( + 373 : : uint8 categoryId, + 374 : : uint16 ltv, + 375 : : uint16 liquidationThreshold, + 376 : : uint16 liquidationBonus, + 377 : : string calldata label 378 : : ) external override onlyRiskOrPoolAdmins { - 379 : 3506 : require(newFee <= PercentageMath.PERCENTAGE_FACTOR, Errors.INVALID_LIQUIDATION_PROTOCOL_FEE); - 380 : 5253 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 381 : 5253 : uint256 oldFee = currentConfig.getLiquidationProtocolFee(); - 382 : 3502 : currentConfig.setLiquidationProtocolFee(newFee); - 383 : 3502 : _pool.setConfiguration(asset, currentConfig); - 384 : 3502 : emit LiquidationProtocolFeeChanged(asset, oldFee, newFee); - 385 : : } - 386 : : - 387 : : /// @inheritdoc IPoolConfigurator - 388 : 38 : function setEModeCategory( - 389 : : uint8 categoryId, - 390 : : uint16 ltv, - 391 : : uint16 liquidationThreshold, - 392 : : uint16 liquidationBonus, - 393 : : address oracle, - 394 : : string calldata label - 395 : : ) external override onlyRiskOrPoolAdmins { - 396 : 74 : require(ltv != 0, Errors.INVALID_EMODE_CATEGORY_PARAMS); - 397 : 72 : require(liquidationThreshold != 0, Errors.INVALID_EMODE_CATEGORY_PARAMS); + 379 : 10035 : require(ltv != 0, Errors.INVALID_EMODE_CATEGORY_PARAMS); + 380 : 10034 : require(liquidationThreshold != 0, Errors.INVALID_EMODE_CATEGORY_PARAMS); + 381 : : + 382 : : // validation of the parameters: the LTV can + 383 : : // only be lower or equal than the liquidation threshold + 384 : : // (otherwise a loan against the asset would cause instantaneous liquidation) + 385 : 10033 : require(ltv <= liquidationThreshold, Errors.INVALID_EMODE_CATEGORY_PARAMS); + 386 : 10032 : require( + 387 : : liquidationBonus > PercentageMath.PERCENTAGE_FACTOR, + 388 : : Errors.INVALID_EMODE_CATEGORY_PARAMS + 389 : : ); + 390 : : + 391 : : // if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment + 392 : : // a loan is taken there is enough collateral available to cover the liquidation bonus + 393 : 10030 : require( + 394 : : uint256(liquidationThreshold).percentMul(liquidationBonus) <= + 395 : : PercentageMath.PERCENTAGE_FACTOR, + 396 : : Errors.INVALID_EMODE_CATEGORY_PARAMS + 397 : : ); 398 : : - 399 : : // validation of the parameters: the LTV can - 400 : : // only be lower or equal than the liquidation threshold - 401 : : // (otherwise a loan against the asset would cause instantaneous liquidation) - 402 : 70 : require(ltv <= liquidationThreshold, Errors.INVALID_EMODE_CATEGORY_PARAMS); - 403 : 66 : require( - 404 : : liquidationBonus > PercentageMath.PERCENTAGE_FACTOR, - 405 : : Errors.INVALID_EMODE_CATEGORY_PARAMS - 406 : : ); - 407 : : - 408 : : // if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment - 409 : : // a loan is taken there is enough collateral available to cover the liquidation bonus - 410 : 62 : require( - 411 : : uint256(liquidationThreshold).percentMul(liquidationBonus) <= - 412 : : PercentageMath.PERCENTAGE_FACTOR, - 413 : : Errors.INVALID_EMODE_CATEGORY_PARAMS - 414 : : ); + 399 : 10029 : DataTypes.EModeCategoryBaseConfiguration memory categoryData; + 400 : 10029 : categoryData.ltv = ltv; + 401 : 10029 : categoryData.liquidationThreshold = liquidationThreshold; + 402 : 10029 : categoryData.liquidationBonus = liquidationBonus; + 403 : 10029 : categoryData.label = label; + 404 : : + 405 : 10029 : _pool.configureEModeCategory(categoryId, categoryData); + 406 : 10029 : emit EModeCategoryAdded( + 407 : : categoryId, + 408 : : ltv, + 409 : : liquidationThreshold, + 410 : : liquidationBonus, + 411 : : address(0), + 412 : : label + 413 : : ); + 414 : : } 415 : : - 416 : 90 : address[] memory reserves = _pool.getReservesList(); - 417 : 256 : for (uint256 i = 0; i < reserves.length; i++) { - 418 : 258 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(reserves[i]); - 419 : 258 : if (categoryId == currentConfig.getEModeCategory()) { - 420 : 6 : require(ltv > currentConfig.getLtv(), Errors.INVALID_EMODE_CATEGORY_PARAMS); - 421 : 2 : require( - 422 : : liquidationThreshold > currentConfig.getLiquidationThreshold(), - 423 : : Errors.INVALID_EMODE_CATEGORY_PARAMS - 424 : : ); - 425 : : } - 426 : : } - 427 : : - 428 : 54 : _pool.configureEModeCategory( - 429 : : categoryId, - 430 : : DataTypes.EModeCategory({ - 431 : : ltv: ltv, - 432 : : liquidationThreshold: liquidationThreshold, - 433 : : liquidationBonus: liquidationBonus, - 434 : : priceSource: oracle, - 435 : : label: label - 436 : : }) - 437 : : ); - 438 : 54 : emit EModeCategoryAdded(categoryId, ltv, liquidationThreshold, liquidationBonus, oracle, label); - 439 : : } - 440 : : - 441 : : /// @inheritdoc IPoolConfigurator - 442 : 1786 : function setAssetEModeCategory( - 443 : : address asset, - 444 : : uint8 newCategoryId - 445 : : ) external override onlyRiskOrPoolAdmins { - 446 : 5355 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 447 : : - 448 : 3570 : if (newCategoryId != 0) { - 449 : 114 : DataTypes.EModeCategory memory categoryData = _pool.getEModeCategoryData(newCategoryId); - 450 : 76 : require( - 451 : : categoryData.liquidationThreshold > currentConfig.getLiquidationThreshold(), - 452 : : Errors.INVALID_EMODE_CATEGORY_ASSIGNMENT - 453 : : ); - 454 : : } - 455 : 5352 : uint256 oldCategoryId = currentConfig.getEModeCategory(); - 456 : 3568 : currentConfig.setEModeCategory(newCategoryId); - 457 : 3568 : _pool.setConfiguration(asset, currentConfig); - 458 : 3568 : emit EModeAssetCategoryChanged(asset, uint8(oldCategoryId), newCategoryId); - 459 : : } - 460 : : - 461 : : /// @inheritdoc IPoolConfigurator - 462 : 7 : function setUnbackedMintCap( - 463 : : address asset, - 464 : : uint256 newUnbackedMintCap - 465 : : ) external override onlyRiskOrPoolAdmins { - 466 : 21 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - 467 : 21 : uint256 oldUnbackedMintCap = currentConfig.getUnbackedMintCap(); - 468 : 14 : currentConfig.setUnbackedMintCap(newUnbackedMintCap); - 469 : 14 : _pool.setConfiguration(asset, currentConfig); - 470 : 14 : emit UnbackedMintCapChanged(asset, oldUnbackedMintCap, newUnbackedMintCap); + 416 : : /// @inheritdoc IPoolConfigurator + 417 : : function setAssetCollateralInEMode( + 418 : : address asset, + 419 : : uint8 categoryId, + 420 : : bool allowed + 421 : : ) external override onlyRiskOrPoolAdmins { + 422 : 10039 : uint128 collateralBitmap = _pool.getEModeCategoryCollateralBitmap(categoryId); + 423 : 10039 : DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + 424 : 10039 : require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); + 425 : 10039 : collateralBitmap = EModeConfiguration.setReserveBitmapBit( + 426 : : collateralBitmap, + 427 : : reserveData.id, + 428 : : allowed + 429 : : ); + 430 : 10039 : _pool.configureEModeCategoryCollateralBitmap(categoryId, collateralBitmap); + 431 : 10039 : emit AssetCollateralInEModeChanged(asset, categoryId, allowed); + 432 : : } + 433 : : + 434 : : /// @inheritdoc IPoolConfigurator + 435 : : function setAssetBorrowableInEMode( + 436 : : address asset, + 437 : : uint8 categoryId, + 438 : : bool borrowable + 439 : : ) external override onlyRiskOrPoolAdmins { + 440 : 7010 : uint128 borrowableBitmap = _pool.getEModeCategoryBorrowableBitmap(categoryId); + 441 : 7010 : DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + 442 : 7010 : require(reserveData.id != 0 || _pool.getReservesList()[0] == asset, Errors.ASSET_NOT_LISTED); + 443 : 7010 : borrowableBitmap = EModeConfiguration.setReserveBitmapBit( + 444 : : borrowableBitmap, + 445 : : reserveData.id, + 446 : : borrowable + 447 : : ); + 448 : 7010 : _pool.configureEModeCategoryBorrowableBitmap(categoryId, borrowableBitmap); + 449 : 7010 : emit AssetBorrowableInEModeChanged(asset, categoryId, borrowable); + 450 : : } + 451 : : + 452 : : /// @inheritdoc IPoolConfigurator + 453 : : function setUnbackedMintCap( + 454 : : address asset, + 455 : : uint256 newUnbackedMintCap + 456 : : ) external override onlyRiskOrPoolAdmins { + 457 : 7 : DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); + 458 : 7 : uint256 oldUnbackedMintCap = currentConfig.getUnbackedMintCap(); + 459 : 7 : currentConfig.setUnbackedMintCap(newUnbackedMintCap); + 460 : 7 : _pool.setConfiguration(asset, currentConfig); + 461 : 7 : emit UnbackedMintCapChanged(asset, oldUnbackedMintCap, newUnbackedMintCap); + 462 : : } + 463 : : + 464 : : /// @inheritdoc IPoolConfigurator + 465 : : function setReserveInterestRateData( + 466 : : address asset, + 467 : : bytes calldata rateData + 468 : : ) external onlyRiskOrPoolAdmins { + 469 : 2 : DataTypes.ReserveDataLegacy memory reserve = _pool.getReserveData(asset); + 470 : 2 : _updateInterestRateStrategy(asset, reserve, reserve.interestRateStrategyAddress, rateData); 471 : : } 472 : : 473 : : /// @inheritdoc IPoolConfigurator - 474 : 0 : function setReserveInterestRateData( + 474 : : function setReserveInterestRateStrategyAddress( 475 : : address asset, - 476 : : bytes calldata rateData - 477 : : ) external onlyRiskOrPoolAdmins { - 478 : 0 : DataTypes.ReserveDataLegacy memory reserve = _pool.getReserveData(asset); - 479 : 0 : _updateInterestRateStrategy(asset, reserve, reserve.interestRateStrategyAddress, rateData); - 480 : : } - 481 : : - 482 : : /// @inheritdoc IPoolConfigurator - 483 : 5 : function setReserveInterestRateStrategyAddress( - 484 : : address asset, - 485 : : address rateStrategyAddress, - 486 : : bytes calldata rateData - 487 : : ) external override onlyRiskOrPoolAdmins { - 488 : 12 : DataTypes.ReserveDataLegacy memory reserve = _pool.getReserveData(asset); - 489 : 8 : _updateInterestRateStrategy(asset, reserve, rateStrategyAddress, rateData); - 490 : : } - 491 : : - 492 : : /// @inheritdoc IPoolConfigurator - 493 : 3003 : function setPoolPause(bool paused, uint40 gracePeriod) public override onlyEmergencyOrPoolAdmin { - 494 : 3009 : address[] memory reserves = _pool.getReservesList(); - 495 : : - 496 : 9027 : for (uint256 i = 0; i < reserves.length; i++) { - 497 : 9027 : if (reserves[i] != address(0)) { - 498 : 6018 : setReservePause(reserves[i], paused, gracePeriod); - 499 : : } - 500 : : } - 501 : : } - 502 : : - 503 : : /// @inheritdoc IPoolConfigurator - 504 : : function setPoolPause(bool paused) external override onlyEmergencyOrPoolAdmin { - 505 : 0 : setPoolPause(paused, 0); - 506 : : } - 507 : : - 508 : : /// @inheritdoc IPoolConfigurator - 509 : 14 : function updateBridgeProtocolFee(uint256 newBridgeProtocolFee) external override onlyPoolAdmin { - 510 : 28 : require( - 511 : : newBridgeProtocolFee <= PercentageMath.PERCENTAGE_FACTOR, - 512 : : Errors.BRIDGE_PROTOCOL_FEE_INVALID - 513 : : ); - 514 : 39 : uint256 oldBridgeProtocolFee = _pool.BRIDGE_PROTOCOL_FEE(); - 515 : 26 : _pool.updateBridgeProtocolFee(newBridgeProtocolFee); - 516 : 26 : emit BridgeProtocolFeeUpdated(oldBridgeProtocolFee, newBridgeProtocolFee); - 517 : : } - 518 : : - 519 : : /// @inheritdoc IPoolConfigurator - 520 : 608 : function updateFlashloanPremiumTotal( - 521 : : uint128 newFlashloanPremiumTotal - 522 : : ) external override onlyPoolAdmin { - 523 : 1214 : require( - 524 : : newFlashloanPremiumTotal <= PercentageMath.PERCENTAGE_FACTOR, - 525 : : Errors.FLASHLOAN_PREMIUM_INVALID - 526 : : ); - 527 : 1818 : uint128 oldFlashloanPremiumTotal = _pool.FLASHLOAN_PREMIUM_TOTAL(); - 528 : 1212 : _pool.updateFlashloanPremiums(newFlashloanPremiumTotal, _pool.FLASHLOAN_PREMIUM_TO_PROTOCOL()); - 529 : 1212 : emit FlashloanPremiumTotalUpdated(oldFlashloanPremiumTotal, newFlashloanPremiumTotal); - 530 : : } - 531 : : - 532 : : /// @inheritdoc IPoolConfigurator - 533 : 608 : function updateFlashloanPremiumToProtocol( - 534 : : uint128 newFlashloanPremiumToProtocol - 535 : : ) external override onlyPoolAdmin { - 536 : 1214 : require( - 537 : : newFlashloanPremiumToProtocol <= PercentageMath.PERCENTAGE_FACTOR, - 538 : : Errors.FLASHLOAN_PREMIUM_INVALID - 539 : : ); - 540 : 1818 : uint128 oldFlashloanPremiumToProtocol = _pool.FLASHLOAN_PREMIUM_TO_PROTOCOL(); - 541 : 1212 : _pool.updateFlashloanPremiums(_pool.FLASHLOAN_PREMIUM_TOTAL(), newFlashloanPremiumToProtocol); - 542 : 1212 : emit FlashloanPremiumToProtocolUpdated( - 543 : : oldFlashloanPremiumToProtocol, - 544 : : newFlashloanPremiumToProtocol - 545 : : ); - 546 : : } - 547 : : - 548 : : /// @inheritdoc IPoolConfigurator - 549 : 2003 : function getPendingLtv(address asset) external view override returns (uint256, bool) { - 550 : 4006 : return (_pendingLtv[asset], _isPendingLtvSet[asset]); - 551 : : } - 552 : : - 553 : : /// @inheritdoc IPoolConfigurator - 554 : 1 : function getConfiguratorLogic() external pure returns (address) { - 555 : 3 : return address(ConfiguratorLogic); - 556 : : } - 557 : : - 558 : 4 : function _updateInterestRateStrategy( - 559 : : address asset, - 560 : : DataTypes.ReserveDataLegacy memory reserve, - 561 : : address newRateStrategyAddress, - 562 : : bytes calldata rateData - 563 : : ) internal { - 564 : 8 : address oldRateStrategyAddress = reserve.interestRateStrategyAddress; - 565 : : - 566 : 8 : _pool.syncIndexesState(asset); - 567 : : - 568 : 8 : IDefaultInterestRateStrategyV2(newRateStrategyAddress).setInterestRateParams(asset, rateData); - 569 : 8 : emit ReserveInterestRateDataChanged(asset, newRateStrategyAddress, rateData); + 476 : : address rateStrategyAddress, + 477 : : bytes calldata rateData + 478 : : ) external override onlyRiskOrPoolAdmins { + 479 : 44 : DataTypes.ReserveDataLegacy memory reserve = _pool.getReserveData(asset); + 480 : 44 : _updateInterestRateStrategy(asset, reserve, rateStrategyAddress, rateData); + 481 : : } + 482 : : + 483 : : /// @inheritdoc IPoolConfigurator + 484 : : function setPoolPause(bool paused, uint40 gracePeriod) public override onlyEmergencyOrPoolAdmin { + 485 : 1003 : address[] memory reserves = _pool.getReservesList(); + 486 : : + 487 : 1003 : for (uint256 i = 0; i < reserves.length; i++) { + 488 : 3009 : if (reserves[i] != address(0)) { + 489 : 3009 : setReservePause(reserves[i], paused, gracePeriod); + 490 : : } + 491 : : } + 492 : : } + 493 : : + 494 : : /// @inheritdoc IPoolConfigurator + 495 : : function setPoolPause(bool paused) external override onlyEmergencyOrPoolAdmin { + 496 : 3 : setPoolPause(paused, 0); + 497 : : } + 498 : : + 499 : : /// @inheritdoc IPoolConfigurator + 500 : : function updateBridgeProtocolFee(uint256 newBridgeProtocolFee) external override onlyPoolAdmin { + 501 : 14 : require( + 502 : : newBridgeProtocolFee <= PercentageMath.PERCENTAGE_FACTOR, + 503 : : Errors.BRIDGE_PROTOCOL_FEE_INVALID + 504 : : ); + 505 : 13 : uint256 oldBridgeProtocolFee = _pool.BRIDGE_PROTOCOL_FEE(); + 506 : 13 : _pool.updateBridgeProtocolFee(newBridgeProtocolFee); + 507 : 13 : emit BridgeProtocolFeeUpdated(oldBridgeProtocolFee, newBridgeProtocolFee); + 508 : : } + 509 : : + 510 : : /// @inheritdoc IPoolConfigurator + 511 : : function updateFlashloanPremiumTotal( + 512 : : uint128 newFlashloanPremiumTotal + 513 : : ) external override onlyPoolAdmin { + 514 : 682 : require( + 515 : : newFlashloanPremiumTotal <= PercentageMath.PERCENTAGE_FACTOR, + 516 : : Errors.FLASHLOAN_PREMIUM_INVALID + 517 : : ); + 518 : 681 : uint128 oldFlashloanPremiumTotal = _pool.FLASHLOAN_PREMIUM_TOTAL(); + 519 : 681 : _pool.updateFlashloanPremiums(newFlashloanPremiumTotal, _pool.FLASHLOAN_PREMIUM_TO_PROTOCOL()); + 520 : 681 : emit FlashloanPremiumTotalUpdated(oldFlashloanPremiumTotal, newFlashloanPremiumTotal); + 521 : : } + 522 : : + 523 : : /// @inheritdoc IPoolConfigurator + 524 : : function updateFlashloanPremiumToProtocol( + 525 : : uint128 newFlashloanPremiumToProtocol + 526 : : ) external override onlyPoolAdmin { + 527 : 682 : require( + 528 : : newFlashloanPremiumToProtocol <= PercentageMath.PERCENTAGE_FACTOR, + 529 : : Errors.FLASHLOAN_PREMIUM_INVALID + 530 : : ); + 531 : 681 : uint128 oldFlashloanPremiumToProtocol = _pool.FLASHLOAN_PREMIUM_TO_PROTOCOL(); + 532 : 681 : _pool.updateFlashloanPremiums(_pool.FLASHLOAN_PREMIUM_TOTAL(), newFlashloanPremiumToProtocol); + 533 : 681 : emit FlashloanPremiumToProtocolUpdated( + 534 : : oldFlashloanPremiumToProtocol, + 535 : : newFlashloanPremiumToProtocol + 536 : : ); + 537 : : } + 538 : : + 539 : : /// @inheritdoc IPoolConfigurator + 540 : : function getPendingLtv(address asset) external view override returns (uint256) { + 541 : 3003 : return _pendingLtv[asset]; + 542 : : } + 543 : : + 544 : : /// @inheritdoc IPoolConfigurator + 545 : : function getConfiguratorLogic() external pure returns (address) { + 546 : 1 : return address(ConfiguratorLogic); + 547 : : } + 548 : : + 549 : : function _updateInterestRateStrategy( + 550 : : address asset, + 551 : : DataTypes.ReserveDataLegacy memory reserve, + 552 : : address newRateStrategyAddress, + 553 : : bytes calldata rateData + 554 : : ) internal { + 555 : 46 : address oldRateStrategyAddress = reserve.interestRateStrategyAddress; + 556 : : + 557 : 46 : _pool.syncIndexesState(asset); + 558 : : + 559 : 46 : IDefaultInterestRateStrategyV2(newRateStrategyAddress).setInterestRateParams(asset, rateData); + 560 : 46 : emit ReserveInterestRateDataChanged(asset, newRateStrategyAddress, rateData); + 561 : : + 562 : 46 : if (oldRateStrategyAddress != newRateStrategyAddress) { + 563 : 44 : _pool.setReserveInterestRateStrategyAddress(asset, newRateStrategyAddress); + 564 : 44 : emit ReserveInterestRateStrategyChanged( + 565 : : asset, + 566 : : oldRateStrategyAddress, + 567 : : newRateStrategyAddress + 568 : : ); + 569 : : } 570 : : - 571 : 8 : if (oldRateStrategyAddress != newRateStrategyAddress) { - 572 : 8 : _pool.setReserveInterestRateStrategyAddress(asset, newRateStrategyAddress); - 573 : 8 : emit ReserveInterestRateStrategyChanged( - 574 : : asset, - 575 : : oldRateStrategyAddress, - 576 : : newRateStrategyAddress - 577 : : ); - 578 : : } - 579 : : - 580 : 8 : _pool.syncRatesState(asset); - 581 : : } - 582 : : - 583 : 1774 : function _checkNoSuppliers(address asset) internal view { - 584 : 5322 : DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); - 585 : 5322 : uint256 totalSupplied = IPoolDataProvider(_addressesProvider.getPoolDataProvider()) - 586 : : .getATokenTotalSupply(asset); - 587 : : - 588 : 3548 : require( - 589 : : totalSupplied == 0 && reserveData.accruedToTreasury == 0, - 590 : : Errors.RESERVE_LIQUIDITY_NOT_ZERO - 591 : : ); - 592 : : } - 593 : : - 594 : 3 : function _checkNoBorrowers(address asset) internal view { - 595 : 9 : uint256 totalDebt = IPoolDataProvider(_addressesProvider.getPoolDataProvider()).getTotalDebt( - 596 : : asset - 597 : : ); - 598 : 6 : require(totalDebt == 0, Errors.RESERVE_DEBT_NOT_ZERO); - 599 : : } - 600 : : - 601 : 1256 : function _onlyPoolAdmin() internal view { - 602 : 3768 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 603 : 2512 : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); - 604 : : } - 605 : : - 606 : 0 : function _onlyEmergencyAdmin() internal view { - 607 : 0 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 608 : 0 : require(aclManager.isEmergencyAdmin(msg.sender), Errors.CALLER_NOT_EMERGENCY_ADMIN); - 609 : : } - 610 : : - 611 : 14903 : function _onlyPoolOrEmergencyAdmin() internal view { - 612 : 44709 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 613 : 29806 : require( - 614 : : aclManager.isPoolAdmin(msg.sender) || aclManager.isEmergencyAdmin(msg.sender), - 615 : : Errors.CALLER_NOT_POOL_OR_EMERGENCY_ADMIN - 616 : : ); - 617 : : } - 618 : : - 619 : 2592 : function _onlyAssetListingOrPoolAdmins() internal view { - 620 : 7776 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 621 : 5184 : require( - 622 : : aclManager.isAssetListingAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), - 623 : : Errors.CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN - 624 : : ); - 625 : : } - 626 : : - 627 : 24323 : function _onlyRiskOrPoolAdmins() internal view { - 628 : 72969 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 629 : 48646 : require( - 630 : : aclManager.isRiskAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), - 631 : : Errors.CALLER_NOT_RISK_OR_POOL_ADMIN - 632 : : ); - 633 : : } - 634 : : - 635 : 1011 : function _onlyRiskOrPoolOrEmergencyAdmins() internal view { - 636 : 3033 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 637 : 2022 : require( - 638 : : aclManager.isRiskAdmin(msg.sender) || - 639 : : aclManager.isPoolAdmin(msg.sender) || - 640 : : aclManager.isEmergencyAdmin(msg.sender), - 641 : : Errors.CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN - 642 : : ); - 643 : : } - 644 : : } + 571 : 46 : _pool.syncRatesState(asset); + 572 : : } + 573 : : + 574 : : function _checkNoSuppliers(address asset) internal view { + 575 : 2971 : DataTypes.ReserveDataLegacy memory reserveData = _pool.getReserveData(asset); + 576 : 2971 : uint256 totalSupplied = IPoolDataProvider(_addressesProvider.getPoolDataProvider()) + 577 : : .getATokenTotalSupply(asset); + 578 : : + 579 : 2971 : require( + 580 : : totalSupplied == 0 && reserveData.accruedToTreasury == 0, + 581 : : Errors.RESERVE_LIQUIDITY_NOT_ZERO + 582 : : ); + 583 : : } + 584 : : + 585 : : function _checkNoBorrowers(address asset) internal view { + 586 : 3 : uint256 totalDebt = IPoolDataProvider(_addressesProvider.getPoolDataProvider()).getTotalDebt( + 587 : : asset + 588 : : ); + 589 : 3 : require(totalDebt == 0, Errors.RESERVE_DEBT_NOT_ZERO); + 590 : : } + 591 : : + 592 : : function _onlyPoolAdmin() internal view { + 593 : 7396 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 594 : 7396 : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); + 595 : : } + 596 : : + 597 : : function _onlyPoolOrEmergencyAdmin() internal view { + 598 : 24030 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 599 : 24030 : require( + 600 : : aclManager.isPoolAdmin(msg.sender) || aclManager.isEmergencyAdmin(msg.sender), + 601 : : Errors.CALLER_NOT_POOL_OR_EMERGENCY_ADMIN + 602 : : ); + 603 : : } + 604 : : + 605 : : function _onlyAssetListingOrPoolAdmins() internal view { + 606 : 8651 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 607 : 8651 : require( + 608 : : aclManager.isAssetListingAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), + 609 : : Errors.CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN + 610 : : ); + 611 : : } + 612 : : + 613 : : function _onlyRiskOrPoolAdmins() internal view { + 614 : 70679 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 615 : 70679 : require( + 616 : : aclManager.isRiskAdmin(msg.sender) || aclManager.isPoolAdmin(msg.sender), + 617 : : Errors.CALLER_NOT_RISK_OR_POOL_ADMIN + 618 : : ); + 619 : : } + 620 : : + 621 : : function _onlyRiskOrPoolOrEmergencyAdmins() internal view { + 622 : 3014 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 623 : 3014 : require( + 624 : : aclManager.isRiskAdmin(msg.sender) || + 625 : : aclManager.isPoolAdmin(msg.sender) || + 626 : : aclManager.isEmergencyAdmin(msg.sender), + 627 : : Errors.CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN + 628 : : ); + 629 : : } + 630 : : } @@ -720,8 +706,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/protocol/pool/index-sort-b.html b/report/protocol/pool/index-sort-b.html new file mode 100644 index 00000000..4a505ab3 --- /dev/null +++ b/report/protocol/pool/index-sort-b.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - protocol/pool + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/poolCoverageTotalHit
Test:lcov.info.pLines:99.4 %331329
Test Date:2024-09-24 09:34:24Functions:100.0 %119119
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Pool.sol +
100.0%
+
100.0 %2020-100.0 %99
Pool.sol +
98.3%98.3%
+
98.3 %121119-100.0 %6767
PoolConfigurator.sol +
100.0%
+
100.0 %190190-100.0 %4343
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/protocol/pool/index-sort-f.html b/report/protocol/pool/index-sort-f.html new file mode 100644 index 00000000..3acdb117 --- /dev/null +++ b/report/protocol/pool/index-sort-f.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - protocol/pool + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/poolCoverageTotalHit
Test:lcov.info.pLines:99.4 %331329
Test Date:2024-09-24 09:34:24Functions:100.0 %119119
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Pool.sol +
100.0%
+
100.0 %2020-100.0 %99
PoolConfigurator.sol +
100.0%
+
100.0 %190190-100.0 %4343
Pool.sol +
98.3%98.3%
+
98.3 %121119-100.0 %6767
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/protocol/pool/index-sort-l.html b/report/protocol/pool/index-sort-l.html new file mode 100644 index 00000000..67060566 --- /dev/null +++ b/report/protocol/pool/index-sort-l.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - protocol/pool + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/poolCoverageTotalHit
Test:lcov.info.pLines:99.4 %331329
Test Date:2024-09-24 09:34:24Functions:100.0 %119119
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
Pool.sol +
98.3%98.3%
+
98.3 %121119-100.0 %6767
L2Pool.sol +
100.0%
+
100.0 %2020-100.0 %99
PoolConfigurator.sol +
100.0%
+
100.0 %190190-100.0 %4343
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/protocol/pool/index.html b/report/protocol/pool/index.html new file mode 100644 index 00000000..2a47059c --- /dev/null +++ b/report/protocol/pool/index.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - lcov.info.p - protocol/pool + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - protocol/poolCoverageTotalHit
Test:lcov.info.pLines:99.4 %331329
Test Date:2024-09-24 09:34:24Functions:100.0 %119119
Branches:-00
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

File Sort by file nameLine Coverage Sort by line coverageBranch Coverage Sort by branch coverageFunction Coverage Sort by function coverage
Rate Total Hit Rate Total Hit Rate Total Hit
L2Pool.sol +
100.0%
+
100.0 %2020-100.0 %99
Pool.sol +
98.3%98.3%
+
98.3 %121119-100.0 %6767
PoolConfigurator.sol +
100.0%
+
100.0 %190190-100.0 %4343
+
+
+ + + + +
Generated by: LCOV version 2.1-1
+
+ + + diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func-c.html b/report/protocol/tokenization/AToken.sol.func-c.html similarity index 70% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func-c.html rename to report/protocol/tokenization/AToken.sol.func-c.html index 9d8e9ac6..c352b47a 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func-c.html +++ b/report/protocol/tokenization/AToken.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/AToken.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - AToken.sol (source / functions)top level - protocol/tokenization - AToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %16161717
0 0
- + - + @@ -79,107 +79,114 @@ - + - + - + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -187,8 +194,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
AToken.DOMAIN_SEPARATORAToken.mintToTreasury46
AToken.mintToTreasuryAToken.620
AToken.DOMAIN_SEPARATOR1004
AToken.nonces81008
AToken.permit153015
AToken.UNDERLYING_ASSET_ADDRESSAToken.transferOnLiquidation10058014
AToken._EIP712BaseIdAToken.handleRepayment347111038
AToken.transferOnLiquidationAToken.burn601511054
AToken.RESERVE_TREASURY_ADDRESSAToken.transferUnderlyingTo701815108
AToken.burnAToken.totalSupply705518137
AToken._transferAToken.balanceOf808631189
AToken.handleRepaymentAToken.UNDERLYING_ASSET_ADDRESS903934168
AToken.transferUnderlyingToAToken._transfer911042097
AToken.totalSupplyAToken.RESERVE_TREASURY_ADDRESS1094543085
AToken.mint1259443527
AToken.balanceOfAToken._EIP712BaseId15189166698
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func.html b/report/protocol/tokenization/AToken.sol.func.html similarity index 70% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func.html rename to report/protocol/tokenization/AToken.sol.func.html index d4c280e6..6a99c7dd 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.func.html +++ b/report/protocol/tokenization/AToken.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/AToken.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,84 +53,91 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - AToken.sol (source / functions)top level - protocol/tokenization - AToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %16161717
0 0
- + - + + + + + + + + - + - + - + - + - + - + - + - + - + @@ -144,14 +151,14 @@ - + - + @@ -165,21 +172,21 @@ - + - + - + @@ -187,8 +194,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
AToken.20
AToken.DOMAIN_SEPARATOR41004
AToken.RESERVE_TREASURY_ADDRESS701843085
AToken.UNDERLYING_ASSET_ADDRESS100534168
AToken._EIP712BaseId3471166698
AToken._transfer808642097
AToken.balanceOf1518931189
AToken.burn705511054
AToken.handleRepayment903911038
AToken.mint1259443527
AToken.nonces81008
AToken.permit153015
AToken.totalSupply1094518137
AToken.transferOnLiquidation60158014
AToken.transferUnderlyingTo911015108
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.gcov.html b/report/protocol/tokenization/AToken.sol.gcov.html similarity index 83% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.gcov.html rename to report/protocol/tokenization/AToken.sol.gcov.html index a1871e3d..f59846f3 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol.gcov.html +++ b/report/protocol/tokenization/AToken.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/AToken.sol - + LCOV - lcov.info.p - protocol/tokenization/AToken.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - AToken.sol (source / functions)top level - protocol/tokenization - AToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %16161717
0 0
@@ -75,7 +75,7 @@ 4 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 5 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; 6 : : import {SafeCast} from '../../dependencies/openzeppelin/contracts/SafeCast.sol'; - 7 : : import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; + 7 : : import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; 8 : : import {Errors} from '../libraries/helpers/Errors.sol'; 9 : : import {WadRayMath} from '../libraries/math/WadRayMath.sol'; 10 : : import {IPool} from '../../interfaces/IPool.sol'; @@ -125,82 +125,82 @@ 54 : : ) public virtual; 55 : : 56 : : /// @inheritdoc IAToken - 57 : 12594 : function mint( + 57 : : function mint( 58 : : address caller, 59 : : address onBehalfOf, 60 : : uint256 amount, 61 : : uint256 index 62 : : ) external virtual override onlyPool returns (bool) { - 63 : 37779 : return _mintScaled(caller, onBehalfOf, amount, index); + 63 : 43526 : return _mintScaled(caller, onBehalfOf, amount, index); 64 : : } 65 : : 66 : : /// @inheritdoc IAToken - 67 : 7055 : function burn( + 67 : : function burn( 68 : : address from, 69 : : address receiverOfUnderlying, 70 : : uint256 amount, 71 : : uint256 index 72 : : ) external virtual override onlyPool { - 73 : 14108 : _burnScaled(from, receiverOfUnderlying, amount, index); - 74 : 21156 : if (receiverOfUnderlying != address(this)) { - 75 : 12094 : IERC20(_underlyingAsset).safeTransfer(receiverOfUnderlying, amount); + 73 : 11053 : _burnScaled(from, receiverOfUnderlying, amount, index); + 74 : 11051 : if (receiverOfUnderlying != address(this)) { + 75 : 10046 : IERC20(_underlyingAsset).safeTransfer(receiverOfUnderlying, amount); 76 : : } 77 : : } 78 : : 79 : : /// @inheritdoc IAToken - 80 : 6 : function mintToTreasury(uint256 amount, uint256 index) external virtual override onlyPool { - 81 : 12 : if (amount == 0) { - 82 : 12 : return; + 80 : : function mintToTreasury(uint256 amount, uint256 index) external virtual override onlyPool { + 81 : 6 : if (amount == 0) { + 82 : 6 : return; 83 : : } - 84 : 10 : _mintScaled(address(POOL), _treasury, amount, index); + 84 : 5 : _mintScaled(address(POOL), _treasury, amount, index); 85 : : } 86 : : 87 : : /// @inheritdoc IAToken - 88 : 6015 : function transferOnLiquidation( + 88 : : function transferOnLiquidation( 89 : : address from, 90 : : address to, 91 : : uint256 value 92 : : ) external virtual override onlyPool { 93 : : // Being a normal transfer, the Transfer() and BalanceTransfer() are emitted 94 : : // so no need to emit a specific event here - 95 : 12028 : _transfer(from, to, value, false); + 95 : 8013 : _transfer(from, to, value, false); 96 : : } 97 : : 98 : : /// @inheritdoc IERC20 - 99 : 15189 : function balanceOf( + 99 : : function balanceOf( 100 : : address user 101 : : ) public view virtual override(IncentivizedERC20, IERC20) returns (uint256) { - 102 : 45567 : return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); + 102 : 31189 : return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); 103 : : } 104 : : 105 : : /// @inheritdoc IERC20 - 106 : 10945 : function totalSupply() public view virtual override(IncentivizedERC20, IERC20) returns (uint256) { - 107 : 32835 : uint256 currentSupplyScaled = super.totalSupply(); + 106 : : function totalSupply() public view virtual override(IncentivizedERC20, IERC20) returns (uint256) { + 107 : 18137 : uint256 currentSupplyScaled = super.totalSupply(); 108 : : - 109 : 21890 : if (currentSupplyScaled == 0) { - 110 : 3568 : return 0; + 109 : 18137 : if (currentSupplyScaled == 0) { + 110 : 1982 : return 0; 111 : : } 112 : : - 113 : 27483 : return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); + 113 : 16155 : return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); 114 : : } 115 : : 116 : : /// @inheritdoc IAToken - 117 : 7018 : function RESERVE_TREASURY_ADDRESS() external view override returns (address) { - 118 : 14036 : return _treasury; + 117 : : function RESERVE_TREASURY_ADDRESS() external view override returns (address) { + 118 : 43085 : return _treasury; 119 : : } 120 : : 121 : : /// @inheritdoc IAToken - 122 : 1005 : function UNDERLYING_ASSET_ADDRESS() external view override returns (address) { - 123 : 2010 : return _underlyingAsset; + 122 : : function UNDERLYING_ASSET_ADDRESS() external view override returns (address) { + 123 : 34168 : return _underlyingAsset; 124 : : } 125 : : 126 : : /// @inheritdoc IAToken - 127 : 9110 : function transferUnderlyingTo(address target, uint256 amount) external virtual override onlyPool { - 128 : 18218 : IERC20(_underlyingAsset).safeTransfer(target, amount); + 127 : : function transferUnderlyingTo(address target, uint256 amount) external virtual override onlyPool { + 128 : 15107 : IERC20(_underlyingAsset).safeTransfer(target, amount); 129 : : } 130 : : 131 : : /// @inheritdoc IAToken - 132 : 9039 : function handleRepayment( + 132 : : function handleRepayment( 133 : : address user, 134 : : address onBehalfOf, 135 : : uint256 amount @@ -209,7 +209,7 @@ 138 : : } 139 : : 140 : : /// @inheritdoc IAToken - 141 : 15 : function permit( + 141 : : function permit( 142 : : address owner, 143 : : address spender, 144 : : uint256 value, @@ -218,20 +218,20 @@ 147 : : bytes32 r, 148 : : bytes32 s 149 : : ) external override { - 150 : 30 : require(owner != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 150 : 3015 : require(owner != address(0), Errors.ZERO_ADDRESS_NOT_VALID); 151 : : //solium-disable-next-line - 152 : 28 : require(block.timestamp <= deadline, Errors.INVALID_EXPIRATION); - 153 : 24 : uint256 currentValidNonce = _nonces[owner]; - 154 : 36 : bytes32 digest = keccak256( + 152 : 3014 : require(block.timestamp <= deadline, Errors.INVALID_EXPIRATION); + 153 : 3012 : uint256 currentValidNonce = _nonces[owner]; + 154 : 3012 : bytes32 digest = keccak256( 155 : : abi.encodePacked( 156 : : '\x19\x01', 157 : : DOMAIN_SEPARATOR(), 158 : : keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)) 159 : : ) 160 : : ); - 161 : 24 : require(owner == ecrecover(digest, v, r, s), Errors.INVALID_SIGNATURE); - 162 : 20 : _nonces[owner] = currentValidNonce + 1; - 163 : 20 : _approve(owner, spender, value); + 161 : 3012 : require(owner == ecrecover(digest, v, r, s), Errors.INVALID_SIGNATURE); + 162 : 1010 : _nonces[owner] = currentValidNonce + 1; + 163 : 1010 : _approve(owner, spender, value); 164 : : } 165 : : 166 : : /** @@ -242,21 +242,21 @@ 171 : : * @param amount The amount getting transferred 172 : : * @param validate True if the transfer needs to be validated, false otherwise 173 : : */ - 174 : 8086 : function _transfer(address from, address to, uint256 amount, bool validate) internal virtual { - 175 : 14100 : address underlyingAsset = _underlyingAsset; + 174 : : function _transfer(address from, address to, uint256 amount, bool validate) internal virtual { + 175 : 25055 : address underlyingAsset = _underlyingAsset; 176 : : - 177 : 21150 : uint256 index = POOL.getReserveNormalizedIncome(underlyingAsset); + 177 : 25055 : uint256 index = POOL.getReserveNormalizedIncome(underlyingAsset); 178 : : - 179 : 21150 : uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); - 180 : 21150 : uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); + 179 : 25055 : uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); + 180 : 25055 : uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); 181 : : - 182 : 14100 : super._transfer(from, to, amount, index); + 182 : 25055 : super._transfer(from, to, amount, index); 183 : : - 184 : 7050 : if (validate) { - 185 : 2072 : POOL.finalizeTransfer(underlyingAsset, from, to, amount, fromBalanceBefore, toBalanceBefore); + 184 : 25055 : if (validate) { + 185 : 17042 : POOL.finalizeTransfer(underlyingAsset, from, to, amount, fromBalanceBefore, toBalanceBefore); 186 : : } 187 : : - 188 : 14098 : emit BalanceTransfer(from, to, amount.rayDiv(index), index); + 188 : 25054 : emit BalanceTransfer(from, to, amount.rayDiv(index), index); 189 : : } 190 : : 191 : : /** @@ -266,34 +266,34 @@ 195 : : * @param amount The amount getting transferred 196 : : */ 197 : : function _transfer(address from, address to, uint128 amount) internal virtual override { - 198 : 2072 : _transfer(from, to, amount, true); + 198 : 17042 : _transfer(from, to, amount, true); 199 : : } 200 : : 201 : : /** 202 : : * @dev Overrides the base function to fully implement IAToken 203 : : * @dev see `EIP712Base.DOMAIN_SEPARATOR()` for more detailed documentation 204 : : */ - 205 : 4 : function DOMAIN_SEPARATOR() public view override(IAToken, EIP712Base) returns (bytes32) { - 206 : 48 : return super.DOMAIN_SEPARATOR(); + 205 : : function DOMAIN_SEPARATOR() public view override(IAToken, EIP712Base) returns (bytes32) { + 206 : 4016 : return super.DOMAIN_SEPARATOR(); 207 : : } 208 : : 209 : : /** 210 : : * @dev Overrides the base function to fully implement IAToken 211 : : * @dev see `EIP712Base.nonces()` for more detailed documentation 212 : : */ - 213 : 8 : function nonces(address owner) public view override(IAToken, EIP712Base) returns (uint256) { - 214 : 24 : return super.nonces(owner); + 213 : : function nonces(address owner) public view override(IAToken, EIP712Base) returns (uint256) { + 214 : 1008 : return super.nonces(owner); 215 : : } 216 : : 217 : : /// @inheritdoc EIP712Base - 218 : 3471 : function _EIP712BaseId() internal view override returns (string memory) { - 219 : 10413 : return name(); + 218 : : function _EIP712BaseId() internal view override returns (string memory) { + 219 : 166698 : return name(); 220 : : } 221 : : 222 : : /// @inheritdoc IAToken - 223 : 3 : function rescueTokens(address token, address to, uint256 amount) external override onlyPoolAdmin { - 224 : 4 : require(token != _underlyingAsset, Errors.UNDERLYING_CANNOT_BE_RESCUED); - 225 : 2 : IERC20(token).safeTransfer(to, amount); + 223 : : function rescueTokens(address token, address to, uint256 amount) external override onlyPoolAdmin { + 224 : 2 : require(token != _underlyingAsset, Errors.UNDERLYING_CANNOT_BE_RESCUED); + 225 : 1 : IERC20(token).safeTransfer(to, amount); 226 : : } 227 : : } @@ -303,8 +303,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func-c.html b/report/protocol/tokenization/VariableDebtToken.sol.func-c.html similarity index 72% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func-c.html rename to report/protocol/tokenization/VariableDebtToken.sol.func-c.html index 967aa03f..455b50f7 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func-c.html +++ b/report/protocol/tokenization/VariableDebtToken.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/VariableDebtToken.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - VariableDebtToken.sol (source / functions)top level - protocol/tokenization - VariableDebtToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %12121313
0 0
- + - + @@ -116,42 +116,49 @@ - + - + - + - + - + - + - + - + - + + + + + + + + - + @@ -159,8 +166,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
VariableDebtToken.totalSupply1815
VariableDebtToken.UNDERLYING_ASSET_ADDRESSVariableDebtToken.burn102315035
VariableDebtToken._EIP712BaseIdVariableDebtToken.347615193
VariableDebtToken.mint909919091
VariableDebtToken.burnVariableDebtToken.balanceOf1104130602
VariableDebtToken.balanceOfVariableDebtToken.UNDERLYING_ASSET_ADDRESS51072
VariableDebtToken._EIP712BaseId26403172697
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func.html b/report/protocol/tokenization/VariableDebtToken.sol.func.html similarity index 72% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func.html rename to report/protocol/tokenization/VariableDebtToken.sol.func.html index b9aff45d..479b2768 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.func.html +++ b/report/protocol/tokenization/VariableDebtToken.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/VariableDebtToken.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - VariableDebtToken.sol (source / functions)top level - protocol/tokenization - VariableDebtToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %12121313
0 0
- + - + + + + + + + + - + - + @@ -102,14 +109,14 @@ - + - + @@ -130,14 +137,14 @@ - + - + @@ -159,8 +166,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
VariableDebtToken.15193
VariableDebtToken.UNDERLYING_ASSET_ADDRESS102351072
VariableDebtToken._EIP712BaseId3476172697
VariableDebtToken.balanceOf2640330602
VariableDebtToken.burn1104115035
VariableDebtToken.mint909919091
VariableDebtToken.totalSupply1815
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.gcov.html b/report/protocol/tokenization/VariableDebtToken.sol.gcov.html similarity index 80% rename from report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.gcov.html rename to report/protocol/tokenization/VariableDebtToken.sol.gcov.html index ffb1fe95..58832fd6 100644 --- a/report/core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol.gcov.html +++ b/report/protocol/tokenization/VariableDebtToken.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization/VariableDebtToken.sol - + LCOV - lcov.info.p - protocol/tokenization/VariableDebtToken.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/src/core/contracts/protocol/tokenization - VariableDebtToken.sol (source / functions)top level - protocol/tokenization - VariableDebtToken.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %12121313
0 0
@@ -74,7 +74,7 @@ 3 : : 4 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 5 : : import {SafeCast} from '../../dependencies/openzeppelin/contracts/SafeCast.sol'; - 6 : : import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; + 6 : : import {VersionedInitializable} from '../../misc/aave-upgradeability/VersionedInitializable.sol'; 7 : : import {WadRayMath} from '../libraries/math/WadRayMath.sol'; 8 : : import {Errors} from '../libraries/helpers/Errors.sol'; 9 : : import {IPool} from '../../interfaces/IPool.sol'; @@ -121,80 +121,80 @@ 50 : : ) external virtual; 51 : : 52 : : /// @inheritdoc IERC20 - 53 : 26403 : function balanceOf(address user) public view virtual override returns (uint256) { - 54 : 79209 : uint256 scaledBalance = super.balanceOf(user); + 53 : : function balanceOf(address user) public view virtual override returns (uint256) { + 54 : 30602 : uint256 scaledBalance = super.balanceOf(user); 55 : : - 56 : 52806 : if (scaledBalance == 0) { - 57 : 2418 : return 0; + 56 : 30602 : if (scaledBalance == 0) { + 57 : 1040 : return 0; 58 : : } 59 : : - 60 : 75582 : return scaledBalance.rayMul(POOL.getReserveNormalizedVariableDebt(_underlyingAsset)); + 60 : 29562 : return scaledBalance.rayMul(POOL.getReserveNormalizedVariableDebt(_underlyingAsset)); 61 : : } 62 : : 63 : : /// @inheritdoc IVariableDebtToken - 64 : 9099 : function mint( + 64 : : function mint( 65 : : address user, 66 : : address onBehalfOf, 67 : : uint256 amount, 68 : : uint256 index 69 : : ) external virtual override onlyPool returns (bool, uint256) { - 70 : 18198 : if (user != onBehalfOf) { - 71 : 4 : _decreaseBorrowAllowance(onBehalfOf, user, amount); + 70 : 19091 : if (user != onBehalfOf) { + 71 : 1001 : _decreaseBorrowAllowance(onBehalfOf, user, amount); 72 : : } - 73 : 18198 : return (_mintScaled(user, onBehalfOf, amount, index), scaledTotalSupply()); + 73 : 19091 : return (_mintScaled(user, onBehalfOf, amount, index), scaledTotalSupply()); 74 : : } 75 : : 76 : : /// @inheritdoc IVariableDebtToken - 77 : 11041 : function burn( + 77 : : function burn( 78 : : address from, 79 : : uint256 amount, 80 : : uint256 index 81 : : ) external virtual override onlyPool returns (uint256) { - 82 : 22082 : _burnScaled(from, address(0), amount, index); - 83 : 33123 : return scaledTotalSupply(); + 82 : 15035 : _burnScaled(from, address(0), amount, index); + 83 : 15035 : return scaledTotalSupply(); 84 : : } 85 : : 86 : : /// @inheritdoc IERC20 - 87 : 18 : function totalSupply() public view virtual override returns (uint256) { - 88 : 54 : return super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(_underlyingAsset)); + 87 : : function totalSupply() public view virtual override returns (uint256) { + 88 : 15 : return super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(_underlyingAsset)); 89 : : } 90 : : 91 : : /// @inheritdoc EIP712Base - 92 : 3476 : function _EIP712BaseId() internal view override returns (string memory) { - 93 : 10428 : return name(); + 92 : : function _EIP712BaseId() internal view override returns (string memory) { + 93 : 172697 : return name(); 94 : : } 95 : : 96 : : /** 97 : : * @dev Being non transferrable, the debt token does not implement any of the 98 : : * standard ERC20 functions for transfer and allowance. 99 : : */ - 100 : 1 : function transfer(address, uint256) external virtual override returns (bool) { - 101 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 100 : : function transfer(address, uint256) external virtual override returns (bool) { + 101 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 102 : : } 103 : : - 104 : 1 : function allowance(address, address) external view virtual override returns (uint256) { - 105 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 104 : : function allowance(address, address) external view virtual override returns (uint256) { + 105 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 106 : : } 107 : : - 108 : 1 : function approve(address, uint256) external virtual override returns (bool) { - 109 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 108 : : function approve(address, uint256) external virtual override returns (bool) { + 109 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 110 : : } 111 : : - 112 : 1 : function transferFrom(address, address, uint256) external virtual override returns (bool) { - 113 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 112 : : function transferFrom(address, address, uint256) external virtual override returns (bool) { + 113 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 114 : : } 115 : : - 116 : 1 : function increaseAllowance(address, uint256) external virtual override returns (bool) { - 117 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 116 : : function increaseAllowance(address, uint256) external virtual override returns (bool) { + 117 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 118 : : } 119 : : - 120 : 1 : function decreaseAllowance(address, uint256) external virtual override returns (bool) { - 121 : 2 : revert(Errors.OPERATION_NOT_SUPPORTED); + 120 : : function decreaseAllowance(address, uint256) external virtual override returns (bool) { + 121 : 1 : revert(Errors.OPERATION_NOT_SUPPORTED); 122 : : } 123 : : 124 : : /// @inheritdoc IVariableDebtToken - 125 : 1023 : function UNDERLYING_ASSET_ADDRESS() external view override returns (address) { - 126 : 2046 : return _underlyingAsset; + 125 : : function UNDERLYING_ASSET_ADDRESS() external view override returns (address) { + 126 : 51072 : return _underlyingAsset; 127 : : } 128 : : } @@ -204,8 +204,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func-c.html b/report/protocol/tokenization/base/DebtTokenBase.sol.func-c.html similarity index 66% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func-c.html rename to report/protocol/tokenization/base/DebtTokenBase.sol.func-c.html index 06a135db..f70d0811 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func-c.html +++ b/report/protocol/tokenization/base/DebtTokenBase.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/DebtTokenBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,11 +37,11 @@ - + - - + + @@ -53,56 +53,63 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - DebtTokenBase.sol (source / functions)top level - protocol/tokenization/base - DebtTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
DebtTokenBase._decreaseBorrowAllowanceDebtTokenBase.20
DebtTokenBase.approveDelegationDebtTokenBase.borrowAllowance35
DebtTokenBase.borrowAllowanceDebtTokenBase.delegationWithSig107
DebtTokenBase._approveDelegationDebtTokenBase._decreaseBorrowAllowance111001
DebtTokenBase.delegationWithSigDebtTokenBase.approveDelegation1001
DebtTokenBase._approveDelegation141005
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func.html b/report/protocol/tokenization/base/DebtTokenBase.sol.func.html similarity index 66% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func.html rename to report/protocol/tokenization/base/DebtTokenBase.sol.func.html index d0a60a25..60ac4de5 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.func.html +++ b/report/protocol/tokenization/base/DebtTokenBase.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/DebtTokenBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,11 +37,11 @@ - + - - + + @@ -53,56 +53,63 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - DebtTokenBase.sol (source / functions)top level - protocol/tokenization/base - DebtTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + + + + + + + + - + - + - + - + - + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
DebtTokenBase.Hit count Sort by function hit count0
DebtTokenBase._approveDelegation111005
DebtTokenBase._decreaseBorrowAllowance21001
DebtTokenBase.approveDelegation31001
DebtTokenBase.borrowAllowance105
DebtTokenBase.delegationWithSig147
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.gcov.html b/report/protocol/tokenization/base/DebtTokenBase.sol.gcov.html similarity index 83% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.gcov.html rename to report/protocol/tokenization/base/DebtTokenBase.sol.gcov.html index 55318c67..8f3fc231 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol.gcov.html +++ b/report/protocol/tokenization/base/DebtTokenBase.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/DebtTokenBase.sol - + LCOV - lcov.info.p - protocol/tokenization/base/DebtTokenBase.sol + - + - +
LCOV - code coverage report
- + @@ -37,11 +37,11 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - DebtTokenBase.sol (source / functions)top level - protocol/tokenization/base - DebtTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
@@ -74,14 +74,14 @@ 3 : : 4 : : import {Context} from '../../../dependencies/openzeppelin/contracts/Context.sol'; 5 : : import {Errors} from '../../libraries/helpers/Errors.sol'; - 6 : : import {VersionedInitializable} from '../../libraries/aave-upgradeability/VersionedInitializable.sol'; + 6 : : import {VersionedInitializable} from '../../../misc/aave-upgradeability/VersionedInitializable.sol'; 7 : : import {ICreditDelegationToken} from '../../../interfaces/ICreditDelegationToken.sol'; 8 : : import {EIP712Base} from './EIP712Base.sol'; 9 : : 10 : : /** 11 : : * @title DebtTokenBase 12 : : * @author Aave - 13 : : * @notice Base contract for different types of debt tokens, like StableDebtToken or VariableDebtToken + 13 : : * @notice Base contract for different types of debt tokens, like VariableDebtToken 14 : : */ 15 : : abstract contract DebtTokenBase is 16 : : VersionedInitializable, @@ -106,12 +106,12 @@ 35 : : } 36 : : 37 : : /// @inheritdoc ICreditDelegationToken - 38 : 3 : function approveDelegation(address delegatee, uint256 amount) external override { - 39 : 6 : _approveDelegation(_msgSender(), delegatee, amount); + 38 : : function approveDelegation(address delegatee, uint256 amount) external override { + 39 : 1001 : _approveDelegation(_msgSender(), delegatee, amount); 40 : : } 41 : : 42 : : /// @inheritdoc ICreditDelegationToken - 43 : 14 : function delegationWithSig( + 43 : : function delegationWithSig( 44 : : address delegator, 45 : : address delegatee, 46 : : uint256 value, @@ -120,11 +120,11 @@ 49 : : bytes32 r, 50 : : bytes32 s 51 : : ) external { - 52 : 28 : require(delegator != address(0), Errors.ZERO_ADDRESS_NOT_VALID); + 52 : 7 : require(delegator != address(0), Errors.ZERO_ADDRESS_NOT_VALID); 53 : : //solium-disable-next-line - 54 : 24 : require(block.timestamp <= deadline, Errors.INVALID_EXPIRATION); - 55 : 20 : uint256 currentValidNonce = _nonces[delegator]; - 56 : 30 : bytes32 digest = keccak256( + 54 : 6 : require(block.timestamp <= deadline, Errors.INVALID_EXPIRATION); + 55 : 5 : uint256 currentValidNonce = _nonces[delegator]; + 56 : 5 : bytes32 digest = keccak256( 57 : : abi.encodePacked( 58 : : '\x19\x01', 59 : : DOMAIN_SEPARATOR(), @@ -133,17 +133,17 @@ 62 : : ) 63 : : ) 64 : : ); - 65 : 20 : require(delegator == ecrecover(digest, v, r, s), Errors.INVALID_SIGNATURE); - 66 : 16 : _nonces[delegator] = currentValidNonce + 1; - 67 : 16 : _approveDelegation(delegator, delegatee, value); + 65 : 5 : require(delegator == ecrecover(digest, v, r, s), Errors.INVALID_SIGNATURE); + 66 : 4 : _nonces[delegator] = currentValidNonce + 1; + 67 : 4 : _approveDelegation(delegator, delegatee, value); 68 : : } 69 : : 70 : : /// @inheritdoc ICreditDelegationToken - 71 : 10 : function borrowAllowance( + 71 : : function borrowAllowance( 72 : : address fromUser, 73 : : address toUser 74 : : ) external view override returns (uint256) { - 75 : 20 : return _borrowAllowances[fromUser][toUser]; + 75 : 5 : return _borrowAllowances[fromUser][toUser]; 76 : : } 77 : : 78 : : /** @@ -152,9 +152,9 @@ 81 : : * @param delegatee The address receiving the delegated borrowing power 82 : : * @param amount The allowance amount being delegated. 83 : : */ - 84 : 11 : function _approveDelegation(address delegator, address delegatee, uint256 amount) internal { - 85 : 22 : _borrowAllowances[delegator][delegatee] = amount; - 86 : 22 : emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, amount); + 84 : : function _approveDelegation(address delegator, address delegatee, uint256 amount) internal { + 85 : 1005 : _borrowAllowances[delegator][delegatee] = amount; + 86 : 1005 : emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, amount); 87 : : } 88 : : 89 : : /** @@ -163,12 +163,12 @@ 92 : : * @param delegatee The address receiving the delegated borrowing power 93 : : * @param amount The amount to subtract from the current allowance 94 : : */ - 95 : 2 : function _decreaseBorrowAllowance(address delegator, address delegatee, uint256 amount) internal { - 96 : 6 : uint256 newAllowance = _borrowAllowances[delegator][delegatee] - amount; + 95 : : function _decreaseBorrowAllowance(address delegator, address delegatee, uint256 amount) internal { + 96 : 1001 : uint256 newAllowance = _borrowAllowances[delegator][delegatee] - amount; 97 : : - 98 : 4 : _borrowAllowances[delegator][delegatee] = newAllowance; + 98 : 1001 : _borrowAllowances[delegator][delegatee] = newAllowance; 99 : : - 100 : 4 : emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, newAllowance); + 100 : 1001 : emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, newAllowance); 101 : : } 102 : : } @@ -178,8 +178,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func-c.html b/report/protocol/tokenization/base/EIP712Base.sol.func-c.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func-c.html rename to report/protocol/tokenization/base/EIP712Base.sol.func-c.html index 92a5be95..c8730717 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func-c.html +++ b/report/protocol/tokenization/base/EIP712Base.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/EIP712Base.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,42 +53,49 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - EIP712Base.sol (source / functions)top level - protocol/tokenization/base - EIP712Base.sol (source / functions) Coverage Lines: 100.0 %6677
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3344
0 0
- + - + - + - + + + + + + + + - + @@ -96,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
EIP712Base.nonces101009
EIP712Base.DOMAIN_SEPARATOR164016
EIP712Base.15145
EIP712Base._calculateDomainSeparator10421339395
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func.html b/report/protocol/tokenization/base/EIP712Base.sol.func.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func.html rename to report/protocol/tokenization/base/EIP712Base.sol.func.html index 6eb42498..83e00732 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.func.html +++ b/report/protocol/tokenization/base/EIP712Base.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/EIP712Base.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,42 +53,49 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - EIP712Base.sol (source / functions)top level - protocol/tokenization/base - EIP712Base.sol (source / functions) Coverage Lines: 100.0 %6677
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3344
0 0
- + - + + + + + + + + - + - + - + @@ -96,8 +103,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
EIP712Base.15145
EIP712Base.DOMAIN_SEPARATOR164016
EIP712Base._calculateDomainSeparator10421339395
EIP712Base.nonces101009
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.gcov.html b/report/protocol/tokenization/base/EIP712Base.sol.gcov.html similarity index 82% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.gcov.html rename to report/protocol/tokenization/base/EIP712Base.sol.gcov.html index bbdf603a..6efe7901 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol.gcov.html +++ b/report/protocol/tokenization/base/EIP712Base.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/EIP712Base.sol - + LCOV - lcov.info.p - protocol/tokenization/base/EIP712Base.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - EIP712Base.sol (source / functions)top level - protocol/tokenization/base - EIP712Base.sol (source / functions) Coverage Lines: 100.0 %6677
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3344
0 0
@@ -92,7 +92,7 @@ 21 : : * @dev Constructor. 22 : : */ 23 : : constructor() { - 24 : : _chainId = block.chainid; + 24 : 15145 : _chainId = block.chainid; 25 : : } 26 : : 27 : : /** @@ -100,11 +100,11 @@ 29 : : * @dev Return cached value if chainId matches cache, otherwise recomputes separator 30 : : * @return The domain separator of the token at current chain 31 : : */ - 32 : 16 : function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { - 33 : 52 : if (block.chainid == _chainId) { - 34 : 50 : return _domainSeparator; + 32 : : function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { + 33 : 4021 : if (block.chainid == _chainId) { + 34 : 4020 : return _domainSeparator; 35 : : } - 36 : 3 : return _calculateDomainSeparator(); + 36 : 1 : return _calculateDomainSeparator(); 37 : : } 38 : : 39 : : /** @@ -112,17 +112,17 @@ 41 : : * @param owner The address for which the nonce is being returned 42 : : * @return The nonce value for the input address` 43 : : */ - 44 : 10 : function nonces(address owner) public view virtual returns (uint256) { - 45 : 20 : return _nonces[owner]; + 44 : : function nonces(address owner) public view virtual returns (uint256) { + 45 : 1009 : return _nonces[owner]; 46 : : } 47 : : 48 : : /** 49 : : * @notice Compute the current domain separator 50 : : * @return The domain separator for the token 51 : : */ - 52 : 10421 : function _calculateDomainSeparator() internal view returns (bytes32) { - 53 : 20842 : return - 54 : 20842 : keccak256( + 52 : : function _calculateDomainSeparator() internal view returns (bytes32) { + 53 : 339395 : return + 54 : 339395 : keccak256( 55 : : abi.encode( 56 : : EIP712_DOMAIN, 57 : : keccak256(bytes(_EIP712BaseId())), @@ -146,8 +146,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html b/report/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html similarity index 57% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html rename to report/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html index b94eb953..8780bbb3 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html +++ b/report/protocol/tokenization/base/IncentivizedERC20.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/IncentivizedERC20.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,147 +53,168 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - IncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - IncentivizedERC20.sol (source / functions) Coverage Lines: 100.0 %36364444
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %18182121
0 0
- + - + - + - + - + + + + + + + + - + - + - + - + - + - + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -201,8 +222,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
IncentivizedERC20.decreaseAllowanceIncentivizedERC20.decreaseAllowance 1
IncentivizedERC20.setIncentivesControllerIncentivizedERC20.setIncentivesController 2
IncentivizedERC20.increaseAllowanceIncentivizedERC20.onlyPoolAdmin3
IncentivizedERC20.increaseAllowance 4
IncentivizedERC20.approveIncentivizedERC20.allowance1626
IncentivizedERC20.transferFromIncentivizedERC20.transfer204018
IncentivizedERC20.allowanceIncentivizedERC20.267197
IncentivizedERC20.approve12021
IncentivizedERC20.transferFrom15025
IncentivizedERC20._approveIncentivizedERC20._transfer5125056
IncentivizedERC20.transferIncentivizedERC20._approve101726061
IncentivizedERC20.symbolIncentivizedERC20.onlyPool304134199
IncentivizedERC20.getIncentivesControllerIncentivizedERC20.getIncentivesController304481148
IncentivizedERC20.decimalsIncentivizedERC20.decimals305981163
IncentivizedERC20.nameIncentivizedERC20.symbol307381379
IncentivizedERC20._transferIncentivizedERC20.name705181404
IncentivizedERC20._setDecimalsIncentivizedERC20.totalSupply10420151623
IncentivizedERC20._setNameIncentivizedERC20.balanceOf10420339045
IncentivizedERC20._setSymbolIncentivizedERC20._setDecimals10420339394
IncentivizedERC20.totalSupplyIncentivizedERC20._setName82841339394
IncentivizedERC20.balanceOfIncentivizedERC20._setSymbol162500339394
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func.html b/report/protocol/tokenization/base/IncentivizedERC20.sol.func.html similarity index 57% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func.html rename to report/protocol/tokenization/base/IncentivizedERC20.sol.func.html index 9474a62e..784ef13b 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.func.html +++ b/report/protocol/tokenization/base/IncentivizedERC20.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/IncentivizedERC20.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,147 +53,168 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - IncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - IncentivizedERC20.sol (source / functions) Coverage Lines: 100.0 %36364444
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %18182121
0 0
- + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + @@ -201,8 +222,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
IncentivizedERC20._approveIncentivizedERC20.517197
IncentivizedERC20._setDecimalsIncentivizedERC20._approve1042026061
IncentivizedERC20._setNameIncentivizedERC20._setDecimals10420339394
IncentivizedERC20._setSymbolIncentivizedERC20._setName10420339394
IncentivizedERC20._transferIncentivizedERC20._setSymbol7051339394
IncentivizedERC20.allowanceIncentivizedERC20._transfer25056
IncentivizedERC20.allowance 26
IncentivizedERC20.approveIncentivizedERC20.approve1612021
IncentivizedERC20.balanceOfIncentivizedERC20.balanceOf162500339045
IncentivizedERC20.decimalsIncentivizedERC20.decimals305981163
IncentivizedERC20.decreaseAllowanceIncentivizedERC20.decreaseAllowance 1
IncentivizedERC20.getIncentivesControllerIncentivizedERC20.getIncentivesController304481148
IncentivizedERC20.increaseAllowanceIncentivizedERC20.increaseAllowance 4
IncentivizedERC20.nameIncentivizedERC20.name81404
IncentivizedERC20.onlyPool34199
IncentivizedERC20.onlyPoolAdmin30733
IncentivizedERC20.setIncentivesControllerIncentivizedERC20.setIncentivesController 2
IncentivizedERC20.symbolIncentivizedERC20.symbol304181379
IncentivizedERC20.totalSupplyIncentivizedERC20.totalSupply82841151623
IncentivizedERC20.transferIncentivizedERC20.transfer10174018
IncentivizedERC20.transferFromIncentivizedERC20.transferFrom2015025
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html b/report/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html similarity index 80% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html rename to report/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html index 83390ab6..19da5541 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html +++ b/report/protocol/tokenization/base/IncentivizedERC20.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/IncentivizedERC20.sol - + LCOV - lcov.info.p - protocol/tokenization/base/IncentivizedERC20.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - IncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - IncentivizedERC20.sol (source / functions) Coverage Lines: 100.0 %36364444
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %18182121
0 0
@@ -96,8 +96,8 @@ 25 : : * @dev Only pool admin can call functions marked by this modifier. 26 : : */ 27 : : modifier onlyPoolAdmin() { - 28 : : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); - 29 : : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); + 28 : 3 : IACLManager aclManager = IACLManager(_addressesProvider.getACLManager()); + 29 : 3 : require(aclManager.isPoolAdmin(msg.sender), Errors.CALLER_NOT_POOL_ADMIN); 30 : : _; 31 : : } 32 : : @@ -105,205 +105,204 @@ 34 : : * @dev Only pool can call functions marked by this modifier. 35 : : */ 36 : : modifier onlyPool() { - 37 : : require(_msgSender() == address(POOL), Errors.CALLER_MUST_BE_POOL); + 37 : 34199 : require(_msgSender() == address(POOL), Errors.CALLER_MUST_BE_POOL); 38 : : _; 39 : : } 40 : : 41 : : /** 42 : : * @dev UserState - additionalData is a flexible field. 43 : : * ATokens and VariableDebtTokens use this field store the index of the - 44 : : * user's last supply/withdrawal/borrow/repayment. StableDebtTokens use - 45 : : * this field to store the user's stable rate. - 46 : : */ - 47 : : struct UserState { - 48 : : uint128 balance; - 49 : : uint128 additionalData; - 50 : : } - 51 : : // Map of users address and their state data (userAddress => userStateData) - 52 : : mapping(address => UserState) internal _userState; - 53 : : - 54 : : // Map of allowances (delegator => delegatee => allowanceAmount) - 55 : : mapping(address => mapping(address => uint256)) private _allowances; - 56 : : - 57 : : uint256 internal _totalSupply; - 58 : : string private _name; - 59 : : string private _symbol; - 60 : : uint8 private _decimals; - 61 : : IAaveIncentivesController internal _incentivesController; - 62 : : IPoolAddressesProvider internal immutable _addressesProvider; - 63 : : IPool public immutable POOL; - 64 : : - 65 : : /** - 66 : : * @dev Constructor. - 67 : : * @param pool The reference to the main Pool contract - 68 : : * @param name_ The name of the token - 69 : : * @param symbol_ The symbol of the token - 70 : : * @param decimals_ The number of decimals of the token - 71 : : */ - 72 : : constructor(IPool pool, string memory name_, string memory symbol_, uint8 decimals_) { - 73 : : _addressesProvider = pool.ADDRESSES_PROVIDER(); - 74 : : _name = name_; - 75 : : _symbol = symbol_; - 76 : : _decimals = decimals_; - 77 : : POOL = pool; - 78 : : } - 79 : : - 80 : : /// @inheritdoc IERC20Detailed - 81 : 3073 : function name() public view override returns (string memory) { - 82 : 26988 : return _name; - 83 : : } - 84 : : - 85 : : /// @inheritdoc IERC20Detailed - 86 : 3041 : function symbol() external view override returns (string memory) { - 87 : 6082 : return _symbol; - 88 : : } - 89 : : - 90 : : /// @inheritdoc IERC20Detailed - 91 : 3059 : function decimals() external view override returns (uint8) { - 92 : 6118 : return _decimals; - 93 : : } - 94 : : - 95 : : /// @inheritdoc IERC20 - 96 : 82841 : function totalSupply() public view virtual override returns (uint256) { - 97 : 165682 : return _totalSupply; - 98 : : } - 99 : : - 100 : : /// @inheritdoc IERC20 - 101 : 162500 : function balanceOf(address account) public view virtual override returns (uint256) { - 102 : 325004 : return _userState[account].balance; - 103 : : } - 104 : : - 105 : : /** - 106 : : * @notice Returns the address of the Incentives Controller contract - 107 : : * @return The address of the Incentives Controller - 108 : : */ - 109 : 3044 : function getIncentivesController() external view virtual returns (IAaveIncentivesController) { - 110 : 6088 : return _incentivesController; - 111 : : } - 112 : : - 113 : : /** - 114 : : * @notice Sets a new Incentives Controller - 115 : : * @param controller the new Incentives controller - 116 : : */ - 117 : 2 : function setIncentivesController(IAaveIncentivesController controller) external onlyPoolAdmin { - 118 : 2 : _incentivesController = controller; - 119 : : } - 120 : : - 121 : : /// @inheritdoc IERC20 - 122 : 1017 : function transfer(address recipient, uint256 amount) external virtual override returns (bool) { - 123 : 3051 : uint128 castAmount = amount.toUint128(); - 124 : 2032 : _transfer(_msgSender(), recipient, castAmount); - 125 : 2030 : return true; - 126 : : } - 127 : : - 128 : : /// @inheritdoc IERC20 - 129 : 26 : function allowance( - 130 : : address owner, - 131 : : address spender - 132 : : ) external view virtual override returns (uint256) { - 133 : 52 : return _allowances[owner][spender]; - 134 : : } - 135 : : - 136 : : /// @inheritdoc IERC20 - 137 : 16 : function approve(address spender, uint256 amount) external virtual override returns (bool) { - 138 : 32 : _approve(_msgSender(), spender, amount); - 139 : 32 : return true; - 140 : : } - 141 : : - 142 : : /// @inheritdoc IERC20 - 143 : 20 : function transferFrom( - 144 : : address sender, - 145 : : address recipient, - 146 : : uint256 amount - 147 : : ) external virtual override returns (bool) { - 148 : 60 : uint128 castAmount = amount.toUint128(); - 149 : 40 : _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - castAmount); - 150 : 40 : _transfer(sender, recipient, castAmount); - 151 : 40 : return true; - 152 : : } - 153 : : - 154 : : /** - 155 : : * @notice Increases the allowance of spender to spend _msgSender() tokens - 156 : : * @param spender The user allowed to spend on behalf of _msgSender() - 157 : : * @param addedValue The amount being added to the allowance - 158 : : * @return `true` - 159 : : */ - 160 : 4 : function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool) { - 161 : 8 : _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); - 162 : 8 : return true; - 163 : : } - 164 : : - 165 : : /** - 166 : : * @notice Decreases the allowance of spender to spend _msgSender() tokens - 167 : : * @param spender The user allowed to spend on behalf of _msgSender() - 168 : : * @param subtractedValue The amount being subtracted to the allowance - 169 : : * @return `true` - 170 : : */ - 171 : 1 : function decreaseAllowance( - 172 : : address spender, - 173 : : uint256 subtractedValue - 174 : : ) external virtual returns (bool) { - 175 : 2 : _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); - 176 : 2 : return true; - 177 : : } - 178 : : - 179 : : /** - 180 : : * @notice Transfers tokens between two users and apply incentives if defined. - 181 : : * @param sender The source address - 182 : : * @param recipient The destination address - 183 : : * @param amount The amount getting transferred - 184 : : */ - 185 : 7051 : function _transfer(address sender, address recipient, uint128 amount) internal virtual { - 186 : 14102 : uint128 oldSenderBalance = _userState[sender].balance; - 187 : 14102 : _userState[sender].balance = oldSenderBalance - amount; - 188 : 14102 : uint128 oldRecipientBalance = _userState[recipient].balance; - 189 : 14102 : _userState[recipient].balance = oldRecipientBalance + amount; - 190 : : - 191 : 14102 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; - 192 : 28204 : if (address(incentivesControllerLocal) != address(0)) { - 193 : 14100 : uint256 currentTotalSupply = _totalSupply; - 194 : 14100 : incentivesControllerLocal.handleAction(sender, currentTotalSupply, oldSenderBalance); - 195 : 14100 : if (sender != recipient) { - 196 : 14096 : incentivesControllerLocal.handleAction(recipient, currentTotalSupply, oldRecipientBalance); - 197 : : } - 198 : : } - 199 : : } - 200 : : - 201 : : /** - 202 : : * @notice Approve `spender` to use `amount` of `owner`s balance - 203 : : * @param owner The address owning the tokens - 204 : : * @param spender The address approved for spending - 205 : : * @param amount The amount of tokens to approve spending of - 206 : : */ - 207 : 51 : function _approve(address owner, address spender, uint256 amount) internal virtual { - 208 : 102 : _allowances[owner][spender] = amount; - 209 : 102 : emit Approval(owner, spender, amount); - 210 : : } - 211 : : - 212 : : /** - 213 : : * @notice Update the name of the token - 214 : : * @param newName The new name for the token - 215 : : */ - 216 : 10420 : function _setName(string memory newName) internal { - 217 : 20840 : _name = newName; - 218 : : } - 219 : : - 220 : : /** - 221 : : * @notice Update the symbol for the token - 222 : : * @param newSymbol The new symbol for the token - 223 : : */ - 224 : 10420 : function _setSymbol(string memory newSymbol) internal { - 225 : 20840 : _symbol = newSymbol; - 226 : : } - 227 : : - 228 : : /** - 229 : : * @notice Update the number of decimals for the token - 230 : : * @param newDecimals The new number of decimals for the token - 231 : : */ - 232 : 10420 : function _setDecimals(uint8 newDecimals) internal { - 233 : 20840 : _decimals = newDecimals; - 234 : : } - 235 : : } + 44 : : * user's last supply/withdrawal/borrow/repayment. + 45 : : */ + 46 : : struct UserState { + 47 : : uint128 balance; + 48 : : uint128 additionalData; + 49 : : } + 50 : : // Map of users address and their state data (userAddress => userStateData) + 51 : : mapping(address => UserState) internal _userState; + 52 : : + 53 : : // Map of allowances (delegator => delegatee => allowanceAmount) + 54 : : mapping(address => mapping(address => uint256)) private _allowances; + 55 : : + 56 : : uint256 internal _totalSupply; + 57 : : string private _name; + 58 : : string private _symbol; + 59 : : uint8 private _decimals; + 60 : : IAaveIncentivesController internal _incentivesController; + 61 : : IPoolAddressesProvider internal immutable _addressesProvider; + 62 : : IPool public immutable POOL; + 63 : : + 64 : : /** + 65 : : * @dev Constructor. + 66 : : * @param pool The reference to the main Pool contract + 67 : : * @param name_ The name of the token + 68 : : * @param symbol_ The symbol of the token + 69 : : * @param decimals_ The number of decimals of the token + 70 : : */ + 71 : : constructor(IPool pool, string memory name_, string memory symbol_, uint8 decimals_) { + 72 : 7197 : _addressesProvider = pool.ADDRESSES_PROVIDER(); + 73 : 15179 : _name = name_; + 74 : 7139 : _symbol = symbol_; + 75 : 7154 : _decimals = decimals_; + 76 : 15111 : POOL = pool; + 77 : : } + 78 : : + 79 : : /// @inheritdoc IERC20Detailed + 80 : : function name() public view override returns (string memory) { + 81 : 420799 : return _name; + 82 : : } + 83 : : + 84 : : /// @inheritdoc IERC20Detailed + 85 : : function symbol() external view override returns (string memory) { + 86 : 81379 : return _symbol; + 87 : : } + 88 : : + 89 : : /// @inheritdoc IERC20Detailed + 90 : : function decimals() external view override returns (uint8) { + 91 : 81163 : return _decimals; + 92 : : } + 93 : : + 94 : : /// @inheritdoc IERC20 + 95 : : function totalSupply() public view virtual override returns (uint256) { + 96 : 151623 : return _totalSupply; + 97 : : } + 98 : : + 99 : : /// @inheritdoc IERC20 + 100 : : function balanceOf(address account) public view virtual override returns (uint256) { + 101 : 339047 : return _userState[account].balance; + 102 : : } + 103 : : + 104 : : /** + 105 : : * @notice Returns the address of the Incentives Controller contract + 106 : : * @return The address of the Incentives Controller + 107 : : */ + 108 : : function getIncentivesController() external view virtual returns (IAaveIncentivesController) { + 109 : 81148 : return _incentivesController; + 110 : : } + 111 : : + 112 : : /** + 113 : : * @notice Sets a new Incentives Controller + 114 : : * @param controller the new Incentives controller + 115 : : */ + 116 : : function setIncentivesController(IAaveIncentivesController controller) external onlyPoolAdmin { + 117 : 1 : _incentivesController = controller; + 118 : : } + 119 : : + 120 : : /// @inheritdoc IERC20 + 121 : : function transfer(address recipient, uint256 amount) external virtual override returns (bool) { + 122 : 4018 : uint128 castAmount = amount.toUint128(); + 123 : 4017 : _transfer(_msgSender(), recipient, castAmount); + 124 : 4016 : return true; + 125 : : } + 126 : : + 127 : : /// @inheritdoc IERC20 + 128 : : function allowance( + 129 : : address owner, + 130 : : address spender + 131 : : ) external view virtual override returns (uint256) { + 132 : 26 : return _allowances[owner][spender]; + 133 : : } + 134 : : + 135 : : /// @inheritdoc IERC20 + 136 : : function approve(address spender, uint256 amount) external virtual override returns (bool) { + 137 : 12021 : _approve(_msgSender(), spender, amount); + 138 : 12021 : return true; + 139 : : } + 140 : : + 141 : : /// @inheritdoc IERC20 + 142 : : function transferFrom( + 143 : : address sender, + 144 : : address recipient, + 145 : : uint256 amount + 146 : : ) external virtual override returns (bool) { + 147 : 15025 : uint128 castAmount = amount.toUint128(); + 148 : 15025 : _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - castAmount); + 149 : 13025 : _transfer(sender, recipient, castAmount); + 150 : 13025 : return true; + 151 : : } + 152 : : + 153 : : /** + 154 : : * @notice Increases the allowance of spender to spend _msgSender() tokens + 155 : : * @param spender The user allowed to spend on behalf of _msgSender() + 156 : : * @param addedValue The amount being added to the allowance + 157 : : * @return `true` + 158 : : */ + 159 : : function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool) { + 160 : 4 : _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + 161 : 4 : return true; + 162 : : } + 163 : : + 164 : : /** + 165 : : * @notice Decreases the allowance of spender to spend _msgSender() tokens + 166 : : * @param spender The user allowed to spend on behalf of _msgSender() + 167 : : * @param subtractedValue The amount being subtracted to the allowance + 168 : : * @return `true` + 169 : : */ + 170 : : function decreaseAllowance( + 171 : : address spender, + 172 : : uint256 subtractedValue + 173 : : ) external virtual returns (bool) { + 174 : 1 : _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); + 175 : 1 : return true; + 176 : : } + 177 : : + 178 : : /** + 179 : : * @notice Transfers tokens between two users and apply incentives if defined. + 180 : : * @param sender The source address + 181 : : * @param recipient The destination address + 182 : : * @param amount The amount getting transferred + 183 : : */ + 184 : : function _transfer(address sender, address recipient, uint128 amount) internal virtual { + 185 : 25056 : uint128 oldSenderBalance = _userState[sender].balance; + 186 : 25056 : _userState[sender].balance = oldSenderBalance - amount; + 187 : 25056 : uint128 oldRecipientBalance = _userState[recipient].balance; + 188 : 25056 : _userState[recipient].balance = oldRecipientBalance + amount; + 189 : : + 190 : 25056 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; + 191 : 25056 : if (address(incentivesControllerLocal) != address(0)) { + 192 : 25055 : uint256 currentTotalSupply = _totalSupply; + 193 : 25055 : incentivesControllerLocal.handleAction(sender, currentTotalSupply, oldSenderBalance); + 194 : 25055 : if (sender != recipient) { + 195 : 25053 : incentivesControllerLocal.handleAction(recipient, currentTotalSupply, oldRecipientBalance); + 196 : : } + 197 : : } + 198 : : } + 199 : : + 200 : : /** + 201 : : * @notice Approve `spender` to use `amount` of `owner`s balance + 202 : : * @param owner The address owning the tokens + 203 : : * @param spender The address approved for spending + 204 : : * @param amount The amount of tokens to approve spending of + 205 : : */ + 206 : : function _approve(address owner, address spender, uint256 amount) internal virtual { + 207 : 26061 : _allowances[owner][spender] = amount; + 208 : 26061 : emit Approval(owner, spender, amount); + 209 : : } + 210 : : + 211 : : /** + 212 : : * @notice Update the name of the token + 213 : : * @param newName The new name for the token + 214 : : */ + 215 : : function _setName(string memory newName) internal { + 216 : 339394 : _name = newName; + 217 : : } + 218 : : + 219 : : /** + 220 : : * @notice Update the symbol for the token + 221 : : * @param newSymbol The new symbol for the token + 222 : : */ + 223 : : function _setSymbol(string memory newSymbol) internal { + 224 : 339394 : _symbol = newSymbol; + 225 : : } + 226 : : + 227 : : /** + 228 : : * @notice Update the number of decimals for the token + 229 : : * @param newDecimals The new number of decimals for the token + 230 : : */ + 231 : : function _setDecimals(uint8 newDecimals) internal { + 232 : 339394 : _decimals = newDecimals; + 233 : : } + 234 : : } @@ -311,8 +310,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html similarity index 64% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html rename to report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html index ad293ab2..3dcb41c6 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html +++ b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/MintableIncentivizedERC20.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + - + + + + + + + + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
MintableIncentivizedERC20.15169
MintableIncentivizedERC20._burn1809426087
MintableIncentivizedERC20._mint2169662621
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html similarity index 64% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html rename to report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html index 593e7ecc..d43afe23 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html +++ b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/MintableIncentivizedERC20.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,35 +53,42 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + - + + + + + + + + - + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
MintableIncentivizedERC20.15169
MintableIncentivizedERC20._burn1809426087
MintableIncentivizedERC20._mint2169662621
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html similarity index 80% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html rename to report/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html index 965f6679..842e74c0 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html +++ b/report/protocol/tokenization/base/MintableIncentivizedERC20.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/MintableIncentivizedERC20.sol - + LCOV - lcov.info.p - protocol/tokenization/base/MintableIncentivizedERC20.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions)top level - protocol/tokenization/base - MintableIncentivizedERC20.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
@@ -103,16 +103,16 @@ 32 : : * @param account The address receiving tokens 33 : : * @param amount The amount of tokens to mint 34 : : */ - 35 : 21696 : function _mint(address account, uint128 amount) internal virtual { - 36 : 43392 : uint256 oldTotalSupply = _totalSupply; - 37 : 43392 : _totalSupply = oldTotalSupply + amount; + 35 : : function _mint(address account, uint128 amount) internal virtual { + 36 : 62621 : uint256 oldTotalSupply = _totalSupply; + 37 : 62621 : _totalSupply = oldTotalSupply + amount; 38 : : - 39 : 43392 : uint128 oldAccountBalance = _userState[account].balance; - 40 : 43392 : _userState[account].balance = oldAccountBalance + amount; + 39 : 62621 : uint128 oldAccountBalance = _userState[account].balance; + 40 : 62621 : _userState[account].balance = oldAccountBalance + amount; 41 : : - 42 : 43392 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; - 43 : 86784 : if (address(incentivesControllerLocal) != address(0)) { - 44 : 43392 : incentivesControllerLocal.handleAction(account, oldTotalSupply, oldAccountBalance); + 42 : 62621 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; + 43 : 62621 : if (address(incentivesControllerLocal) != address(0)) { + 44 : 62621 : incentivesControllerLocal.handleAction(account, oldTotalSupply, oldAccountBalance); 45 : : } 46 : : } 47 : : @@ -121,17 +121,17 @@ 50 : : * @param account The account whose tokens are burnt 51 : : * @param amount The amount of tokens to burn 52 : : */ - 53 : 18094 : function _burn(address account, uint128 amount) internal virtual { - 54 : 36188 : uint256 oldTotalSupply = _totalSupply; - 55 : 36188 : _totalSupply = oldTotalSupply - amount; + 53 : : function _burn(address account, uint128 amount) internal virtual { + 54 : 26087 : uint256 oldTotalSupply = _totalSupply; + 55 : 26087 : _totalSupply = oldTotalSupply - amount; 56 : : - 57 : 36188 : uint128 oldAccountBalance = _userState[account].balance; - 58 : 36188 : _userState[account].balance = oldAccountBalance - amount; + 57 : 26087 : uint128 oldAccountBalance = _userState[account].balance; + 58 : 26087 : _userState[account].balance = oldAccountBalance - amount; 59 : : - 60 : 36186 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; + 60 : 26086 : IAaveIncentivesController incentivesControllerLocal = _incentivesController; 61 : : - 62 : 72372 : if (address(incentivesControllerLocal) != address(0)) { - 63 : 36186 : incentivesControllerLocal.handleAction(account, oldTotalSupply, oldAccountBalance); + 62 : 26086 : if (address(incentivesControllerLocal) != address(0)) { + 63 : 26086 : incentivesControllerLocal.handleAction(account, oldTotalSupply, oldAccountBalance); 64 : : } 65 : : } 66 : : } @@ -142,8 +142,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html similarity index 68% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html rename to report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html index ec6d699a..81fbdfc5 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html +++ b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/ScaledBalanceTokenBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions)top level - protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7788
0 0
- + - + @@ -84,39 +84,46 @@ + + + + + + + - + - + - + - + - + - + - + @@ -124,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
39
ScaledBalanceTokenBase.15136
ScaledBalanceTokenBase._transfer705125056
ScaledBalanceTokenBase._burnScaled1809526088
ScaledBalanceTokenBase._mintScaled2169762622
ScaledBalanceTokenBase.scaledTotalSupplyScaledBalanceTokenBase.scaledBalanceOf5171788301
ScaledBalanceTokenBase.scaledBalanceOfScaledBalanceTokenBase.scaledTotalSupply5289399324
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html similarity index 69% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html rename to report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html index b9f719d3..97d165d5 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html +++ b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol - functions - + LCOV - lcov.info.p - protocol/tokenization/base/ScaledBalanceTokenBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,42 +53,49 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions)top level - protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7788
0 0
- + - + + + + + + + + - + - + - + @@ -109,14 +116,14 @@ - + - + @@ -124,8 +131,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
ScaledBalanceTokenBase.15136
ScaledBalanceTokenBase._burnScaled1809526088
ScaledBalanceTokenBase._mintScaled2169762622
ScaledBalanceTokenBase._transfer705125056
ScaledBalanceTokenBase.scaledBalanceOf5289388301
ScaledBalanceTokenBase.scaledTotalSupply5171799324
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html similarity index 80% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html rename to report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html index 6cfe5084..bc1b261d 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html +++ b/report/protocol/tokenization/base/ScaledBalanceTokenBase.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol - + LCOV - lcov.info.p - protocol/tokenization/base/ScaledBalanceTokenBase.sol + - + - +
LCOV - code coverage report
- + @@ -37,12 +37,12 @@ - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions)top level - protocol/tokenization/base - ScaledBalanceTokenBase.sol (source / functions) Coverage
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %7788
0 0
@@ -105,25 +105,25 @@ 34 : : } 35 : : 36 : : /// @inheritdoc IScaledBalanceToken - 37 : 52893 : function scaledBalanceOf(address user) external view override returns (uint256) { - 38 : 158679 : return super.balanceOf(user); + 37 : : function scaledBalanceOf(address user) external view override returns (uint256) { + 38 : 88301 : return super.balanceOf(user); 39 : : } 40 : : 41 : : /// @inheritdoc IScaledBalanceToken - 42 : 21 : function getScaledUserBalanceAndSupply( + 42 : : function getScaledUserBalanceAndSupply( 43 : : address user 44 : : ) external view override returns (uint256, uint256) { - 45 : 42 : return (super.balanceOf(user), super.totalSupply()); + 45 : 21 : return (super.balanceOf(user), super.totalSupply()); 46 : : } 47 : : 48 : : /// @inheritdoc IScaledBalanceToken - 49 : 51717 : function scaledTotalSupply() public view virtual override returns (uint256) { - 50 : 215571 : return super.totalSupply(); + 49 : : function scaledTotalSupply() public view virtual override returns (uint256) { + 50 : 133450 : return super.totalSupply(); 51 : : } 52 : : 53 : : /// @inheritdoc IScaledBalanceToken - 54 : 39 : function getPreviousIndex(address user) external view virtual override returns (uint256) { - 55 : 78 : return _userState[user].additionalData; + 54 : : function getPreviousIndex(address user) external view virtual override returns (uint256) { + 55 : 39 : return _userState[user].additionalData; 56 : : } 57 : : 58 : : /** @@ -134,28 +134,28 @@ 63 : : * @param index The next liquidity index of the reserve 64 : : * @return `true` if the the previous balance of the user was 0 65 : : */ - 66 : 21697 : function _mintScaled( + 66 : : function _mintScaled( 67 : : address caller, 68 : : address onBehalfOf, 69 : : uint256 amount, 70 : : uint256 index 71 : : ) internal returns (bool) { - 72 : 65091 : uint256 amountScaled = amount.rayDiv(index); - 73 : 43394 : require(amountScaled != 0, Errors.INVALID_MINT_AMOUNT); + 72 : 62622 : uint256 amountScaled = amount.rayDiv(index); + 73 : 62622 : require(amountScaled != 0, Errors.INVALID_MINT_AMOUNT); 74 : : - 75 : 65088 : uint256 scaledBalance = super.balanceOf(onBehalfOf); - 76 : 86784 : uint256 balanceIncrease = scaledBalance.rayMul(index) - - 77 : 43392 : scaledBalance.rayMul(_userState[onBehalfOf].additionalData); + 75 : 62621 : uint256 scaledBalance = super.balanceOf(onBehalfOf); + 76 : 62621 : uint256 balanceIncrease = scaledBalance.rayMul(index) - + 77 : 62621 : scaledBalance.rayMul(_userState[onBehalfOf].additionalData); 78 : : - 79 : 43392 : _userState[onBehalfOf].additionalData = index.toUint128(); + 79 : 62621 : _userState[onBehalfOf].additionalData = index.toUint128(); 80 : : - 81 : 43392 : _mint(onBehalfOf, amountScaled.toUint128()); + 81 : 62621 : _mint(onBehalfOf, amountScaled.toUint128()); 82 : : - 83 : 65088 : uint256 amountToMint = amount + balanceIncrease; - 84 : 43392 : emit Transfer(address(0), onBehalfOf, amountToMint); - 85 : 43392 : emit Mint(caller, onBehalfOf, amountToMint, balanceIncrease, index); + 83 : 62621 : uint256 amountToMint = amount + balanceIncrease; + 84 : 62621 : emit Transfer(address(0), onBehalfOf, amountToMint); + 85 : 62621 : emit Mint(caller, onBehalfOf, amountToMint, balanceIncrease, index); 86 : : - 87 : 43392 : return (scaledBalance == 0); + 87 : 62621 : return (scaledBalance == 0); 88 : : } 89 : : 90 : : /** @@ -167,26 +167,26 @@ 96 : : * @param amount The amount getting burned 97 : : * @param index The variable debt index of the reserve 98 : : */ - 99 : 18095 : function _burnScaled(address user, address target, uint256 amount, uint256 index) internal { - 100 : 54285 : uint256 amountScaled = amount.rayDiv(index); - 101 : 36190 : require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT); + 99 : : function _burnScaled(address user, address target, uint256 amount, uint256 index) internal { + 100 : 26088 : uint256 amountScaled = amount.rayDiv(index); + 101 : 26088 : require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT); 102 : : - 103 : 54282 : uint256 scaledBalance = super.balanceOf(user); - 104 : 72376 : uint256 balanceIncrease = scaledBalance.rayMul(index) - - 105 : 36188 : scaledBalance.rayMul(_userState[user].additionalData); + 103 : 26087 : uint256 scaledBalance = super.balanceOf(user); + 104 : 26087 : uint256 balanceIncrease = scaledBalance.rayMul(index) - + 105 : 26087 : scaledBalance.rayMul(_userState[user].additionalData); 106 : : - 107 : 36188 : _userState[user].additionalData = index.toUint128(); + 107 : 26087 : _userState[user].additionalData = index.toUint128(); 108 : : - 109 : 36188 : _burn(user, amountScaled.toUint128()); + 109 : 26087 : _burn(user, amountScaled.toUint128()); 110 : : - 111 : 36186 : if (balanceIncrease > amount) { - 112 : 4416 : uint256 amountToMint = balanceIncrease - amount; - 113 : 2944 : emit Transfer(address(0), user, amountToMint); - 114 : 2944 : emit Mint(user, user, amountToMint, balanceIncrease, index); + 111 : 26086 : if (balanceIncrease > amount) { + 112 : 1560 : uint256 amountToMint = balanceIncrease - amount; + 113 : 1560 : emit Transfer(address(0), user, amountToMint); + 114 : 1560 : emit Mint(user, user, amountToMint, balanceIncrease, index); 115 : : } else { - 116 : 49863 : uint256 amountToBurn = amount - balanceIncrease; - 117 : 33242 : emit Transfer(user, address(0), amountToBurn); - 118 : 33242 : emit Burn(user, target, amountToBurn, balanceIncrease, index); + 116 : 24526 : uint256 amountToBurn = amount - balanceIncrease; + 117 : 24526 : emit Transfer(user, address(0), amountToBurn); + 118 : 24526 : emit Burn(user, target, amountToBurn, balanceIncrease, index); 119 : : } 120 : : } 121 : : @@ -198,31 +198,31 @@ 127 : : * @param amount The amount getting transferred 128 : : * @param index The next liquidity index of the reserve 129 : : */ - 130 : 7051 : function _transfer(address sender, address recipient, uint256 amount, uint256 index) internal { - 131 : 21153 : uint256 senderScaledBalance = super.balanceOf(sender); - 132 : 28204 : uint256 senderBalanceIncrease = senderScaledBalance.rayMul(index) - - 133 : 14102 : senderScaledBalance.rayMul(_userState[sender].additionalData); + 130 : : function _transfer(address sender, address recipient, uint256 amount, uint256 index) internal { + 131 : 25056 : uint256 senderScaledBalance = super.balanceOf(sender); + 132 : 25056 : uint256 senderBalanceIncrease = senderScaledBalance.rayMul(index) - + 133 : 25056 : senderScaledBalance.rayMul(_userState[sender].additionalData); 134 : : - 135 : 21153 : uint256 recipientScaledBalance = super.balanceOf(recipient); - 136 : 28204 : uint256 recipientBalanceIncrease = recipientScaledBalance.rayMul(index) - - 137 : 14102 : recipientScaledBalance.rayMul(_userState[recipient].additionalData); + 135 : 25056 : uint256 recipientScaledBalance = super.balanceOf(recipient); + 136 : 25056 : uint256 recipientBalanceIncrease = recipientScaledBalance.rayMul(index) - + 137 : 25056 : recipientScaledBalance.rayMul(_userState[recipient].additionalData); 138 : : - 139 : 14102 : _userState[sender].additionalData = index.toUint128(); - 140 : 14102 : _userState[recipient].additionalData = index.toUint128(); + 139 : 25056 : _userState[sender].additionalData = index.toUint128(); + 140 : 25056 : _userState[recipient].additionalData = index.toUint128(); 141 : : - 142 : 14102 : super._transfer(sender, recipient, amount.rayDiv(index).toUint128()); + 142 : 25056 : super._transfer(sender, recipient, amount.rayDiv(index).toUint128()); 143 : : - 144 : 14102 : if (senderBalanceIncrease > 0) { - 145 : 2006 : emit Transfer(address(0), sender, senderBalanceIncrease); - 146 : 2006 : emit Mint(_msgSender(), sender, senderBalanceIncrease, senderBalanceIncrease, index); + 144 : 25056 : if (senderBalanceIncrease > 0) { + 145 : 1003 : emit Transfer(address(0), sender, senderBalanceIncrease); + 146 : 1003 : emit Mint(_msgSender(), sender, senderBalanceIncrease, senderBalanceIncrease, index); 147 : : } 148 : : - 149 : 28202 : if (sender != recipient && recipientBalanceIncrease > 0) { - 150 : 2 : emit Transfer(address(0), recipient, recipientBalanceIncrease); - 151 : 2 : emit Mint(_msgSender(), recipient, recipientBalanceIncrease, recipientBalanceIncrease, index); + 149 : 25056 : if (sender != recipient && recipientBalanceIncrease > 0) { + 150 : 1 : emit Transfer(address(0), recipient, recipientBalanceIncrease); + 151 : 1 : emit Mint(_msgSender(), recipient, recipientBalanceIncrease, recipientBalanceIncrease, index); 152 : : } 153 : : - 154 : 14102 : emit Transfer(sender, recipient, amount); + 154 : 25056 : emit Transfer(sender, recipient, amount); 155 : : } 156 : : } @@ -232,8 +232,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-b.html b/report/protocol/tokenization/base/index-sort-b.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-b.html rename to report/protocol/tokenization/base/index-sort-b.html index 29cd7fa4..7e154b07 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-b.html +++ b/report/protocol/tokenization/base/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - + LCOV - lcov.info.p - protocol/tokenization/base + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/basetop level - protocol/tokenization/base Coverage Lines: 100.0 %115115124124
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %353597.6 %4241
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - DebtTokenBase.sol + DebtTokenBase.sol -
100.0%
+
100.0%
100.0 % 14 @@ -106,44 +106,44 @@ - - 100.0 % - 5 + 83.3 % + 6 5 - EIP712Base.sol + EIP712Base.sol -
100.0%
+
100.0%
100.0 % - 6 - 6 + 7 + 7 - 100.0 % - 3 - 3 + 4 + 4 - IncentivizedERC20.sol + IncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % - 36 - 36 + 44 + 44 - 100.0 % - 18 - 18 + 21 + 21 - MintableIncentivizedERC20.sol + MintableIncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % 14 @@ -152,13 +152,13 @@ 100.0 % - 2 - 2 + 3 + 3 - ScaledBalanceTokenBase.sol + ScaledBalanceTokenBase.sol -
100.0%
+
100.0%
100.0 % 45 @@ -167,16 +167,16 @@ 100.0 % - 7 - 7 + 8 + 8

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-f.html b/report/protocol/tokenization/base/index-sort-f.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-f.html rename to report/protocol/tokenization/base/index-sort-f.html index 2e83cf55..33cceeb2 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-f.html +++ b/report/protocol/tokenization/base/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - + LCOV - lcov.info.p - protocol/tokenization/base + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/basetop level - protocol/tokenization/base Coverage Lines: 100.0 %115115124124
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %353597.6 %4241
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - MintableIncentivizedERC20.sol + DebtTokenBase.sol -
100.0%
+
100.0%
100.0 % 14 @@ -106,18 +106,18 @@ - - 100.0 % - 2 - 2 + 83.3 % + 6 + 5 - EIP712Base.sol + MintableIncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % - 6 - 6 + 14 + 14 - @@ -126,24 +126,24 @@ 3 - DebtTokenBase.sol + EIP712Base.sol -
100.0%
+
100.0%
100.0 % - 14 - 14 + 7 + 7 - 100.0 % - 5 - 5 + 4 + 4 - ScaledBalanceTokenBase.sol + ScaledBalanceTokenBase.sol -
100.0%
+
100.0%
100.0 % 45 @@ -152,31 +152,31 @@ 100.0 % - 7 - 7 + 8 + 8 - IncentivizedERC20.sol + IncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % - 36 - 36 + 44 + 44 - 100.0 % - 18 - 18 + 21 + 21

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-l.html b/report/protocol/tokenization/base/index-sort-l.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-l.html rename to report/protocol/tokenization/base/index-sort-l.html index 0eea4c33..73d52925 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index-sort-l.html +++ b/report/protocol/tokenization/base/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - + LCOV - lcov.info.p - protocol/tokenization/base + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/basetop level - protocol/tokenization/base Coverage Lines: 100.0 %115115124124
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %353597.6 %4241
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - EIP712Base.sol + EIP712Base.sol -
100.0%
+
100.0%
100.0 % - 6 - 6 + 7 + 7 - 100.0 % - 3 - 3 + 4 + 4 - DebtTokenBase.sol + DebtTokenBase.sol -
100.0%
+
100.0%
100.0 % 14 @@ -121,14 +121,14 @@ - - 100.0 % - 5 + 83.3 % + 6 5 - MintableIncentivizedERC20.sol + MintableIncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % 14 @@ -137,28 +137,28 @@ 100.0 % - 2 - 2 + 3 + 3 - IncentivizedERC20.sol + IncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % - 36 - 36 + 44 + 44 - 100.0 % - 18 - 18 + 21 + 21 - ScaledBalanceTokenBase.sol + ScaledBalanceTokenBase.sol -
100.0%
+
100.0%
100.0 % 45 @@ -167,16 +167,16 @@ 100.0 % - 7 - 7 + 8 + 8

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index.html b/report/protocol/tokenization/base/index.html similarity index 62% rename from report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index.html rename to report/protocol/tokenization/base/index.html index 4296bf54..96058176 100644 --- a/report/core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base/index.html +++ b/report/protocol/tokenization/base/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/base - + LCOV - lcov.info.p - protocol/tokenization/base + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/protocol/tokenization/base/src/core/contracts/protocol/tokenization/basetop level - protocol/tokenization/base Coverage Lines: 100.0 %115115124124
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %353597.6 %4241
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,9 +96,9 @@ Hit - DebtTokenBase.sol + DebtTokenBase.sol -
100.0%
+
100.0%
100.0 % 14 @@ -106,44 +106,44 @@ - - 100.0 % - 5 + 83.3 % + 6 5 - EIP712Base.sol + EIP712Base.sol -
100.0%
+
100.0%
100.0 % - 6 - 6 + 7 + 7 - 100.0 % - 3 - 3 + 4 + 4 - IncentivizedERC20.sol + IncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % - 36 - 36 + 44 + 44 - 100.0 % - 18 - 18 + 21 + 21 - MintableIncentivizedERC20.sol + MintableIncentivizedERC20.sol -
100.0%
+
100.0%
100.0 % 14 @@ -152,13 +152,13 @@ 100.0 % - 2 - 2 + 3 + 3 - ScaledBalanceTokenBase.sol + ScaledBalanceTokenBase.sol -
100.0%
+
100.0%
100.0 % 45 @@ -167,16 +167,16 @@ 100.0 % - 7 - 7 + 8 + 8

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/index-sort-b.html b/report/protocol/tokenization/index-sort-b.html similarity index 59% rename from report/core/contracts/misc/src/core/contracts/misc/index-sort-b.html rename to report/protocol/tokenization/index-sort-b.html index 7d93d509..5b0ce9c8 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/index-sort-b.html +++ b/report/protocol/tokenization/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc - + LCOV - lcov.info.p - protocol/tokenization + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misctop level - protocol/tokenization Coverage Lines: 100.0 %93935555
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %20203030
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,42 +96,42 @@ Hit - AaveOracle.sol + AToken.sol -
100.0%
+
100.0%
100.0 % - 25 - 25 + 37 + 37 - 100.0 % - 9 - 9 + 17 + 17 - L2Encoder.sol + VariableDebtToken.sol -
100.0%
+
100.0%
100.0 % - 68 - 68 + 18 + 18 - 100.0 % - 11 - 11 + 13 + 13

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/index-sort-f.html b/report/protocol/tokenization/index-sort-f.html similarity index 59% rename from report/core/contracts/misc/src/core/contracts/misc/index-sort-f.html rename to report/protocol/tokenization/index-sort-f.html index a99df311..11806bda 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/index-sort-f.html +++ b/report/protocol/tokenization/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc - + LCOV - lcov.info.p - protocol/tokenization + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misctop level - protocol/tokenization Coverage Lines: 100.0 %93935555
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %20203030
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,42 +96,42 @@ Hit - AaveOracle.sol + VariableDebtToken.sol -
100.0%
+
100.0%
100.0 % - 25 - 25 + 18 + 18 - 100.0 % - 9 - 9 + 13 + 13 - L2Encoder.sol + AToken.sol -
100.0%
+
100.0%
100.0 % - 68 - 68 + 37 + 37 - 100.0 % - 11 - 11 + 17 + 17

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/index-sort-l.html b/report/protocol/tokenization/index-sort-l.html similarity index 59% rename from report/core/contracts/misc/src/core/contracts/misc/index-sort-l.html rename to report/protocol/tokenization/index-sort-l.html index 3464dc07..59ef346b 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/index-sort-l.html +++ b/report/protocol/tokenization/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc - + LCOV - lcov.info.p - protocol/tokenization + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misctop level - protocol/tokenization Coverage Lines: 100.0 %93935555
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %20203030
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,42 +96,42 @@ Hit - AaveOracle.sol + VariableDebtToken.sol -
100.0%
+
100.0%
100.0 % - 25 - 25 + 18 + 18 - 100.0 % - 9 - 9 + 13 + 13 - L2Encoder.sol + AToken.sol -
100.0%
+
100.0%
100.0 % - 68 - 68 + 37 + 37 - 100.0 % - 11 - 11 + 17 + 17

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/core/contracts/misc/src/core/contracts/misc/index.html b/report/protocol/tokenization/index.html similarity index 59% rename from report/core/contracts/misc/src/core/contracts/misc/index.html rename to report/protocol/tokenization/index.html index 1fd42a0a..6f6015ee 100644 --- a/report/core/contracts/misc/src/core/contracts/misc/index.html +++ b/report/protocol/tokenization/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - core/contracts/misc/src/core/contracts/misc - + LCOV - lcov.info.p - protocol/tokenization + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - core/contracts/misc/src/core/contracts/misctop level - protocol/tokenization Coverage Lines: 100.0 %93935555
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %20203030
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,42 +96,42 @@ Hit - AaveOracle.sol + AToken.sol -
100.0%
+
100.0%
100.0 % - 25 - 25 + 37 + 37 - 100.0 % - 9 - 9 + 17 + 17 - L2Encoder.sol + VariableDebtToken.sol -
100.0%
+
100.0%
100.0 % - 68 - 68 + 18 + 18 - 100.0 % - 11 - 11 + 13 + 13

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func-c.html b/report/rewards/EmissionManager.sol.func-c.html similarity index 68% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func-c.html rename to report/rewards/EmissionManager.sol.func-c.html index da53ffae..7861551c 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func-c.html +++ b/report/rewards/EmissionManager.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol - functions - + LCOV - lcov.info.p - rewards/EmissionManager.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - EmissionManager.sol (source / functions)top level - rewards - EmissionManager.sol (source / functions) Coverage Lines: 100.0 %16161818
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %10101212
0 0
- + - + @@ -77,6 +77,13 @@ + + + + + + + @@ -107,37 +114,44 @@ - + - + - + - + - + - + - + - + - + + + + + + + + - + @@ -145,8 +159,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
2
EmissionManager.onlyEmissionAdmin2
EmissionManager.setDistributionEnd
EmissionManager.setClaimerEmissionManager.getEmissionAdmin46
EmissionManager.getEmissionAdminEmissionManager.setEmissionAdmin641
EmissionManager.configureAssetsEmissionManager.20238
EmissionManager.setEmissionAdminEmissionManager.setRewardsController25680
EmissionManager.setRewardsControllerEmissionManager.setClaimer1004
EmissionManager.configureAssets6069023
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func.html b/report/rewards/EmissionManager.sol.func.html similarity index 68% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func.html rename to report/rewards/EmissionManager.sol.func.html index 3493873d..fefade3f 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.func.html +++ b/report/rewards/EmissionManager.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol - functions - + LCOV - lcov.info.p - rewards/EmissionManager.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,28 +53,35 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - EmissionManager.sol (source / functions)top level - rewards - EmissionManager.sol (source / functions) Coverage Lines: 100.0 %16161818
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %10101212
0 0
- + - + + + + + + + + - + @@ -91,11 +98,18 @@ + + + + + + + - + @@ -109,7 +123,7 @@ - + @@ -130,7 +144,7 @@ - + @@ -145,8 +159,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
EmissionManager.238
EmissionManager.configureAssets209023
2
EmissionManager.onlyEmissionAdmin2
EmissionManager.setClaimer41004
EmissionManager.setEmissionAdmin2541
EmissionManager.setRewardsController606680
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.gcov.html b/report/rewards/EmissionManager.sol.gcov.html similarity index 78% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.gcov.html rename to report/rewards/EmissionManager.sol.gcov.html index 3acc4377..e1acb304 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol.gcov.html +++ b/report/rewards/EmissionManager.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/EmissionManager.sol - + LCOV - lcov.info.p - rewards/EmissionManager.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - EmissionManager.sol (source / functions)top level - rewards - EmissionManager.sol (source / functions) Coverage Lines: 100.0 %16161818
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %10101212
0 0
@@ -72,8 +72,8 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {Ownable} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; - 5 : : import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; + 4 : : import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; + 5 : : import {IEACAggregatorProxy} from '../helpers/interfaces/IEACAggregatorProxy.sol'; 6 : : import {IEmissionManager} from './interfaces/IEmissionManager.sol'; 7 : : import {ITransferStrategyBase} from './interfaces/ITransferStrategyBase.sol'; 8 : : import {IRewardsController} from './interfaces/IRewardsController.sol'; @@ -94,7 +94,7 @@ 23 : : * @dev Only emission admin of the given reward can call functions marked by this modifier. 24 : : **/ 25 : : modifier onlyEmissionAdmin(address reward) { - 26 : : require(msg.sender == _emissionAdmins[reward], 'ONLY_EMISSION_ADMIN'); + 26 : 2 : require(msg.sender == _emissionAdmins[reward], 'ONLY_EMISSION_ADMIN'); 27 : : _; 28 : : } 29 : : @@ -103,79 +103,79 @@ 32 : : * @param owner The address of the owner 33 : : */ 34 : : constructor(address owner) { - 35 : : transferOwnership(owner); + 35 : 91 : transferOwnership(owner); 36 : : } 37 : : 38 : : /// @inheritdoc IEmissionManager - 39 : 20 : function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) external override { - 40 : 100 : for (uint256 i = 0; i < config.length; i++) { - 41 : 40 : require(_emissionAdmins[config[i].reward] == msg.sender, 'ONLY_EMISSION_ADMIN'); + 39 : : function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) external override { + 40 : 9023 : for (uint256 i = 0; i < config.length; i++) { + 41 : 9023 : require(_emissionAdmins[config[i].reward] == msg.sender, 'ONLY_EMISSION_ADMIN'); 42 : : } - 43 : 40 : _rewardsController.configureAssets(config); + 43 : 9023 : _rewardsController.configureAssets(config); 44 : : } 45 : : 46 : : /// @inheritdoc IEmissionManager - 47 : 2 : function setTransferStrategy( + 47 : : function setTransferStrategy( 48 : : address reward, 49 : : ITransferStrategyBase transferStrategy 50 : : ) external override onlyEmissionAdmin(reward) { - 51 : 4 : _rewardsController.setTransferStrategy(reward, transferStrategy); + 51 : 2 : _rewardsController.setTransferStrategy(reward, transferStrategy); 52 : : } 53 : : 54 : : /// @inheritdoc IEmissionManager - 55 : 2 : function setRewardOracle( + 55 : : function setRewardOracle( 56 : : address reward, 57 : : IEACAggregatorProxy rewardOracle 58 : : ) external override onlyEmissionAdmin(reward) { - 59 : 4 : _rewardsController.setRewardOracle(reward, rewardOracle); + 59 : 2 : _rewardsController.setRewardOracle(reward, rewardOracle); 60 : : } 61 : : 62 : : /// @inheritdoc IEmissionManager - 63 : 2 : function setDistributionEnd( + 63 : : function setDistributionEnd( 64 : : address asset, 65 : : address reward, 66 : : uint32 newDistributionEnd 67 : : ) external override onlyEmissionAdmin(reward) { - 68 : 4 : _rewardsController.setDistributionEnd(asset, reward, newDistributionEnd); + 68 : 2 : _rewardsController.setDistributionEnd(asset, reward, newDistributionEnd); 69 : : } 70 : : 71 : : /// @inheritdoc IEmissionManager - 72 : 2 : function setEmissionPerSecond( + 72 : : function setEmissionPerSecond( 73 : : address asset, 74 : : address[] calldata rewards, 75 : : uint88[] calldata newEmissionsPerSecond 76 : : ) external override { - 77 : 10 : for (uint256 i = 0; i < rewards.length; i++) { - 78 : 4 : require(_emissionAdmins[rewards[i]] == msg.sender, 'ONLY_EMISSION_ADMIN'); + 77 : 2 : for (uint256 i = 0; i < rewards.length; i++) { + 78 : 2 : require(_emissionAdmins[rewards[i]] == msg.sender, 'ONLY_EMISSION_ADMIN'); 79 : : } - 80 : 4 : _rewardsController.setEmissionPerSecond(asset, rewards, newEmissionsPerSecond); + 80 : 2 : _rewardsController.setEmissionPerSecond(asset, rewards, newEmissionsPerSecond); 81 : : } 82 : : 83 : : /// @inheritdoc IEmissionManager - 84 : 4 : function setClaimer(address user, address claimer) external override onlyOwner { - 85 : 8 : _rewardsController.setClaimer(user, claimer); + 84 : : function setClaimer(address user, address claimer) external override onlyOwner { + 85 : 1004 : _rewardsController.setClaimer(user, claimer); 86 : : } 87 : : 88 : : /// @inheritdoc IEmissionManager - 89 : 25 : function setEmissionAdmin(address reward, address admin) external override onlyOwner { - 90 : 50 : address oldAdmin = _emissionAdmins[reward]; - 91 : 50 : _emissionAdmins[reward] = admin; - 92 : 50 : emit EmissionAdminUpdated(reward, oldAdmin, admin); + 89 : : function setEmissionAdmin(address reward, address admin) external override onlyOwner { + 90 : 41 : address oldAdmin = _emissionAdmins[reward]; + 91 : 41 : _emissionAdmins[reward] = admin; + 92 : 41 : emit EmissionAdminUpdated(reward, oldAdmin, admin); 93 : : } 94 : : 95 : : /// @inheritdoc IEmissionManager - 96 : 606 : function setRewardsController(address controller) external override onlyOwner { - 97 : 1212 : _rewardsController = IRewardsController(controller); + 96 : : function setRewardsController(address controller) external override onlyOwner { + 97 : 680 : _rewardsController = IRewardsController(controller); 98 : : } 99 : : 100 : : /// @inheritdoc IEmissionManager - 101 : 2 : function getRewardsController() external view override returns (IRewardsController) { - 102 : 4 : return _rewardsController; + 101 : : function getRewardsController() external view override returns (IRewardsController) { + 102 : 2 : return _rewardsController; 103 : : } 104 : : 105 : : /// @inheritdoc IEmissionManager - 106 : 6 : function getEmissionAdmin(address reward) external view override returns (address) { - 107 : 12 : return _emissionAdmins[reward]; + 106 : : function getEmissionAdmin(address reward) external view override returns (address) { + 107 : 6 : return _emissionAdmins[reward]; 108 : : } 109 : : } @@ -185,8 +185,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func-c.html b/report/rewards/RewardsController.sol.func-c.html similarity index 74% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func-c.html rename to report/rewards/RewardsController.sol.func-c.html index 352a1250..162f744e 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func-c.html +++ b/report/rewards/RewardsController.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol - functions - + LCOV - lcov.info.p - rewards/RewardsController.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsController.sol (source / functions)top level - rewards - RewardsController.sol (source / functions) Coveragelcov.info.p Lines:98.7 %98.8 %80 7978
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %232396.0 %2524
0 0
- + - + + + + + + + + @@ -121,9 +128,9 @@ - + - + @@ -149,86 +156,93 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + @@ -236,8 +250,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
RewardsController.0
RewardsController.getClaimerRewardsController.onlyAuthorizedClaimers21
RewardsController.claimRewardsRewardsController.setClaimer41004
RewardsController.setClaimerRewardsController.getRevision41387
RewardsController._claimRewardsRewardsController.initialize61387
RewardsController._transferRewards71902
RewardsController._getUserAssetBalancesRewardsController.getClaimer192002
RewardsController.configureAssetsRewardsController.claimRewards202521
RewardsController._installTransferStrategyRewardsController._claimRewards222523
RewardsController._isContractRewardsController._getUserAssetBalances223537
RewardsController._setRewardOracleRewardsController.configureAssets229023
RewardsController.getRevisionRewardsController._installTransferStrategy12319025
RewardsController.initializeRewardsController._isContract9025
RewardsController._setRewardOracle12319025
RewardsController.handleAction53887138815
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func.html b/report/rewards/RewardsController.sol.func.html similarity index 74% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func.html rename to report/rewards/RewardsController.sol.func.html index 81283855..88712b4e 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.func.html +++ b/report/rewards/RewardsController.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol - functions - + LCOV - lcov.info.p - rewards/RewardsController.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsController.sol (source / functions)top level - rewards - RewardsController.sol (source / functions) Coveragelcov.info.p Lines:98.7 %98.8 %80 7978
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %232396.0 %2524
0 0
- + - + + + + + + + + @@ -81,42 +88,42 @@ - + - + - + - + - + - + @@ -144,7 +151,7 @@ - + @@ -165,21 +172,21 @@ - + - + - + @@ -200,21 +207,28 @@ - + - + + + + + + + + - + @@ -236,8 +250,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
RewardsController.0
RewardsController._claimRewards62523
RewardsController._getUserAssetBalances193537
RewardsController._installTransferStrategy229025
RewardsController._isContract229025
RewardsController._setRewardOracle229025
RewardsController._transferRewards71902
RewardsController.claimRewards42521
RewardsController.configureAssets209023
RewardsController.getClaimer22002
RewardsController.getRevision12311387
RewardsController.handleAction53887138815
RewardsController.initialize12311387
RewardsController.onlyAuthorizedClaimers1
RewardsController.setClaimer41004
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.gcov.html b/report/rewards/RewardsController.sol.gcov.html similarity index 82% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.gcov.html rename to report/rewards/RewardsController.sol.gcov.html index 67e5d544..2d62f326 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol.gcov.html +++ b/report/rewards/RewardsController.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsController.sol - + LCOV - lcov.info.p - rewards/RewardsController.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsController.sol (source / functions)top level - rewards - RewardsController.sol (source / functions) Coveragelcov.info.p Lines:98.7 %98.8 %80 7978
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %232396.0 %2524
0 0
@@ -72,14 +72,14 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {VersionedInitializable} from 'aave-v3-core/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; - 5 : : import {SafeCast} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; - 6 : : import {IScaledBalanceToken} from 'aave-v3-core/contracts/interfaces/IScaledBalanceToken.sol'; + 4 : : import {VersionedInitializable} from '../misc/aave-upgradeability/VersionedInitializable.sol'; + 5 : : import {SafeCast} from '../dependencies/openzeppelin/contracts/SafeCast.sol'; + 6 : : import {IScaledBalanceToken} from '../interfaces/IScaledBalanceToken.sol'; 7 : : import {RewardsDistributor} from './RewardsDistributor.sol'; 8 : : import {IRewardsController} from './interfaces/IRewardsController.sol'; 9 : : import {ITransferStrategyBase} from './interfaces/ITransferStrategyBase.sol'; 10 : : import {RewardsDataTypes} from './libraries/RewardsDataTypes.sol'; - 11 : : import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; + 11 : : import {IEACAggregatorProxy} from '../helpers/interfaces/IEACAggregatorProxy.sol'; 12 : : 13 : : /** 14 : : * @title RewardsController @@ -108,7 +108,7 @@ 37 : : mapping(address => IEACAggregatorProxy) internal _rewardOracle; 38 : : 39 : : modifier onlyAuthorizedClaimers(address claimer, address user) { - 40 : : require(_authorizedClaimers[user] == claimer, 'CLAIMER_UNAUTHORIZED'); + 40 : 1 : require(_authorizedClaimers[user] == claimer, 'CLAIMER_UNAUTHORIZED'); 41 : : _; 42 : : } 43 : : @@ -118,113 +118,113 @@ 47 : : * @dev Initialize for RewardsController 48 : : * @dev It expects an address as argument since its initialized via PoolAddressesProvider._updateImpl() 49 : : **/ - 50 : 1231 : function initialize(address) external initializer {} + 50 : : function initialize(address) external initializer {} 51 : : 52 : : /// @inheritdoc IRewardsController - 53 : 2 : function getClaimer(address user) external view override returns (address) { - 54 : 4 : return _authorizedClaimers[user]; + 53 : : function getClaimer(address user) external view override returns (address) { + 54 : 2002 : return _authorizedClaimers[user]; 55 : : } 56 : : 57 : : /** 58 : : * @dev Returns the revision of the implementation contract 59 : : * @return uint256, current revision version 60 : : */ - 61 : 1231 : function getRevision() internal pure override returns (uint256) { - 62 : 2462 : return REVISION; + 61 : : function getRevision() internal pure override returns (uint256) { + 62 : 1387 : return REVISION; 63 : : } 64 : : 65 : : /// @inheritdoc IRewardsController - 66 : 1 : function getRewardOracle(address reward) external view override returns (address) { - 67 : 3 : return address(_rewardOracle[reward]); + 66 : : function getRewardOracle(address reward) external view override returns (address) { + 67 : 1 : return address(_rewardOracle[reward]); 68 : : } 69 : : 70 : : /// @inheritdoc IRewardsController - 71 : 1 : function getTransferStrategy(address reward) external view override returns (address) { - 72 : 3 : return address(_transferStrategy[reward]); + 71 : : function getTransferStrategy(address reward) external view override returns (address) { + 72 : 1 : return address(_transferStrategy[reward]); 73 : : } 74 : : 75 : : /// @inheritdoc IRewardsController - 76 : 20 : function configureAssets( + 76 : : function configureAssets( 77 : : RewardsDataTypes.RewardsConfigInput[] memory config 78 : : ) external override onlyEmissionManager { - 79 : 100 : for (uint256 i = 0; i < config.length; i++) { + 79 : 9023 : for (uint256 i = 0; i < config.length; i++) { 80 : : // Get the current Scaled Total Supply of AToken or Debt token - 81 : 40 : config[i].totalSupply = IScaledBalanceToken(config[i].asset).scaledTotalSupply(); + 81 : 9023 : config[i].totalSupply = IScaledBalanceToken(config[i].asset).scaledTotalSupply(); 82 : : 83 : : // Install TransferStrategy logic at IncentivesController - 84 : 40 : _installTransferStrategy(config[i].reward, config[i].transferStrategy); + 84 : 9023 : _installTransferStrategy(config[i].reward, config[i].transferStrategy); 85 : : 86 : : // Set reward oracle, enforces input oracle to have latestPrice function - 87 : 40 : _setRewardOracle(config[i].reward, config[i].rewardOracle); + 87 : 9023 : _setRewardOracle(config[i].reward, config[i].rewardOracle); 88 : : } - 89 : 40 : _configureAssets(config); + 89 : 9023 : _configureAssets(config); 90 : : } 91 : : 92 : : /// @inheritdoc IRewardsController - 93 : 2 : function setTransferStrategy( + 93 : : function setTransferStrategy( 94 : : address reward, 95 : : ITransferStrategyBase transferStrategy 96 : : ) external onlyEmissionManager { - 97 : 4 : _installTransferStrategy(reward, transferStrategy); + 97 : 2 : _installTransferStrategy(reward, transferStrategy); 98 : : } 99 : : 100 : : /// @inheritdoc IRewardsController - 101 : 2 : function setRewardOracle( + 101 : : function setRewardOracle( 102 : : address reward, 103 : : IEACAggregatorProxy rewardOracle 104 : : ) external onlyEmissionManager { - 105 : 4 : _setRewardOracle(reward, rewardOracle); + 105 : 2 : _setRewardOracle(reward, rewardOracle); 106 : : } 107 : : 108 : : /// @inheritdoc IRewardsController - 109 : 53887 : function handleAction(address user, uint256 totalSupply, uint256 userBalance) external override { - 110 : 107774 : _updateData(msg.sender, user, userBalance, totalSupply); + 109 : : function handleAction(address user, uint256 totalSupply, uint256 userBalance) external override { + 110 : 138815 : _updateData(msg.sender, user, userBalance, totalSupply); 111 : : } 112 : : 113 : : /// @inheritdoc IRewardsController - 114 : 4 : function claimRewards( + 114 : : function claimRewards( 115 : : address[] calldata assets, 116 : : uint256 amount, 117 : : address to, 118 : : address reward 119 : : ) external override returns (uint256) { - 120 : 8 : require(to != address(0), 'INVALID_TO_ADDRESS'); - 121 : 12 : return _claimRewards(assets, amount, msg.sender, msg.sender, to, reward); + 120 : 2521 : require(to != address(0), 'INVALID_TO_ADDRESS'); + 121 : 2521 : return _claimRewards(assets, amount, msg.sender, msg.sender, to, reward); 122 : : } 123 : : 124 : : /// @inheritdoc IRewardsController - 125 : 1 : function claimRewardsOnBehalf( + 125 : : function claimRewardsOnBehalf( 126 : : address[] calldata assets, 127 : : uint256 amount, 128 : : address user, 129 : : address to, 130 : : address reward 131 : : ) external override onlyAuthorizedClaimers(msg.sender, user) returns (uint256) { - 132 : 2 : require(user != address(0), 'INVALID_USER_ADDRESS'); - 133 : 2 : require(to != address(0), 'INVALID_TO_ADDRESS'); - 134 : 3 : return _claimRewards(assets, amount, msg.sender, user, to, reward); + 132 : 1 : require(user != address(0), 'INVALID_USER_ADDRESS'); + 133 : 1 : require(to != address(0), 'INVALID_TO_ADDRESS'); + 134 : 1 : return _claimRewards(assets, amount, msg.sender, user, to, reward); 135 : : } 136 : : 137 : : /// @inheritdoc IRewardsController - 138 : 1 : function claimRewardsToSelf( + 138 : : function claimRewardsToSelf( 139 : : address[] calldata assets, 140 : : uint256 amount, 141 : : address reward 142 : : ) external override returns (uint256) { - 143 : 3 : return _claimRewards(assets, amount, msg.sender, msg.sender, msg.sender, reward); + 143 : 1 : return _claimRewards(assets, amount, msg.sender, msg.sender, msg.sender, reward); 144 : : } 145 : : 146 : : /// @inheritdoc IRewardsController - 147 : 1 : function claimAllRewards( + 147 : : function claimAllRewards( 148 : : address[] calldata assets, 149 : : address to 150 : : ) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts) { - 151 : 2 : require(to != address(0), 'INVALID_TO_ADDRESS'); - 152 : 3 : return _claimAllRewards(assets, msg.sender, msg.sender, to); + 151 : 1 : require(to != address(0), 'INVALID_TO_ADDRESS'); + 152 : 1 : return _claimAllRewards(assets, msg.sender, msg.sender, to); 153 : : } 154 : : 155 : : /// @inheritdoc IRewardsController - 156 : 1 : function claimAllRewardsOnBehalf( + 156 : : function claimAllRewardsOnBehalf( 157 : : address[] calldata assets, 158 : : address user, 159 : : address to @@ -234,22 +234,22 @@ 163 : : onlyAuthorizedClaimers(msg.sender, user) 164 : : returns (address[] memory rewardsList, uint256[] memory claimedAmounts) 165 : : { - 166 : 2 : require(user != address(0), 'INVALID_USER_ADDRESS'); - 167 : 2 : require(to != address(0), 'INVALID_TO_ADDRESS'); - 168 : 3 : return _claimAllRewards(assets, msg.sender, user, to); + 166 : 1 : require(user != address(0), 'INVALID_USER_ADDRESS'); + 167 : 1 : require(to != address(0), 'INVALID_TO_ADDRESS'); + 168 : 1 : return _claimAllRewards(assets, msg.sender, user, to); 169 : : } 170 : : 171 : : /// @inheritdoc IRewardsController - 172 : 1 : function claimAllRewardsToSelf( + 172 : : function claimAllRewardsToSelf( 173 : : address[] calldata assets 174 : : ) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts) { - 175 : 3 : return _claimAllRewards(assets, msg.sender, msg.sender, msg.sender); + 175 : 1 : return _claimAllRewards(assets, msg.sender, msg.sender, msg.sender); 176 : : } 177 : : 178 : : /// @inheritdoc IRewardsController - 179 : 4 : function setClaimer(address user, address caller) external override onlyEmissionManager { - 180 : 8 : _authorizedClaimers[user] = caller; - 181 : 8 : emit ClaimerSet(user, caller); + 179 : : function setClaimer(address user, address caller) external override onlyEmissionManager { + 180 : 1004 : _authorizedClaimers[user] = caller; + 181 : 1004 : emit ClaimerSet(user, caller); 182 : : } 183 : : 184 : : /** @@ -258,14 +258,14 @@ 187 : : * @param user Address of the user 188 : : * @return userAssetBalances contains a list of structs with user balance and total supply of the given assets 189 : : */ - 190 : 19 : function _getUserAssetBalances( + 190 : : function _getUserAssetBalances( 191 : : address[] calldata assets, 192 : : address user 193 : : ) internal view override returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances) { - 194 : 38 : userAssetBalances = new RewardsDataTypes.UserAssetBalance[](assets.length); - 195 : 95 : for (uint256 i = 0; i < assets.length; i++) { - 196 : 38 : userAssetBalances[i].asset = assets[i]; - 197 : 38 : (userAssetBalances[i].userBalance, userAssetBalances[i].totalSupply) = IScaledBalanceToken( + 194 : 3537 : userAssetBalances = new RewardsDataTypes.UserAssetBalance[](assets.length); + 195 : 3537 : for (uint256 i = 0; i < assets.length; i++) { + 196 : 3537 : userAssetBalances[i].asset = assets[i]; + 197 : 3537 : (userAssetBalances[i].userBalance, userAssetBalances[i].totalSupply) = IScaledBalanceToken( 198 : : assets[i] 199 : : ).getScaledUserBalanceAndSupply(user); 200 : : } @@ -282,7 +282,7 @@ 211 : : * @param reward Address of the reward token 212 : : * @return Rewards claimed 213 : : **/ - 214 : 6 : function _claimRewards( + 214 : : function _claimRewards( 215 : : address[] calldata assets, 216 : : uint256 amount, 217 : : address claimer, @@ -290,34 +290,34 @@ 219 : : address to, 220 : : address reward 221 : : ) internal returns (uint256) { - 222 : 12 : if (amount == 0) { - 223 : 2 : return 0; + 222 : 2523 : if (amount == 0) { + 223 : 1 : return 0; 224 : : } - 225 : 10 : uint256 totalRewards; + 225 : 2522 : uint256 totalRewards; 226 : : - 227 : 10 : _updateDataMultiple(user, _getUserAssetBalances(assets, user)); - 228 : 23 : for (uint256 i = 0; i < assets.length; i++) { - 229 : 10 : address asset = assets[i]; - 230 : 10 : totalRewards += _assets[asset].rewards[reward].usersData[user].accrued; + 227 : 2522 : _updateDataMultiple(user, _getUserAssetBalances(assets, user)); + 228 : 2522 : for (uint256 i = 0; i < assets.length; i++) { + 229 : 2522 : address asset = assets[i]; + 230 : 2522 : totalRewards += _assets[asset].rewards[reward].usersData[user].accrued; 231 : : - 232 : 10 : if (totalRewards <= amount) { - 233 : 8 : _assets[asset].rewards[reward].usersData[user].accrued = 0; + 232 : 2522 : if (totalRewards <= amount) { + 233 : 2521 : _assets[asset].rewards[reward].usersData[user].accrued = 0; 234 : : } else { - 235 : 3 : uint256 difference = totalRewards - amount; - 236 : 2 : totalRewards -= difference; - 237 : 2 : _assets[asset].rewards[reward].usersData[user].accrued = difference.toUint128(); - 238 : 2 : break; + 235 : 1 : uint256 difference = totalRewards - amount; + 236 : 1 : totalRewards -= difference; + 237 : 1 : _assets[asset].rewards[reward].usersData[user].accrued = difference.toUint128(); + 238 : 1 : break; 239 : : } 240 : : } 241 : : - 242 : 10 : if (totalRewards == 0) { - 243 : 2 : return 0; + 242 : 2522 : if (totalRewards == 0) { + 243 : 623 : return 0; 244 : : } 245 : : - 246 : 8 : _transferRewards(to, reward, totalRewards); - 247 : 8 : emit RewardsClaimed(user, reward, to, claimer, totalRewards); + 246 : 1899 : _transferRewards(to, reward, totalRewards); + 247 : 1899 : emit RewardsClaimed(user, reward, to, claimer, totalRewards); 248 : : - 249 : 8 : return totalRewards; + 249 : 1899 : return totalRewards; 250 : : } 251 : : 252 : : /** @@ -330,36 +330,36 @@ 259 : : * rewardsList List of reward addresses 260 : : * claimedAmount List of claimed amounts, follows "rewardsList" items order 261 : : **/ - 262 : 3 : function _claimAllRewards( + 262 : : function _claimAllRewards( 263 : : address[] calldata assets, 264 : : address claimer, 265 : : address user, 266 : : address to 267 : : ) internal returns (address[] memory rewardsList, uint256[] memory claimedAmounts) { - 268 : 6 : uint256 rewardsListLength = _rewardsList.length; - 269 : 6 : rewardsList = new address[](rewardsListLength); - 270 : 6 : claimedAmounts = new uint256[](rewardsListLength); + 268 : 3 : uint256 rewardsListLength = _rewardsList.length; + 269 : 3 : rewardsList = new address[](rewardsListLength); + 270 : 3 : claimedAmounts = new uint256[](rewardsListLength); 271 : : - 272 : 6 : _updateDataMultiple(user, _getUserAssetBalances(assets, user)); + 272 : 3 : _updateDataMultiple(user, _getUserAssetBalances(assets, user)); 273 : : - 274 : 15 : for (uint256 i = 0; i < assets.length; i++) { - 275 : 6 : address asset = assets[i]; - 276 : 15 : for (uint256 j = 0; j < rewardsListLength; j++) { - 277 : 9 : if (rewardsList[j] == address(0)) { - 278 : 6 : rewardsList[j] = _rewardsList[j]; + 274 : 3 : for (uint256 i = 0; i < assets.length; i++) { + 275 : 3 : address asset = assets[i]; + 276 : 3 : for (uint256 j = 0; j < rewardsListLength; j++) { + 277 : 3 : if (rewardsList[j] == address(0)) { + 278 : 3 : rewardsList[j] = _rewardsList[j]; 279 : : } - 280 : 6 : uint256 rewardAmount = _assets[asset].rewards[rewardsList[j]].usersData[user].accrued; - 281 : 6 : if (rewardAmount != 0) { - 282 : 6 : claimedAmounts[j] += rewardAmount; - 283 : 6 : _assets[asset].rewards[rewardsList[j]].usersData[user].accrued = 0; + 280 : 3 : uint256 rewardAmount = _assets[asset].rewards[rewardsList[j]].usersData[user].accrued; + 281 : 3 : if (rewardAmount != 0) { + 282 : 3 : claimedAmounts[j] += rewardAmount; + 283 : 3 : _assets[asset].rewards[rewardsList[j]].usersData[user].accrued = 0; 284 : : } 285 : : } 286 : : } - 287 : 15 : for (uint256 i = 0; i < rewardsListLength; i++) { - 288 : 6 : _transferRewards(to, rewardsList[i], claimedAmounts[i]); - 289 : 6 : emit RewardsClaimed(user, rewardsList[i], to, claimer, claimedAmounts[i]); + 287 : 3 : for (uint256 i = 0; i < rewardsListLength; i++) { + 288 : 3 : _transferRewards(to, rewardsList[i], claimedAmounts[i]); + 289 : 3 : emit RewardsClaimed(user, rewardsList[i], to, claimer, claimedAmounts[i]); 290 : : } - 291 : 6 : return (rewardsList, claimedAmounts); + 291 : 3 : return (rewardsList, claimedAmounts); 292 : : } 293 : : 294 : : /** @@ -368,12 +368,12 @@ 297 : : * @param reward Address of the reward token 298 : : * @param amount Amount of rewards to transfer 299 : : */ - 300 : 7 : function _transferRewards(address to, address reward, uint256 amount) internal { - 301 : 14 : ITransferStrategyBase transferStrategy = _transferStrategy[reward]; + 300 : : function _transferRewards(address to, address reward, uint256 amount) internal { + 301 : 1902 : ITransferStrategyBase transferStrategy = _transferStrategy[reward]; 302 : : - 303 : 21 : bool success = transferStrategy.performTransfer(to, reward, amount); + 303 : 1902 : bool success = transferStrategy.performTransfer(to, reward, amount); 304 : : - 305 : 14 : require(success == true, 'TRANSFER_ERROR'); + 305 : 1902 : require(success == true, 'TRANSFER_ERROR'); 306 : : } 307 : : 308 : : /** @@ -381,17 +381,17 @@ 310 : : * @param account The address of the account 311 : : * @return bool, true if contract, false otherwise 312 : : */ - 313 : 22 : function _isContract(address account) internal view returns (bool) { + 313 : : function _isContract(address account) internal view returns (bool) { 314 : : // This method relies on extcodesize, which returns 0 for contracts in 315 : : // construction, since the code is only stored at the end of the 316 : : // constructor execution. 317 : : - 318 : 44 : uint256 size; + 318 : 9025 : uint256 size; 319 : : // solhint-disable-next-line no-inline-assembly 320 : : assembly { - 321 : 44 : size := extcodesize(account) + 321 : 9025 : size := extcodesize(account) 322 : : } - 323 : 66 : return size > 0; + 323 : 9025 : return size > 0; 324 : : } 325 : : 326 : : /** @@ -399,16 +399,16 @@ 328 : : * @param reward The address of the reward token 329 : : * @param transferStrategy The address of the reward TransferStrategy 330 : : */ - 331 : 22 : function _installTransferStrategy( + 331 : : function _installTransferStrategy( 332 : : address reward, 333 : : ITransferStrategyBase transferStrategy 334 : : ) internal { - 335 : 44 : require(address(transferStrategy) != address(0), 'STRATEGY_CAN_NOT_BE_ZERO'); - 336 : 44 : require(_isContract(address(transferStrategy)) == true, 'STRATEGY_MUST_BE_CONTRACT'); + 335 : 9025 : require(address(transferStrategy) != address(0), 'STRATEGY_CAN_NOT_BE_ZERO'); + 336 : 9025 : require(_isContract(address(transferStrategy)) == true, 'STRATEGY_MUST_BE_CONTRACT'); 337 : : - 338 : 44 : _transferStrategy[reward] = transferStrategy; + 338 : 9025 : _transferStrategy[reward] = transferStrategy; 339 : : - 340 : 44 : emit TransferStrategyInstalled(reward, address(transferStrategy)); + 340 : 9025 : emit TransferStrategyInstalled(reward, address(transferStrategy)); 341 : : } 342 : : 343 : : /** @@ -418,10 +418,10 @@ 347 : : * @param rewardOracle The address of the price oracle 348 : : */ 349 : : - 350 : 22 : function _setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) internal { - 351 : 44 : require(rewardOracle.latestAnswer() > 0, 'ORACLE_MUST_RETURN_PRICE'); - 352 : 44 : _rewardOracle[reward] = rewardOracle; - 353 : 44 : emit RewardOracleUpdated(reward, address(rewardOracle)); + 350 : : function _setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) internal { + 351 : 9025 : require(rewardOracle.latestAnswer() > 0, 'ORACLE_MUST_RETURN_PRICE'); + 352 : 9025 : _rewardOracle[reward] = rewardOracle; + 353 : 9025 : emit RewardOracleUpdated(reward, address(rewardOracle)); 354 : : } 355 : : } @@ -431,8 +431,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func-c.html b/report/rewards/RewardsDistributor.sol.func-c.html similarity index 73% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func-c.html rename to report/rewards/RewardsDistributor.sol.func-c.html index db9103f1..fb18b19d 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func-c.html +++ b/report/rewards/RewardsDistributor.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol - functions - + LCOV - lcov.info.p - rewards/RewardsDistributor.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,33 +53,33 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsDistributor.sol (source / functions)top level - rewards - RewardsDistributor.sol (source / functions) Coveragelcov.info.p Lines:99.2 %98.3 %121 119118
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %222295.8 %2423
0 0
- + - + - + - + - + @@ -112,6 +112,13 @@ + + + + + + + @@ -128,100 +135,107 @@ - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + - + - + - + - + - + - + @@ -229,8 +243,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
RewardsDistributor.getAllUserRewardsRewardsDistributor.10
RewardsDistributor.getAssetIndexRewardsDistributor.getAllUserRewards 12
RewardsDistributor.onlyEmissionManager2
RewardsDistributor.setDistributionEnd
RewardsDistributor.getEmissionManagerRewardsDistributor.getRewardsData 3
RewardsDistributor.getRewardsDataRewardsDistributor.getEmissionManager35
RewardsDistributor._updateDataMultipleRewardsDistributor.getRewardsList830
RewardsDistributor._getPendingRewards91009
RewardsDistributor._getUserReward101011
RewardsDistributor.getUserRewards101011
RewardsDistributor._getRewardsRewardsDistributor._updateDataMultiple172525
RewardsDistributor._updateUserData172533
RewardsDistributor._getRewards2912
RewardsDistributor._configureAssets209023
RewardsDistributor.getRewardsByAsset309118
RewardsDistributor.getRewardsListRewardsDistributor._updateRewardData3011558
RewardsDistributor._updateRewardDataRewardsDistributor.getAssetIndex3937954
RewardsDistributor._getAssetIndex4950521
RewardsDistributor._updateData53895141340
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func.html b/report/rewards/RewardsDistributor.sol.func.html similarity index 73% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func.html rename to report/rewards/RewardsDistributor.sol.func.html index cf5b1b7f..0cafab95 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.func.html +++ b/report/rewards/RewardsDistributor.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol - functions - + LCOV - lcov.info.p - rewards/RewardsDistributor.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,84 +53,91 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsDistributor.sol (source / functions)top level - rewards - RewardsDistributor.sol (source / functions) Coveragelcov.info.p Lines:99.2 %98.3 %121 119118
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %222295.8 %2423
0 0
- + - + + + + + + + + - + - + - + - + - + - + - + - + - + @@ -151,7 +158,7 @@ - + @@ -165,14 +172,14 @@ - + - + @@ -207,7 +214,14 @@ - + + + + + + + + @@ -229,8 +243,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
RewardsDistributor.0
RewardsDistributor._configureAssets209023
RewardsDistributor._getAssetIndex4950521
RewardsDistributor._getPendingRewards91009
RewardsDistributor._getRewards172912
RewardsDistributor._getUserReward101011
RewardsDistributor._updateData53895141340
RewardsDistributor._updateDataMultiple82525
RewardsDistributor._updateRewardData3911558
RewardsDistributor._updateUserData172533
RewardsDistributor.getAssetIndex137954
RewardsDistributor.getEmissionManager35
RewardsDistributor.getRewardsByAsset309118
RewardsDistributor.getUserRewards101011
RewardsDistributor.onlyEmissionManager2
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.gcov.html b/report/rewards/RewardsDistributor.sol.gcov.html similarity index 84% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.gcov.html rename to report/rewards/RewardsDistributor.sol.gcov.html index dcb78dba..af1d21c0 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol.gcov.html +++ b/report/rewards/RewardsDistributor.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards/RewardsDistributor.sol - + LCOV - lcov.info.p - rewards/RewardsDistributor.sol + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - + + - - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewards - RewardsDistributor.sol (source / functions)top level - rewards - RewardsDistributor.sol (source / functions) Coveragelcov.info.p Lines:99.2 %98.3 %121 119118
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %222295.8 %2423
0 0
@@ -72,9 +72,9 @@ 1 : : // SPDX-License-Identifier: BUSL-1.1 2 : : pragma solidity ^0.8.10; 3 : : - 4 : : import {IScaledBalanceToken} from 'aave-v3-core/contracts/interfaces/IScaledBalanceToken.sol'; - 5 : : import {IERC20Detailed} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; - 6 : : import {SafeCast} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; + 4 : : import {IScaledBalanceToken} from '../interfaces/IScaledBalanceToken.sol'; + 5 : : import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; + 6 : : import {SafeCast} from '../dependencies/openzeppelin/contracts/SafeCast.sol'; 7 : : import {IRewardsDistributor} from './interfaces/IRewardsDistributor.sol'; 8 : : import {RewardsDataTypes} from './libraries/RewardsDataTypes.sol'; 9 : : @@ -104,20 +104,20 @@ 33 : : address[] internal _assetsList; 34 : : 35 : : modifier onlyEmissionManager() { - 36 : : require(msg.sender == EMISSION_MANAGER, 'ONLY_EMISSION_MANAGER'); + 36 : 2 : require(msg.sender == EMISSION_MANAGER, 'ONLY_EMISSION_MANAGER'); 37 : : _; 38 : : } 39 : : 40 : : constructor(address emissionManager) { - 41 : : EMISSION_MANAGER = emissionManager; + 41 : 0 : EMISSION_MANAGER = emissionManager; 42 : : } 43 : : 44 : : /// @inheritdoc IRewardsDistributor - 45 : 3 : function getRewardsData( + 45 : : function getRewardsData( 46 : : address asset, 47 : : address reward - 48 : : ) public view override returns (uint256, uint256, uint256, uint256) { - 49 : 6 : return ( + 48 : : ) external view override returns (uint256, uint256, uint256, uint256) { + 49 : 3 : return ( 50 : : _assets[asset].rewards[reward].index, 51 : : _assets[asset].rewards[reward].emissionPerSecond, 52 : : _assets[asset].rewards[reward].lastUpdateTimestamp, @@ -126,13 +126,13 @@ 55 : : } 56 : : 57 : : /// @inheritdoc IRewardsDistributor - 58 : 1 : function getAssetIndex( + 58 : : function getAssetIndex( 59 : : address asset, 60 : : address reward 61 : : ) external view override returns (uint256, uint256) { - 62 : 2 : RewardsDataTypes.RewardData storage rewardData = _assets[asset].rewards[reward]; - 63 : 2 : return - 64 : 2 : _getAssetIndex( + 62 : 37954 : RewardsDataTypes.RewardData storage rewardData = _assets[asset].rewards[reward]; + 63 : 37954 : return + 64 : 37954 : _getAssetIndex( 65 : : rewardData, 66 : : IScaledBalanceToken(asset).scaledTotalSupply(), 67 : : 10 ** _assets[asset].decimals @@ -140,62 +140,62 @@ 69 : : } 70 : : 71 : : /// @inheritdoc IRewardsDistributor - 72 : 1 : function getDistributionEnd( + 72 : : function getDistributionEnd( 73 : : address asset, 74 : : address reward 75 : : ) external view override returns (uint256) { - 76 : 2 : return _assets[asset].rewards[reward].distributionEnd; + 76 : 1 : return _assets[asset].rewards[reward].distributionEnd; 77 : : } 78 : : 79 : : /// @inheritdoc IRewardsDistributor - 80 : 30 : function getRewardsByAsset(address asset) external view override returns (address[] memory) { - 81 : 60 : uint128 rewardsCount = _assets[asset].availableRewardsCount; - 82 : 90 : address[] memory availableRewards = new address[](rewardsCount); + 80 : : function getRewardsByAsset(address asset) external view override returns (address[] memory) { + 81 : 9118 : uint128 rewardsCount = _assets[asset].availableRewardsCount; + 82 : 9118 : address[] memory availableRewards = new address[](rewardsCount); 83 : : - 84 : 150 : for (uint128 i = 0; i < rewardsCount; i++) { - 85 : 60 : availableRewards[i] = _assets[asset].availableRewards[i]; + 84 : 9118 : for (uint128 i = 0; i < rewardsCount; i++) { + 85 : 9033 : availableRewards[i] = _assets[asset].availableRewards[i]; 86 : : } - 87 : 60 : return availableRewards; + 87 : 9118 : return availableRewards; 88 : : } 89 : : 90 : : /// @inheritdoc IRewardsDistributor - 91 : 30 : function getRewardsList() external view override returns (address[] memory) { - 92 : 60 : return _rewardsList; + 91 : : function getRewardsList() external view override returns (address[] memory) { + 92 : 30 : return _rewardsList; 93 : : } 94 : : 95 : : /// @inheritdoc IRewardsDistributor - 96 : 1 : function getUserAssetIndex( + 96 : : function getUserAssetIndex( 97 : : address user, 98 : : address asset, 99 : : address reward - 100 : : ) public view override returns (uint256) { - 101 : 2 : return _assets[asset].rewards[reward].usersData[user].index; + 100 : : ) external view override returns (uint256) { + 101 : 1 : return _assets[asset].rewards[reward].usersData[user].index; 102 : : } 103 : : 104 : : /// @inheritdoc IRewardsDistributor - 105 : 1 : function getUserAccruedRewards( + 105 : : function getUserAccruedRewards( 106 : : address user, 107 : : address reward 108 : : ) external view override returns (uint256) { - 109 : 2 : uint256 totalAccrued; - 110 : 5 : for (uint256 i = 0; i < _assetsList.length; i++) { - 111 : 2 : totalAccrued += _assets[_assetsList[i]].rewards[reward].usersData[user].accrued; + 109 : 1 : uint256 totalAccrued; + 110 : 1 : for (uint256 i = 0; i < _assetsList.length; i++) { + 111 : 1 : totalAccrued += _assets[_assetsList[i]].rewards[reward].usersData[user].accrued; 112 : : } 113 : : - 114 : 2 : return totalAccrued; + 114 : 1 : return totalAccrued; 115 : : } 116 : : 117 : : /// @inheritdoc IRewardsDistributor - 118 : 10 : function getUserRewards( + 118 : : function getUserRewards( 119 : : address[] calldata assets, 120 : : address user, 121 : : address reward 122 : : ) external view override returns (uint256) { - 123 : 30 : return _getUserReward(user, reward, _getUserAssetBalances(assets, user)); + 123 : 1011 : return _getUserReward(user, reward, _getUserAssetBalances(assets, user)); 124 : : } 125 : : 126 : : /// @inheritdoc IRewardsDistributor - 127 : 1 : function getAllUserRewards( + 127 : : function getAllUserRewards( 128 : : address[] calldata assets, 129 : : address user 130 : : ) @@ -204,41 +204,41 @@ 133 : : override 134 : : returns (address[] memory rewardsList, uint256[] memory unclaimedAmounts) 135 : : { - 136 : 3 : RewardsDataTypes.UserAssetBalance[] memory userAssetBalances = _getUserAssetBalances( + 136 : 1 : RewardsDataTypes.UserAssetBalance[] memory userAssetBalances = _getUserAssetBalances( 137 : : assets, 138 : : user 139 : : ); - 140 : 2 : rewardsList = new address[](_rewardsList.length); - 141 : 2 : unclaimedAmounts = new uint256[](rewardsList.length); + 140 : 1 : rewardsList = new address[](_rewardsList.length); + 141 : 1 : unclaimedAmounts = new uint256[](rewardsList.length); 142 : : 143 : : // Add unrealized rewards from user to unclaimedRewards - 144 : 5 : for (uint256 i = 0; i < userAssetBalances.length; i++) { - 145 : 5 : for (uint256 r = 0; r < rewardsList.length; r++) { - 146 : 2 : rewardsList[r] = _rewardsList[r]; - 147 : 2 : unclaimedAmounts[r] += _assets[userAssetBalances[i].asset] + 144 : 1 : for (uint256 i = 0; i < userAssetBalances.length; i++) { + 145 : 1 : for (uint256 r = 0; r < rewardsList.length; r++) { + 146 : 1 : rewardsList[r] = _rewardsList[r]; + 147 : 1 : unclaimedAmounts[r] += _assets[userAssetBalances[i].asset] 148 : : .rewards[rewardsList[r]] 149 : : .usersData[user] 150 : : .accrued; 151 : : - 152 : 2 : if (userAssetBalances[i].userBalance == 0) { - 153 : 2 : continue; + 152 : 1 : if (userAssetBalances[i].userBalance == 0) { + 153 : 1 : continue; 154 : : } - 155 : 2 : unclaimedAmounts[r] += _getPendingRewards(user, rewardsList[r], userAssetBalances[i]); + 155 : 1 : unclaimedAmounts[r] += _getPendingRewards(user, rewardsList[r], userAssetBalances[i]); 156 : : } 157 : : } - 158 : 2 : return (rewardsList, unclaimedAmounts); + 158 : 1 : return (rewardsList, unclaimedAmounts); 159 : : } 160 : : 161 : : /// @inheritdoc IRewardsDistributor - 162 : 2 : function setDistributionEnd( + 162 : : function setDistributionEnd( 163 : : address asset, 164 : : address reward, 165 : : uint32 newDistributionEnd 166 : : ) external override onlyEmissionManager { - 167 : 4 : uint256 oldDistributionEnd = _assets[asset].rewards[reward].distributionEnd; - 168 : 4 : _assets[asset].rewards[reward].distributionEnd = newDistributionEnd; + 167 : 2 : uint256 oldDistributionEnd = _assets[asset].rewards[reward].distributionEnd; + 168 : 2 : _assets[asset].rewards[reward].distributionEnd = newDistributionEnd; 169 : : - 170 : 4 : emit AssetConfigUpdated( + 170 : 2 : emit AssetConfigUpdated( 171 : : asset, 172 : : reward, 173 : : _assets[asset].rewards[reward].emissionPerSecond, @@ -250,31 +250,31 @@ 179 : : } 180 : : 181 : : /// @inheritdoc IRewardsDistributor - 182 : 2 : function setEmissionPerSecond( + 182 : : function setEmissionPerSecond( 183 : : address asset, 184 : : address[] calldata rewards, 185 : : uint88[] calldata newEmissionsPerSecond 186 : : ) external override onlyEmissionManager { - 187 : 4 : require(rewards.length == newEmissionsPerSecond.length, 'INVALID_INPUT'); - 188 : 10 : for (uint256 i = 0; i < rewards.length; i++) { - 189 : 4 : RewardsDataTypes.AssetData storage assetConfig = _assets[asset]; - 190 : 4 : RewardsDataTypes.RewardData storage rewardConfig = _assets[asset].rewards[rewards[i]]; - 191 : 4 : uint256 decimals = assetConfig.decimals; - 192 : 4 : require( + 187 : 2 : require(rewards.length == newEmissionsPerSecond.length, 'INVALID_INPUT'); + 188 : 2 : for (uint256 i = 0; i < rewards.length; i++) { + 189 : 2 : RewardsDataTypes.AssetData storage assetConfig = _assets[asset]; + 190 : 2 : RewardsDataTypes.RewardData storage rewardConfig = _assets[asset].rewards[rewards[i]]; + 191 : 2 : uint256 decimals = assetConfig.decimals; + 192 : 2 : require( 193 : : decimals != 0 && rewardConfig.lastUpdateTimestamp != 0, 194 : : 'DISTRIBUTION_DOES_NOT_EXIST' 195 : : ); 196 : : - 197 : 6 : (uint256 newIndex, ) = _updateRewardData( + 197 : 2 : (uint256 newIndex, ) = _updateRewardData( 198 : : rewardConfig, 199 : : IScaledBalanceToken(asset).scaledTotalSupply(), 200 : : 10 ** decimals 201 : : ); 202 : : - 203 : 4 : uint256 oldEmissionPerSecond = rewardConfig.emissionPerSecond; - 204 : 4 : rewardConfig.emissionPerSecond = newEmissionsPerSecond[i]; + 203 : 2 : uint256 oldEmissionPerSecond = rewardConfig.emissionPerSecond; + 204 : 2 : rewardConfig.emissionPerSecond = newEmissionsPerSecond[i]; 205 : : - 206 : 4 : emit AssetConfigUpdated( + 206 : 2 : emit AssetConfigUpdated( 207 : : asset, 208 : : rewards[i], 209 : : oldEmissionPerSecond, @@ -290,49 +290,49 @@ 219 : : * @dev Configure the _assets for a specific emission 220 : : * @param rewardsInput The array of each asset configuration 221 : : **/ - 222 : 20 : function _configureAssets(RewardsDataTypes.RewardsConfigInput[] memory rewardsInput) internal { - 223 : 100 : for (uint256 i = 0; i < rewardsInput.length; i++) { - 224 : 40 : if (_assets[rewardsInput[i].asset].decimals == 0) { + 222 : : function _configureAssets(RewardsDataTypes.RewardsConfigInput[] memory rewardsInput) internal { + 223 : 9023 : for (uint256 i = 0; i < rewardsInput.length; i++) { + 224 : 9023 : if (_assets[rewardsInput[i].asset].decimals == 0) { 225 : : //never initialized before, adding to the list of assets - 226 : 40 : _assetsList.push(rewardsInput[i].asset); + 226 : 9023 : _assetsList.push(rewardsInput[i].asset); 227 : : } 228 : : - 229 : 60 : uint256 decimals = _assets[rewardsInput[i].asset].decimals = IERC20Detailed( + 229 : 9023 : uint256 decimals = _assets[rewardsInput[i].asset].decimals = IERC20Detailed( 230 : : rewardsInput[i].asset 231 : : ).decimals(); 232 : : - 233 : 40 : RewardsDataTypes.RewardData storage rewardConfig = _assets[rewardsInput[i].asset].rewards[ + 233 : 9023 : RewardsDataTypes.RewardData storage rewardConfig = _assets[rewardsInput[i].asset].rewards[ 234 : : rewardsInput[i].reward 235 : : ]; 236 : : 237 : : // Add reward address to asset available rewards if latestUpdateTimestamp is zero - 238 : 40 : if (rewardConfig.lastUpdateTimestamp == 0) { - 239 : 40 : _assets[rewardsInput[i].asset].availableRewards[ + 238 : 9023 : if (rewardConfig.lastUpdateTimestamp == 0) { + 239 : 9023 : _assets[rewardsInput[i].asset].availableRewards[ 240 : : _assets[rewardsInput[i].asset].availableRewardsCount 241 : : ] = rewardsInput[i].reward; - 242 : 40 : _assets[rewardsInput[i].asset].availableRewardsCount++; + 242 : 9023 : _assets[rewardsInput[i].asset].availableRewardsCount++; 243 : : } 244 : : 245 : : // Add reward address to global rewards list if still not enabled - 246 : 40 : if (_isRewardEnabled[rewardsInput[i].reward] == false) { - 247 : 40 : _isRewardEnabled[rewardsInput[i].reward] = true; - 248 : 40 : _rewardsList.push(rewardsInput[i].reward); + 246 : 9023 : if (_isRewardEnabled[rewardsInput[i].reward] == false) { + 247 : 9023 : _isRewardEnabled[rewardsInput[i].reward] = true; + 248 : 9023 : _rewardsList.push(rewardsInput[i].reward); 249 : : } 250 : : 251 : : // Due emissions is still zero, updates only latestUpdateTimestamp - 252 : 60 : (uint256 newIndex, ) = _updateRewardData( + 252 : 9023 : (uint256 newIndex, ) = _updateRewardData( 253 : : rewardConfig, 254 : : rewardsInput[i].totalSupply, 255 : : 10 ** decimals 256 : : ); 257 : : 258 : : // Configure emission and distribution end of the reward per asset - 259 : 40 : uint88 oldEmissionsPerSecond = rewardConfig.emissionPerSecond; - 260 : 40 : uint32 oldDistributionEnd = rewardConfig.distributionEnd; - 261 : 40 : rewardConfig.emissionPerSecond = rewardsInput[i].emissionPerSecond; - 262 : 40 : rewardConfig.distributionEnd = rewardsInput[i].distributionEnd; + 259 : 9023 : uint88 oldEmissionsPerSecond = rewardConfig.emissionPerSecond; + 260 : 9023 : uint32 oldDistributionEnd = rewardConfig.distributionEnd; + 261 : 9023 : rewardConfig.emissionPerSecond = rewardsInput[i].emissionPerSecond; + 262 : 9023 : rewardConfig.distributionEnd = rewardsInput[i].distributionEnd; 263 : : - 264 : 40 : emit AssetConfigUpdated( + 264 : 9023 : emit AssetConfigUpdated( 265 : : rewardsInput[i].asset, 266 : : rewardsInput[i].reward, 267 : : oldEmissionsPerSecond, @@ -352,25 +352,25 @@ 281 : : * @return The new distribution index 282 : : * @return True if the index was updated, false otherwise 283 : : **/ - 284 : 39 : function _updateRewardData( + 284 : : function _updateRewardData( 285 : : RewardsDataTypes.RewardData storage rewardData, 286 : : uint256 totalSupply, 287 : : uint256 assetUnit 288 : : ) internal returns (uint256, bool) { - 289 : 117 : (uint256 oldIndex, uint256 newIndex) = _getAssetIndex(rewardData, totalSupply, assetUnit); - 290 : 78 : bool indexUpdated; - 291 : 78 : if (newIndex != oldIndex) { - 292 : 16 : require(newIndex <= type(uint104).max, 'INDEX_OVERFLOW'); - 293 : 16 : indexUpdated = true; + 289 : 11558 : (uint256 oldIndex, uint256 newIndex) = _getAssetIndex(rewardData, totalSupply, assetUnit); + 290 : 11558 : bool indexUpdated; + 291 : 11558 : if (newIndex != oldIndex) { + 292 : 1903 : require(newIndex <= type(uint104).max, 'INDEX_OVERFLOW'); + 293 : 1903 : indexUpdated = true; 294 : : 295 : : //optimization: storing one after another saves one SSTORE - 296 : 16 : rewardData.index = uint104(newIndex); - 297 : 16 : rewardData.lastUpdateTimestamp = block.timestamp.toUint32(); + 296 : 1903 : rewardData.index = uint104(newIndex); + 297 : 1903 : rewardData.lastUpdateTimestamp = block.timestamp.toUint32(); 298 : : } else { - 299 : 62 : rewardData.lastUpdateTimestamp = block.timestamp.toUint32(); + 299 : 9655 : rewardData.lastUpdateTimestamp = block.timestamp.toUint32(); 300 : : } 301 : : - 302 : 78 : return (newIndex, indexUpdated); + 302 : 11558 : return (newIndex, indexUpdated); 303 : : } 304 : : 305 : : /** @@ -382,26 +382,26 @@ 311 : : * @param assetUnit One unit of asset (10**decimals) 312 : : * @return The rewards accrued since the last update 313 : : **/ - 314 : 17 : function _updateUserData( + 314 : : function _updateUserData( 315 : : RewardsDataTypes.RewardData storage rewardData, 316 : : address user, 317 : : uint256 userBalance, 318 : : uint256 newAssetIndex, 319 : : uint256 assetUnit 320 : : ) internal returns (uint256, bool) { - 321 : 34 : uint256 userIndex = rewardData.usersData[user].index; - 322 : 34 : uint256 rewardsAccrued; - 323 : 34 : bool dataUpdated; - 324 : 17 : if ((dataUpdated = userIndex != newAssetIndex)) { + 321 : 2533 : uint256 userIndex = rewardData.usersData[user].index; + 322 : 2533 : uint256 rewardsAccrued; + 323 : 2533 : bool dataUpdated; + 324 : 2533 : if ((dataUpdated = userIndex != newAssetIndex)) { 325 : : // already checked for overflow in _updateRewardData - 326 : 16 : rewardData.usersData[user].index = uint104(newAssetIndex); - 327 : 16 : if (userBalance != 0) { - 328 : 16 : rewardsAccrued = _getRewards(userBalance, newAssetIndex, userIndex, assetUnit); + 326 : 1903 : rewardData.usersData[user].index = uint104(newAssetIndex); + 327 : 1903 : if (userBalance != 0) { + 328 : 1903 : rewardsAccrued = _getRewards(userBalance, newAssetIndex, userIndex, assetUnit); 329 : : - 330 : 16 : rewardData.usersData[user].accrued += rewardsAccrued.toUint128(); + 330 : 1903 : rewardData.usersData[user].accrued += rewardsAccrued.toUint128(); 331 : : } 332 : : } - 333 : 34 : return (rewardsAccrued, dataUpdated); + 333 : 2533 : return (rewardsAccrued, dataUpdated); 334 : : } 335 : : 336 : : /** @@ -411,33 +411,33 @@ 340 : : * @param userBalance The current user asset balance 341 : : * @param totalSupply Total supply of the asset 342 : : **/ - 343 : 53895 : function _updateData( + 343 : : function _updateData( 344 : : address asset, 345 : : address user, 346 : : uint256 userBalance, 347 : : uint256 totalSupply 348 : : ) internal { - 349 : 107790 : uint256 assetUnit; - 350 : 107790 : uint256 numAvailableRewards = _assets[asset].availableRewardsCount; + 349 : 141340 : uint256 assetUnit; + 350 : 141340 : uint256 numAvailableRewards = _assets[asset].availableRewardsCount; 351 : : unchecked { - 352 : 107790 : assetUnit = 10 ** _assets[asset].decimals; + 352 : 141340 : assetUnit = 10 ** _assets[asset].decimals; 353 : : } 354 : : - 355 : 107790 : if (numAvailableRewards == 0) { - 356 : 107756 : return; + 355 : 141340 : if (numAvailableRewards == 0) { + 356 : 138807 : return; 357 : : } 358 : : unchecked { - 359 : 85 : for (uint128 r = 0; r < numAvailableRewards; r++) { - 360 : 34 : address reward = _assets[asset].availableRewards[r]; - 361 : 34 : RewardsDataTypes.RewardData storage rewardData = _assets[asset].rewards[reward]; + 359 : 2533 : for (uint128 r = 0; r < numAvailableRewards; r++) { + 360 : 2533 : address reward = _assets[asset].availableRewards[r]; + 361 : 2533 : RewardsDataTypes.RewardData storage rewardData = _assets[asset].rewards[reward]; 362 : : - 363 : 51 : (uint256 newAssetIndex, bool rewardDataUpdated) = _updateRewardData( + 363 : 2533 : (uint256 newAssetIndex, bool rewardDataUpdated) = _updateRewardData( 364 : : rewardData, 365 : : totalSupply, 366 : : assetUnit 367 : : ); 368 : : - 369 : 51 : (uint256 rewardsAccrued, bool userDataUpdated) = _updateUserData( + 369 : 2533 : (uint256 rewardsAccrued, bool userDataUpdated) = _updateUserData( 370 : : rewardData, 371 : : user, 372 : : userBalance, @@ -445,8 +445,8 @@ 374 : : assetUnit 375 : : ); 376 : : - 377 : 34 : if (rewardDataUpdated || userDataUpdated) { - 378 : 16 : emit Accrued(asset, reward, user, newAssetIndex, newAssetIndex, rewardsAccrued); + 377 : 2533 : if (rewardDataUpdated || userDataUpdated) { + 378 : 1903 : emit Accrued(asset, reward, user, newAssetIndex, newAssetIndex, rewardsAccrued); 379 : : } 380 : : } 381 : : } @@ -457,12 +457,12 @@ 386 : : * @param user The address of the user 387 : : * @param userAssetBalances List of structs with the user balance and total supply of a set of assets 388 : : **/ - 389 : 8 : function _updateDataMultiple( + 389 : : function _updateDataMultiple( 390 : : address user, 391 : : RewardsDataTypes.UserAssetBalance[] memory userAssetBalances 392 : : ) internal { - 393 : 40 : for (uint256 i = 0; i < userAssetBalances.length; i++) { - 394 : 16 : _updateData( + 393 : 2525 : for (uint256 i = 0; i < userAssetBalances.length; i++) { + 394 : 2525 : _updateData( 395 : : userAssetBalances[i].asset, 396 : : user, 397 : : userAssetBalances[i].userBalance, @@ -478,20 +478,20 @@ 407 : : * @param userAssetBalances List of structs with the user balance and total supply of a set of assets 408 : : * @return unclaimedRewards The accrued rewards for the user until the moment 409 : : **/ - 410 : 10 : function _getUserReward( + 410 : : function _getUserReward( 411 : : address user, 412 : : address reward, 413 : : RewardsDataTypes.UserAssetBalance[] memory userAssetBalances 414 : : ) internal view returns (uint256 unclaimedRewards) { 415 : : // Add unrealized rewards - 416 : 50 : for (uint256 i = 0; i < userAssetBalances.length; i++) { - 417 : 20 : if (userAssetBalances[i].userBalance == 0) { - 418 : 4 : unclaimedRewards += _assets[userAssetBalances[i].asset] + 416 : 1011 : for (uint256 i = 0; i < userAssetBalances.length; i++) { + 417 : 1011 : if (userAssetBalances[i].userBalance == 0) { + 418 : 3 : unclaimedRewards += _assets[userAssetBalances[i].asset] 419 : : .rewards[reward] 420 : : .usersData[user] 421 : : .accrued; 422 : : } else { - 423 : 16 : unclaimedRewards += + 423 : 1008 : unclaimedRewards += 424 : : _getPendingRewards(user, reward, userAssetBalances[i]) + 425 : : _assets[userAssetBalances[i].asset].rewards[reward].usersData[user].accrued; 426 : : } @@ -507,19 +507,19 @@ 436 : : * @param userAssetBalance struct with the user balance and total supply of the incentivized asset 437 : : * @return The pending rewards for the user since the last user action 438 : : **/ - 439 : 9 : function _getPendingRewards( + 439 : : function _getPendingRewards( 440 : : address user, 441 : : address reward, 442 : : RewardsDataTypes.UserAssetBalance memory userAssetBalance 443 : : ) internal view returns (uint256) { - 444 : 18 : RewardsDataTypes.RewardData storage rewardData = _assets[userAssetBalance.asset].rewards[ + 444 : 1009 : RewardsDataTypes.RewardData storage rewardData = _assets[userAssetBalance.asset].rewards[ 445 : : reward 446 : : ]; - 447 : 27 : uint256 assetUnit = 10 ** _assets[userAssetBalance.asset].decimals; - 448 : 27 : (, uint256 nextIndex) = _getAssetIndex(rewardData, userAssetBalance.totalSupply, assetUnit); + 447 : 1009 : uint256 assetUnit = 10 ** _assets[userAssetBalance.asset].decimals; + 448 : 1009 : (, uint256 nextIndex) = _getAssetIndex(rewardData, userAssetBalance.totalSupply, assetUnit); 449 : : - 450 : 18 : return - 451 : 18 : _getRewards( + 450 : 1009 : return + 451 : 1009 : _getRewards( 452 : : userAssetBalance.userBalance, 453 : : nextIndex, 454 : : rewardData.usersData[user].index, @@ -535,17 +535,17 @@ 464 : : * @param assetUnit One unit of asset (10**decimals) 465 : : * @return The rewards 466 : : **/ - 467 : 17 : function _getRewards( + 467 : : function _getRewards( 468 : : uint256 userBalance, 469 : : uint256 reserveIndex, 470 : : uint256 userIndex, 471 : : uint256 assetUnit 472 : : ) internal pure returns (uint256) { - 473 : 51 : uint256 result = userBalance * (reserveIndex - userIndex); + 473 : 2912 : uint256 result = userBalance * (reserveIndex - userIndex); 474 : : assembly { - 475 : 34 : result := div(result, assetUnit) + 475 : 2912 : result := div(result, assetUnit) 476 : : } - 477 : 34 : return result; + 477 : 2912 : return result; 478 : : } 479 : : 480 : : /** @@ -555,34 +555,34 @@ 484 : : * @param assetUnit One unit of asset (10**decimals) 485 : : * @return The new index. 486 : : **/ - 487 : 49 : function _getAssetIndex( + 487 : : function _getAssetIndex( 488 : : RewardsDataTypes.RewardData storage rewardData, 489 : : uint256 totalSupply, 490 : : uint256 assetUnit 491 : : ) internal view returns (uint256, uint256) { - 492 : 98 : uint256 oldIndex = rewardData.index; - 493 : 98 : uint256 distributionEnd = rewardData.distributionEnd; - 494 : 98 : uint256 emissionPerSecond = rewardData.emissionPerSecond; - 495 : 98 : uint256 lastUpdateTimestamp = rewardData.lastUpdateTimestamp; + 492 : 50521 : uint256 oldIndex = rewardData.index; + 493 : 50521 : uint256 distributionEnd = rewardData.distributionEnd; + 494 : 50521 : uint256 emissionPerSecond = rewardData.emissionPerSecond; + 495 : 50521 : uint256 lastUpdateTimestamp = rewardData.lastUpdateTimestamp; 496 : : 497 : : if ( - 498 : 245 : emissionPerSecond == 0 || - 499 : 58 : totalSupply == 0 || - 500 : 36 : lastUpdateTimestamp == block.timestamp || - 501 : 36 : lastUpdateTimestamp >= distributionEnd + 498 : 50521 : emissionPerSecond == 0 || + 499 : 40167 : totalSupply == 0 || + 500 : 31462 : lastUpdateTimestamp == block.timestamp || + 501 : 20033 : lastUpdateTimestamp >= distributionEnd 502 : : ) { - 503 : 62 : return (oldIndex, oldIndex); + 503 : 31961 : return (oldIndex, oldIndex); 504 : : } 505 : : - 506 : 54 : uint256 currentTimestamp = block.timestamp > distributionEnd + 506 : 18560 : uint256 currentTimestamp = block.timestamp > distributionEnd 507 : : ? distributionEnd 508 : : : block.timestamp; - 509 : 54 : uint256 timeDelta = currentTimestamp - lastUpdateTimestamp; - 510 : 72 : uint256 firstTerm = emissionPerSecond * timeDelta * assetUnit; + 509 : 18560 : uint256 timeDelta = currentTimestamp - lastUpdateTimestamp; + 510 : 18560 : uint256 firstTerm = emissionPerSecond * timeDelta * assetUnit; 511 : : assembly { - 512 : 36 : firstTerm := div(firstTerm, totalSupply) + 512 : 18560 : firstTerm := div(firstTerm, totalSupply) 513 : : } - 514 : 36 : return (oldIndex, (firstTerm + oldIndex)); + 514 : 18560 : return (oldIndex, (firstTerm + oldIndex)); 515 : : } 516 : : 517 : : /** @@ -597,13 +597,13 @@ 526 : : ) internal view virtual returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances); 527 : : 528 : : /// @inheritdoc IRewardsDistributor - 529 : 2 : function getAssetDecimals(address asset) external view returns (uint8) { - 530 : 4 : return _assets[asset].decimals; + 529 : : function getAssetDecimals(address asset) external view returns (uint8) { + 530 : 2 : return _assets[asset].decimals; 531 : : } 532 : : 533 : : /// @inheritdoc IRewardsDistributor - 534 : 3 : function getEmissionManager() external view returns (address) { - 535 : 6 : return EMISSION_MANAGER; + 534 : : function getEmissionManager() external view returns (address) { + 535 : 5 : return EMISSION_MANAGER; 536 : : } 537 : : } @@ -613,8 +613,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index.html b/report/rewards/index-sort-b.html similarity index 57% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/index.html rename to report/rewards/index-sort-b.html index c312bdc4..40bea0d0 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index.html +++ b/report/rewards/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards - + LCOV - lcov.info.p - rewards + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewardstop level - rewards Coveragelcov.info.p Lines:99.1 %21421298.6 %219216
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %555596.7 %6159
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - EmissionManager.sol + EmissionManager.sol -
100.0%
+
100.0%
100.0 % - 16 - 16 + 18 + 18 - 100.0 % - 10 - 10 + 12 + 12 - RewardsController.sol + RewardsController.sol -
98.7%98.7%
+
98.8%98.8%
- 98.7 % + 98.8 % + 80 79 - 78 - - 100.0 % - 23 - 23 + 96.0 % + 25 + 24 - RewardsDistributor.sol + RewardsDistributor.sol -
99.2%99.2%
+
98.3%98.3%
- 99.2 % + 98.3 % + 121 119 - 118 - - 100.0 % - 22 - 22 + 95.8 % + 24 + 23

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-f.html b/report/rewards/index-sort-f.html similarity index 57% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-f.html rename to report/rewards/index-sort-f.html index 52a4a0d6..f8ef4622 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-f.html +++ b/report/rewards/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards - + LCOV - lcov.info.p - rewards + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewardstop level - rewards Coveragelcov.info.p Lines:99.1 %21421298.6 %219216
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %555596.7 %6159
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - EmissionManager.sol + RewardsDistributor.sol -
100.0%
+
98.3%98.3%
- 100.0 % - 16 - 16 + 98.3 % + 121 + 119 - - 100.0 % - 10 - 10 + 95.8 % + 24 + 23 - RewardsDistributor.sol + RewardsController.sol -
99.2%99.2%
+
98.8%98.8%
- 99.2 % - 119 - 118 + 98.8 % + 80 + 79 - - 100.0 % - 22 - 22 + 96.0 % + 25 + 24 - RewardsController.sol + EmissionManager.sol -
98.7%98.7%
+
100.0%
- 98.7 % - 79 - 78 + 100.0 % + 18 + 18 - 100.0 % - 23 - 23 + 12 + 12

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-l.html b/report/rewards/index-sort-l.html similarity index 57% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-l.html rename to report/rewards/index-sort-l.html index 03d2ac1a..9d3a50d5 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-l.html +++ b/report/rewards/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards - + LCOV - lcov.info.p - rewards + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewardstop level - rewards Coveragelcov.info.p Lines:99.1 %21421298.6 %219216
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %555596.7 %6159
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - RewardsController.sol + RewardsDistributor.sol -
98.7%98.7%
+
98.3%98.3%
- 98.7 % - 79 - 78 + 98.3 % + 121 + 119 - - 100.0 % - 23 + 95.8 % + 24 23 - RewardsDistributor.sol + RewardsController.sol -
99.2%99.2%
+
98.8%98.8%
- 99.2 % - 119 - 118 + 98.8 % + 80 + 79 - - 100.0 % - 22 - 22 + 96.0 % + 25 + 24 - EmissionManager.sol + EmissionManager.sol -
100.0%
+
100.0%
100.0 % - 16 - 16 + 18 + 18 - 100.0 % - 10 - 10 + 12 + 12

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-b.html b/report/rewards/index.html similarity index 57% rename from report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-b.html rename to report/rewards/index.html index e5282164..a50dcfc8 100644 --- a/report/periphery/contracts/rewards/src/periphery/contracts/rewards/index-sort-b.html +++ b/report/rewards/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/src/periphery/contracts/rewards - + LCOV - lcov.info.p - rewards + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/src/periphery/contracts/rewardstop level - rewards Coveragelcov.info.p Lines:99.1 %21421298.6 %219216
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %555596.7 %6159
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - EmissionManager.sol + EmissionManager.sol -
100.0%
+
100.0%
100.0 % - 16 - 16 + 18 + 18 - 100.0 % - 10 - 10 + 12 + 12 - RewardsController.sol + RewardsController.sol -
98.7%98.7%
+
98.8%98.8%
- 98.7 % + 98.8 % + 80 79 - 78 - - 100.0 % - 23 - 23 + 96.0 % + 25 + 24 - RewardsDistributor.sol + RewardsDistributor.sol -
99.2%99.2%
+
98.3%98.3%
- 99.2 % + 98.3 % + 121 119 - 118 - - 100.0 % - 22 - 22 + 95.8 % + 24 + 23

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html similarity index 64% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html rename to report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html index cf59fe14..744cbbcd 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html +++ b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/PullRewardsTransferStrategy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions) Coverage Lines: 100.0 %3344
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + - + @@ -77,11 +77,18 @@ + + + + + + + - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
1
PullRewardsTransferStrategy.866
PullRewardsTransferStrategy.performTransfer71902
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html similarity index 64% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html rename to report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html index ed02ea5a..b36edeb1 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html +++ b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/PullRewardsTransferStrategy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions) Coverage Lines: 100.0 %3344
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
- + + + + + + + + - + @@ -81,7 +88,7 @@ - + @@ -89,8 +96,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
PullRewardsTransferStrategy.Hit count Sort by function hit count866
PullRewardsTransferStrategy.performTransfer71902
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html similarity index 79% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html rename to report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html index c52092d8..28784529 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html +++ b/report/rewards/transfer-strategies/PullRewardsTransferStrategy.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol - + LCOV - lcov.info.p - rewards/transfer-strategies/PullRewardsTransferStrategy.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - PullRewardsTransferStrategy.sol (source / functions) Coverage Lines: 100.0 %3344
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %2233
0 0
@@ -75,8 +75,8 @@ 4 : : import {IPullRewardsTransferStrategy} from '../interfaces/IPullRewardsTransferStrategy.sol'; 5 : : import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; 6 : : import {TransferStrategyBase} from './TransferStrategyBase.sol'; - 7 : : import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; - 8 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; + 7 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; + 8 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 9 : : 10 : : /** 11 : : * @title PullRewardsTransferStrategy @@ -94,11 +94,11 @@ 23 : : address rewardsAdmin, 24 : : address rewardsVault 25 : : ) TransferStrategyBase(incentivesController, rewardsAdmin) { - 26 : : REWARDS_VAULT = rewardsVault; + 26 : 380 : REWARDS_VAULT = rewardsVault; 27 : : } 28 : : 29 : : /// @inheritdoc TransferStrategyBase - 30 : 7 : function performTransfer( + 30 : : function performTransfer( 31 : : address to, 32 : : address reward, 33 : : uint256 amount @@ -108,14 +108,14 @@ 37 : : onlyIncentivesController 38 : : returns (bool) 39 : : { - 40 : 14 : IERC20(reward).safeTransferFrom(REWARDS_VAULT, to, amount); + 40 : 1902 : IERC20(reward).safeTransferFrom(REWARDS_VAULT, to, amount); 41 : : - 42 : 14 : return true; + 42 : 1902 : return true; 43 : : } 44 : : 45 : : /// @inheritdoc IPullRewardsTransferStrategy - 46 : 1 : function getRewardsVault() external view returns (address) { - 47 : 2 : return REWARDS_VAULT; + 46 : : function getRewardsVault() external view returns (address) { + 47 : 1 : return REWARDS_VAULT; 48 : : } 49 : : } @@ -125,8 +125,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html similarity index 67% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html rename to report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html index 95d87bcd..b68d95c7 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html +++ b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/StakedTokenTransferStrategy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions) Coveragelcov.info.p Lines:100.0 %866.7 %12 8
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + + + + + + + + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
StakedTokenTransferStrategy.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html similarity index 67% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html rename to report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html index 26f341d4..f0e7459a 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html +++ b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/StakedTokenTransferStrategy.sol - functions + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions) Coveragelcov.info.p Lines:100.0 %866.7 %12 8
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
- + + + + + + + + - + @@ -110,8 +117,8 @@

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit count
StakedTokenTransferStrategy.Hit count Sort by function hit count0
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html similarity index 76% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html rename to report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html index 07c0b5dc..b71c62ba 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html +++ b/report/rewards/transfer-strategies/StakedTokenTransferStrategy.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol - + LCOV - lcov.info.p - rewards/transfer-strategies/StakedTokenTransferStrategy.sol + - + - +
LCOV - code coverage report
- + @@ -31,17 +31,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions)top level - rewards/transfer-strategies - StakedTokenTransferStrategy.sol (source / functions) Coveragelcov.info.p Lines:100.0 %866.7 %12 8
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %583.3 %6 5
0 0
@@ -76,8 +76,8 @@ 5 : : import {IStakedTokenTransferStrategy} from '../interfaces/IStakedTokenTransferStrategy.sol'; 6 : : import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; 7 : : import {TransferStrategyBase} from './TransferStrategyBase.sol'; - 8 : : import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; - 9 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; + 8 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; + 9 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 10 : : 11 : : /** 12 : : * @title StakedTokenTransferStrategy @@ -96,15 +96,15 @@ 25 : : address rewardsAdmin, 26 : : IStakedToken stakeToken 27 : : ) TransferStrategyBase(incentivesController, rewardsAdmin) { - 28 : : STAKE_CONTRACT = stakeToken; - 29 : : UNDERLYING_TOKEN = STAKE_CONTRACT.STAKED_TOKEN(); + 28 : 0 : STAKE_CONTRACT = stakeToken; + 29 : 0 : UNDERLYING_TOKEN = STAKE_CONTRACT.STAKED_TOKEN(); 30 : : - 31 : : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); - 32 : : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), type(uint256).max); + 31 : 0 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); + 32 : 0 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), type(uint256).max); 33 : : } 34 : : 35 : : /// @inheritdoc TransferStrategyBase - 36 : 1 : function performTransfer( + 36 : : function performTransfer( 37 : : address to, 38 : : address reward, 39 : : uint256 amount @@ -114,32 +114,32 @@ 43 : : onlyIncentivesController 44 : : returns (bool) 45 : : { - 46 : 2 : require(reward == address(STAKE_CONTRACT), 'REWARD_TOKEN_NOT_STAKE_CONTRACT'); + 46 : 1 : require(reward == address(STAKE_CONTRACT), 'REWARD_TOKEN_NOT_STAKE_CONTRACT'); 47 : : - 48 : 2 : STAKE_CONTRACT.stake(to, amount); + 48 : 1 : STAKE_CONTRACT.stake(to, amount); 49 : : - 50 : 2 : return true; + 50 : 1 : return true; 51 : : } 52 : : 53 : : /// @inheritdoc IStakedTokenTransferStrategy - 54 : 1 : function renewApproval() external onlyRewardsAdmin { - 55 : 2 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); - 56 : 2 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), type(uint256).max); + 54 : : function renewApproval() external onlyRewardsAdmin { + 55 : 1 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); + 56 : 1 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), type(uint256).max); 57 : : } 58 : : 59 : : /// @inheritdoc IStakedTokenTransferStrategy - 60 : 1 : function dropApproval() external onlyRewardsAdmin { - 61 : 2 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); + 60 : : function dropApproval() external onlyRewardsAdmin { + 61 : 1 : IERC20(UNDERLYING_TOKEN).approve(address(STAKE_CONTRACT), 0); 62 : : } 63 : : 64 : : /// @inheritdoc IStakedTokenTransferStrategy - 65 : 1 : function getStakeContract() external view returns (address) { - 66 : 3 : return address(STAKE_CONTRACT); + 65 : : function getStakeContract() external view returns (address) { + 66 : 1 : return address(STAKE_CONTRACT); 67 : : } 68 : : 69 : : /// @inheritdoc IStakedTokenTransferStrategy - 70 : 1 : function getUnderlyingToken() external view returns (address) { - 71 : 2 : return UNDERLYING_TOKEN; + 70 : : function getUnderlyingToken() external view returns (address) { + 71 : 1 : return UNDERLYING_TOKEN; 72 : : } 73 : : } @@ -149,8 +149,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html b/report/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html similarity index 57% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html rename to report/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html index 9221e237..baaa9b82 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html +++ b/report/rewards/transfer-strategies/TransferStrategyBase.sol.func-c.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/TransferStrategyBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,21 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - TransferStrategyBase.sol (source / functions)top level - rewards/transfer-strategies - TransferStrategyBase.sol (source / functions) Coverage Lines: 100.0 %4488
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3366
0 0
- + - + @@ -91,13 +91,34 @@ + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
1
TransferStrategyBase.onlyRewardsAdmin1
TransferStrategyBase.344
TransferStrategyBase.onlyIncentivesController1903

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func.html b/report/rewards/transfer-strategies/TransferStrategyBase.sol.func.html similarity index 57% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func.html rename to report/rewards/transfer-strategies/TransferStrategyBase.sol.func.html index 4a7b7bdd..ce59f793 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.func.html +++ b/report/rewards/transfer-strategies/TransferStrategyBase.sol.func.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol - functions - + LCOV - lcov.info.p - rewards/transfer-strategies/TransferStrategyBase.sol - functions + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,21 +53,28 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - TransferStrategyBase.sol (source / functions)top level - rewards/transfer-strategies - TransferStrategyBase.sol (source / functions) Coverage Lines: 100.0 %4488
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3366
0 0
- + - + + + + + + + + @@ -91,13 +98,27 @@ + + + + + + + + + + + + + +

Function Name Sort by function nameFunction Name Sort by function nameHit count Sort by function hit countHit count Sort by function hit count
TransferStrategyBase.344
1
TransferStrategyBase.onlyIncentivesController1903
TransferStrategyBase.onlyRewardsAdmin1

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html b/report/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html similarity index 78% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html rename to report/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html index 7ae8da4c..6eb5665f 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html +++ b/report/rewards/transfer-strategies/TransferStrategyBase.sol.gcov.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/TransferStrategyBase.sol - + LCOV - lcov.info.p - rewards/transfer-strategies/TransferStrategyBase.sol + - + - +
LCOV - code coverage report
- + @@ -32,17 +32,17 @@ - - + + - + - - + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - TransferStrategyBase.sol (source / functions)top level - rewards/transfer-strategies - TransferStrategyBase.sol (source / functions) Coverage Lines: 100.0 %4488
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions: 100.0 %3366
0 0
@@ -73,8 +73,8 @@ 2 : : pragma solidity ^0.8.10; 3 : : 4 : : import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; - 5 : : import {GPv2SafeERC20} from 'aave-v3-core/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; - 6 : : import {IERC20} from 'aave-v3-core/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; + 5 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol'; + 6 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; 7 : : 8 : : /** 9 : : * @title TransferStrategyStorage @@ -87,15 +87,15 @@ 16 : : address internal immutable REWARDS_ADMIN; 17 : : 18 : : constructor(address incentivesController, address rewardsAdmin) { - 19 : : INCENTIVES_CONTROLLER = incentivesController; - 20 : : REWARDS_ADMIN = rewardsAdmin; + 19 : 344 : INCENTIVES_CONTROLLER = incentivesController; + 20 : 398 : REWARDS_ADMIN = rewardsAdmin; 21 : : } 22 : : 23 : : /** 24 : : * @dev Modifier for incentives controller only functions 25 : : */ 26 : : modifier onlyIncentivesController() { - 27 : : require(INCENTIVES_CONTROLLER == msg.sender, 'CALLER_NOT_INCENTIVES_CONTROLLER'); + 27 : 1903 : require(INCENTIVES_CONTROLLER == msg.sender, 'CALLER_NOT_INCENTIVES_CONTROLLER'); 28 : : _; 29 : : } 30 : : @@ -103,18 +103,18 @@ 32 : : * @dev Modifier for reward admin only functions 33 : : */ 34 : : modifier onlyRewardsAdmin() { - 35 : : require(msg.sender == REWARDS_ADMIN, 'ONLY_REWARDS_ADMIN'); + 35 : 1 : require(msg.sender == REWARDS_ADMIN, 'ONLY_REWARDS_ADMIN'); 36 : : _; 37 : : } 38 : : 39 : : /// @inheritdoc ITransferStrategyBase - 40 : 1 : function getIncentivesController() external view override returns (address) { - 41 : 2 : return INCENTIVES_CONTROLLER; + 40 : : function getIncentivesController() external view override returns (address) { + 41 : 1 : return INCENTIVES_CONTROLLER; 42 : : } 43 : : 44 : : /// @inheritdoc ITransferStrategyBase - 45 : 1 : function getRewardsAdmin() external view override returns (address) { - 46 : 2 : return REWARDS_ADMIN; + 45 : : function getRewardsAdmin() external view override returns (address) { + 46 : 1 : return REWARDS_ADMIN; 47 : : } 48 : : 49 : : /// @inheritdoc ITransferStrategyBase @@ -125,14 +125,14 @@ 54 : : ) external virtual returns (bool); 55 : : 56 : : /// @inheritdoc ITransferStrategyBase - 57 : 1 : function emergencyWithdrawal( + 57 : : function emergencyWithdrawal( 58 : : address token, 59 : : address to, 60 : : uint256 amount 61 : : ) external onlyRewardsAdmin { - 62 : 2 : IERC20(token).safeTransfer(to, amount); + 62 : 1 : IERC20(token).safeTransfer(to, amount); 63 : : - 64 : 2 : emit EmergencyWithdrawal(msg.sender, token, to, amount); + 64 : 1 : emit EmergencyWithdrawal(msg.sender, token, to, amount); 65 : : } 66 : : } @@ -142,8 +142,8 @@
- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-b.html b/report/rewards/transfer-strategies/index-sort-b.html similarity index 60% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-b.html rename to report/rewards/transfer-strategies/index-sort-b.html index 93cc44a3..3a810862 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-b.html +++ b/report/rewards/transfer-strategies/index-sort-b.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - + LCOV - lcov.info.p - rewards/transfer-strategies + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategiestop level - rewards/transfer-strategies Coveragelcov.info.p Lines:100.0 %151583.3 %2420
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %101093.3 %1514
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - PullRewardsTransferStrategy.sol + PullRewardsTransferStrategy.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 4 + 4 - 100.0 % - 2 - 2 + 3 + 3 - StakedTokenTransferStrategy.sol + StakedTokenTransferStrategy.sol -
100.0%
+
66.7%66.7%
- 100.0 % - 8 + 66.7 % + 12 8 - - 100.0 % - 5 + 83.3 % + 6 5 - TransferStrategyBase.sol + TransferStrategyBase.sol -
100.0%
+
100.0%
100.0 % - 4 - 4 + 8 + 8 - 100.0 % - 3 - 3 + 6 + 6

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-f.html b/report/rewards/transfer-strategies/index-sort-f.html similarity index 60% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-f.html rename to report/rewards/transfer-strategies/index-sort-f.html index a0bf2774..dd9ad31f 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-f.html +++ b/report/rewards/transfer-strategies/index-sort-f.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - + LCOV - lcov.info.p - rewards/transfer-strategies + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategiestop level - rewards/transfer-strategies Coveragelcov.info.p Lines:100.0 %151583.3 %2420
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %101093.3 %1514
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - PullRewardsTransferStrategy.sol + StakedTokenTransferStrategy.sol -
100.0%
+
66.7%66.7%
- 100.0 % - 3 - 3 + 66.7 % + 12 + 8 - - 100.0 % - 2 - 2 + 83.3 % + 6 + 5 - TransferStrategyBase.sol + PullRewardsTransferStrategy.sol -
100.0%
+
100.0%
100.0 % 4 @@ -126,9 +126,9 @@ 3 - StakedTokenTransferStrategy.sol + TransferStrategyBase.sol -
100.0%
+
100.0%
100.0 % 8 @@ -137,16 +137,16 @@ 100.0 % - 5 - 5 + 6 + 6

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-l.html b/report/rewards/transfer-strategies/index-sort-l.html similarity index 60% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-l.html rename to report/rewards/transfer-strategies/index-sort-l.html index 5949512f..d96ecee6 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index-sort-l.html +++ b/report/rewards/transfer-strategies/index-sort-l.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - + LCOV - lcov.info.p - rewards/transfer-strategies + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategiestop level - rewards/transfer-strategies Coveragelcov.info.p Lines:100.0 %151583.3 %2420
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %101093.3 %1514
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,24 +96,24 @@ Hit - PullRewardsTransferStrategy.sol + StakedTokenTransferStrategy.sol -
100.0%
+
66.7%66.7%
- 100.0 % - 3 - 3 + 66.7 % + 12 + 8 - - 100.0 % - 2 - 2 + 83.3 % + 6 + 5 - TransferStrategyBase.sol + PullRewardsTransferStrategy.sol -
100.0%
+
100.0%
100.0 % 4 @@ -126,9 +126,9 @@ 3 - StakedTokenTransferStrategy.sol + TransferStrategyBase.sol -
100.0%
+
100.0%
100.0 % 8 @@ -137,16 +137,16 @@ 100.0 % - 5 - 5 + 6 + 6

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

diff --git a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index.html b/report/rewards/transfer-strategies/index.html similarity index 60% rename from report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index.html rename to report/rewards/transfer-strategies/index.html index 1059339f..c141bbe9 100644 --- a/report/periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies/index.html +++ b/report/rewards/transfer-strategies/index.html @@ -4,22 +4,22 @@ - LCOV - lcov.info.p - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategies - + LCOV - lcov.info.p - rewards/transfer-strategies + - + - +
LCOV - code coverage report
- + @@ -31,18 +31,18 @@ - - - + + + - + - - - + + + @@ -53,12 +53,12 @@ - +
Current view:top level - periphery/contracts/rewards/transfer-strategies/src/periphery/contracts/rewards/transfer-strategiestop level - rewards/transfer-strategies Coveragelcov.info.p Lines:100.0 %151583.3 %2420
Test Date:2024-04-09 14:12:282024-09-24 09:34:24 Functions:100.0 %101093.3 %1514
0 0
@@ -79,10 +79,10 @@ - Filename Sort by file name - Line Coverage Sort by line coverage - Branch Coverage Sort by branch coverage - Function Coverage Sort by function coverage + File Sort by file name + Line Coverage Sort by line coverage + Branch Coverage Sort by branch coverage + Function Coverage Sort by function coverage Rate @@ -96,57 +96,57 @@ Hit - PullRewardsTransferStrategy.sol + PullRewardsTransferStrategy.sol -
100.0%
+
100.0%
100.0 % - 3 - 3 + 4 + 4 - 100.0 % - 2 - 2 + 3 + 3 - StakedTokenTransferStrategy.sol + StakedTokenTransferStrategy.sol -
100.0%
+
66.7%66.7%
- 100.0 % - 8 + 66.7 % + 12 8 - - 100.0 % - 5 + 83.3 % + 6 5 - TransferStrategyBase.sol + TransferStrategyBase.sol -
100.0%
+
100.0%
100.0 % - 4 - 4 + 8 + 8 - 100.0 % - 3 - 3 + 6 + 6

- - + +
Generated by: LCOV version 2.0-1
Generated by: LCOV version 2.1-1

From be45428a4c927e2a0d73a3c89901a3ed4c207887 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 24 Sep 2024 14:57:19 +0200 Subject: [PATCH 88/88] feat: script (#32) * feat: add library deploy scripts * fix: patch eMode snapshots --- Makefile | 13 +++++++++++++ foundry.toml | 14 ++++++++------ tests/utils/ProtocolV3TestBase.sol | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 8db35cf3..8db7ae3b 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,22 @@ coverage : make coverage-clean make coverage-report make coverage-badge + # Utilities download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address} git-diff : @mkdir -p diffs @npx prettier ${before} ${after} --write @printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md + +# Deploy +deploy-libs-one :; + forge script scripts/misc/LibraryPreCompileOne.sol --rpc-url ${chain} --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --slow --broadcast +deploy-libs-two :; + forge script scripts/misc/LibraryPreCompileTwo.sol --rpc-url ${chain} --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --slow --broadcast + +deploy-libs : + make deploy-libs-one chain=${chain} + npx catapulta-verify -b broadcast/LibraryPreCompileOne.sol/${chainId}/run-latest.json + make deploy-libs-two chain=${chain} + npx catapulta-verify -b broadcast/LibraryPreCompileTwo.sol/${chainId}/run-latest.json diff --git a/foundry.toml b/foundry.toml index 97da41a2..a2c225e2 100644 --- a/foundry.toml +++ b/foundry.toml @@ -40,6 +40,7 @@ bnb_testnet = "${RPC_BNB_TESTNET}" bnb = "${RPC_BNB}" gnosis = "${RPC_GNOSIS}" base = "${RPC_BASE}" +metis = "${RPC_METIS}" [etherscan] mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 1 } @@ -47,14 +48,15 @@ optimism = { key = "${ETHERSCAN_API_KEY_OPTIMISM}", chainId = 10 } avalanche = { key = "${ETHERSCAN_API_KEY_AVALANCHE}", chainId = 43114 } polygon = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 137 } arbitrum = { key = "${ETHERSCAN_API_KEY_ARBITRUM}", chainId = 42161 } -fantom = { key = "${ETHERSCAN_API_KEY_FANTOM}", chainId = 250 } +# fantom = { key = "${ETHERSCAN_API_KEY_FANTOM}", chainId = 250 } scroll = { key = "${ETHERSCAN_API_KEY_SCROLL}", chainId = 534352, url = 'https://api.scrollscan.com/api\?' } -celo = { key = "${ETHERSCAN_API_KEY_CELO}", chainId = 42220 } -sepolia = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 11155111 } -mumbai = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80001 } -amoy = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80002 } -bnb_testnet = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 97, url = 'https://api-testnet.bscscan.com/api' } +# celo = { key = "${ETHERSCAN_API_KEY_CELO}", chainId = 42220 } +# sepolia = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 11155111 } +# mumbai = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80001 } +# amoy = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 80002 } +# bnb_testnet = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 97, url = 'https://api-testnet.bscscan.com/api' } bnb = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 56, url = 'https://api.bscscan.com/api' } base = { key = "${ETHERSCAN_API_KEY_BASE}", chain = 8453 } gnosis = { key = "${ETHERSCAN_API_KEY_GNOSIS}", chainId = 100 } +metis = { key = "", chainId = 1088, url = 'https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan/api' } # See more config options https://github.com/gakonst/foundry/tree/master/config diff --git a/tests/utils/ProtocolV3TestBase.sol b/tests/utils/ProtocolV3TestBase.sol index 407ab8dc..dbfbea39 100644 --- a/tests/utils/ProtocolV3TestBase.sol +++ b/tests/utils/ProtocolV3TestBase.sol @@ -156,6 +156,7 @@ contract ProtocolV3TestBase is DiffUtils { // keys for json stringification string memory eModesKey = 'emodes'; string memory content = '{}'; + vm.serializeJson(eModesKey, '{}'); uint8 emptyCounter = 0; for (uint8 i = 0; i < 256; i++) { DataTypes.CollateralConfig memory cfg = pool.getEModeCategoryCollateralConfig(i); @@ -163,6 +164,7 @@ contract ProtocolV3TestBase is DiffUtils { if (++emptyCounter > 2) break; } else { string memory key = vm.toString(i); + vm.serializeJson(key, '{}'); vm.serializeUint(key, 'eModeCategory', i); vm.serializeString(key, 'label', pool.getEModeCategoryLabel(i)); vm.serializeUint(key, 'ltv', cfg.ltv);