tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[TASK] Remove the hardcoded `NativeToken` names while fetching prices #412

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Overview

Instead of Hard-coding chain native token names in the relayer, we should instead use something like

https://chainid.network/chains.json

Which contains a big list of networks/chains, each has a chainId, a name and nativeCurrency with its symbol and decimals too!

We should make use of that and bundle this file with the relayer binary, no need to fetch it every time.

Coingecko-Specific Token Ids

Coingecko uses it's own set of token ids, different than just using the token symbol or ticker, hence, the generated chains.json file should include somehow the corresponding coingecko token id by query the

https://api.coingecko.com/api/v3/coins/list?include_platform=false

endpoint which contains the id, symbol and name.

The result chains.json file should include the minimum information needed by the relayer, for now the ChainInfo struct may look like the following:

struct ChainInfo {
    pub name: String,
    pub short_name: String,
    pub chain_id: u32,
    pub native_currency: ChainNativeCurrency,
}

struct ChainNativeCurrency {
    pub name: String,
    pub symbol: String,
    pub decimals: u8,
   pub coingecko_token_id: Option<String>,
}

Task Checklist