ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 49 forks source link

Added ERC20 token weird pack of behaviours #1932

Open DanielAtKrypton opened 3 years ago

DanielAtKrypton commented 3 years ago

Added ERC20 token weird pack of behaviours

Versions

With:

OS Name Microsoft Windows 10 Pro Version 10.0.19041 Build 19041

WSL2 - Debian Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

Docker Desktop 2.4.0.0

mainnet > xucli --version
1.1.0

Docker images:

Imgur

Description

After strictly following this, I entered the following command to add the SER token:

xucli addcurrency SER Connext --decimal_places 7 --token_address 0xB561fEF0d624C0826ff869946f6076B7c4f2ba42

The result returned:

success

Happy with the success I made the following sequence:

mainnet > getbalance

Balance:
┌──────────┬───────────────┬────────────────────────────┬───────────────────────────────┐
│ Currency │ Total Balance │ Channel Balance (Tradable) │ Wallet Balance (Not Tradable) │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ BTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ DAI      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ ETH      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ LTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ USDT     │ 0             │ 0                          │ 0                             │
└──────────┴───────────────┴────────────────────────────┴───────────────────────────────┘
mainnet > getbalance SER
Error: 9 FAILED_PRECONDITION: swapClient for currency SER not found
mainnet > xucli addcurrency SER Lnd --decimal_places 7 --token_address 0xB561fEF0d624C0826ff869946f6076B7c4f2ba42
Error: 6 ALREADY_EXISTS: currency SER already exists
mainnet > xucli removecurrency SER
Error: 3 INVALID_ARGUMENT: currency must consist of 2 to 5 upper case English letters or numbers
mainnet > xucli listcurrencies

Currencies:
┌────────┬────────┬────────────────────────────────────────────┬─────────────┐
│ Ticker │ Digits │ Token Address                              │ Swap Client │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ BTC    │ 8      │                                            │ Lnd         │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ LTC    │ 8      │                                            │ Lnd         │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ ETH    │ 18     │ 0x0000000000000000000000000000000000000000 │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ USDT   │ 6      │ 0xdAC17F958D2ee523a2206206994597C13D831ec7 │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ DAI    │ 18     │ 0x6B175474E89094C44Da98b954EedeAC495271d0F │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ SER    │ 7      │ 0xB561fEF0d624C0826ff869946f6076B7c4f2ba42 │ Connext     │
└────────┴────────┴────────────────────────────────────────────┴─────────────┘
mainnet > getbalance

Balance:
┌──────────┬───────────────┬────────────────────────────┬───────────────────────────────┐
│ Currency │ Total Balance │ Channel Balance (Tradable) │ Wallet Balance (Not Tradable) │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ BTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ DAI      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ ETH      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ LTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ USDT     │ 0             │ 0                          │ 0                             │
└──────────┴───────────────┴────────────────────────────┴───────────────────────────────┘

mainnet > exit

So I decided to exit and enter again:

❯ bash xud.sh
1) Simnet
2) Testnet
3) Mainnet
Please choose the network: 3
🚀 Launching mainnet environment
🌍 Checking for updates...
- Container mainnet_lndbtc_1: recreate
- Container mainnet_lndltc_1: recreate
- Container mainnet_connext_1: recreate
- Container mainnet_arby_1: recreate
- Container mainnet_boltz_1: recreate
- Container mainnet_xud_1: recreate
A new version is available. Would you like to upgrade (Warning: this may restart your environment and cancel all open orders)? [Y/n] y
Recreating mainnet_lndbtc_1...
Recreating mainnet_lndltc_1...
Recreating mainnet_connext_1...
Recreating mainnet_arby_1...
Recreating mainnet_boltz_1...
Recreating mainnet_xud_1...

🏃 Warming up...

Enter master xud password:
xud was unlocked succesfully
The following wallets were unlocked: LTC, BTC

                           .___           __  .__
          ___  _____ __  __| _/     _____/  |_|  |
          \  \/  /  |  \/ __ |    _/ ___\   __\  |
           >    <|  |  / /_/ |    \  \___|  | |  |__
          /__/\_ \____/\____ |     \___  >__| |____/
                \/          \/         \/
--------------------------------------------------------------

mainnet > getbalance

Balance:
┌──────────┬───────────────┬────────────────────────────┬───────────────────────────────┐
│ Currency │ Total Balance │ Channel Balance (Tradable) │ Wallet Balance (Not Tradable) │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ BTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ DAI      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ ETH      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ LTC      │ 0             │ 0                          │ 0                             │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ USDT     │ 0             │ 0                          │ 0                             │
└──────────┴───────────────┴────────────────────────────┴───────────────────────────────┘
mainnet > getbalance SER
Error: 2 UNKNOWN: cannot convert SER units of 0 to amount because units per currency was not found in the database
mainnet > xucli listcurrencies

Currencies:
┌────────┬────────┬────────────────────────────────────────────┬─────────────┐
│ Ticker │ Digits │ Token Address                              │ Swap Client │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ BTC    │ 8      │                                            │ Lnd         │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ LTC    │ 8      │                                            │ Lnd         │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ ETH    │ 18     │ 0x0000000000000000000000000000000000000000 │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ USDT   │ 6      │ 0xdAC17F958D2ee523a2206206994597C13D831ec7 │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ DAI    │ 18     │ 0x6B175474E89094C44Da98b954EedeAC495271d0F │ Connext     │
├────────┼────────┼────────────────────────────────────────────┼─────────────┤
│ SER    │ 7      │ 0xB561fEF0d624C0826ff869946f6076B7c4f2ba42 │ Connext     │
└────────┴────────┴────────────────────────────────────────────┴─────────────┘
mainnet > getbalance DAI

Balance:
┌──────────┬───────────────┬────────────────────────────┬───────────────────────────────┐
│ Currency │ Total Balance │ Channel Balance (Tradable) │ Wallet Balance (Not Tradable) │
├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤
│ DAI      │ 0             │ 0                          │ 0                             │
└──────────┴───────────────┴────────────────────────────┴───────────────────────────────┘
mainnet > listpairs
Trading Pairs:
┌──────────────┐
│ Trading pair │
├──────────────┤
│ BTC / USDT   │
├──────────────┤
│ ETH / BTC    │
├──────────────┤
│ LTC / BTC    │
├──────────────┤
│ USDT / DAI   │
└──────────────┘
mainnet > xucli walletdeposit SER
{
  "address": "0x9B6eE9076f5972999C28F79Ed0144e9eaBf0A087"
}
mainnet > xucli walletdeposit ETH
{
  "address": "0x9B6eE9076f5972999C28F79Ed0144e9eaBf0A087"
}

Potential problems found

Weirdness no 1:

mainnet > getbalance SER Error: 9 FAILED_PRECONDITION: swapClient for currency SER not found

Weirdness no 2:

mainnet > xucli removecurrency SER Error: 3 INVALID_ARGUMENT: currency must consist of 2 to 5 upper case English letters or numbers

Weirdness no 3:

mainnet > getbalance

Balance: ┌──────────┬───────────────┬────────────────────────────┬───────────────────────────────┐ │ Currency │ Total Balance │ Channel Balance (Tradable) │ Wallet Balance (Not Tradable) │ ├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤ │ BTC │ 0 │ 0 │ 0 │ ├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤ │ DAI │ 0 │ 0 │ 0 │ ├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤ │ ETH │ 0 │ 0 │ 0 │ ├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤ │ LTC │ 0 │ 0 │ 0 │ ├──────────┼───────────────┼────────────────────────────┼───────────────────────────────┤ │ USDT │ 0 │ 0 │ 0 │ └──────────┴───────────────┴────────────────────────────┴───────────────────────────────┘

getbalance command above doesn't show SER balance.

Weirdness no 4:

The following wallets were unlocked: LTC, BTC

Why aren't ETH and ETH(ERC20) in the unlocked list as well?

Weirdness no 5: Even after restart, getbalance command still doesn't show SER balance.

Weirdness no 6:

mainnet > getbalance SER Error: 2 UNKNOWN: cannot convert SER units of 0 to amount because units per currency was not found in the database

Summarizing

These were the I believe problems I could find when adding an ERC20 token to XUD. Maybe there is something I am missing to make all these points work correctly, any ideas?

kilrau commented 3 years ago

Thanks for opening this issue!

kilrau commented 3 years ago

Quick update here:

* Weirdness no 1-3 is a known issue and should be solved by #1746, please run above steps to confirm @LePremierHomme

1746 should be merged soon, just one small fix left. @raladev will make sure this fixes 1-3.

* Weirdness 5 & 6

These are far more complex than initially thought. In order to list add any ERC20 and start trading it, the connext node has to support this token and has to be funded with it. @jgarzik came up with a "wild" idea how to do that: https://github.com/ExchangeUnion/xud/issues/1956

* Weirdness no 4

The following wallets were unlocked: LTC, BTC

This is what should be fixed in this issue @sangaman