0

I'm working on a POC to pull data from various liquidity pools (paired tokens, i.e. WEI/USDT from various exchanges.

In trying to create something like the DAI chart seen here:

enter image description here

I am trying to come up with a query and data model in JavaScript to contain this data.

The given would be "DAI". First get Uniswap results with DAI pools (any pool pairs containing "DAI"). Then get a list of results from SushiSwap of matching "WETH". Since both sources will likely not have all matching pools, with these two lists in memory, create a list of all items that match, i.e. USDT/WETH (matching in green in the image above).

I initially was going to create an associative array with a list of tokens to match:

poolList["Uniswap"] = { collection of pool objects }
poolList["Sushiswap"] = { collection of pool objects }

Where the collection data would looks something like

{
  "data": {
    "pools": [
      {
        "token0": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "name": "Wrapped Ether",
          "symbol": "WETH"
        },
        "token1": {
          "id": "0xd1063ee5ec2891991a29fefb52bcc448cd386844",
          "name": "BanDogge Mastiff",
          "symbol": "DOGGE"
        }
      },
      {
        "token0": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "name": "Wrapped Ether",
          "symbol": "WETH"
        },

How would one store the data from various exchanges so that either a filters list exists of common pairs, or create some sort of 2D array reflecting how the chart above appears?

ElHaix
  • 12,846
  • 27
  • 115
  • 203

1 Answers1

0

I went about looking at this at the ground level: What kind of data problem is this?

In addressing this, I was able to work through a suggested response to my question, What can be used to identify the source collection for common elements from n-number of collections? and came up with a solution that renders the data in a workable format:

enter image description here

The table does not exactly reflect the initial question, however, (index) represents the pool name or token pairs, i.e. USDT/ETH. Subsequent columns represent exchanges and their properties that contain these token pairs or liquidity pools.

To maintain the context of the original question and to assist others, the full code solution can be found here.

ElHaix
  • 12,846
  • 27
  • 115
  • 203