Fxpool fix oracle conversion for TXAU and TXAG #584
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fix is a follow-up of PR #575 Multiple Quote Tokens support for FXPools: FXPoolDeployerTracker
For some RWA tokens (metal tokens like Aurus: TXAU, TXAG), the token represents a gram unit while the Chainlink Aggregator returns the price in $ / ounce. For example: each TXAU token represents a gram of Gold while the Chainlink Aggregator for XAU will return the price in ounces. Because of this we added an oracle adaptor contract in front of said aggregator. We found a workaround so that the subgraph code can dynamically pickup on such oracle adapter contracts. Moving forward we will be using an
AggregatorConverter
that exposes aDIVISOR
andDECIMALS
public state variables. With these 2 parameters the subgraph code can perform the required conversion for theAnswerUpdated
event that is emitted directly by the Chainlink Aggregator.Additionally, we spotted an older bug in our code whereby if one of the tokens in a pool happened to not have an existing oracle associated with it, the code would
return
thus exiting the loop and missing out on subsequent valid tokens / oracles. The way this is reflected in the subgraph results that the TXAU token would return alatestFXPrice
ofnull
. We only noticed this bug in the fork/testing environment, production doesn't seem to have it (possibly because prod gets re-synced from an earlier block).Type of change
How should this be tested?
We've deployed the changes over to our balancer subgraph polygon clone (trimmed down version, starting from block 54559454 ): https://thegraph.com/hosted-service/subgraph/xave-finance/balancer-v2-polygon
Simply run the following query:
The return should looks like the one below. Both Aurus tokens show the correct price / gram.
The current production code on polygon returns the price in $ / ounce which is incorrect:
Checklist:
dev
->master
Merges to
dev