-
Notifications
You must be signed in to change notification settings - Fork 37
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: remove curve oracle from redemption contract #232
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
black==22.3.0 | ||
eth-ape==0.6.20 | ||
eth-ape==0.6.26 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,13 +136,13 @@ def test_sweep(d_yfi, yfi, redemption, gov): | |
def test_oracle(project, yfi, d_yfi, ve_yfi, gov): | ||
mock = project.MockOracle.deploy(sender=gov) | ||
redemption = project.Redemption.deploy( | ||
yfi, d_yfi, ve_yfi, gov, mock, mock, 10 * AMOUNT, sender=gov | ||
yfi, d_yfi, ve_yfi, gov, mock, 10 * AMOUNT, sender=gov | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since unit tests mostly using the mock oracle and we had the contract live we have some sample data of actual values return is it to much work to add to ape a fork test using this same account and value and check that return with new contract matches reedem expectations? since test can be integration only on specific block number, to check how this contract new only CL feed would have behaved against these past trxs one example we could use others i guess There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added a test here that compares the oracle price in the old and new redemption contract, after making sure the old one uses the chainlink price. This should be an equivalent test without having to run a test on an old block, which is (afaik) not very easy to do |
||
) | ||
|
||
mock.set_price(2 * AMOUNT, AMOUNT, sender=gov) | ||
assert redemption.get_latest_price() == 2 * AMOUNT | ||
|
||
mock.set_price(2 * AMOUNT, 3 * AMOUNT, sender=gov) | ||
mock.set_price(3 * AMOUNT, 2 * AMOUNT, sender=gov) | ||
assert redemption.get_latest_price() == 3 * AMOUNT | ||
|
||
mock.set_updated(1, sender=gov) | ||
|
@@ -166,21 +166,31 @@ def test_chainlink_oracle(project, yfi, d_yfi, ve_yfi, gov): | |
assert actual == expected | ||
assert abs(yfieth.latestRoundData()[1] - actual) / actual <= 0.01 | ||
|
||
mock = project.MockOracle.deploy(sender=gov) | ||
mock.set_price(AMOUNT, AMOUNT, sender=gov) | ||
|
||
redemption = project.Redemption.deploy( | ||
yfi, d_yfi, ve_yfi, gov, combined, mock, 10 * AMOUNT, sender=gov | ||
yfi, d_yfi, ve_yfi, gov, combined, 10 * AMOUNT, sender=gov | ||
) | ||
assert redemption.get_latest_price() == actual | ||
|
||
|
||
def test_curve_oracle(project, yfi, d_yfi, ve_yfi, gov): | ||
mock = project.MockOracle.deploy(sender=gov) | ||
mock.set_price(AMOUNT, AMOUNT, sender=gov) | ||
curve = project.MockOracle.at("0xC26b89A667578ec7b3f11b2F98d6Fd15C07C54ba") | ||
redemption = project.Redemption.deploy( | ||
yfi, d_yfi, ve_yfi, gov, mock, curve, 10 * AMOUNT, sender=gov | ||
def test_redeployment_oracle(chain, accounts, project, d_yfi, ve_yfi, gov): | ||
ychad = accounts["0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52"] | ||
pool = ape.Contract("0xC26b89A667578ec7b3f11b2F98d6Fd15C07C54ba") | ||
yfi = ape.Contract("0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e") | ||
yfi.approve(pool, 1000 * AMOUNT, sender=ychad) | ||
pool.exchange(1, 0, 100 * AMOUNT, 0, sender=ychad) | ||
chain.pending_timestamp += 60 | ||
pool.exchange(1, 0, 100 * AMOUNT, 0, sender=ychad) | ||
chain.pending_timestamp += 60 | ||
pool.exchange(1, 0, 100 * AMOUNT, 0, sender=ychad) | ||
|
||
old = ape.Contract("0x2fBa208E1B2106d40DaA472Cb7AE0c6C7EFc0224") | ||
new = project.Redemption.deploy( | ||
yfi, | ||
d_yfi, | ||
ve_yfi, | ||
gov, | ||
"0x3EbEACa272Ce4f60E800f6C5EE678f50D2882fd4", | ||
10 * AMOUNT, | ||
sender=gov, | ||
) | ||
actual = curve.price_oracle() | ||
assert redemption.get_latest_price() == actual | ||
assert old.get_latest_price() == new.get_latest_price() |
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.
For reference the price data is sourced from this aggregate contract
https://etherscan.io/address/0x3ebeaca272ce4f60e800f6c5ee678f50d2882fd4#code
That merges this 2 sources to create a YFI/ETH price