Why does only half of a dextrade swap show up in the results?

Hello,
I am trying to find a list of trades by a wallets address but getting incomplete transaction info in dextrades.

I run the following query:

{
  ethereum(network: ethereum) {
    dexTrades(
      makerOrTaker: {is: "0x1027b7aa689ea0c4b48b17d85b2a5093ee8f051e"}
      date: {after: "2022-06-01", before: "2022-06-03"}
      exchangeName: {}
      txHash: {}
    ) {
      transaction {
        hash
      }
      smartContract {
        address {
          address
        }
        contractType
        currency {
          name
        }
      }
      tradeIndex
      date {
        date
      }
      block {
        height
      }
      buyAmount
      buyAmountInUsd: buyAmount(in: USD)
      buyCurrency {
        symbol
        address
      }
      sellAmount
      sellAmountInUsd: sellAmount(in: USD)
      sellCurrency {
        symbol
        address
      }
      sellAmountInUsd: sellAmount(in: USD)
      tradeAmount(in: USD)
      transaction {
        gasValue
        gasPrice
        gas
      }
    }
  }
}

And this is the result:

{
  "ethereum": {
    "dexTrades": [
      {
        "transaction": {
          "hash": "0x43fce7f74d7b1b959541a09569456fa1d79b0d68681e3761f235880b9872c5b5",
          "gasValue": 0.025356828126265343,
          "gasPrice": 85.495701504,
          "gas": 296586
        },
        "smartContract": {
          "address": {
            "address": "0x290a6a7460b308ee3f19023d2d00de604bcf5b42"
          },
          "contractType": "DEX",
          "currency": {
            "name": "-"
          }
        },
        "tradeIndex": "6",
        "date": {
          "date": "2022-06-02"
        },
        "block": {
          "height": 14892573
        },
        "buyAmount": 25.622545819611368,
        "buyAmountInUsd": 46422.116551507184,
        "buyCurrency": {
          "symbol": "WETH",
          "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
        },
        "sellAmount": 75000,
        "sellAmountInUsd": 45648.35429191589,
        "sellCurrency": {
          "symbol": "MATIC",
          "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"
        },
        "tradeAmount": 45648.35429191589
      }
    ]
  }
}

So basically it shows the User going from WETH → MATIC

But if you look up the tx on bitqueries own blockexplorer or etherscan you see that the
actual transaction is USDC → WETH → MATIC

i’ve tested this across a dozen addreses… that when i look up a transaction ID later, it only shows me the last leg of the transfer, but doesn’t show me the other steps.

Is there something I can add to the query to show me all the legs of the transaction?

In the initial query, I have limited the time period to just a day to make the issue clear with just one tx, but if i was to get a full wallets dextrades over a period of months, I would basically not be getting a full picture of that users interaction.

So thats my issue, i want to see what token the user got rid of, not just what token the user ended up getting in the last step.

Any help would be greatly appreciated!

Hello! if you want to get the route of a trade you can check this query! let me know if that fits your needs

query {
  ethereum(network: ethereum) {
    dexTrades(
      options: {asc: ["block.height", "tradeIndex"], limit: 50, offset: 0}
      txHash: {is: "0x43fce7f74d7b1b959541a09569456fa1d79b0d68681e3761f235880b9872c5b5"}
    ) {
      side
      baseCurrency {
        address
        symbol
        decimals
      }
      quoteCurrency {
        address
        symbol
        decimals
      }
      quotePrice
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      tradeIndex
      protocol
      exchange {
        fullName
      }
      smartContract {
        address {
          address
          annotation
        }
      }
      sellAmount: buyAmount
      sellCurrency: buyCurrency {
        address
        symbol
      }
      buyAmount: sellAmount
      buyCurrency: sellCurrency {
        address
        symbol
      }
      tradeAmount(in: USD)
    }
  }
}

Yes, I did this but that doesn’t help when you have a list of X wallets where you’re getting all the transactions for each wallet.
All those transactions that involve multiple steps only give you the final step or leg of the transaction when you look up the list of transactions by wallet.

If I do what you suggested and look by up a specific transaction by tx id it shows all the steps. My issue occurs when looking up all the transactions by wallet.

The only way around this that I can think of is that for every wallet id you would first have to get every single transaction hash then run every transaction ID through what you suggested to see which transactions have multiple steps?

Hi, check below query to see if this returns what you are looking for.

Query is looking for taker and txSender to include the trades by wallet.

{
ethereum(network: ethereum) {
dexTrades(
date: {after: “2022-06-01”, before: “2022-06-03”}
any: [{taker: {is: “0x1027b7aa689ea0c4b48b17d85b2a5093ee8f051e”}}, {txSender: {is: “0x1027b7aa689ea0c4b48b17d85b2a5093ee8f051e”}}]
exchangeName: {}
txHash: {}
) {
transaction {
hash
}
smartContract {
address {
address
}
contractType
currency {
name
}
}
tradeIndex
date {
date
}
block {
height
}
buyAmount
buyAmountInUsd: buyAmount(in: USD)
buyCurrency {
symbol
address
}
sellAmount
sellAmountInUsd: sellAmount(in: USD)
sellCurrency {
symbol
address
}
sellAmountInUsd: sellAmount(in: USD)
tradeAmount(in: USD)
transaction {
gasValue
gasPrice
gas
}
}
}
}

1 Like