Repository: rotki/rotki

Issue:
CHAI token balance is doubled
## Problem Definition

The CHAI balance on my account is doubled.

I believe that it's just missing in this dict 
https://github.com/rotki/rotki/blob/3eed14163de71705b9ed199560b83b3a8b029d39/rotkehlchen/chain/aggregator.py#L149
and handled the second time as the asset

## Logs

```
[25/11/2023 23:48:38 EET] DEBUG rotkehlchen.chain.evm.tokens Greenlet-21: Found ethereum CHAI(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215) token balance for %MY_ADDRESS% and balance 1637.xx
...
[25/11/2023 23:48:47 EET] DEBUG rotkehlchen.chain.aggregator Greenlet-21: Adding DeFi asset balance for eip155:1/erc20:0x06AF07097C9Eeb7fD685c692751D5C66dB49c215(CHAI) Balance(amount=FVal(1637.xx), usd_value=FVal(1707.xx))
```

### System Description


Operating system: Mac OS Sonoma 14.0
Rotki version: 1.31.0



Discussion:
Hey @folkyatina thanks a lot for your report!

I can confirm. I reproduced it. The fix is indeed simple and where you pointed out. Since you even know where to put the fix do you feel like making a PR? Always appreciate external PRs :smile: 

The diff should be like this:

```diff
diff --git a/rotkehlchen/chain/aggregator.py b/rotkehlchen/chain/aggregator.py
index 923178223..90ea9d0d7 100644
--- a/rotkehlchen/chain/aggregator.py
+++ b/rotkehlchen/chain/aggregator.py
@@ -156,7 +156,9 @@ DEFI_PROTOCOLS_TO_SKIP_ASSETS = {
     'Curve': True,  # True means all
     # Curve gauges balances are now being detected separately by us
     'Curve • Liquidity Gauges': True,  # True means all
-    # Chitoken is is in our packaged DB
+    # Chai is a normal token we query
+    'Chai': True,  # True means all
+    # Chitoken is a normal token we query
     'Chi Gastoken by 1inch': True,  # True means all
     # yearn vault balances are detected by the yTokens
     'yearn.finance • Vaults': True,  # True means all
```

And also if you can add a changelog entry to: https://github.com/rotki/rotki/blob/develop/docs/changelog.rst

An entry like:

```
* :bug:`6999` Chai token balances should not appear doubled under certain conditions.
```

If you don't feel like doing it I can whip it up in a minute, so no worries!

-------------------

And an explanation! So why is this there? It's quite simple actually. Among many other sources for token detection we use an aggregator contract (0x06FE76B2f432fdfEcAEf1a7d4f6C3d41B5861672) that with one call can give us many protocol + balances of an address.

This helps make things faster and not have to detect hard cases for some protocols. The problem is this aggregator contract is also updated remotely from time to time and has more detection added, and some times simple things like Chai, which we already find by just token balance queries. So we maintain this list of known things to avoid duplication.

We consider to get rid of this aggregator contract at some point but have not acted on it yet as it's still useful ;)
It would be an honor to contribute; hope I will find a minute tomorrow. 

BTW. If you write such a letter for every reporter, I'm starting to understand why your keyboard looks like it looks on twitter photos. 
> It would be an honor to contribute; hope I will find a minute tomorrow.
> 
> BTW. If you write such a letter for every reporter, I'm starting to understand why your keyboard looks like it looks on twitter photos.

hahah you should pop by our discord to see how much writing goes in there :rofl: 

https://discord.rotki.com/

Resolving patch:
diff --git a/rotkehlchen/chain/aggregator.py b/rotkehlchen/chain/aggregator.py
--- a/rotkehlchen/chain/aggregator.py
+++ b/rotkehlchen/chain/aggregator.py
@@ -146,7 +146,9 @@ def _module_name_to_class(module_name: ModuleName) -> type[EthereumModule]:
     'Curve': True,  # True means all
     # Curve gauges balances are now being detected separately by us
     'Curve • Liquidity Gauges': True,  # True means all
-    # Chitoken is is in our packaged DB
+    # Chai is a normal token we query
+    'Chai': True,  # True means all
+    # Chitoken is a normal token we query
     'Chi Gastoken by 1inch': True,  # True means all
     # yearn vault balances are detected by the yTokens
     'yearn.finance • Vaults': True,  # True means all


Test patch: