Repository: rotki/rotki

Issue:
Properly support assets ignored in _is_token_non_standard()
## Problem Definition

Some assets are skipped and warning is not emitted in `_is_token_non_standard()` to not spam the user with messages since we know we don't support them yet.

## Task

Well .. ehm support them and their USD value equivalent query


Discussion:

Resolving patch:
diff --git a/rotkehlchen/chain/ethereum/zerion.py b/rotkehlchen/chain/ethereum/zerion.py
--- a/rotkehlchen/chain/ethereum/zerion.py
+++ b/rotkehlchen/chain/ethereum/zerion.py
@@ -26,8 +26,8 @@
 
 
 def _is_token_non_standard(symbol: str, address: ChecksumEthAddress) -> bool:
-    """ignore some assets we do not yet support and don't want to spam warnings with"""
-    if symbol in ('UNI-V2', 'swUSD', 'crCRV'):
+    """ignore some assets we do not query directly as token balances"""
+    if symbol in ('UNI-V2',):
         return True
 
     if address in ('0xCb2286d9471cc185281c4f763d34A962ED212962',):  # Sushi LP token
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@
     url='https://github.com/rotki/rotki',
     packages=find_packages('.'),
     package_data={
-        "rotkehlchen": ["data/*.json"],
+        "rotkehlchen": ["data/*.json", "data/*.meta"],
     },
     python_requires='>=3.6',
     install_requires=requirements,
diff --git a/tools/uniswapv2/detect.py b/tools/uniswapv2/detect.py
--- a/tools/uniswapv2/detect.py
+++ b/tools/uniswapv2/detect.py
@@ -2,10 +2,12 @@
 import json
 import os
 from pathlib import Path
-from typing import Any, Dict, Optional
+from typing import Any, Dict, Optional, Set
 
 from eth_utils.address import to_checksum_address
 
+from rotkehlchen.assets.asset import EthereumToken
+from rotkehlchen.assets.unknown_asset import UnknownEthereumToken
 from rotkehlchen.chain.ethereum.contracts import EthereumContract
 from rotkehlchen.chain.ethereum.graph import Graph
 from rotkehlchen.chain.ethereum.manager import (
@@ -13,8 +15,8 @@
     EthereumManager,
     NodeName,
 )
+from rotkehlchen.chain.ethereum.uniswap.utils import uniswap_lp_token_balances
 from rotkehlchen.chain.ethereum.utils import multicall_specific
-from rotkehlchen.chain.ethereum.zerion import uniswap_lp_token_balances
 from rotkehlchen.externalapis.etherscan import Etherscan
 from rotkehlchen.greenlets import GreenletManager
 from rotkehlchen.tests.utils.ethereum import wait_until_all_nodes_connected
@@ -169,6 +171,11 @@ def read_file_if_exists(name: str) -> Optional[Dict[str, Any]]:
         help='Even if the results have been saved in a file requery',
         action='store_true',
     )
+    parser.add_argument(
+        '--no-query-balances',
+        help='Do not query balances, just create the lp tokens file',
+        action='store_true',
+    )
     args = parser.parse_args()
 
     results = {}
@@ -194,15 +201,20 @@ def read_file_if_exists(name: str) -> Optional[Dict[str, Any]]:
             results['ethereum'] = result
             write_result_to_file(result, 'uniswap_lp_tokens_ethereum.json')
 
-        start = ts_now()
-        balances = uniswap_lp_token_balances(
-            address='0x1554d34D46842778999cB4eb1381b19f651e4a9d',  # test address
-            ethereum=ethereum,
-            lp_addresses=results['ethereum'],
-        )
-        end = ts_now()
-        print(f'Querying balances took {end-start} seconds')
-        print(balances)
+        if args.no_query_balances is False:
+            start = ts_now()
+            known_assets: Set[EthereumToken] = set()
+            unknown_assets: Set[UnknownEthereumToken] = set()
+            balances = uniswap_lp_token_balances(
+                address='0x1554d34D46842778999cB4eb1381b19f651e4a9d',  # test address
+                ethereum=ethereum,
+                lp_addresses=results['ethereum'],
+                known_assets=known_assets,
+                unknown_assets=unknown_assets,
+            )
+            end = ts_now()
+            print(f'Querying balances took {end-start} seconds')
+            print(balances)
 
     if args.source == 'both':
         for entry in results['graph']:


Test patch:
diff --git a/rotkehlchen/tests/api/test_compound.py b/rotkehlchen/tests/api/test_compound.py
--- a/rotkehlchen/tests/api/test_compound.py
+++ b/rotkehlchen/tests/api/test_compound.py
@@ -14,6 +14,7 @@
 from rotkehlchen.serialization.deserialize import deserialize_ethereum_address
 from rotkehlchen.serialization.serialize import process_result_list
 from rotkehlchen.tests.utils.api import (
+    ASYNC_TASK_WAIT_TIMEOUT,
     api_url_for,
     assert_error_response,
     assert_ok_async_response,
@@ -528,8 +529,12 @@ def test_query_compound_history(rotkehlchen_api_server, ethereum_accounts):  # p
         ), json={'async_query': async_query})
         if async_query:
             task_id = assert_ok_async_response(response)
-            # Timeout of 120 since this test can take a long time
-            outcome = wait_for_async_task(rotkehlchen_api_server, task_id, timeout=120)
+            # Big timeout since this test can take a long time
+            outcome = wait_for_async_task(
+                rotkehlchen_api_server,
+                task_id,
+                timeout=ASYNC_TASK_WAIT_TIMEOUT * 10,
+            )
             assert outcome['message'] == ''
             result = outcome['result']
         else:
diff --git a/rotkehlchen/tests/unit/test_assets.py b/rotkehlchen/tests/unit/test_assets.py
--- a/rotkehlchen/tests/unit/test_assets.py
+++ b/rotkehlchen/tests/unit/test_assets.py
@@ -182,7 +182,7 @@ def test_coingecko_identifiers_are_reachable():
 def test_assets_json_meta():
     """Test that all_assets.json md5 matches and that if md5 changes since last
     time then version is also bumped"""
-    last_meta = {'md5': 'e7f7220c07bd60426e79b4510753b18e', 'version': 26}
+    last_meta = {'md5': 'e327a3f7ffa1435ffb0fc481ab6dc63d', 'version': 26}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
 
diff --git a/rotkehlchen/tests/unit/uniswap/test_utils.py b/rotkehlchen/tests/unit/uniswap/test_utils.py
--- a/rotkehlchen/tests/unit/uniswap/test_utils.py
+++ b/rotkehlchen/tests/unit/uniswap/test_utils.py
@@ -7,7 +7,7 @@
 def test_uniswapv2_lp_tokens_json_meta():
     """Test that uniswapv2_lp_tokens.json md5 matches and that if md5 changes since last
     time then version is also bumped"""
-    last_meta = {'md5': '5520c3b05773f6aba3d9495ea2a90706', 'version': 1}
+    last_meta = {'md5': 'c9a123a4bdf20c1effeb2ff23a5314fe', 'version': 2}
     data_dir = Path(__file__).resolve().parent.parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'uniswapv2_lp_tokens.json')