Repository: rotki/rotki

Issue:
Double liability amount for some recent makerdao vaults
## Problem Definition

A user noticed that their makerdao vault has double the liabilities amount than it should. It's a quite new vault and their problem is not reproducible for all makerdao vaults we know of and track.

For example my own vaults don't have this problem.

The problem manifests in the usual way all our double balances are. The "DeFi SDK" adapter smart contract that we use to detect balances we don't normally support seems to have added MakerDAO vaults Debt, but not for all vaults.

## Task

The fix should be easy. Fix it.
Double liability amount for some recent makerdao vaults
## Problem Definition

A user noticed that their makerdao vault has double the liabilities amount than it should. It's a quite new vault and their problem is not reproducible for all makerdao vaults we know of and track.

For example my own vaults don't have this problem.

The problem manifests in the usual way all our double balances are. The "DeFi SDK" adapter smart contract that we use to detect balances we don't normally support seems to have added MakerDAO vaults Debt, but not for all vaults.

## Task

The fix should be easy. Fix it.


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
@@ -139,6 +139,12 @@ def _module_name_to_class(module_name: ModuleName) -> EthereumModule:
     # We already got some pie dao tokens in all_assets.json
     'PieDAO': ['BCP', 'BTC++', 'DEFI++', 'DEFI+S', 'DEFI+L', 'YPIE'],
 }
+DEFI_PROTOCOLS_TO_SKIP_LIABILITIES = {
+    'Multi-Collateral Dai': True,  # True means all
+    'Aave': True,
+    'Aave V2': True,
+    'Compound': True,
+}
 
 
 T = TypeVar('T')
@@ -1390,16 +1396,23 @@ def _add_account_defi_balances_to_token_and_totals(
     ) -> None:
         """Add a single account's defi balances to per account and totals"""
         for entry in balances:
+            found_double_entry = False
+            # filter our specific protocols for double entries
+            for skip_mapping, balance_type in (
+                    (DEFI_PROTOCOLS_TO_SKIP_ASSETS, 'Asset'),
+                    (DEFI_PROTOCOLS_TO_SKIP_LIABILITIES, 'Debt'),
+            ):
+                skip_list = skip_mapping.get(entry.protocol.name, None)  # type: ignore
+                double_entry = (
+                    entry.balance_type == balance_type and
+                    skip_list and
+                    (skip_list is True or entry.base_balance.token_symbol in skip_list)
+                )
+                if double_entry:
+                    found_double_entry = True
+                    break
 
-            skip_list = DEFI_PROTOCOLS_TO_SKIP_ASSETS.get(entry.protocol.name, None)
-            double_entry = (
-                entry.balance_type == 'Asset' and
-                skip_list and
-                (skip_list is True or entry.base_balance.token_symbol in skip_list)  # type: ignore
-            )
-
-            # We have to filter out specific balances/protocols here to not get double entries
-            if double_entry:
+            if found_double_entry:
                 continue
 
             if entry.balance_type == 'Asset' and entry.base_balance.token_symbol == 'ETH':


Test patch: