Skip to content

Commit

Permalink
Merge branch 'certora' into certora-squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
nisnislevi committed Mar 17, 2024
2 parents c43aa47 + 590b552 commit bf3baff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/contracts/misc/GhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ contract GhoStewardV2 is Ownable, IGhoStewardV2 {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;

/// @inheritdoc IGhoStewardV2
uint256 public constant GHO_BORROW_RATE_MAX = 0.0950e27; // 9.50%
uint256 public constant GHO_BORROW_RATE_MAX = 0.2500e27; // 25.00%

/// @inheritdoc IGhoStewardV2
uint256 public constant GHO_BORROW_RATE_CHANGE_MAX = 0.0050e27; // 0.50%
uint256 public constant GHO_BORROW_RATE_CHANGE_MAX = 0.0500e27; // 5.00%

/// @inheritdoc IGhoStewardV2
uint256 public constant GSM_FEE_RATE_CHANGE_MAX = 0.0050e4; // 0.50%

/// @inheritdoc IGhoStewardV2
uint256 public constant MINIMUM_DELAY = 7 days;
uint256 public constant MINIMUM_DELAY = 2 days;

/// @inheritdoc IGhoStewardV2
address public immutable POOL_ADDRESSES_PROVIDER;
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/misc/interfaces/IGhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ interface IGhoStewardV2 {
function GSM_FEE_RATE_CHANGE_MAX() external view returns (uint256);

/**
* @notice Returns maximun value that can be assigned to GHO borrow rate.
* @return The maximun value that can be assigned to GHO borrow rate in ray (e.g. 0.01e27 results in 1.0%)
* @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 (uint256);

Expand Down
22 changes: 18 additions & 4 deletions src/test/TestGhoStewardV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,19 @@ contract TestGhoStewardV2 is TestGhoBase {
}

function testUpdateGhoBorrowRateMaxDecrement() public {
vm.startPrank(RISK_COUNCIL);

// set a high borrow rate
GHO_STEWARD_V2.updateGhoBorrowRate(GHO_STEWARD_V2.GHO_BORROW_RATE_CHANGE_MAX() + 1);
vm.warp(block.timestamp + GHO_STEWARD_V2.MINIMUM_DELAY() + 1);

uint256 oldBorrowRate = _getGhoBorrowRate();
uint256 newBorrowRate = oldBorrowRate - GHO_STEWARD_V2.GHO_BORROW_RATE_CHANGE_MAX();
vm.prank(RISK_COUNCIL);
GHO_STEWARD_V2.updateGhoBorrowRate(newBorrowRate);
uint256 currentBorrowRate = _getGhoBorrowRate();
assertEq(currentBorrowRate, newBorrowRate);

vm.stopPrank();
}

function testUpdateGhoBorrowRateTimelock() public {
Expand Down Expand Up @@ -352,20 +359,27 @@ contract TestGhoStewardV2 is TestGhoBase {
GHO_STEWARD_V2.updateGhoBorrowRate(maxGhoBorrowRate + 1);
}

function testRevertUpdateGhoBorrowRateIfDifferenceHigherThanMax() public {
function testRevertUpdateGhoBorrowRateIfMaxExceededUpwards() public {
uint256 oldBorrowRate = _getGhoBorrowRate();
uint256 newBorrowRate = oldBorrowRate + GHO_STEWARD_V2.GHO_BORROW_RATE_CHANGE_MAX() + 1;
vm.prank(RISK_COUNCIL);
vm.expectRevert('INVALID_BORROW_RATE_UPDATE');
GHO_STEWARD_V2.updateGhoBorrowRate(newBorrowRate);
}

function testRevertUpdateGhoBorrowRateIfDifferenceLowerThanMax() public {
function testRevertUpdateGhoBorrowRateIfMaxExceededDownwards() public {
vm.startPrank(RISK_COUNCIL);

// set a high borrow rate
GHO_STEWARD_V2.updateGhoBorrowRate(GHO_STEWARD_V2.GHO_BORROW_RATE_CHANGE_MAX() + 1);
vm.warp(block.timestamp + GHO_STEWARD_V2.MINIMUM_DELAY() + 1);

uint256 oldBorrowRate = _getGhoBorrowRate();
uint256 newBorrowRate = oldBorrowRate - GHO_STEWARD_V2.GHO_BORROW_RATE_CHANGE_MAX() - 1;
vm.prank(RISK_COUNCIL);
vm.expectRevert('INVALID_BORROW_RATE_UPDATE');
GHO_STEWARD_V2.updateGhoBorrowRate(newBorrowRate);

vm.stopPrank();
}

function testUpdateGsmExposureCap() public {
Expand Down
6 changes: 3 additions & 3 deletions src/test/helpers/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ contract Constants {
uint40 constant STEWARD_LIFESPAN = 90 days;

// GhoStewardV2
uint256 constant GHO_BORROW_RATE_CHANGE_MAX = 0.0050e27;
uint256 constant GHO_BORROW_RATE_CHANGE_MAX = 0.0500e27;
uint256 constant GSM_FEE_RATE_CHANGE_MAX = 0.0050e4;
uint256 constant GHO_BORROW_RATE_MAX = 0.095e27;
uint256 constant MINIMUM_DELAY_V2 = 7 days;
uint256 constant GHO_BORROW_RATE_MAX = 0.2500e27;
uint256 constant MINIMUM_DELAY_V2 = 2 days;
uint256 constant FIXED_RATE_STRATEGY_FACTORY_REVISION = 1;

// sample users used across unit tests
Expand Down

0 comments on commit bf3baff

Please sign in to comment.