From a0dca17ee88fbbf8aa463e8fb461ee03491c0622 Mon Sep 17 00:00:00 2001 From: dhairya <55102840+DhairyaSethi@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:28:40 +0530 Subject: [PATCH] fix: Removes max variable borrow rate check in GhoAaveSteward for rates updates (#436) * feat(aave steward): rm max variable borrow rate check * upd: sync change with certora * doc: fix natspec of `updateGhoBorrowRate` --- certora/steward/specs/GhoAaveSteward.spec | 18 -------- src/contracts/misc/GhoAaveSteward.sol | 11 ----- .../misc/interfaces/IGhoAaveSteward.sol | 7 ---- src/test/TestGhoAaveSteward.t.sol | 41 ++++++++++--------- src/test/helpers/Constants.sol | 1 - 5 files changed, 22 insertions(+), 56 deletions(-) diff --git a/certora/steward/specs/GhoAaveSteward.spec b/certora/steward/specs/GhoAaveSteward.spec index 15514470..7d9a28d5 100644 --- a/certora/steward/specs/GhoAaveSteward.spec +++ b/certora/steward/specs/GhoAaveSteward.spec @@ -32,7 +32,6 @@ methods { function getGhoTimelocks() external returns (IGhoAaveSteward.GhoDebounce) envfree; - function GHO_BORROW_RATE_MAX() external returns uint32 envfree; function MINIMUM_DELAY() external returns uint256 envfree; function RISK_COUNCIL() external returns address envfree; @@ -225,23 +224,6 @@ rule updateGhoSupplyCap__correctness() { } -rule updateGhoBorrowRate__correctness() { - env e; uint16 optimalUsageRatio; uint32 baseVariableBorrowRate; - uint32 variableRateSlope1; uint32 variableRateSlope2; - - uint16 optimalUsageRatio_before = OPTIMAL_USAGE_RATIO; - uint32 baseVariableBorrowRate_before = BASE_VARIABLE_BORROW_RATE; - uint32 variableRateSlope1_before = VARIABLE_RATE_SLOPE1; - uint32 variableRateSlope2_before = VARIABLE_RATE_SLOPE2; - - updateGhoBorrowRate(e,optimalUsageRatio, baseVariableBorrowRate, variableRateSlope1, variableRateSlope2); - - - assert baseVariableBorrowRate + variableRateSlope1 + variableRateSlope2 <= to_mathint(GHO_BORROW_RATE_MAX()); -} - - - diff --git a/src/contracts/misc/GhoAaveSteward.sol b/src/contracts/misc/GhoAaveSteward.sol index 5481f064..2f0d765b 100644 --- a/src/contracts/misc/GhoAaveSteward.sol +++ b/src/contracts/misc/GhoAaveSteward.sol @@ -21,9 +21,6 @@ import {RiskCouncilControlled} from './RiskCouncilControlled.sol'; contract GhoAaveSteward is Ownable, RiskCouncilControlled, IGhoAaveSteward { using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - /// @inheritdoc IGhoAaveSteward - uint32 public constant GHO_BORROW_RATE_MAX = 0.25e4; // 25.00% - uint256 internal constant BPS_MAX = 100_00; /// @inheritdoc IGhoAaveSteward @@ -227,14 +224,6 @@ contract GhoAaveSteward is Ownable, RiskCouncilControlled, IGhoAaveSteward { ), 'INVALID_VARIABLE_RATE_SLOPE2' ); - - require( - uint256(newRates.baseVariableBorrowRate) + - uint256(newRates.variableRateSlope1) + - uint256(newRates.variableRateSlope2) <= - GHO_BORROW_RATE_MAX, - 'BORROW_RATE_HIGHER_THAN_MAX' - ); } /** diff --git a/src/contracts/misc/interfaces/IGhoAaveSteward.sol b/src/contracts/misc/interfaces/IGhoAaveSteward.sol index 002ae3ef..8d74ed24 100644 --- a/src/contracts/misc/interfaces/IGhoAaveSteward.sol +++ b/src/contracts/misc/interfaces/IGhoAaveSteward.sol @@ -30,7 +30,6 @@ interface IGhoAaveSteward { * @notice Updates the borrow rate of GHO, only if: * - respects `MINIMUM_DELAY`, the minimum time delay between updates * - the update changes parameters up to the maximum allowed change according to risk config - * - the update is lower than `GHO_BORROW_RATE_MAX` * @dev Only callable by Risk Council * @dev Values are all expressed in BPS * @param optimalUsageRatio The new optimal usage ratio @@ -90,12 +89,6 @@ interface IGhoAaveSteward { */ function getGhoTimelocks() external view returns (GhoDebounce memory); - /** - * @notice Returns maximum value that can be assigned to GHO borrow rate. - * @return The maximum value that can be assigned to GHO borrow rate in ray (e.g. 0.01e27 results in 1.0%) - */ - function GHO_BORROW_RATE_MAX() external view returns (uint32); - /** * @notice The address of pool data provider of the POOL the steward controls */ diff --git a/src/test/TestGhoAaveSteward.t.sol b/src/test/TestGhoAaveSteward.t.sol index 8b546b25..868a0e70 100644 --- a/src/test/TestGhoAaveSteward.t.sol +++ b/src/test/TestGhoAaveSteward.t.sol @@ -327,6 +327,21 @@ contract TestGhoAaveSteward is TestGhoBase { assertEq(currentBorrowRate, newBorrowRate); } + function testUpdateGhoBorrowRateUpwardsFromHigh() public { + // set a very high borrow rate of 80% + uint32 highBaseBorrowRate = 0.80e4; + _setGhoBorrowRateViaConfigurator(highBaseBorrowRate); + highBaseBorrowRate += 0.04e4; + vm.prank(RISK_COUNCIL); + GHO_AAVE_STEWARD.updateGhoBorrowRate( + defaultRateParams.optimalUsageRatio, + highBaseBorrowRate, + defaultRateParams.variableRateSlope1, + defaultRateParams.variableRateSlope2 + ); + assertEq(highBaseBorrowRate, _getGhoBorrowRate()); + } + function testUpdateGhoBorrowRateDownwards() public { uint32 oldBorrowRate = _getGhoBorrowRate(); uint32 newBorrowRate = oldBorrowRate - 1; @@ -341,18 +356,19 @@ contract TestGhoAaveSteward is TestGhoBase { assertEq(currentBorrowRate, newBorrowRate); } - function testUpdateGhoBorrowRateMaxValue() public { - uint32 ghoBorrowRateMax = GHO_AAVE_STEWARD.GHO_BORROW_RATE_MAX(); - _setGhoBorrowRateViaConfigurator(ghoBorrowRateMax - 1); + function testUpdateGhoBorrowRateDownwardsFromHigh() public { + // set a very high borrow rate of 80% + uint32 highBaseBorrowRate = 0.80e4; + _setGhoBorrowRateViaConfigurator(highBaseBorrowRate); + highBaseBorrowRate -= 0.04e4; vm.prank(RISK_COUNCIL); GHO_AAVE_STEWARD.updateGhoBorrowRate( defaultRateParams.optimalUsageRatio, - ghoBorrowRateMax, + highBaseBorrowRate, defaultRateParams.variableRateSlope1, defaultRateParams.variableRateSlope2 ); - uint32 currentBorrowRate = _getGhoBorrowRate(); - assertEq(currentBorrowRate, ghoBorrowRateMax); + assertEq(highBaseBorrowRate, _getGhoBorrowRate()); } function testUpdateGhoBorrowRateMaxIncrement() public { @@ -660,19 +676,6 @@ contract TestGhoAaveSteward is TestGhoBase { ); } - function testRevertUpdateGhoBorrowRateIfValueMoreThanMax() public { - uint32 maxGhoBorrowRate = GHO_BORROW_RATE_MAX; - _setGhoBorrowRateViaConfigurator(maxGhoBorrowRate); - vm.prank(RISK_COUNCIL); - vm.expectRevert('BORROW_RATE_HIGHER_THAN_MAX'); - GHO_AAVE_STEWARD.updateGhoBorrowRate( - defaultRateParams.optimalUsageRatio, - maxGhoBorrowRate + 1, - defaultRateParams.variableRateSlope1, - defaultRateParams.variableRateSlope2 - ); - } - function testRevertUpdateGhoBorrowRateIfMaxExceededUpwards() public { uint32 oldBorrowRate = _getGhoBorrowRate(); uint32 newBorrowRate = oldBorrowRate + GHO_BORROW_RATE_CHANGE_MAX + 1; diff --git a/src/test/helpers/Constants.sol b/src/test/helpers/Constants.sol index 17b9c5b7..da6d684e 100644 --- a/src/test/helpers/Constants.sol +++ b/src/test/helpers/Constants.sol @@ -52,7 +52,6 @@ contract Constants { // Gho Stewards uint32 constant GHO_BORROW_RATE_CHANGE_MAX = 0.05e4; uint256 constant GSM_FEE_RATE_CHANGE_MAX = 0.0050e4; - uint32 constant GHO_BORROW_RATE_MAX = 0.25e4; uint256 constant MINIMUM_DELAY_V2 = 1 days; uint256 constant FIXED_RATE_STRATEGY_FACTORY_REVISION = 1;