0

I'm trying to query the entire transaction history of a given pair (e.g. WETH/USDT). Hence, this question is similar to How to get a token pair's uniswap trade history?

My approach is to use the GraphQL Python client and iterate through the transactions using the skip keyword. In the example below, I'd increment skip by 1000 for every iteration.

query {
            swaps(first: 1000, skip: ''' + str(x) + ''', where: {pair: "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852"} orderBy: timestamp, orderDirection: desc) {
                    transaction {
                        id
                        timestamp
                    }
                    id
                    pair {
                        token0 {
                            id
                            symbol
                        }
                        token1 {    
                            id
                            symbol
                        }
                }
                amount0In
                amount1In
                amount0Out
                amount1Out
                amountUSD
                to
            }
            }

Sadly, this only works for values from 0 to 5000. Does anyone know how to circumvent this issue or knows another way to get the entire transaction history?

1 Answer 1

0

I don't have a ready solution to offer you, but I can shine some light on the matter. Solutions like TheGraph are amazing for lighter tasks, like getting a few thousand events. But in order to work with larger datasets, it's usually not sufficient.

So in order to get all history of a specific pair on Uniswap, you would have to have access to an Ethereum full node (either your own or someone else's), and go through each block looking for the Swap event. Then you would need t o build up a database with these events, which you then can query similarly to what you are doing with TheGraph.

I'm working hard on rolling out this functionality through a simple API through Moralis, where I work. But we need a few more weeks.

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.