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.
{
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.
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
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.