-
Notifications
You must be signed in to change notification settings - Fork 608
Sip 75 keeper isynths phase one #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…etixio/synthetix into sip-76-warning-flags-invalid-rates
Codecov Report
@@ Coverage Diff @@
## develop #669 +/- ##
========================================
Coverage 99.52% 99.52%
========================================
Files 51 51
Lines 3165 3191 +26
Branches 422 428 +6
========================================
+ Hits 3150 3176 +26
Misses 15 15
Continue to review full report at Codecov.
|
contracts/ExchangeRates.sol
Outdated
|
||
_setRate(currencyKey, freezeAtUpperLimit ? upperLimit : lowerLimit, now); | ||
inversePricing[currencyKey].frozenAtUpperLimit = freezeAtUpperLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention here to reset both frozenAtUpperLimit
and frozenAtLowerLimit
to either false / true regardless during the resetting process? Ie, if frozenAtUpperLimit || frozenAtLowerLimit was true, we want them to be false after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When setInversePricing
is called, it can be frozen upper, lower, or not at all. Keep in mind this function is used both a) when repricing a synth and b) populating a new ExchangeRates
to replicate the state in an older one, hence the need, on occasion, to be able to set an inverse as frozen directly.
for (uint i = 0; i < aggregatorKeys.length; i++) { | ||
bytes32 currencyKey = aggregatorKeys[i]; | ||
if (address(aggregators[currencyKey]) == aggregator) { | ||
currencies[count++] = currencyKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinjmoses Is it going to be possible to have multiple currencies / prices based off the same aggregator
address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so for example ETHUSD will support both sETH
and iETH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some points where gas efficiency can be improved for getting rates.
RFAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Only left minor comments.
contracts/ExchangeRates.sol
Outdated
|
||
uint rate = _getRate(currencyKey); | ||
|
||
if (rate == inverse.upperLimit || rate == inverse.lowerLimit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By this code, I'm assuming that _getRate(...)
returns a value bounded within the price limits. Even if that's the case, to improve readability and have a cero cost sanity check, use <=
and >=
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. I will adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually then it will think 0
is a valid lowerLimit and it should not be. 0
will be returned for an inverse that has no underlying rate, and in which case it should not be frozen. I will add that condition as well
@@ -1031,18 +1033,19 @@ const deploy = async ({ | |||
) { | |||
if (oldExrates.options.address !== addressOf(exchangeRates)) { | |||
const freezeAtUpperLimit = +w3utils.fromWei(currentRateForCurrency) === upperLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider that Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2
and MAX_SAFE_INTEGER = 9007199254740991
, so might be a good idea to use big numbers here.
Considerations
ExchangeRates
canFreezeRate()
toisInverseRateAtBounds()
which is more accurateExchangeRates
helper viewAncillary Tasks
IExchangeRates
)address aggregator
tobytes32
(see 2) below).Notes
ExchangeRates.RatesUpdated
no longer has inverse rate emitted but rather the companion long rate (to align it withAnswerUpdated
). This event will be removed altogether in a separate PRAnswerUpdated
events on long synths cause aRateUpdate
to the inverse (will require a reverse lookup onExchangeRates
- something likecurrenciesUsingAggregator(address aggregator) external view returns (bytes32[] currencies)
to determine if a given aggregator update impacts an inverse