-
Notifications
You must be signed in to change notification settings - Fork 0
feat: exchange rates #14
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
shahthepro
left a comment
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.
One obvious bug with usage of latestRound, latestAnswer should be used instead. Other than that, looks good to me
- `Currency` type
- ensure exchange rates exist in the appropriate places
- docs
- add `base` and `quote` to `ExchangeRate`
|
While running this I see it saying around ~36 minutes to complete on my system. It's around 10 minutes slower than it used to be. Maybe some sort of multicall or batching might help. Or ensuring we have a minimum span of time/blocks between rate refreshes. ( though we lose accuracy :( ) |
- uncomment the other processors
- comment on the quantity of exchange rates being processed
|
After doing more testing I'm not sure this adds much time at all. It seems quite negligible. I took a dump of the results and reran it using the result set as a cache/datasource from JSON and the difference was very small. (frax-staking processor 58907 vs 58842) |
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.
Looks good to me. Few comments inline
| pairs: [Currency, Currency][], | ||
| ) => { | ||
| await Promise.all( | ||
| pairs.map(([base, quote]) => ensureExchangeRate(ctx, block, base, quote)), |
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.
nit: Can probably do some filtering here. If the event was for tokens frxETH and stETH, could probably just query those tokens' price on-chain. For the rest, can find the previous value in DB and use that. Will reduce the number of RPC calls, while ensuring we have a price for all assets at a given block.
But probably better to leave this as it is for now rather than complicating it. If we run into rate-limit issues or performance bottlenecks, we could consider doing it then
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.
Problem is if we did that then we would be showing some of the values at wrong prices for the block numbers shown. For any block number where we have a value for a currency in our database we are going to need the exchange rate for it at the same block.
| if (!vault) { | ||
| result.promises.push( | ||
| ensureExchangeRates(ctx, block, [ | ||
| ['ETH', 'USD'], |
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.
nit: These could be constants as well. Same for other processors and their related files
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 am not sure what you mean.
No description provided.