zeitgeistpm / zeitgeist-subsquid

Zeitgeist chain block indexer and processor that provides data sets for powerful GraphQL queries.
7 stars 4 forks source link

What is this additional base asset transfer? #526

Closed Chralt98 closed 7 months ago

Chralt98 commented 7 months ago
query MyQuery {
  h2: historicalAccountBalances(limit: 100, orderBy: timestamp_ASC, where: {
    accountId_eq: "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
    extrinsic: { hash_eq: "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
    }}) {
    accountId
    assetId
    blockNumber
    dBalance
    event
    extrinsic {
      name
      hash
    }
    id
    timestamp
  }
}
{
  "data": {
    "h2": [
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"poolShare\":51}",
        "blockNumber": 3866297,
        "dBalance": "-70000000000",
        "event": "BalanceSet",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000010-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "Ztg",
        "blockNumber": 3866297,
        "dBalance": "-270976121",
        "event": "Withdraw",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000003-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Long\"]}",
        "blockNumber": 3866297,
        "dBalance": "63100000000",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000005-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Short\"]}",
        "blockNumber": 3866297,
        "dBalance": "72000000000",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000007-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "Ztg",
        "blockNumber": 3866297,
        "dBalance": "72873477086",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000009-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "Ztg",
        "blockNumber": 3866297,
        "dBalance": "45071428553",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000016-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Long\"]}",
        "blockNumber": 3866297,
        "dBalance": "-63100000000",
        "event": "TokensRedeemed",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000017-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "Ztg",
        "blockNumber": 3866297,
        "dBalance": "20571428592",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000020-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Short\"]}",
        "blockNumber": 3866297,
        "dBalance": "-72000000000",
        "event": "TokensRedeemed",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000021-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      }
    ]
  }
}

What I don't really understand is the following part:

      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Long\"]}",
        "blockNumber": 3866297,
        "dBalance": "63100000000",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000005-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "{\"scalarOutcome\":[69,\"Short\"]}",
        "blockNumber": 3866297,
        "dBalance": "72000000000",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000007-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },
      {
        "accountId": "dE3vB7wmyf195xiuFbsRquZCEYxEbfpGBTZRtbCTL4sRZ3jtx",
        "assetId": "Ztg",
        "blockNumber": 3866297,
        "dBalance": "72873477086",
        "event": "Transfer",
        "extrinsic": {
          "name": "Utility.batch_all",
          "hash": "0x1ebbbb8f5e8e363b823f02d472f8e66445d439adf7c38f2ede722be033f07507"
        },
        "id": "0003866297-1785f-000009-Z3jtx",
        "timestamp": "2023-09-20T08:17:54.393000Z"
      },

I expected this happens because of the pool_exit resulting in PoolExit batched together with redeem_shares resulting in TokensRedeemed here. When exiting the pool I would totally expect that the caller receives outcome tokens and burns pool shares (BalanceSet), but what has the Ztg transfer with amount 72873477086 to do with that?

Chralt98 commented 7 months ago

In the old swaps pool a pool share is burned for a complete set of outcome tokens including the markets base asset.