-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feat/moving mid #79
Feat/moving mid #79
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.
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... |
Feat/undo oracle inheritance hack
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
/defunds
move 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,burn
andfund
.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.