-
Notifications
You must be signed in to change notification settings - Fork 32
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
Alternative oracle to avoid overflows #37
Conversation
Quantity memory base = Quantity(denominatorSample, DENOMINATOR_TOKEN_DECIMALS); | ||
base = BASE_FEED_2.convert(base, BASE_TOKEN_2_DECIMALS); | ||
base = BASE_FEED_1.convert(base, BASE_TOKEN_1_DECIMALS); | ||
base.amount = address(VAULT) == address(0) ? base.amount : VAULT.convertToShares(base.amount); |
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.
aren't we loosing precision here if base.amount
is too low?
AggregatorV3Interface quoteFeed2, | ||
uint256 quoteToken2Decimals, | ||
uint256 denominatorTokenDecimals | ||
) { |
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.
we'll need to update it with the require we added in the other oracle I think
|
||
/// @inheritdoc IOracle | ||
function price() external view returns (uint256) { | ||
uint256 denominatorSample = 10 ** DENOMINATOR_TOKEN_DECIMALS; |
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.
could be an immutable
|
||
import {ErrorsLib} from "./ErrorsLib.sol"; | ||
|
||
struct Quantity { |
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.
maybe we should specify what decimals
are we talking about, the feed? The token?
Closing in favor of #36. The idea is still interesting and could be used for a future version of the oracle |
This PR implements the third proposition in #15 (comment). The idea is to use a sample amount, and to only convert between amounts, in order to avoid multiplication overflow.
Remarks:
price()
function, but could be set at deployment insteadfeed.decimals()
in the Chainlink library