-
Notifications
You must be signed in to change notification settings - Fork 4
Add priceOracle to appconfig, add defillama price oracle, and selector #1651
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
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
c9f9d1c to
8eb26e0
Compare
8eb26e0 to
2c27830
Compare
| appConfig, | ||
| }); | ||
| let alreadyExists = false; | ||
| try { |
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.
I'm not sure I understand why we need the try catch here. Since getToken returns undefined can we just look at the variable to determine if it exists?
const alreadyExists = !!getToken({
chainId: reward.chainId,
tokenAddress: reward.tokenAddress,
appConfig,
});
if (alreadyExists) {
return;
}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.
getToken will throw an error now if you call it and it doesn't find a token. This is the behavior we want because it's a sign that the appconfig is malformed. In this case, though, since we're calling it before the reward tokens are included, we'll get an error thrown at us.
Related to #1629
This PR introduces a new
priceOraclefield to theTokenConfiginterface and defines aPriceOracleFnfunction type. This uses a strategy pattern (similar to what we're doing for rewards), so that it's easy to add new price oracle functions.At the moment, we only need
defillamastrategy, but a TODO has been added to provide auniswapv3oracle function to handle zappable tokens in the near future.