Uniswap / v2-subgraph

Uniswap V2 subgraph 📊
https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2
GNU General Public License v3.0
401 stars 736 forks source link

Bug: For AAVE-WETH pair, some swaps ignore decimals for AAVE in amount #85

Open LefterisJP opened 3 years ago

LefterisJP commented 3 years ago

Problem Definition

A user of rotki reported to us that one of their swaps as displayed in the app was completely off as far as the decimals were concerned.

It concerned the WETH-AAVE token pair.

After some investigation I noticed that the problem was not in our code, but came already from the results of the subgraph. The subgraph seems to always return the amounts with the decimals properly counted in. This has been our experience so far.

But at least for the WETH-AAVE token pair and only for some of its swaps this does not seem to be the case. It seems that for some swaps of this token the amount of AAVE will be returned without taking the 18 decimals into account.

You can easily find some examples with the following query in: https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2

{
swaps 
 (where: {
  pair: "0xdfc14d2af169b0d36c4eff567ada9b2e0cae044f"
  amount0In_gt: 10000000000
})
  {
                id
                logIndex
                sender
                to
                timestamp
                pair{
                    token0 {
                        id
                        decimals
                        name
                        symbol
                    }
                    token1 {
                        id
                        decimals
                        name
                        symbol
                    }
                }
                amount0In
                amount0Out
                amount1In
                amount1Out
            }
        }

I am not sure if this problem concerns other pairs too. But our users have only reported this one instance.

Task

I am not very familiar with how the subgraph works. But I hope the problem explanation can point you to the right direction.

caelavey commented 3 years ago

For those who land here and don't wanna waste time reading through cross-linked issues: https://thegraph.com/explorer/subgraph/benesjan/uniswap-v2 solves the problem.