Feat/moving mid#79
Merged
Merged
Conversation
…ow returns (price, updateTime).
…s in USMTemplate, should have zero behavior change.
…, storedPrice, distinct from the oracle's mid, latestPrice(). But USMTemplate doesn't actually modify storedPrice yet: that change is coming up...
…ere view-only users (eg Alex's stats webpage) go for stats based on "pretty recent" prices; those needing the very latest prices/stats need to call usm.refreshPrice().
1. Made USMTemplate store and update its own price. 2. Calculate sliding prices based on new math: % change in ETH pool, rather than % change in debt ratio. 3. Major updates to tests, especially test 3, plus removing proxy test 5 (redundant with test 4).
…mber, eg $1200 or whatever.
…ntract code size near the limit again...
… TWAPs: needed to make test 3's sample TWAP observations > 10 min apart. That said I still don't fully understand why it was breaking...
…with test 3's, and compatible with 10-minute TWAPs.
…m Oracle. Now it has an Oracle member instead, like a sane person would do, and it only seems to cost ~1-2k gas per operation? Surprisingly few lines changed too.
Collaborator
Author
|
OK, this is now feature-complete, the tests pass, and I think it's good to merge! I need to add/update quite a few comments, and I expect there are some little bugs left, this is hot off the presses. But I'm not aware of any gaping holes. I propose we get this up on kovan and fool around with it (but not announce the testnet version publicly yet because it's too raw - may need to redeploy). Also, don't deploy until reading my next comment here... |
Collaborator
Author
Feat/undo oracle inheritance hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a bunch of changes related to the two big new features. Not ready to merge or even test yet, I'll update this PR when it is. I am trying to make each commit reasonably legible and bite-sized.
"Moving mid", ie,
mints/burns/funds/defundsmove the USM contract's mid ETH/USD price separately from oracle updates. (When a fresh oracle price comes in, the USM mid is reset to the oracle's mid; this change is about what happens to the mid between oracle updates.)In plain English, the behavior we're targeting here is: "A short-ETH op (
mint/defund) pushes the system's mid ETH price down, and pushes the price you actually sell at down even more." And of course the reverse for the long-ETH ops,burnandfund.New sliding-price math, based on % change in ETH pool, rather than on % change in debt ratio. Eg, suppose the pool contains 200 ETH, and the user calls
mint(10 ETH), increasing the pool by 5% = a factor of 1.05×. Then our new math says:This math is actually all straightforward: the hairy part is how to translate this for
fund/defund... More on that soon.