0

Is it possible to get the price of a pair using graphql for uniswap without knowing its id?

I use this website to try things out: https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2
For example, this query allows me to get 5 pairs and their ids and symbols:

{
  pairs(first: 5) {
    id
    token0 {
      symbol
    }
    token1 {
      symbol
    }
  }
}

But what if i only have the symbol and want to get the id?
example:

symbol: ETH / WBTC
id: ??

What query do i have to send?

3
  • 1
    Probably not possible. The symbol is freely chosen when a token is created, so multiple tokens have the same symbol and there is no way to know which one is which by just looking at the symbols – Lauri Peltonen Feb 4 at 11:28
  • Ok thanks, if you write this as an answer i would mark it as correct answer – Alexanus Feb 4 at 11:39
  • Well, I don't know if they provide such functionality or not. Anyway, added an answer, but it's not a definitive one. – Lauri Peltonen Feb 4 at 11:59
2

Token symbols are arbitrary strings. They can be chosen freely by the token creator, so multiple tokens may have the same symbols.

Therefore it does not make much sense to search by token symbol. It is also impossible to know which token is which just by looking at the symbols.

Token address is the global unique identifier - never trust anything else.

So even if there was functionality to search by symbol it would only be of limited use.

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.