-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use decimals to normalize aggregator prices #853
Conversation
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.
LGTM, minor comments.
I suggest adding a test, using a real rpc client to test this e2e if not already done. You can drop the test afterwards.
} | ||
} | ||
chainCalls := batchCallsPerChain[aggCfg.ChainID] | ||
chainCalls.decimalCalls = append(chainCalls.decimalCalls, rpclib.NewEvmCall( |
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.
aggregator contract is one per token that's why we don't need to pass token address as a param, right?
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.
Indeed, the type AggregatorPriceConfig
defines this chaindID/aggregatorAddress pair.
Motivation
Aggregators may returns prices with various decimal settings, not always 18.
We need to normalize returned results to wei.
Solution
Use decimals call to the aggregator to know its format and perform conversion if needed (i.e. if decimals not already 18).