Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Transfer transaction in swap (SwapExactAmountIn) #503

Open
Chralt98 opened this issue Jan 28, 2024 · 6 comments
Open

Unexpected Transfer transaction in swap (SwapExactAmountIn) #503

Chralt98 opened this issue Jan 28, 2024 · 6 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@Chralt98
Copy link
Member

Consider the following query:

query MyQuery {
  txs: historicalAccountBalances(limit: 100, orderBy: timestamp_ASC, where: {
    extrinsic: { hash_eq: "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33" }
    accountId_eq: "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
  }) {
    accountId
    assetId
    dBalance
    blockNumber
    event
    extrinsic {
      hash
      name
    }
    id
    timestamp
  }
  swaps: historicalSwaps(limit: 10, orderBy: timestamp_ASC, where: {
    extrinsic: { hash_eq: "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33"},
  }) {
    accountId
    assetAmountIn
    assetAmountOut
    assetIn
    assetOut
    blockNumber
    event
    extrinsic {
      name
      hash
    }
    id
    timestamp
  }
}

I get this output:

    "txs": [
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetId": "Ztg",
        "dBalance": "-255840876",
        "blockNumber": 4316427,
        "event": "Withdraw",
        "extrinsic": {
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33",
          "name": "Swaps.swap_exact_amount_in"
        },
        "id": "0004316427-9e5fc-000003-6vQ7o",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      },
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetId": "{\"categoricalOutcome\":[317,3]}",
        "dBalance": "-840170",
        "blockNumber": 4316427,
        "event": "Transfer",
        "extrinsic": {
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33",
          "name": "Swaps.swap_exact_amount_in"
        },
        "id": "0004316427-9e5fc-000004-6vQ7o",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      },
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetId": "{\"categoricalOutcome\":[317,3]}",
        "dBalance": "-1765752000000",
        "blockNumber": 4316427,
        "event": "Transfer",
        "extrinsic": {
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33",
          "name": "Swaps.swap_exact_amount_in"
        },
        "id": "0004316427-9e5fc-000006-6vQ7o",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      },
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetId": "Ztg",
        "dBalance": "80008656190",
        "blockNumber": 4316427,
        "event": "Transfer",
        "extrinsic": {
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33",
          "name": "Swaps.swap_exact_amount_in"
        },
        "id": "0004316427-9e5fc-000007-6vQ7o",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      },
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetId": "Ztg",
        "dBalance": "-400043280",
        "blockNumber": 4316427,
        "event": "MarketCreatorFeesPaid",
        "extrinsic": {
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33",
          "name": "Swaps.swap_exact_amount_in"
        },
        "id": "0004316427-9e5fc-000010-6vQ7o",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      }
    ],
    "swaps": [
      {
        "accountId": "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o",
        "assetAmountIn": "1765752000000",
        "assetAmountOut": "80008656190",
        "assetIn": "{\"categoricalOutcome\":[317,3]}",
        "assetOut": "Ztg",
        "blockNumber": 4316427,
        "event": "SwapExactAmountIn",
        "extrinsic": {
          "name": "Swaps.swap_exact_amount_in",
          "hash": "0x22cc65dd857ba6799d27a2ada8efb6496015638bd4c2c8da9d468c5f82cc8f33"
        },
        "id": "0004316427-9e5fc-000008",
        "timestamp": "2023-11-22T15:40:12.423000Z"
      }
    ],

I couldn't match the -840170 Transfer transaction. Why does this transaction appear? All other transactions are fine (expected) associated to the swap event.

@Chralt98 Chralt98 added the question Further information is requested label Jan 28, 2024
@Chralt98
Copy link
Member Author

The same question for the following extrinsic hash: 0x3d1ae6633e6f811ecbacad51bb9bae6f40254ba941c68eba45e1c41096eb4b2b.

@saboonikhil
Copy link
Member

On checking on-chain, it looks like some tokens were lost as dust.

@Chralt98
Copy link
Member Author

Chralt98 commented Jan 29, 2024

Ok, perfect, thanks! I will expect this kind of transaction in my capital gain export.

@Chralt98 Chralt98 reopened this Jan 29, 2024
@Chralt98
Copy link
Member Author

Chralt98 commented Jan 29, 2024

Why does this query yield no result then?

query MyQuery {
  historicalAccountBalances(limit: 10, orderBy: timestamp_ASC, where: {
       accountId_eq: "dE17owFuqybtXatuqm4n4Qu1Gxjdatctj7SY224E19x86vQ7o", 
       event_eq: "DustLost",
  }) {
    accountId
    assetId
    dBalance
    blockNumber
    event
    extrinsic {
      hash
      name
    }
    id
    timestamp
  }
}

When I can see it here? https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmain.rpc.zeitgeist.pm%2Fws#/explorer/query/4655902

@saboonikhil

@Chralt98
Copy link
Member Author

Because DustLost is not captured (Transfer is given priority)

@Chralt98 Chralt98 reopened this Feb 13, 2024
@Chralt98
Copy link
Member Author

@saboonikhil Can we use the DustLost event instead of the Transfer event instead? From a capital gain point of view, it is a loss instead of a normal transfer. Or can we somehow add a label onto these records so that I can figure out that these are DustLost events?

@Chralt98 Chralt98 added help wanted Extra attention is needed and removed question Further information is requested labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants