From a51ba0a2b4c2f537e3f02056b1e9dab8b7f94ce2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 11 Mar 2026 21:40:19 +0100 Subject: [PATCH] fix(hyperliquid): dex balance requests are only necessary in non-unified mode --- freqtrade/exchange/hyperliquid.py | 36 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/freqtrade/exchange/hyperliquid.py b/freqtrade/exchange/hyperliquid.py index 8d83b1600..41895199b 100644 --- a/freqtrade/exchange/hyperliquid.py +++ b/freqtrade/exchange/hyperliquid.py @@ -169,27 +169,29 @@ class Hyperliquid(Exchange): if self.unified_account: params["type"] = "spot" balances = super().get_balances(params) - dexes = self._get_configured_hip3_dexes() - for dex in dexes: - try: - dex_balance = super().get_balances(params={"dex": dex}) + if not self.unified_account: + # In unified accounts, the balance already includes all DEXes + dexes = self._get_configured_hip3_dexes() + for dex in dexes: + try: + dex_balance = super().get_balances(params={"dex": dex}) - for currency, amount_info in dex_balance.items(): - if currency in ["info", "free", "used", "total", "datetime", "timestamp"]: - continue + for currency, amount_info in dex_balance.items(): + if currency in ["info", "free", "used", "total", "datetime", "timestamp"]: + continue - if currency not in balances: - balances[currency] = amount_info - else: - balances[currency]["free"] += amount_info["free"] - balances[currency]["used"] += amount_info["used"] - balances[currency]["total"] += amount_info["total"] + if currency not in balances: + balances[currency] = amount_info + else: + balances[currency]["free"] += amount_info["free"] + balances[currency]["used"] += amount_info["used"] + balances[currency]["total"] += amount_info["total"] - except Exception as e: - logger.error(f"Could not fetch balance for HIP-3 DEX '{dex}': {e}") + except Exception as e: + logger.error(f"Could not fetch balance for HIP-3 DEX '{dex}': {e}") - if dexes: - self._log_exchange_response("fetch_balance", balances, add_info="combined") + if dexes: + self._log_exchange_response("fetch_balance", balances, add_info="combined") return balances def fetch_positions(