fix(hyperliquid): dex balance requests are only necessary in non-unified mode

This commit is contained in:
Matthias
2026-03-11 21:40:19 +01:00
parent 9da9250865
commit a51ba0a2b4
+19 -17
View File
@@ -169,27 +169,29 @@ class Hyperliquid(Exchange):
if self.unified_account: if self.unified_account:
params["type"] = "spot" params["type"] = "spot"
balances = super().get_balances(params) balances = super().get_balances(params)
dexes = self._get_configured_hip3_dexes() if not self.unified_account:
for dex in dexes: # In unified accounts, the balance already includes all DEXes
try: dexes = self._get_configured_hip3_dexes()
dex_balance = super().get_balances(params={"dex": dex}) for dex in dexes:
try:
dex_balance = super().get_balances(params={"dex": dex})
for currency, amount_info in dex_balance.items(): for currency, amount_info in dex_balance.items():
if currency in ["info", "free", "used", "total", "datetime", "timestamp"]: if currency in ["info", "free", "used", "total", "datetime", "timestamp"]:
continue continue
if currency not in balances: if currency not in balances:
balances[currency] = amount_info balances[currency] = amount_info
else: else:
balances[currency]["free"] += amount_info["free"] balances[currency]["free"] += amount_info["free"]
balances[currency]["used"] += amount_info["used"] balances[currency]["used"] += amount_info["used"]
balances[currency]["total"] += amount_info["total"] balances[currency]["total"] += amount_info["total"]
except Exception as e: except Exception as e:
logger.error(f"Could not fetch balance for HIP-3 DEX '{dex}': {e}") logger.error(f"Could not fetch balance for HIP-3 DEX '{dex}': {e}")
if dexes: if dexes:
self._log_exchange_response("fetch_balance", balances, add_info="combined") self._log_exchange_response("fetch_balance", balances, add_info="combined")
return balances return balances
def fetch_positions( def fetch_positions(