2

I am trying to get a list of all pools containing a token symbol with Uniswap v3 for arbitrage opportunities. For example, if I want to find all pools containing "WETH".

Using the subgraph,

{
    tokens(first: 10, where:{symbol:"WETH"}){
    id
    name
    symbol
  }
}

Returns:

{
  "data": {
    "tokens": [
      {
        "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "name": "Wrapped Ether",
        "symbol": "WETH"
      }
    ]
  }
}

Once I have a selected pool, I then will have token0 and token1 to use later in factory.getPool().

Now to find the pools that contain WETH, I use the graph to check if token0 OR token1 contains the WETH ID, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.

// search token0
{
    pools(first:10, where: {
    token0:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",            
}){
    token0{
      name
      symbol
      id
    }
    token1{
      name
      symbol
      id
    }
    }
}


// search token1
{
    pools(first:10, where: {
    token1:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",            
}){
    token0{
      name
      symbol
      id
    }
    token1{
      name
      symbol
      id
    }
    }
}

Now I have a list of all pools that that contain "WETH" and the pool ID's to use in factory to perform swaps.

So, what I would like to know is if there is a much simpler way of doing this please!?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.