wormhole-foundation / wormhole-token-list

119 stars 150 forks source link

tokenMarkets is overly verbose #14

Closed keone closed 2 years ago

keone commented 2 years ago

tokenMarkets[x][y][TOK]['markets'] = ['uniswap'] says: token TOK starting from chain id x, sent to chain id y, will be tradeable on uniswap.

this requires a lot of duplicate information because, for example, the below 4 tokens are UST on Solana, Ethereum, Terra, and BSC, and the below states the fact that UST:

"tokenMarkets": { // <-- this key is already in the file
    "1": { // source = Sol
      "2": {  // dest = Eth
        "9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i": {
          "markets":["curve","uniswap"]
        },
      },
      "3": {  // dest = Terra
        "9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i": {
          "markets": ["anchor"]
        },
      "4": {  // dest = BSC
        "9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i": {
          "markets": ["pancakeswap"]
        }
      }
    },
    "2": { // source = Eth
      "1": {  // dest = Sol
        "0xa693B19d2931d498c5B318dF961919BB4aee87a5": {
          "markets": ["saber", "mercurial", "jupiter","aldrin", "sunny", "apricot"]
        },
      },
      "3": {
        "0xa693B19d2931d498c5B318dF961919BB4aee87a5": {
          "markets": ["anchor"]
        },
      },
      "4": {  // dest = BSC
        "0xa693B19d2931d498c5B318dF961919BB4aee87a5": {
          "markets": ["pancakeswap"]
        }
      }
    },
    "3": { // source = Terra
      "1": {  // dest = Sol
        "uusd": {
          "markets": ["saber", "mercurial", "jupiter","aldrin", "sunny", "apricot"]
        }
      },
      "2": {  // dest = Eth
        "uusd": {
          "markets": ["curve", "uniswap"]
        }
      },
      "4": {  // dest = BSC
        "uusd": {
          "markets": ["pancakeswap"]
        }
      }
    },
    "4": { // source = BSC
      "1": {  // dest = Sol
        "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a": {
          "markets": ["saber", "mercurial", "jupiter","aldrin", "sunny", "apricot"]
        },
      },
      "2": {  // dest = Eth
        "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a": {
          "markets": ["curve", "uniswap"]
        },
      },
      "3": {  // dest = Terra
        "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a": {
          "markets": ["anchor"]
        },
      "4": {  // dest = BSC
        "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a": {
          "markets": ["pancakeswap"]
        }
      }
    }
}

it would be a lot less verbose to just have:

  1. tokens list the native tokens for each chain, and then for each native token, the addresses on all other chains (this part can be autogenerated)
  2. tokenMarkets lists the markets (on every chain) for each native token

for example the above information would be encoded with

"tokens":  {
    "3": {
      "uusd": {
        "symbol": "UST",
        "logo": "https://assets.terra.money/icon/60/UST.png",
        "addresses": {
          "1": "9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i",
          "2": "0xa693B19d2931d498c5B318dF961919BB4aee87a5",
          "4": "0x3d4350cD54aeF9f9b2C29435e0fa809957B3F30a"
        },
      }
},
"tokenMarkets" {
    "3": {
      "uusd": {
        "1": { 
          "markets": ["saber", "mercurial", "jupiter","aldrin", "sunny", "apricot"]
        },
        "2": { 
          "markets": ["curve", "uniswap"]
        },
        "3": { 
          "markets": ["anchor"]
        },
        "4": { 
          "markets": ["pancakeswap"]
        }
    }
}
keone commented 2 years ago

the addition of https://github.com/certusone/wormhole-token-list/blob/main/src/utils/gen_data.py halfway addresses this (adds a mapping of source to dest addresses).

still need to add mapping of dest addresses to markets