Skip to content

Commit

Permalink
Merge branch 'feat/116-sequencer-health' of https://github.com/aave/a…
Browse files Browse the repository at this point in the history
…ave-v3-core into feat/116-sequencer-health
  • Loading branch information
LHerskind committed Sep 28, 2021
2 parents 3cfc67c + ccd5a96 commit 6f1c345
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 67 deletions.
17 changes: 17 additions & 0 deletions contracts/interfaces/IOperationalValidator.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.7;

/**
* @title IOperationalValidator
* @author Aave
* @notice Defines the basic interface for the OperationValidator
*/
interface IOperationalValidator {
/**
* @notice Returns true if the `borrow` operation is allowed.
* @dev Operation not allowed when sequencer is down or grace period not passed.
* @return True if the `borrow` operation is allowed, false otherwise.
*/
function isBorrowAllowed() external view returns (bool);

/**
* @notice Returns true if the `liquidation` operation is allowed.
* @dev Operation not allowed when sequencer is down or grace period not passed.
* @dev If the healthfactor is below a minimum threshold, the liquidation is allowed.
* @param healthFactor The health factor of the position to liquidate
* @return True if the `liquidation` operation is allowed, false otherwise.
*/
function isLiquidationAllowed(uint256 healthFactor) external view returns (bool);
}
File renamed without changes.
10 changes: 5 additions & 5 deletions contracts/protocol/configuration/OperationalValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import {ISequencerOracle} from '../../interfaces/ISequencerOracle.sol';
/**
* @title OperationalValidator
* @author Aave
* @notice
* @notice It validates if operations are allowed depending on the Sequencer Health.
* @dev After a Sequencer downtime, users can make their positions healthier during the grace period.
*/
contract OperationalValidator is IOperationalValidator {
IPoolAddressesProvider public _addressesProvider;
ISequencerOracle public _sequencerOracle;
uint256 public _gracePeriod;

uint256 public constant MINIMUM_HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 0.95 ether;

/**
* @notice Constructor
* @dev
Expand All @@ -32,18 +35,15 @@ contract OperationalValidator is IOperationalValidator {

/// @inheritdoc IOperationalValidator
function isBorrowAllowed() public view override returns (bool) {
// If the sequencer goes down, borrowing is not allowed
return _isUpAndGracePeriodPassed();
}

/// @inheritdoc IOperationalValidator
function isLiquidationAllowed(uint256 healthFactor) public view override returns (bool) {
if (healthFactor < 0.95 ether) {
if (healthFactor < MINIMUM_HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
return true;
}
return _isUpAndGracePeriodPassed();
// If the sequencer goes down AND HF > 0.9, liquidation is not allowed
// If timestampSequencerGotUp - block.timestamp > gracePeriod, liquidation allowed
}

function _isUpAndGracePeriodPassed() internal view returns (bool) {
Expand Down
3 changes: 0 additions & 3 deletions helpers/contracts-deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import {
MockReserveConfigurationFactory,
MockPoolFactory,
MockReentrantInitializableImpleFactory,
EModeLogicFactory,
OperationalValidatorFactory,
} from '../types';
import {
withSave,
Expand All @@ -51,7 +49,6 @@ import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { PoolLibraryAddresses } from '../types/PoolFactory';
import AaveConfig from '../market-config';
import { BigNumber } from 'ethers';

const readArtifact = async (id: string) => {
return (DRE as HardhatRuntimeEnvironment).artifacts.readArtifact(id);
Expand Down
6 changes: 2 additions & 4 deletions test-suites/__setup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rawBRE from 'hardhat';
import { BigNumber, ethers, Signer } from 'ethers';
import { ethers, Signer } from 'ethers';
import {
insertContractAddressInDb,
getEthersSigners,
Expand Down Expand Up @@ -33,11 +33,9 @@ import AaveConfig from '../market-config';
import {
getPool,
getPoolConfiguratorProxy,
getPairsTokenAggregator,
getACLManager,
getPairsTokenAggregator
} from '../helpers/contracts-getters';
import { initializeMakeSuite } from './helpers/make-suite';
import { ZERO_ADDRESS } from '../helpers/constants';

const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
Expand Down
Loading

0 comments on commit 6f1c345

Please sign in to comment.