Uniswap – Is There a Data Difference Between Uniswap v3 Subgraph and Smart Contract Queries?

api-designuniswap

I have been using Uniswap's v3 subgraph to query pool and other data. On the docs page, connecting using ethers.js (smart contract transactions), https://docs.uniswap.org/sdk/guides/using-ethers:

While this tutorial doesn't use the V3 SDK – it will set us up to use
it after we get the on-chain data we need.

Is there a difference in the data between the two – specifically pool prices? In addition, is it possible to perform trades, swaps, etc. Uniswap actions through Graphql? It seems from the documentation it's query only?

Best Answer

Collecting data from smart contracts can a cumbersome work, especially when you have a factory contract. Graph is used to make that task easier and reduce the number of requests sent to a node.

The data you get from the Graph is taken from the Uniswap contracts. Whenever an event in one of the Smart Contracts is triggered, a Graph node performs a task based on the event and stores the data. Once this is done, everyone is able to query the data from the Graph node in a single request, using a GraphQl query.

It is not possible to perform state-changing transactions through the Graph. It is only used to aggregate data. (mutate is the GraphQl terminology)