1

I'm trying to do a lookup for an unsupported price feed on polygon network: eg. BTC/MATIC on chainlink's data feed (https://docs.chain.link/docs/matic-addresses/). What's the best way to do this?

  1. It appears BTC/USD and MATIC/USD are supported, and I should be able to do separate lookups to 2 chainlink oracles. But this seems like a problem that others should have faced before. What's the best way to consume this data on-chain from a solidity smart contract?

  2. Are there existing libraries that I can leverage for this?

1 Answer 1

1

Correct, the best way to do it for an unsupported Chainlink Price Feeds pair is to get the price of both pairs in the same denomination (eg USD), then manually do the conversion yourself.

Eg say you want the BTC/EUR price, you can divide the BTC/USD price feed with the EUR/USD price feed, and the result would be the current BTC/EUR price. Check out the Chainlink docs for a guide on doing this

Just be careful with math/rounding though, either use SafeMath library, or use solidity 0.8 (which has SafeMath built in)

Finally, in the near future when Chainlink CCIP is released, you'll be able to make cross chain function calls, so if the price feed you want is on another chain, you would be able to use CCIP to consume the feed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.