Skip to content
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

Merged
merged 17 commits into from
May 23, 2024
Merged

Use decimals to normalize aggregator prices #853

merged 17 commits into from
May 23, 2024

Conversation

jarnaud
Copy link
Contributor

@jarnaud jarnaud commented May 15, 2024

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).

@jarnaud jarnaud requested a review from a team as a code owner May 15, 2024 10:14
@jarnaud jarnaud self-assigned this May 15, 2024
@jarnaud jarnaud changed the title Use decimals to normalize prices Use decimals to normalize aggregator prices May 15, 2024
Copy link
Member

@dimkouv dimkouv left a 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(
Copy link
Member

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?

Copy link
Contributor Author

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.

@jarnaud jarnaud merged commit b5ec207 into ccip-develop May 23, 2024
52 of 59 checks passed
@jarnaud jarnaud deleted the CCIP-2288 branch May 23, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants