webb-tools / relayer

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

[SPEC] Relayer Open-Market for unlisted Assets #406

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Overview

In the world of cryptocurrency, there are many assets available for trading. However, not all of them are listed on popular exchanges, which makes it difficult for us to fetch the prices of that asset. An open-market for unlisted crypto assets can be very useful in this case. An open-market for unlisted assets is a feature where the Relayer operator can decide the price of an asset using it's symbol (tTNT, WEBB, ..etc). The price is determined based on the demand and supply of the asset in question, without the need for bidding or an open-close bookkeeping system, It is really up to the Relayer operator to set the price for any asset, and the user is free to choose which relayer to use and see it fits its needs. A good and honest UI would optionally query all the available relayers to get a good quote of the transaction, and sort them by the best price & fees.

Proposed Config Changes

in the config files we can add a new config option under the global section for asset prices.

For example,

# Assets in assets.toml
[assets]
tTNT.price = 0.10 # 10 cents
TNT.price = 0.1
# ..etc

Also, we should make sure that the asset prices appears when we query the api/v1/info endpoint, like the following:

{
  "evm": {},
  "substrate": {},
  "experimental": {},
  "features": {},
  "assets": {
    "tTNT": {
      "price": 0.1
    },
    "TNT": {
      "price": 0.1
    }
  }
}

Using the Configured Asset prices

While querying the Price Oracle API for a price of a cretin token, and we can't find this said token symbol listed on that Oracle, we fallback to read it from our configured assets, However, if we can't find it there either, we should return an error to the user saying Unsupported Asset for example.

SPEC Checklist

Default Assets

fn default_assets() -> HashMap<String, UnlistedAsset> {
    HashMap::from_iter([
       (String::from("tTNT"), UnlistedAsset { price: 0.1 }), 
       (String::from("TNT"), UnlistedAsset { price: 0.1 }), 
   ])
}

Related Issues

404

Nutomic commented 1 year ago

By "open-market for unlisted assets" do you mean using something like uniswap for prices like described in #403?

shekohex commented 1 year ago

By "open-market for unlisted assets" do you mean using something like uniswap for prices like described in #403?

Well, not entirely, these are two separate issues.

403 tries to solve a problem where we should use a more reliable API for fetching token prices.

This one however, tries to solve the issue where that token is not even listed anywhere, hence it does not have a price. Having a value for this token in the config would solve this, and it is an open-market since anyone can set their price for that said token, or even add any other unlisted token with their prices.

shekohex commented 1 year ago

Closed #407