Skip to content

Commit

Permalink
Merge pull request #5 from bgd-labs/fix/lint
Browse files Browse the repository at this point in the history
fix: update linting
  • Loading branch information
kyzia551 authored May 16, 2024
2 parents 617a90f + 9ae7f7f commit 204041f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ For each risk param, `minDelay` can be configured, which is the minimum amount o
For each risk param, `maxPercentChange` which is the maximum percent change allowed (both upwards and downwards) for the risk param using the RiskStewards.

- Supply cap, Borrow cap and Debt ceiling: The `maxPercentChange` is relative and is denominated in BPS. (Ex. `50_00` for +-50% relative change).
For example, for a current supply cap of an asset at 1_000_000 and `maxPercentChange` configured for supply cap at `50_00`, the max supply cap that can be configured is 1_500_000 and the minimum 500_000 via the steward.
For example, for a current supply cap of an asset at 1_000_000 and `maxPercentChange` configured for supply cap at `50_00`, the max supply cap that can be configured is 1_500_000 and the minimum 500_000 via the steward.

- LTV, LT, LB: The `maxPercentChange` is in absolute values and is also denominated in BPS. (Ex. `5_00` for +-5% change in LTV).
For example, for a current LTV of an asset configured at 70_00 (70%) and `maxPercentChange` configured for ltv at `10_00`, the max ltv that can be configured is 77_00 (77%) and the minimum 63_00 (63%) via the steward.
For example, for a current LTV of an asset configured at 70_00 (70%) and `maxPercentChange` configured for ltv at `10_00`, the max ltv that can be configured is 77_00 (77%) and the minimum 63_00 (63%) via the steward.

- Interest rates params: For Base Variable Borrow Rate, Slope 1, Slope 2, uOptimal the `maxPercentChange` is in absolute values and is denominated in BPS.
For example, for a current uOptimal of an asset configured at 50_00 (50%) and `maxPercentChange` configured for uOptimal at `10_00`, the max ltv that can be configured is 55_00 (55%) and the minimum 45_00 (45%) via the steward.
For example, for a current uOptimal of an asset configured at 50_00 (50%) and `maxPercentChange` configured for uOptimal at `10_00`, the max ltv that can be configured is 55_00 (55%) and the minimum 45_00 (45%) via the steward.

After the activation proposal, these params could only be changed by the governance by calling the `setRiskConfig()` method.

Expand Down
13 changes: 7 additions & 6 deletions src/contracts/RiskSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ contract RiskSteward is Ownable, IRiskSteward {
address asset = capsUpdate[i].asset;

if (_restrictedAssets[asset]) revert AssetIsRestricted();
if (capsUpdate[i].supplyCap == 0 || capsUpdate[i].borrowCap == 0) revert InvalidUpdateToZero();
if (capsUpdate[i].supplyCap == 0 || capsUpdate[i].borrowCap == 0)
revert InvalidUpdateToZero();

(uint256 currentBorrowCap, uint256 currentSupplyCap) = POOL_DATA_PROVIDER.getReserveCaps(
capsUpdate[i].asset
Expand Down Expand Up @@ -216,7 +217,8 @@ contract RiskSteward is Ownable, IRiskSteward {
address asset = collateralUpdates[i].asset;

if (_restrictedAssets[asset]) revert AssetIsRestricted();
if (collateralUpdates[i].liqProtocolFee != EngineFlags.KEEP_CURRENT) revert ParamChangeNotAllowed();
if (collateralUpdates[i].liqProtocolFee != EngineFlags.KEEP_CURRENT)
revert ParamChangeNotAllowed();
if (
collateralUpdates[i].ltv == 0 ||
collateralUpdates[i].liqThreshold == 0 ||
Expand Down Expand Up @@ -281,12 +283,11 @@ contract RiskSteward is Ownable, IRiskSteward {
* @notice method to validate the risk param update is within the allowed bound and the debounce is respected
* @param validationParam struct containing values used for validation of the risk param update
*/
function _validateParamUpdate(
ParamUpdateValidationInput memory validationParam
) internal view {
function _validateParamUpdate(ParamUpdateValidationInput memory validationParam) internal view {
if (validationParam.newValue == EngineFlags.KEEP_CURRENT) return;

if (block.timestamp - validationParam.lastUpdated < validationParam.riskConfig.minDelay) revert DebounceNotRespected();
if (block.timestamp - validationParam.lastUpdated < validationParam.riskConfig.minDelay)
revert DebounceNotRespected();
if (
!_updateWithinAllowedRange(
validationParam.currentValue,
Expand Down
80 changes: 64 additions & 16 deletions tests/RiskSteward.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,10 @@ contract RiskSteward_Test is Test {
riskConfig
);

assertEq(address(steward.POOL_DATA_PROVIDER()), address(AaveV3Ethereum.AAVE_PROTOCOL_DATA_PROVIDER));
assertEq(
address(steward.POOL_DATA_PROVIDER()),
address(AaveV3Ethereum.AAVE_PROTOCOL_DATA_PROVIDER)
);
assertEq(address(steward.CONFIG_ENGINE()), address(IEngine(configEngine)));
assertEq(steward.RISK_COUNCIL(), riskCouncil);
_validateRiskConfig(riskConfig, steward.getRiskConfig());
Expand All @@ -794,24 +797,69 @@ contract RiskSteward_Test is Test {
) internal {
assertEq(initialRiskConfig.ltv.minDelay, updatedRiskConfig.ltv.minDelay);
assertEq(initialRiskConfig.ltv.maxPercentChange, updatedRiskConfig.ltv.maxPercentChange);
assertEq(initialRiskConfig.liquidationThreshold.minDelay, updatedRiskConfig.liquidationThreshold.minDelay);
assertEq(initialRiskConfig.liquidationThreshold.maxPercentChange, updatedRiskConfig.liquidationThreshold.maxPercentChange);
assertEq(initialRiskConfig.liquidationBonus.minDelay, updatedRiskConfig.liquidationBonus.minDelay);
assertEq(initialRiskConfig.liquidationBonus.maxPercentChange, updatedRiskConfig.liquidationBonus.maxPercentChange);
assertEq(
initialRiskConfig.liquidationThreshold.minDelay,
updatedRiskConfig.liquidationThreshold.minDelay
);
assertEq(
initialRiskConfig.liquidationThreshold.maxPercentChange,
updatedRiskConfig.liquidationThreshold.maxPercentChange
);
assertEq(
initialRiskConfig.liquidationBonus.minDelay,
updatedRiskConfig.liquidationBonus.minDelay
);
assertEq(
initialRiskConfig.liquidationBonus.maxPercentChange,
updatedRiskConfig.liquidationBonus.maxPercentChange
);
assertEq(initialRiskConfig.supplyCap.minDelay, updatedRiskConfig.supplyCap.minDelay);
assertEq(initialRiskConfig.supplyCap.maxPercentChange, updatedRiskConfig.supplyCap.maxPercentChange);
assertEq(
initialRiskConfig.supplyCap.maxPercentChange,
updatedRiskConfig.supplyCap.maxPercentChange
);
assertEq(initialRiskConfig.borrowCap.minDelay, updatedRiskConfig.borrowCap.minDelay);
assertEq(initialRiskConfig.borrowCap.maxPercentChange, updatedRiskConfig.borrowCap.maxPercentChange);
assertEq(
initialRiskConfig.borrowCap.maxPercentChange,
updatedRiskConfig.borrowCap.maxPercentChange
);
assertEq(initialRiskConfig.debtCeiling.minDelay, updatedRiskConfig.debtCeiling.minDelay);
assertEq(initialRiskConfig.debtCeiling.maxPercentChange, updatedRiskConfig.debtCeiling.maxPercentChange);
assertEq(initialRiskConfig.baseVariableBorrowRate.minDelay, updatedRiskConfig.baseVariableBorrowRate.minDelay);
assertEq(initialRiskConfig.baseVariableBorrowRate.maxPercentChange, updatedRiskConfig.baseVariableBorrowRate.maxPercentChange);
assertEq(initialRiskConfig.variableRateSlope1.minDelay, updatedRiskConfig.variableRateSlope1.minDelay);
assertEq(initialRiskConfig.variableRateSlope1.maxPercentChange, updatedRiskConfig.variableRateSlope1.maxPercentChange);
assertEq(initialRiskConfig.variableRateSlope2.minDelay, updatedRiskConfig.variableRateSlope2.minDelay);
assertEq(initialRiskConfig.variableRateSlope2.maxPercentChange, updatedRiskConfig.variableRateSlope2.maxPercentChange);
assertEq(initialRiskConfig.optimalUsageRatio.minDelay, updatedRiskConfig.optimalUsageRatio.minDelay);
assertEq(initialRiskConfig.optimalUsageRatio.maxPercentChange, updatedRiskConfig.optimalUsageRatio.maxPercentChange);
assertEq(
initialRiskConfig.debtCeiling.maxPercentChange,
updatedRiskConfig.debtCeiling.maxPercentChange
);
assertEq(
initialRiskConfig.baseVariableBorrowRate.minDelay,
updatedRiskConfig.baseVariableBorrowRate.minDelay
);
assertEq(
initialRiskConfig.baseVariableBorrowRate.maxPercentChange,
updatedRiskConfig.baseVariableBorrowRate.maxPercentChange
);
assertEq(
initialRiskConfig.variableRateSlope1.minDelay,
updatedRiskConfig.variableRateSlope1.minDelay
);
assertEq(
initialRiskConfig.variableRateSlope1.maxPercentChange,
updatedRiskConfig.variableRateSlope1.maxPercentChange
);
assertEq(
initialRiskConfig.variableRateSlope2.minDelay,
updatedRiskConfig.variableRateSlope2.minDelay
);
assertEq(
initialRiskConfig.variableRateSlope2.maxPercentChange,
updatedRiskConfig.variableRateSlope2.maxPercentChange
);
assertEq(
initialRiskConfig.optimalUsageRatio.minDelay,
updatedRiskConfig.optimalUsageRatio.minDelay
);
assertEq(
initialRiskConfig.optimalUsageRatio.maxPercentChange,
updatedRiskConfig.optimalUsageRatio.maxPercentChange
);
}

function _getInterestRatesForAsset(
Expand Down

0 comments on commit 204041f

Please sign in to comment.