Skip to content

Commit

Permalink
fix: Removes max variable borrow rate check in GhoAaveSteward for rat…
Browse files Browse the repository at this point in the history
…es updates (#436)

* feat(aave steward): rm max variable borrow rate check

* upd: sync change with certora

* doc: fix natspec of `updateGhoBorrowRate`
  • Loading branch information
DhairyaSethi authored Jan 6, 2025
1 parent 0a6fbd4 commit a0dca17
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 56 deletions.
18 changes: 0 additions & 18 deletions certora/steward/specs/GhoAaveSteward.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}






Expand Down
11 changes: 0 additions & 11 deletions src/contracts/misc/GhoAaveSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
);
}

/**
Expand Down
7 changes: 0 additions & 7 deletions src/contracts/misc/interfaces/IGhoAaveSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
41 changes: 22 additions & 19 deletions src/test/TestGhoAaveSteward.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/test/helpers/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a0dca17

Please sign in to comment.