stefanmendoza / uniswap-price-feed

Real time price feeds from Uniswap by leveraging Infura
MIT License
27 stars 9 forks source link

Create price feed using Uniswap end-of-block midpoint price #2

Open stefanmendoza opened 4 years ago

stefanmendoza commented 4 years ago

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.

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