Skip to content
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

Write PHOTWAPOracle Contracts && Tests #44

Merged
merged 8 commits into from
Sep 30, 2022
Merged

Write PHOTWAPOracle Contracts && Tests #44

merged 8 commits into from
Sep 30, 2022

Conversation

steve0xp
Copy link
Collaborator

@steve0xp steve0xp commented Sep 28, 2022

Write PHOTWAPOracle Contracts && Tests

Core changes:

  • Write oracle contracts based off of feedback on heavy research phase && draft PR Feat: write oracle contracts and tests #33
  • Write tests for new oracle contracts
  • Update draft Figjam to go with new PHOTWAPOracle arrangement
  • Queue up what will be needed for integration into rest of code-base (separate PR)
    • This will be revisited once more robust tests are written && new protocol architecture is flushed out.

Notes:

  • Some issues occurred with running tests altogether, using forge test, essentially tests took way longer than anticipated (or not at all really in full). So I simply run forge test -vvv --match-contract PHOTWAPOracle
  • A lot of the TWAP concepts are derived from this, among other resources.

Figjam screenshot for visual:
image

  • I will be writing some github issues tomorrow, including what to do when price fluctuates widely, right now we just revert when the priceUpdateThreshold is exceeded.
  • Effects on USD/PHO price from adding and removing liquidity are not included in the tests currently, can and will likely address these tomorrow, but these tests as is are good for showcasing basic functionality for PHOTWAPOracle.sol
  • PR Feat: write oracle contracts and tests #33 available for reference, but it has a lot of outdated conversation topics.

@steve0xp
Copy link
Collaborator Author

Notes/Comments from Kevin in draft PR #33 outlined here for continued discussion:

#33 (comment)

#33 (comment)

#33 (comment)

test/BaseSetup.t.sol Outdated Show resolved Hide resolved
test/PHOTWAPOracle.t.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@davekaj davekaj left a comment

Choose a reason for hiding this comment

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

I only skimmed the tests as I don't have time and we have other higher priorities.

But I went over the code in depth. Please fix all requests.

When we merge this we need to add a TODO to write more tests for this oracle. basically f from what I see, we just copy paste the Solidity into the tests and test the same function against itself. it's not the most useful kind of test.

we could write the tests in another environment.

but more importantly, we need to run a more aggressive test against this oracle, put it in a more realistic scenario, simulate a few hundred deposits and then see if everything is still returning the right price. we'd also have to run tests to push the oracle to its limits (where slippage occurs)

src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Show resolved Hide resolved
src/oracle/PHOTWAPOracle.sol Outdated Show resolved Hide resolved
test/BaseSetup.t.sol Outdated Show resolved Hide resolved
test/BaseSetup.t.sol Outdated Show resolved Hide resolved
@steve0xp
Copy link
Collaborator Author

I will address your change requests and add a TODO for more tests within the oracle test file. Are we saying to make the changes requested and submit the oracle code and tests as is though before adding such complex oracle tests? I think the more complicated oracle tests in their own PR is fair.

@steve0xp
Copy link
Collaborator Author

I have addressed all requested changes, and opened up appropriate issues for any outstanding tasks outside of the scope of this PR (ex. contingency plans).

One carry-over comment / change requested by Kevin was to switch the arrays to single vars. I wonder if there is really much benefit to doing this. I could but just wondering before making the change.

ref: #33 (comment)

@steve0xp
Copy link
Collaborator Author

Final changes have been made and ready for review.

@steve0xp steve0xp merged commit c4c608a into main Sep 30, 2022
steve0xp added a commit that referenced this pull request Sep 30, 2022
steve0xp added a commit that referenced this pull request Sep 30, 2022
steve0xp added a commit that referenced this pull request Sep 30, 2022
@steve0xp steve0xp deleted the sp/crv-twap-oracle branch October 10, 2022 01:42
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