Skip to content

Commit

Permalink
feat: Rename OperationalValidator to PriceOracleSentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Sep 28, 2021
1 parent 53ab533 commit 9004f49
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 63 deletions.
14 changes: 7 additions & 7 deletions contracts/interfaces/IPoolAddressesProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IPoolAddressesProvider {
event RateOracleUpdated(address indexed newAddress);
event ACLManagerUpdated(address indexed newAddress);
event ACLAdminUpdated(address indexed newAddress);
event OperationalValidatorUpdated(address indexed newAddress);
event PriceOracleSentinelUpdated(address indexed newAddress);
event ProxyCreated(bytes32 id, address indexed newAddress);
event BridgeAccessControlUpdated(address indexed newAddress);
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
Expand Down Expand Up @@ -115,14 +115,14 @@ interface IPoolAddressesProvider {
function setACLAdmin(address aclAdmin) external;

/**
* @notice Returns the address of the OperationalValidator
* @return The OperationalValidator address
* @notice Returns the address of the PriceOracleSentinel
* @return The PriceOracleSentinel address
*/
function getOperationalValidator() external view returns (address);
function getPriceOracleSentinel() external view returns (address);

/**
* @notice Updates the address of the OperationalValidator
* @param operationalValidator The address of the new OperationalValidator
* @notice Updates the address of the PriceOracleSentinel
* @param oracleSentinel The address of the new PriceOracleSentinel
**/
function setOperationalValidator(address operationalValidator) external;
function setPriceOracleSentinel(address oracleSentinel) external;
}
14 changes: 7 additions & 7 deletions contracts/interfaces/IPoolConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ interface IPoolConfigurator {
event ReserveUnpaused(address indexed asset);

/**
* @notice Emitted when the OperationalValidator is activated for the reserve
* @notice Emitted when the PriceOracleSentinel is activated for the reserve
* @param asset The address of the underlying asset of the reserve
**/
event OperationalValidatorActivated(address indexed asset);
event PriceOracleSentinelActivated(address indexed asset);

/**
* @notice Emitted when the OperationalValidator is deactivated for the reserve
* @notice Emitted when the PriceOracleSentinel is deactivated for the reserve
* @param asset The address of the underlying asset of the reserve
**/
event OperationalValidatorDeactivated(address indexed asset);
event PriceOracleSentinelDeactivated(address indexed asset);

/**
* @notice Emitted when a reserve is dropped
Expand Down Expand Up @@ -356,11 +356,11 @@ interface IPoolConfigurator {
function setReservePause(address asset, bool val) external;

/**
* @notice Set the state of the OperationalValidator for the reserve
* @notice Set the state of the PriceOracleSentinel for the reserve
* @param asset The address of the underlying asset of the reserve
* @param state True if activating the OperationalValidator, false if deactivating
* @param state True if activating the PriceOracleSentinel, false if deactivating
**/
function setOperationalValidatorActive(address asset, bool state) external;
function setPriceOracleSentinelActive(address asset, bool state) external;

/**
* @notice Updates the reserve factor of a reserve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity 0.8.7;

/**
* @title IOperationalValidator
* @title IPriceOracleSentinel
* @author Aave
* @notice Defines the basic interface for the OperationValidator
* @notice Defines the basic interface for the PriceOracleSentinel
*/
interface IOperationalValidator {
interface IPriceOracleSentinel {
/**
* @notice Returns true if the `borrow` operation is allowed.
* @dev Operation not allowed when PriceOracle is down or grace period not passed.
Expand Down
8 changes: 4 additions & 4 deletions contracts/misc/AaveProtocolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ contract AaveProtocolDataProvider {
}

/**
* Returns the state of the OperationValidator of the reserve
* Returns the state of the PriceOracleSentinel of the reserve
* @param asset The address of the underlying asset of the reserve
* @return True if the OperationalValidator is active for the reserve, false otherwise
* @return True if the PriceOracleSentinel is active for the reserve, false otherwise
*/
function getReserveOperationValidatorState(address asset) external view returns (bool) {
function getReservePriceOracleSentinelState(address asset) external view returns (bool) {
DataTypes.ReserveConfigurationMap memory configuration = IPool(ADDRESSES_PROVIDER.getPool())
.getConfiguration(asset);
return configuration.getOperationalValidatorActive();
return configuration.getPriceOracleSentinelActive();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions contracts/protocol/configuration/PoolAddressesProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider {
bytes32 private constant RATE_ORACLE = 'RATE_ORACLE';
bytes32 private constant ACL_MANAGER = 'ACL_MANAGER';
bytes32 private constant ACL_ADMIN = 'ACL_ADMIN';
bytes32 private constant OPERATIONAL_VALIDATOR = 'OPERATIONAL_VALIDATOR';
bytes32 private constant PRICE_ORACLE_SENTINEL = 'PRICE_ORACLE_SENTINEL';

constructor(string memory marketId) {
_setMarketId(marketId);
Expand Down Expand Up @@ -122,14 +122,14 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider {
}

/// @inheritdoc IPoolAddressesProvider
function setOperationalValidator(address operationalValidator) external override onlyOwner {
_addresses[OPERATIONAL_VALIDATOR] = operationalValidator;
emit OperationalValidatorUpdated(operationalValidator);
function setPriceOracleSentinel(address oracleSentinel) external override onlyOwner {
_addresses[PRICE_ORACLE_SENTINEL] = oracleSentinel;
emit PriceOracleSentinelUpdated(oracleSentinel);
}

/// @inheritdoc IPoolAddressesProvider
function getOperationalValidator() external view override returns (address) {
return getAddress(OPERATIONAL_VALIDATOR);
function getPriceOracleSentinel() external view override returns (address) {
return getAddress(PRICE_ORACLE_SENTINEL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
pragma solidity 0.8.7;

import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol';
import {IOperationalValidator} from '../../interfaces/IOperationalValidator.sol';
import {IPriceOracleSentinel} from '../../interfaces/IPriceOracleSentinel.sol';
import {ISequencerOracle} from '../../interfaces/ISequencerOracle.sol';

/**
* @title OperationalValidator
* @title PriceOracleSentinel
* @author Aave
* @notice It validates if operations are allowed depending on the PriceOracle health.
* @dev After a PriceOracle downtime, once it gets up, users can make their positions healthy during a grace period.
*/
contract OperationalValidator is IOperationalValidator {
contract PriceOracleSentinel is IPriceOracleSentinel {
IPoolAddressesProvider public _addressesProvider;
ISequencerOracle public _oracle;
uint256 public _gracePeriod;
Expand All @@ -34,12 +34,12 @@ contract OperationalValidator is IOperationalValidator {
_gracePeriod = gracePeriod;
}

/// @inheritdoc IOperationalValidator
/// @inheritdoc IPriceOracleSentinel
function isBorrowAllowed() public view override returns (bool) {
return _isUpAndGracePeriodPassed();
}

/// @inheritdoc IOperationalValidator
/// @inheritdoc IPriceOracleSentinel
function isLiquidationAllowed(uint256 healthFactor) public view override returns (bool) {
if (healthFactor < MINIMUM_HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
return true;
Expand Down
22 changes: 11 additions & 11 deletions contracts/protocol/libraries/configuration/ReserveConfiguration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library ReserveConfiguration {
uint256 constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore
uint256 constant PAUSED_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant OPERATIONAL_VALIDATOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant PRICE_ORACLE_SENTINEL_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant BORROW_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore
uint256 constant SUPPLY_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore
Expand All @@ -36,7 +36,7 @@ library ReserveConfiguration {
uint256 constant BORROWING_ENABLED_START_BIT_POSITION = 58;
uint256 constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59;
uint256 constant IS_PAUSED_START_BIT_POSITION = 60;
uint256 constant OPERATIONAL_VALIDATOR_ACTIVE_START_BIT_POSITION = 62;
uint256 constant PRICE_ORACLE_SENTINEL_ACTIVE_START_BIT_POSITION = 62;
/// @dev bits 61 63 unused yet
uint256 constant RESERVE_FACTOR_START_BIT_POSITION = 64;
uint256 constant BORROW_CAP_START_BIT_POSITION = 80;
Expand Down Expand Up @@ -222,30 +222,30 @@ library ReserveConfiguration {
}

/**
* @notice Sets the state of the operational validator for the reserve
* @notice Sets the state of the price oracle sentinel for the reserve
* @param self The reserve configuration
* @param state True if the operational validator is active, false otherwise
* @param state True if the price oracle sentinel is active, false otherwise
**/
function setOperationalValidatorActive(DataTypes.ReserveConfigurationMap memory self, bool state)
function setPriceOracleSentinelActive(DataTypes.ReserveConfigurationMap memory self, bool state)
internal
pure
{
self.data =
(self.data & OPERATIONAL_VALIDATOR_MASK) |
(uint256(state ? 1 : 0) << OPERATIONAL_VALIDATOR_ACTIVE_START_BIT_POSITION);
(self.data & PRICE_ORACLE_SENTINEL_MASK) |
(uint256(state ? 1 : 0) << PRICE_ORACLE_SENTINEL_ACTIVE_START_BIT_POSITION);
}

/**
* @notice Gets the state of the operational validator for the reserve
* @notice Gets the state of the price oracle sentinel for the reserve
* @param self The reserve configuration
* @return True if the operational validator is active, false otherwise
* @return True if the price oracle sentinel is active, false otherwise
**/
function getOperationalValidatorActive(DataTypes.ReserveConfigurationMap memory self)
function getPriceOracleSentinelActive(DataTypes.ReserveConfigurationMap memory self)
internal
pure
returns (bool)
{
return (self.data & ~OPERATIONAL_VALIDATOR_MASK) != 0;
return (self.data & ~PRICE_ORACLE_SENTINEL_MASK) != 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/protocol/libraries/logic/BorrowLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ library BorrowLogic {
params.reservesCount,
params.oracle,
params.userEModeCategory,
params.operationalValidator
params.priceOracleSentinel
)
);

Expand Down Expand Up @@ -314,7 +314,7 @@ library BorrowLogic {
params.reservesCount,
params.oracle,
params.userEModeCategory,
params.operationalValidator
params.priceOracleSentinel
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ library LiquidationLogic {
params.reservesCount,
params.priceOracle,
params.userEModeCategory,
params.operationalValidator
params.priceOracleSentinel
)
);

Expand Down
10 changes: 5 additions & 5 deletions contracts/protocol/libraries/logic/ValidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol';
import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol';
import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol';
import {IAToken} from '../../../interfaces/IAToken.sol';
import {IOperationalValidator} from '../../../interfaces/IOperationalValidator.sol';
import {IPriceOracleSentinel} from '../../../interfaces/IPriceOracleSentinel.sol';
import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol';
import {UserConfiguration} from '../configuration/UserConfiguration.sol';
import {Errors} from '../helpers/Errors.sol';
Expand Down Expand Up @@ -142,8 +142,8 @@ library ValidationLogic {
require(vars.borrowingEnabled, Errors.VL_BORROWING_NOT_ENABLED);

require(
!params.reserveCache.reserveConfiguration.getOperationalValidatorActive() ||
IOperationalValidator(params.operationalValidator).isBorrowAllowed(),
!params.reserveCache.reserveConfiguration.getPriceOracleSentinelActive() ||
IPriceOracleSentinel(params.priceOracleSentinel).isBorrowAllowed(),
Errors.VL_PRICE_ORACLE_SENTINEL_FAILED
);

Expand Down Expand Up @@ -498,8 +498,8 @@ library ValidationLogic {
);

require(
!params.debtReserveCache.reserveConfiguration.getOperationalValidatorActive() ||
IOperationalValidator(params.operationalValidator).isLiquidationAllowed(vars.healthFactor),
!params.debtReserveCache.reserveConfiguration.getPriceOracleSentinelActive() ||
IPriceOracleSentinel(params.priceOracleSentinel).isLiquidationAllowed(vars.healthFactor),
Errors.VL_PRICE_ORACLE_SENTINEL_FAILED
);

Expand Down
10 changes: 5 additions & 5 deletions contracts/protocol/libraries/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ library DataTypes {
bool receiveAToken;
address priceOracle;
uint8 userEModeCategory;
address operationalValidator;
address priceOracleSentinel;
}

struct ExecuteSupplyParams {
Expand All @@ -127,7 +127,7 @@ library DataTypes {
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address operationalValidator;
address priceOracleSentinel;
}

struct ExecuteRepayParams {
Expand Down Expand Up @@ -181,7 +181,7 @@ library DataTypes {
address oracle;
uint8 userEModeCategory;
bool isAuthorizedFlashBorrower;
address operationalValidator;
address priceOracleSentinel;
}

struct CalculateUserAccountDataParams {
Expand All @@ -203,7 +203,7 @@ library DataTypes {
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address operationalValidator;
address priceOracleSentinel;
}

struct ValidateLiquidationCallParams {
Expand All @@ -213,7 +213,7 @@ library DataTypes {
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address operationalValidator;
address priceOracleSentinel;
}

struct CalculateInterestRatesParams {
Expand Down
6 changes: 3 additions & 3 deletions contracts/protocol/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
_reservesCount,
_addressesProvider.getPriceOracle(),
_usersEModeCategory[msg.sender],
_addressesProvider.getOperationalValidator()
_addressesProvider.getPriceOracleSentinel()
)
);
}
Expand Down Expand Up @@ -318,7 +318,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
receiveAToken,
_addressesProvider.getPriceOracle(),
_usersEModeCategory[user],
_addressesProvider.getOperationalValidator()
_addressesProvider.getPriceOracleSentinel()
)
);
}
Expand Down Expand Up @@ -348,7 +348,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
_addressesProvider.getPriceOracle(),
_usersEModeCategory[onBehalfOf],
IACLManager(_addressesProvider.getACLManager()).isFlashBorrower(msg.sender),
_addressesProvider.getOperationalValidator()
_addressesProvider.getPriceOracleSentinel()
);

BorrowLogic.executeFlashLoan(
Expand Down
8 changes: 4 additions & 4 deletions contracts/protocol/pool/PoolConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,20 @@ contract PoolConfigurator is VersionedInitializable, IPoolConfigurator {
}

/// @inheritdoc IPoolConfigurator
function setOperationalValidatorActive(address asset, bool state)
function setPriceOracleSentinelActive(address asset, bool state)
public
override
onlyRiskOrPoolAdmins
{
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
currentConfig.setOperationalValidatorActive(state);
currentConfig.setPriceOracleSentinelActive(state);

_pool.setConfiguration(asset, currentConfig.data);

if (state) {
emit OperationalValidatorActivated(asset);
emit PriceOracleSentinelActivated(asset);
} else {
emit OperationalValidatorDeactivated(asset);
emit PriceOracleSentinelDeactivated(asset);
}
}

Expand Down

0 comments on commit 9004f49

Please sign in to comment.