pendulum-chain / oracle-pallet

The Unlicense
0 stars 0 forks source link

Add support for fiat currencies #3

Closed ebma closed 1 year ago

ebma commented 1 year ago

This PR adds support for fetching fiat prices from the DIA batching server. It also fixes the default value parsing for the supported_currencies argument.

It works as follows: If the blockchain identifier of a queried currency equals FIAT, the batching server will request the price information from the Traditional Finance Data API Endpoint. The symbol should be of form <base>-<target>. For our use cases the off-chain worker in the DIA pallet should always query using USD as the target currency but this has to be configured in the respective runtime/chain spec of the substrate chains. I decided not to make an assumption of USD always being the target currency here to not make the batching server too limited to our case. The price information for USD-USD is handled separately because we want the offchain-worker to also feed that price to the on-chain storage. Although it does not make too much sense to query the USD to USD price, we need to have the price available on-chain for our other (price) oracle pallet to work properly.