Skip to content

Collateralization Oracle Wrapper Refactor#162

Merged
Joeysantoro merged 7 commits intofeat/v2from
feat/v2-CollateralizationOracleWrapperRefactor
Sep 12, 2021
Merged

Collateralization Oracle Wrapper Refactor#162
Joeysantoro merged 7 commits intofeat/v2from
feat/v2-CollateralizationOracleWrapperRefactor

Conversation

@Joeysantoro
Copy link
Contributor

@Joeysantoro Joeysantoro commented Sep 12, 2021

Refactors the CollateralizationOracleWrapper to use more transparent logic around deviation thresholds being exceeded. Also includes an interface and new update method that reverts unless the oracle is currently out of date.

The new update method is used in a keeper that incentivizes updates of the oracle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated cleanup from merge conflict


/// @title CollateralizationOracleKeeper
/// @notice a FEI timed minter which only rewards when updating the collateralization oracle
contract CollateralizationOracleKeeper is FeiTimedMinter {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not add a unit test for this class because it is such as simple override of the FeiTimedMinter.

Decimal.D256 memory _thresholdLow = Decimal.from(10_000 - deviationThresholdBasisPoints).div(10_000);
Decimal.D256 memory _thresholdHigh = Decimal.from(10_000 + deviationThresholdBasisPoints).div(10_000);

obsolete = paused();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the "paused" condition for exceeded deviation threshold. Feels unnatural to include that as a criteria

Copy link
Contributor

@eswak eswak Sep 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the exception message should rather be "not outdated"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

obsolete = obsolete || circFeiRatio.lessThan(_thresholdLow);
// CircFEI > threshold
obsolete = obsolete || circFeiRatio.greaterThan(_thresholdHigh);
function _isExceededDeviationThreshold(uint256 cached, uint256 current) internal view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit it's more elegant like this 😇

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful

collateralizationOracleWrapper = _collateralizationOracleWrapper;
}

function _afterMint() internal override {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use afterMint hook

obsolete = obsolete || circFeiRatio.lessThan(_thresholdLow);
// CircFEI > threshold
obsolete = obsolete || circFeiRatio.greaterThan(_thresholdHigh);
function _isExceededDeviationThreshold(uint256 cached, uint256 current) internal view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful

@Joeysantoro Joeysantoro merged commit 9cd6200 into feat/v2 Sep 12, 2021
@xklob xklob deleted the feat/v2-CollateralizationOracleWrapperRefactor branch September 19, 2021 18:59
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.

3 participants

Comments