generated from ZeframLou/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[TOB-SANDCLOCK-6] use Liquity USD/ETH oracle (chainlink + tellor backup) #101
Merged
Conversation
This file contains 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
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
coolhill
commented
Jul 21, 2023
@@ -23,7 +23,7 @@ | |||
uint256 public totalProfit; | |||
|
|||
IStabilityPool public stabilityPool = IStabilityPool(C.LIQUITY_STABILITY_POOL); | |||
IPriceFeed public lusd2eth = IPriceFeed(C.CHAINLINK_LUSD_ETH_PRICE_FEED); | |||
IPriceFeed public usd2eth = IPriceFeed(C.LIQUITY_USD_ETH_PRICE_FEED); |
Check warning
Code scanning / Slither
State variables that could be declared immutable
scLiquity.usd2eth (src/liquity/scLiquity.sol#26) should be immutable
fyang1024
approved these changes
Jul 25, 2023
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.
Description
The LUSD/ETH price feed used by the scLiquity vault is an intermediate contract that calls depricated latestAnswer methods on upstream chainlink oracles. It also connects to upgradable proxie pricefeeds with unclear owners.
Solution
Instead of the intermediate contract use the Liquity USD->ETH oracle which uses Chainlink USD->ETH as a primary and Tellor USD->ETH as a backup and has extra safety checks. Disregard LUSD peg and estimate ETH holdings at LUSD/USD 1:1.
Side-effects
This means we estimate the ETH holdings to be worth as many LUSD as it is worth USD (as if LUSD is pegged 1:1), disregarding current market value/peg of LUSD. If LUSD trades at less than USD we would overestimate the total assets and users could redeem at a slight advantage until the keeper sells the ETH for LUSD. If the LUSD trades above the dollar then we would under-report the total holdings until the keeper rebalances into LUSD.
Since ETH is to be traded into LUSD asap and ETH total would only be a small temporary portion of the total holdings this is an OK compromise. Depending on the Liquity USD->ETH oracle is preferable to the previous intermediate contract that connects to upgradable proxies with unknown owners.
Previous Liquity oracle bug
Because of the complexity in the dual-oracle Liquity design there was a bug in the Tellor fallback functionality. However it has been fixed. Using the same oracle for scLUSD as is used for LUSD makes sense and a bug in LUSD or its oracle cannot be avoided anyways, since we fundamentally depend on LUSD as our underlying.
Rundown on different oracles