v3-subgraph icon indicating copy to clipboard operation
v3-subgraph copied to clipboard

Improve usability of graphQL for consumers

Open sydneyhenrard opened this issue 4 years ago • 0 comments

Uniswap graphQL via The Graph is a great way to provide Uniswap data without interacting directly with the contract (with Infura for instance).

For some data it's easily consumable without involving too much math. For instance you can get the token0price and token1price without calculating it from sqrtPrice.

But for other data, it's impossible to get what you want without being a math expert. Even if the equation seems easy like 6.3, 6.4, 6.5 and 6.6 in the whitepaper, it's fairly complex to implement due to the representation of numbers (big integer).

For instance would it be possible to have the feeGrowthInside0LastX128 for a position in a readable attribute in decimal.

Current output: 23943438193679638481270179092394037871828650
Actual output based on the UI: 3.99
How to calculate it? Math wizardry

I think raw data (sqrtPrice, liquidity, feeGrowthGlobal0X128) should be available because it's "free" as stored in the blockchain. But it would be a huge improvement to have ready to consume data.

It would make one source of truth because by providing raw data, all consumers have to reimplement the calculation. It would also make possible to use the language of your choice. Today Uniswap libraries are only supported in Javascript/Typescript which makes sense but not always the best language depending on the use case.

What do you think? Thanks

sydneyhenrard avatar Aug 29 '21 15:08 sydneyhenrard