From 9ae7f7ff6c2326527c290df59b71e878deeab2b3 Mon Sep 17 00:00:00 2001 From: Rustem Kurmaev Date: Thu, 16 May 2024 14:56:38 +0200 Subject: [PATCH] update linting --- README.md | 6 +-- src/contracts/RiskSteward.sol | 13 +++--- tests/RiskSteward.t.sol | 80 ++++++++++++++++++++++++++++------- 3 files changed, 74 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 827ac22..9d1f3fc 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/contracts/RiskSteward.sol b/src/contracts/RiskSteward.sol index 5aeb417..4630aa8 100644 --- a/src/contracts/RiskSteward.sol +++ b/src/contracts/RiskSteward.sol @@ -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 @@ -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 || @@ -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, diff --git a/tests/RiskSteward.t.sol b/tests/RiskSteward.t.sol index 545fe09..533c9e4 100644 --- a/tests/RiskSteward.t.sol +++ b/tests/RiskSteward.t.sol @@ -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()); @@ -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(