We should be able to get a price feed of a token pair by leveraging the uniswap-sdk. By providing an ethers provider when fetching the token pair information we can hook into the Infura websocket and get price information block-by-block. Most likely the best way to handle this is to have a web3 (or ethers?) subscription to get new blocks and on receipt of a new block, leverage the helper methods from the SDK to get the mid-price.
We should be able to get a price feed of a token pair by leveraging the uniswap-sdk. By providing an
ethers
provider when fetching the token pair information we can hook into the Infura websocket and get price information block-by-block. Most likely the best way to handle this is to have aweb3
(orethers
?) subscription to get new blocks and on receipt of a new block, leverage the helper methods from the SDK to get the mid-price.Docs for pricing: https://uniswap.org/docs/v2/javascript-SDK/pricing/
See section 2.2 of the Uniswap V2 whitepaper: https://uniswap.org/whitepaper.pdf