[SOLVED] Streams API::Mint Event

Hello.

How I can find out pair / token for which one I get log (Mint Event) from Stream?

So I created Stream with ABI:

[
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "token0",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "token1",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "pair",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "name": "PairCreated",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "sender",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "amount0",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "amount1",
        "type": "uint256"
      }
    ],
    "name": "Mint",
    "type": "event"
  }
]

So now I am getting a lot of logs. How I can find out pair / token when I get Mint Event from Stream?

Thanks.

you can give it a name here in the abi for this field, so that it is easier to parse it

after you have the logs, you parse/interpret them using the abi and the logs and you should get the parsed information after that, I think that you already did that with ethers in a separate forum post (to parse/interpret the logs information)

in this case, being simple events, you can parse them directly in PHP too if you want, you will have for PairCreated event token0 in topic1, token1 in topic2, and the pair in log data in the first half of it

Sorry but In this case I am not talking about PairCreated Event. I am talking about Mint Event. And yes I can parse data from logs and get only sender / amount0 / amount1 (for Mint Event). But this information doesn’t help me programly determine which pair address / token address the Mint Event arose. Therefore, I ask the question how I can get the pair address / token address from the logs for which this Mint Event arose.

Do you understand the essence of my question?

Thanks.

I thought that the pair is here.
Can you give a more exact example?

Of course when it comes with PairCreated Event not with Mint Event. For Mint Event I already wrote:

And yes I can parse data from logs and get only sender / amount0 / amount1 (for Mint Event ).

Example:

{
    "confirmed": false,
    "chainId": "0x38",
    "abi": [
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "token0",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "token1",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "pair",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "name": "PairCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "sender",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "amount0",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "amount1",
                    "type": "uint256"
                }
            ],
            "name": "Mint",
            "type": "event"
        }
    ],
    "streamId": "b8293b3c-05ae-4b01-b46d-2daf32afbaa8",
    "tag": "bsc mainnet, eth mainnet",
    "retries": 0,
    "block": {
        "number": "23368731",
        "hash": "0xbe7a3255c34ffe0563e591dd090dad2c4d567ae13ef61592df1b03a66868c28a",
        "timestamp": "1669405082"
    },
    "logs": [
        {
            "logIndex": "86",
            "transactionHash": "0xb6d53ee5ff09259f59e26148c9e982492af72f546ed5b2032aab55570ae5d9b7",
            "address": "0x060db3037dadb84be0bab9ecb1c22103d092f8a1",
            "data": "0x0000000000000000000000000000000000000000000000000000246139ca80000000000000000000000000000000000000000000000000000082e0962ea6dd7c",
            "topic0": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f",
            "topic1": "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e",
            "topic2": null,
            "topic3": null
        },
        {
            "logIndex": "133",
            "transactionHash": "0xbc1e447a47f5c54aec4e833e2ea4668338d1ed57f903477758bb61d9895a6a38",
            "address": "0x36472da1ea27ad9d49d57827530757f6e7548a86",
            "data": "0x000000000000000000000000000000000000000000000066e7b55c7ff31593e1000000000000000000000000000000000000000000000000000000f3c6aa6789",
            "topic0": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f",
            "topic1": "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e",
            "topic2": null,
            "topic3": null
        }
    ],
    "txs": [],
    "txsInternal": [],
    "erc20Transfers": [],
    "erc20Approvals": [],
    "nftApprovals": {
        "ERC1155": [],
        "ERC721": []
    },
    "nftTransfers": []
}

It is the record come from Stream. There is Mint Event. So I need find out for which pair address / token address this Mint Event.

Thanks.

it looks like the liquidity pair address is in the address field:

            "address": "0x060db3037dadb84be0bab9ecb1c22103d092f8a1",
curl --request GET \
     --url 'https://deep-index.moralis.io/api/v2/0x060db3037dadb84be0bab9ecb1c22103d092f8a1/reserves?chain=bsc' \
     --header 'X-API-Key: API_KEY_HERE' \
     --header 'accept: application/json'

=>

{
  "reserve0": "28219005763368380",
  "reserve1": "9839737790162631542"
}
1 Like

This is not entirely true, but, partly you are right. I found out this by the example of this record:

{
    "confirmed": true,
    "chainId": "0x38",
    "abi": [
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "token0",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "token1",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "pair",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "name": "PairCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "sender",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "amount0",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "amount1",
                    "type": "uint256"
                }
            ],
            "name": "Mint",
            "type": "event"
        }
    ],
    "streamId": "b8293b3c-05ae-4b01-b46d-2daf32afbaa8",
    "tag": "bsc mainnet, eth mainnet",
    "retries": 0,
    "block": {
        "number": "23368716",
        "hash": "0x333f6dc7901b331e0c4be0ec20ec945c40b361d91b21f8293b35c4f27af10e79",
        "timestamp": "1669405037"
    },
    "logs": [
        {
            "logIndex": "71",
            "transactionHash": "0xd3608293c19c00182cfc63c14eb57cae4a81ce6019baefa39bd3d3391cf86519",
            "address": "0xb07956e0372ef2be02bea1e46ff0a984deb13b49",
            "data": "0x00000000000000000000000000000000000000000000000551369210a676941100000000000000000000000000000000000000000000000821ab0d4414980000",
            "topic0": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f",
            "topic1": "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e",
            "topic2": null,
            "topic3": null
        },
        {
            "logIndex": "113",
            "transactionHash": "0x7cabf4bc90124fdd6213b8beb80c8a8a814ba4b3e584ae632709e1fed632b620",
            "address": "0xca143ce32fe78f1f7019d7d551a6402fc5350c73",
            "data": "0x000000000000000000000000353ccf1a92f07e1336626fe08e9cab0b2ea6a7270000000000000000000000000000000000000000000000000000000000120f7a",
            "topic0": "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
            "topic1": "0x0000000000000000000000002df03f1e6661f496a8daa2c22a58f83e7b255790",
            "topic2": "0x000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
            "topic3": null
        },
        {
            "logIndex": "121",
            "transactionHash": "0x7cabf4bc90124fdd6213b8beb80c8a8a814ba4b3e584ae632709e1fed632b620",
            "address": "0x353ccf1a92f07e1336626fe08e9cab0b2ea6a727",
            "data": "0x0000000000000000000000000000000000000003c95a2f0b4856475fe000000000000000000000000000000000000000000000000000000014d1120d7b160000",
            "topic0": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f",
            "topic1": "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e",
            "topic2": null,
            "topic3": null
        },
        {
            "logIndex": "145",
            "transactionHash": "0x8ffeb8f24cf3f824b962ebb0d6566f9de485292c270faa28fce4795e9bf28ea3",
            "address": "0x35182c82717cfffd63bf53990721517794b7a314",
            "data": "0x00000000000000000000000000000000000000000000000d8d726b7177a8000000000000000000000000000000000000000000000000000000fe1fa410dfeb01",
            "topic0": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f",
            "topic1": "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e",
            "topic2": null,
            "topic3": null
        }
    ],
    "txs": [],
    "txsInternal": [],
    "erc20Transfers": [],
    "erc20Approvals": [],
    "nftApprovals": {
        "ERC1155": [],
        "ERC721": []
    },
    "nftTransfers": []
}

When in the JSON.logs[i] in the data has sender / amount0 / amount1 - that is we get the Mint Event, then the JSON.logs[i].address has pair address and when in the data there is pair / token0 / token1 - that is we get the PairCreted Event, then the JSON.logs[i].address has Factory Address.

I hope this information will help other forum participants.

Thanks.

1 Like