0

I'm currently developing a simple project. After a payment is done, I call a smart contract to mint some coins and send them to a wallet.

All good over there, but I need to know the value in USD of the payment done to know how much coins will I mint.

I'm currently working on the Mumbai Testnet, so my coins would be MATIC and This Coin

I read about "aggregator interface v3" on this link:

https://stackoverflow.com/questions/69233678/using-web3js-get-coin-price-on-uniswap-and-sushiswap-exchange-without-using-thei

However, I don't know exactly how to use it on my case. The example gets the price for ETH/USD pair on Kovan network, how do I get the address I would need to instanciate the aggregator? Would it work on Mumbai Testnet and/or Polygon Mainnet?

Of course, all this will be up on Polygon Mainnet so if the uses are different somehow, let me know!

Thanks for your time!

2 Answers 2

0

Uniswap oracles can be very useful, but they can also be quite risky. Bad actors can manipulate the price in the uniswap pool if the liquidity is low enough, then exploit your protocol using the manipulated price. The tellor oracle, alternatively, includes a token-incentivized dispute mechanism to prevent oracle manipulation for profit. Tellor relies on a network of anon reporters to submit good data, monitor it for faults, and dispute bad data if necessary.

You mentioned that you want to read the ETH/USD feed on chain. Reporters on tellor are currently maintaining that feed actively, so you could simply read the tellor oracle on chain using a getter function, without the need to maintain the feed in any way yourself.

0

You could use the Tellor oracle to get your price data. Set up a data feed for each separate token price. Then once data reporters are submitting your data, you can retrieve your data from the oracle using the usingtellor helper library.

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.