alpha-wallet-android icon indicating copy to clipboard operation
alpha-wallet-android copied to clipboard

Enhance Token Swap

Open JamesSmartCell opened this issue 2 years ago • 7 comments

When using our native Token Swap the following concerns have been raised:

1 - Who is the provider? I see the provider in the ActionSheet but have no idea if they are legit. I would like to be able to click on a link to read about them (See if the API provides a link to the provider site, if so add a hyperlink somewhere). 2 - I would like to see a comparison between the rate which the LiFi aggregator is showing, and a site like 1inch or Uniswap, which I have used before. 3 - Provide filters so that the LiFi aggregator only selects certain swap protocols eg choose between DODO, 1Inch and Uniswap. For this you'll have to determine if the API lists all providers, and if the API allows you to fine tune the result.

Currently the actual screens for this are being designed by @colourfreak but there is lot of investigation work needed that can be done, and a start can be made on integrating these.

JamesSmartCell avatar Aug 30 '22 01:08 JamesSmartCell

1 - Unfortunately the link to an exchange's website is not available. Only the logo URI is available in the response data. Any ideas for a workaround?

2/3 - We can query the full list of exchanges via the /tools endpoint, and allow the user to select their preferred exchanges. I think there is also an advanced endpoint where we can query all possible quotes from the selected endpoints.

Full list of exchanges:

[
    {
      "key": "dodo",
      "name": "DODO",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/dodo.png"
    },
    {
      "key": "paraswap",
      "name": "ParaSwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/paraswap.png"
    },
    {
      "key": "1inch",
      "name": "1inch",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/oneinch.png"
    },
    {
      "key": "openocean",
      "name": "OpenOcean",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/openocean.png"
    },
    {
      "key": "0x",
      "name": "0x",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/zerox.png"
    },
    {
      "key": "superfluid",
      "name": "Superfluid",
      "logoURI": "https://www.superfluid.finance/icons/icon-72x72.png"
    },
    {
      "key": "uniswap",
      "name": "UniswapV2",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/uniswap.png"
    },
    {
      "key": "quickswap",
      "name": "Quickswap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/quick.png"
    },
    {
      "key": "pancakeswap",
      "name": "Pancake",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/pancake.png"
    },
    {
      "key": "honeyswap",
      "name": "Honeyswap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/honey.png"
    },
    {
      "key": "spookyswap",
      "name": "SpookySwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/spooky.png"
    },
    {
      "key": "spiritswap",
      "name": "SpiritSwap",
      "logoURI": "https://github.com/Layer3Org/spiritswap-tokens-list-icon/blob/master/token-list/images/inspirit.png?raw=true"
    },
    {
      "key": "solarbeam",
      "name": "Solarbeam",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/solarbeam.png"
    },
    {
      "key": "jswap",
      "name": "JSwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/jswap.png"
    },
    {
      "key": "cronaswap",
      "name": "CronaSwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/cronaswap.png"
    },
    {
      "key": "voltage",
      "name": "Voltage",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/voltage.png"
    },
    {
      "key": "ubeswap",
      "name": "UbeSwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/ubeswap.png"
    },
    {
      "key": "sushiswap",
      "name": "SushiSwap",
      "logoURI": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/sushi.png"
    }
  ]

justindg avatar Aug 30 '22 06:08 justindg

  1. Damn that's a shame. Can we concierge a list of websites manually, and add a unit test that checks for new exchanges? 2/3. This is good news.

So to proceed let's create our own list of exchanges -> websites probably in JSON format and add a unit test that scans the API for new exchanges (unless it requires an API key for this functionality, in which case we'll have to add it to the API scan server we have).

JamesSmartCell avatar Aug 30 '22 06:08 JamesSmartCell

So to proceed let's create our own list of exchanges

I'll copy the json above and then add the link manually, then add it to our local assets. It does however require an API key, let me know how to add it to the scan server.

justindg avatar Aug 30 '22 06:08 justindg

So to proceed let's create our own list of exchanges

I'll copy the json above and then add the link manually, then add it to our local assets. It does however require an API key, let me know how to add it to the scan server.

I haven't added any tests to that API check server yet, I think @hboon might know more details about it. Would like to know how to add things to it though, as I think there's a lot we can put there - not only do the endpoint locations change but API restrictions/formats can be changed from time to time.

JamesSmartCell avatar Aug 30 '22 10:08 JamesSmartCell

1 - Unfortunately the link to an exchange's website is not available. Only the logo URI is available in the response data. Any ideas for a workaround?

A simple workaround — the underlying exchanges are a short finite list, so we can build our own mapping and update when we find more. And add a unit test (or services-monitoring at long as it's something we already run diligently) to discover for new ones

(Was typing this before James wrote his. So yeah, go for it!)


I haven't added any tests to that API check server yet, I think @hboon might know more details about it. Would like to know how to add things to it though, as I think there's a lot we can put there - not only do the endpoint locations change but API restrictions/formats can be changed from time to time.

Yeah, instructions in the README https://github.com/AlphaWallet/services-monitor/. We'll have to ping Hu to manual redeploy it after merging, but we can test locally. Usually I'll comment out all the other endpoints to when "developing" so it's much faster. Only 1 file (api/src/service/endpoints.ts) needs to be edited. Sample PR: https://github.com/AlphaWallet/services-monitor/pull/19/files. There is no facility to add API keys at the moment, so we just embed them in the file. Search for {infuraKey} for how (so the keys don't get logged to Discord or anywhere we might add to later)

I've asked Vlad earlier to help add more based on our app's usage (just created https://github.com/AlphaWallet/services-monitor/issues/21 to avoid duplicating work), so coordinate with him if you would like to add those.

hboon avatar Aug 31 '22 02:08 hboon

@justindg would you also help write up an issue for iOS for the changes (for swap, not monitoring) once you have figure it out/done

hboon avatar Aug 31 '22 02:08 hboon

We'll have to ping Hu to manual redeploy it after merging, but we can test locally.

ok, I will ask @abcfy2 to help the ci pipeline in service-monitor repo, ;)

foxgem avatar Aug 31 '22 03:08 foxgem