internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rotki/rotki

Issue:
Wrong Binance asset mapping for STX
## Problem Definition

This was reported by a user via email. They own some STX in binance. For Rotki STX is Stox (https://www.coingecko.com/en/coins/stox) but in Binance it's another token not called Stacks (https://www.coingecko.com/en/coins/stack). We support it in Rotki as blockstacks (STX-2) so we just need to change the binance mapping.

## Task

Fix the binance mapping.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/assets/asset.py b/rotkehlchen/assets/asset.py
--- a/rotkehlchen/assets/asset.py
+++ b/rotkehlchen/assets/asset.py
@@ -154,6 +154,8 @@
     'SOL-2': 'SOL',
     # BETH is the eth staked in beacon chain
     'ETH2': 'BETH',
+    # STX is Blockstack in Binance
+    'STX-2': 'STX',
 }
 
 WORLD_TO_BITFINEX = {


Test patch:
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
@@ -186,7 +186,7 @@ def test_coingecko_identifiers_are_reachable(data_dir):
 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': '6499628db3b6996da07eb0e19741d8c0', 'version': 48}
+    last_meta = {'md5': '9d34eb6018b8d6013b4cb3fd8af22edf', 'version': 48}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
Repository: rotki/rotki

Issue:
TNT Tierion shows wrong value
TNT Tierion calculates to a value of $4.12 per token  instead of $0.00623








Operating system: Window 10
Rotki version: 1.13.0



Discussion:

Resolving patch:
diff --git a/rotkehlchen/chain/manager.py b/rotkehlchen/chain/manager.py
--- a/rotkehlchen/chain/manager.py
+++ b/rotkehlchen/chain/manager.py
@@ -1078,6 +1078,14 @@ def _add_protocol_balances(self) -> None:
                 token_usd_price=token_usd_price,
             )
 
+            # also query defi balances to get liabilities
+            defi_balances_map = self.defichad.query_defi_balances(proxy_addresses)
+            for proxy_address, defi_balances in defi_balances_map.items():
+                self._add_account_defi_balances_to_token_and_totals(
+                    account=proxy_to_address[proxy_address],
+                    balances=defi_balances,
+                )
+
         adex_module = self.adex
         if adex_module is not None and self.premium is not None:
             adex_balances = adex_module.get_balances(addresses=self.accounts.eth)


Test patch:
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
@@ -188,7 +188,7 @@ def test_coingecko_identifiers_are_reachable(data_dir):
 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': '6ffbfb27e631568c9c43ff09190c192d', 'version': 53}
+    last_meta = {'md5': 'd165367b3fcd68331fd8a265ba8eca0b', 'version': 54}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
Repository: rotki/rotki

Issue:
Rotki premium DB upload does not respect user setting
## Problem Definition

It seems that rotki users who use premium experienced encrypted DB uploads even with the setting off. 2 versions back we broke the functionality and made it always upload.

## Task

Fix it


Discussion:

Resolving patch:
diff --git a/rotkehlchen/premium/sync.py b/rotkehlchen/premium/sync.py
--- a/rotkehlchen/premium/sync.py
+++ b/rotkehlchen/premium/sync.py
@@ -149,6 +149,9 @@ def maybe_upload_data_to_server(self, force_upload: bool = False) -> bool:
         if self.premium is None:
             return False
 
+        if not self.data.db.get_premium_sync() and not force_upload:
+            return False
+
         # upload only once per hour
         diff = ts_now() - self.last_data_upload_ts
         if diff < 3600 and not force_upload:


Test patch:
diff --git a/rotkehlchen/tests/api/test_adex.py b/rotkehlchen/tests/api/test_adex.py
--- a/rotkehlchen/tests/api/test_adex.py
+++ b/rotkehlchen/tests/api/test_adex.py
@@ -98,6 +98,7 @@ def test_get_balances_premium(
         assert staking_balance['dai_unclaimed_balance']['usd_value']
 
 
+@pytest.mark.skip('Needs to be fixed by Victor after the changes to the subgraph')
 @pytest.mark.parametrize('ethereum_accounts', [[ADEX_TEST_ADDR]])
 @pytest.mark.parametrize('ethereum_modules', [['adex']])
 @pytest.mark.parametrize('start_with_valid_premium', [True])
diff --git a/rotkehlchen/tests/integration/test_premium.py b/rotkehlchen/tests/integration/test_premium.py
--- a/rotkehlchen/tests/integration/test_premium.py
+++ b/rotkehlchen/tests/integration/test_premium.py
@@ -27,7 +27,11 @@
 
 
 @pytest.mark.parametrize('start_with_valid_premium', [True])
-def test_upload_data_to_server(rotkehlchen_instance, username, db_password):
+@pytest.mark.parametrize('db_settings', [
+    {'premium_should_sync': True},
+    {'premium_should_sync': False},
+])
+def test_upload_data_to_server(rotkehlchen_instance, username, db_password, db_settings):
     """Test our side of uploading data to the server"""
     last_ts = rotkehlchen_instance.data.db.get_last_data_upload_ts()
     assert last_ts == 0
@@ -73,6 +77,11 @@ def mock_succesfull_upload_data_to_server(
     with patched_get, patched_put:
         rotkehlchen_instance.premium_sync_manager.maybe_upload_data_to_server()
 
+    if db_settings['premium_should_sync'] is False:
+        assert rotkehlchen_instance.data.db.get_last_data_upload_ts() == 0
+        assert rotkehlchen_instance.premium_sync_manager.last_data_upload_ts == 0
+        return
+
     last_ts = rotkehlchen_instance.data.db.get_last_data_upload_ts()
     msg = 'The last data upload timestamp should have been saved in the db as now'
     assert last_ts >= now and last_ts - now < 50, msg
Repository: rotki/rotki

Issue:
Maker DAO ETH deposits are double-counted
## Problem Definition
My MakerDAO ETH-A vault balance seems to be counted as ETH and as WETH resulting in a double count.


### System Description


Operating system: MacOS Big Sur
Rotki version: 1.13.1



Discussion:
I can confirm this. This must have started happening today as it did not happen yesterday. I also use rotki and makerdao vaults. Let me investigate. I suspect the defi adapter SDK we use started returning different results, resulting in double counting.

Resolving patch:
diff --git a/rotkehlchen/chain/manager.py b/rotkehlchen/chain/manager.py
--- a/rotkehlchen/chain/manager.py
+++ b/rotkehlchen/chain/manager.py
@@ -101,6 +101,9 @@
     'Synthetix': ['SNX'],
     # Ampleforth's AMPL token is in all_assets.json
     'Ampleforth': ['AMPL'],
+    # MakerDAO vault balances are already detected by our code.
+    # Note that DeFi SDK only detects them for the proxies.
+    'Multi-Collateral Dai': True,  # True means all
 }
 
 


Test patch:
Repository: rotki/rotki

Issue:
Force restoring a database after adding api keys doesn't work.
## Problem Definition

This requires an empty account without premium or a fresh account without premium set up during the account creation.
After logging into this account, if you go to the API keys page and insert the premium keys and then try to force sync (download) a backed-up database, this will fail with an error that says that the user doesn't have premium.

Performing a logout and re-login seems to resolve the issue.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/rotkehlchen.py b/rotkehlchen/rotkehlchen.py
--- a/rotkehlchen/rotkehlchen.py
+++ b/rotkehlchen/rotkehlchen.py
@@ -362,6 +362,7 @@ def set_premium_credentials(self, credentials: PremiumCredentials) -> None:
             self.premium.set_credentials(credentials)
         else:
             self.premium = premium_create_and_verify(credentials)
+            self.premium_sync_manager.premium = self.premium
 
         self.data.db.set_rotkehlchen_premium(credentials)
 


Test patch:
Repository: rotki/rotki

Issue:
add stETH (Lido Staked Ether)
## Abstract
Lido has a staking pool that allows you to trade your stacking position as a erc20. This token is currently not tracked on rotki.
<!-- Please describe by example what problem you see in the current Rotki implementation that you would like addressed.-->

## Motivation
To keep track of users staking positions on lido.
<!-- Why do you think this feature should be addressed. What is the value added to the users of Rotki and why would they want to have it implemented? -->

## Specification
The stETH token is also traded on defi. This means that stETH can be worth less then 1 ETH since withdrawals aren't enabled but deposits are.
Some users might prefer the stETH price on defi (me 😊) while others would like to represent it as plain ETH. 
I anticipate that most prefer the stETH price so adding a option to switch might be niche (but cool).

details stETH: https://blog.lido.fi/steth-the-mechanics-of-steth/
coingecko: https://www.coingecko.com/en/coins/lido-staked-ether
<!-- If the feature is techical in nature please write as detailed as possible a specification of what needs to be built. -->



Discussion:

Resolving patch:
diff --git a/rotkehlchen/externalapis/coingecko.py b/rotkehlchen/externalapis/coingecko.py
--- a/rotkehlchen/externalapis/coingecko.py
+++ b/rotkehlchen/externalapis/coingecko.py
@@ -138,6 +138,9 @@ class CoingeckoAssetData(NamedTuple):
     'yDAI+yUSDC+yUSDT+yBUSD',
     'yyDAI+yUSDC+yUSDT+yBUSD',
     'ypaxCrv',
+    'crvRenWBTC',
+    'crvRenWSBTC',
+    'ycrvRenWSBTC',
 ]
 
 COINGECKO_SIMPLE_VS_CURRENCIES = [


Test patch:
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
@@ -188,7 +188,7 @@ def test_coingecko_identifiers_are_reachable(data_dir):
 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': 'db2df74337ecc3dd07a10809e6bf76a5', 'version': 57}
+    last_meta = {'md5': '415b54ba0afd4a552a3e7313c881ac07', 'version': 58}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
Repository: rotki/rotki

Issue:
Binance added test assets "123" and "456" which break rotki balance query
## Problem Definition

It seems that binance added two new test assets 

```
 {'asset': 123, 'free': FVal(0E-8), 'locked': FVal(0E-8)},   
 {'asset': 456, 'free': FVal(0E-8), 'locked': FVal(0E-8)},   
```

These break rotki, since they are interpreted as ints.

```
[11/02/2021 07:51:30 W. Europe Standard Time] ERROR rotkehlchen.api.rest: Greenlet for task 1 dies with exception: object of type 'int' has no len().
Exception Name: <class 'TypeError'>
Exception Info: object of type 'int' has no len()
Traceback:
   File "src\\gevent\\greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "rotkehlchen\api\rest.py", line 268, in _do_query_async
  File "rotkehlchen\api\rest.py", line 399, in _query_all_balances
  File "rotkehlchen\rotkehlchen.py", line 748, in query_balances
  File "rotkehlchen\utils\interfaces.py", line 115, in wrapper
  File "rotkehlchen\utils\interfaces.py", line 74, in wrapper
  File "rotkehlchen\exchanges\binance.py", line 672, in query_balances
  File "rotkehlchen\exchanges\binance.py", line 446, in _query_spot_balances
```


## Task

- [x] Fix the place where this breaks rotki.
- [ ] Ask binance to fix their shit and not suddenly add non-existing test assets that break our app


Discussion:

Resolving patch:
diff --git a/rotkehlchen/exchanges/binance.py b/rotkehlchen/exchanges/binance.py
--- a/rotkehlchen/exchanges/binance.py
+++ b/rotkehlchen/exchanges/binance.py
@@ -442,17 +442,29 @@ def _query_spot_balances(
             balances: DefaultDict[Asset, Balance],
     ) -> DefaultDict[Asset, Balance]:
         account_data = self.api_query_dict('api', 'account')
-        for entry in account_data['balances']:
-            if len(entry['asset']) >= 5 and entry['asset'].startswith('LD'):
+        binance_balances = account_data.get('balances', None)
+        if not binance_balances:
+            raise RemoteError('Binance spot balances response did not contain the balances key')
+
+        for entry in binance_balances:
+            try:
+                # force string https://github.com/rotki/rotki/issues/2342
+                asset_symbol = str(entry['asset'])
+                free = entry['free']
+                locked = entry['locked']
+            except KeyError as e:
+                raise RemoteError(f'Binance spot balance asset entry did not contain key {str(e)}') from e  # noqa: E501
+
+            if len(asset_symbol) >= 5 and asset_symbol.startswith('LD'):
                 # Some lending coins also appear to start with the LD prefix. Ignore them
                 continue
 
-            amount = entry['free'] + entry['locked']
+            amount = free + locked
             if amount == ZERO:
                 continue
 
             try:
-                asset = asset_from_binance(entry['asset'])
+                asset = asset_from_binance(asset_symbol)
             except UnsupportedAsset as e:
                 self.msg_aggregator.add_warning(
                     f'Found unsupported {self.name} asset {e.asset_name}. '


Test patch:
Repository: rotki/rotki

Issue:
Add mobilecoin support
## Abstract

Add mobilecoin support (MOB)

## Motivation

mobilecoin is becoming more and more important, especially now that Signal has announced it will be used as the default payment method 

Euxaristw!


Discussion:

Resolving patch:
diff --git a/rotkehlchen/externalapis/coingecko.py b/rotkehlchen/externalapis/coingecko.py
--- a/rotkehlchen/externalapis/coingecko.py
+++ b/rotkehlchen/externalapis/coingecko.py
@@ -151,6 +151,18 @@ class CoingeckoAssetData(NamedTuple):
     'ATX-2',
     'SONIQ',
     'TRUST',
+    'CDX',
+    'CRB',
+    'CTX',
+    'EGC',
+    'ICOS',
+    'MTRC',
+    'NOX',
+    'PHI',
+    'RLT',
+    'SPIN',
+    'VIEW',
+    'VRM',
 ]
 
 COINGECKO_SIMPLE_VS_CURRENCIES = [
diff --git a/rotkehlchen/externalapis/cryptocompare.py b/rotkehlchen/externalapis/cryptocompare.py
--- a/rotkehlchen/externalapis/cryptocompare.py
+++ b/rotkehlchen/externalapis/cryptocompare.py
@@ -1207,8 +1207,6 @@ def all_coins(self) -> Dict[str, Any]:
         data['QBIT'] = object()
         # This is DPRating https://coinmarketcap.com/currencies/dprating/
         data['RATING'] = object()
-        # This is RouletteToken https://coinmarketcap.com/currencies/roulettetoken/
-        data['RLT'] = object()
         # This is RocketPool https://coinmarketcap.com/currencies/rocket-pool/
         data['RPL'] = object()
         # This is SpeedMiningService (https://coinmarketcap.com/currencies/speed-mining-service/)


Test patch:
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
@@ -228,7 +228,7 @@ def test_coingecko_identifiers_are_reachable(data_dir):
 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': 'cd625c7c32ff0ea562dcc1459cb0d10a', 'version': 66}
+    last_meta = {'md5': 'cf80df4e169499945d8f05a922283707', 'version': 67}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
Repository: rotki/rotki

Issue:
Validation error on adding manual balance: "Failed to deserialize location symbol. Unknown symbol realestate for location"
## Problem Definition

When adding a manual balance, and choosing "Real Estate" from "location" a cryptic error message appears. 

Expected outcome:
* No error shown.
* An error shown with a descriptive error explaining what I must do to fix it.

Actual outcome:

![Schermafdruk van 2021-02-28 12-00-07](https://user-images.githubusercontent.com/77059/109416629-b9ed8e80-79bf-11eb-93d6-105d460e1d54.png)

`Failed to deserialize location symbol. Unknown symbol realestate for location`

Choosing "External" works.

Editing existing balances and then choosing "Real Estate" gives the same error. 

## Logs

Logs were generated but showed nothing related to this issue. It does include privacy-sensitive data, so I'd prefer not to include those there, unless I know what parts to include here. If required, please let me know what I should look for, to provide the relevant parts of the logs.

### System Description

Operating system: Ubuntu 20.04.2 LTS x86_64 
Rotki version: 1.14.2 (rotki-linux_x86_64-v1.14.2.AppImage)



Discussion:
Hey @berkes thank you for opening an issue.

There is no need for additional logs. This is probably enough. Sounds like a bug. Let us investigate and fix. I will write here if there is more information needed but probably not.

Edit: Yes this is easy to reproduce. We will fix. Thanks a lot for making an issue

Resolving patch:
diff --git a/rotkehlchen/serialization/deserialize.py b/rotkehlchen/serialization/deserialize.py
--- a/rotkehlchen/serialization/deserialize.py
+++ b/rotkehlchen/serialization/deserialize.py
@@ -455,7 +455,7 @@ def deserialize_location(symbol: str) -> Location:
         return Location.GEMINI
     if symbol == 'equities':
         return Location.EQUITIES
-    if symbol == 'real estate':
+    if symbol == 'realestate':
         return Location.REALESTATE
     if symbol == 'commodities':
         return Location.COMMODITIES
diff --git a/rotkehlchen/typing.py b/rotkehlchen/typing.py
--- a/rotkehlchen/typing.py
+++ b/rotkehlchen/typing.py
@@ -382,7 +382,7 @@ def __str__(self) -> str:
         if self == Location.EQUITIES:
             return 'equities'
         if self == Location.REALESTATE:
-            return 'real estate'
+            return 'realestate'
         if self == Location.COMMODITIES:
             return 'commodities'
         if self == Location.CRYPTOCOM:


Test patch:
Repository: rotki/rotki

Issue:
Poloniex still shows LEND balance if LEND was swapped for AAVE in the exchange.
## Problem Definition

It seems that poloniex's API is still returning LEND balances for people who held LEND when they swapped it to AAVE. This is a mistake on poloniex's side but also displays in rotki and may inflate user's balances.

## Task

Fix it.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/exchanges/poloniex.py b/rotkehlchen/exchanges/poloniex.py
--- a/rotkehlchen/exchanges/poloniex.py
+++ b/rotkehlchen/exchanges/poloniex.py
@@ -490,6 +490,9 @@ def query_balances(self) -> ExchangeQueryBalances:
                     )
                     continue
 
+                if asset == Asset('LEND'):  # poloniex mistakenly returns LEND balances
+                    continue  # https://github.com/rotki/rotki/issues/2530
+
                 try:
                     usd_price = Inquirer().find_usd_price(asset=asset)
                 except RemoteError as e:


Test patch:
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
@@ -244,7 +244,7 @@ def test_coingecko_identifiers_are_reachable(data_dir):
 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': '29a8dd8b73db28b2736c8ee8231d9e22', 'version': 70}
+    last_meta = {'md5': '271b43b7fcb2ae995260a869adcf8e48', 'version': 71}
     data_dir = Path(__file__).resolve().parent.parent.parent / 'data'
     data_md5 = file_md5(data_dir / 'all_assets.json')
Repository: rotki/rotki

Issue:
aCRV token amount shown is double the actual amount
## Problem Definition

The Aave interst bearing CRV tokens are twice the amount shown on the Aave platform or the Etherscan. I think problem started around version V1.14.1


### System Description


Operating system: macOS BigSur
Rotki version: V1.15.0



Discussion:
On a related note, I was wondering why aCRV is not here?
https://github.com/rotki/rotki/blob/develop/rotkehlchen/chain/ethereum/modules/aave/common.py
By checking it seems that aCRV is only a v2 token. So that's the reason it's not there. The aave module is only for v1. We have not supported v2 yet for deposits/lending/liquidations.

As for the double counting let me have a look.

Resolving patch:
diff --git a/rotkehlchen/chain/manager.py b/rotkehlchen/chain/manager.py
--- a/rotkehlchen/chain/manager.py
+++ b/rotkehlchen/chain/manager.py
@@ -122,6 +122,7 @@ def _module_name_to_class(module_name: ModuleName) -> EthereumModule:
 DEFI_PROTOCOLS_TO_SKIP_ASSETS = {
     # aTokens are already detected at token balance queries
     'Aave': True,  # True means all
+    'Aave V2': True,  # True means all
     # cTokens are already detected at token balance queries
     'Compound': True,  # True means all
     # Chitoken is in our all_assets.json


Test patch:
Repository: rotki/rotki

Issue:
Cryptocompare cache data for assets should return rotki and not cryptocompare identifier
## Abstract

At the moment the query of the cryptocompare cache endpoint returns the assets of each cached pair. But the returned asset identifiers are in the cryptocompare identifier and not the rotki one.

## Task

Create a reverse mapping (or any other way with which this can be done) to go from cryptocompare ID to rotki id and return the rotki ID in the cache endpoint.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/externalapis/cryptocompare.py b/rotkehlchen/externalapis/cryptocompare.py
--- a/rotkehlchen/externalapis/cryptocompare.py
+++ b/rotkehlchen/externalapis/cryptocompare.py
@@ -821,8 +821,7 @@ def _get_histohour_data_for_range(
     def get_all_cache_data(self) -> List[Dict[str, Any]]:
         """Returns all current cryptocompare cache data
 
-        Note: The return asset identifiers are the cryptocompare ones and not
-        the canonical ones
+        Each list entry contains from/to asset ids and from to timestamps
         """
         cache_data = []
         for cache_key in self.price_history_file:


Test patch: