Uniswap / v3-subgraph

Subgraph for Uniswap V3
GNU General Public License v3.0
338 stars 464 forks source link

Subgraph data miss-align for amount0 and amount1 #235

Open studentofcoding opened 3 months ago

studentofcoding commented 3 months ago

If we query swaps activity on V3 with this query

{
  swaps(first: 10, skip: 0, orderBy: timestamp, orderDirection: desc) {
    transaction {
      id
      blockNumber
      gasUsed
      gasPrice
    }
    timestamp
    token0 {
      symbol
    }
    token1 {
      symbol
    }
    sender
    recipient
    amount0
    amount1
  }
}

We would get the example data below

{
        "transaction": {
          "id": "0xfbc144494e603ed67258e49d948d3f0e0617ca71123f1dd362b4e9e80a6c05ce",
          "blockNumber": "20018060",
          "gasUsed": "266251",
          "gasPrice": "7729821113"
        },
        "timestamp": "1717499327",
        "token0": {
          "symbol": "FI"
        },
        "token1": {
          "symbol": "WETH"
        },
        "sender": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
        "recipient": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
        "amount0": "-50125",
        "amount1": "0.114394037615079189"
      },

And when we checked, the amount0 shouldn't be negative (-) as it's buying 50125 FI with 0.114++ WETH (here is the tx)

Screenshot 2024-06-04 at 18 16 56

This is all around the swap transactions, is there any reason why this is happening?