Skip to content

Conversation

miguelmtzinf
Copy link
Contributor

No description provided.

@miguelmtzinf
Copy link
Contributor Author

Trafeoffs of this approach:

  • The price check is only made in 1 single asset (the borrowed asset on borrow, the debt asset on liquidation)
  • The price fetch is done twice: when calculating health factor, when validating the action
  • There is only 1 asset price validated, but not the other assets part of the user's position.

Gas comparison:

|                         ·  Min        ·  Max        ·  Avg             │
| without oracle sentinel ·     236441  ·     362175  ·        286168    │
| original version        ·     252095  ·     377829  ·        301822    │
| modified version        ·     260518  ·     386252  ·        310245    │

@miguelmtzinf
Copy link
Contributor Author

Alternative: create a keeper function at PriceOracleSentinel that checks price stability of all the reserves.

  function keeper() external {
    address[] memory reserveList = IPool(ADDRESSES_PROVIDER.getPool()).getReservesList();
    uint256 i = 0;
    uint256 reserveLength = reserveList.length;
    uint256 updatedAt = block.timestamp;
    for (i = 0; i < reserveLength; ) {
      (, , , updatedAt, ) = AggregatorV3Interface(_aaveOracle.getSourceOfAsset(reserveList[i]))
        .latestRoundData();
      _isPriceStale = (block.timestamp - updatedAt) > _priceExpirationTime;
      if (_isPriceStale) break;
      unchecked {
        ++i;
      }
    }
  }
  function isBorrowAllowed(address priceOracle, address asset) public view override returns (bool) {
  return _isUpAndGracePeriodPassed() && !_isPriceStale;
}

The flag _isPriceStale can be converted to a mapping of asset prices (similar to the userConfig map) so the whole user position can be taken into account when interacting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant