Prechádzať zdrojové kódy

Add user parameter setup for Hyperliquid API in deposit/withdrawal checks - Enhance deposit and withdrawal fetching by including user parameters based on the configured private key, improving API call accuracy and error handling in the Telegram bot.

Carles Sentis 5 dní pred
rodič
commit
ab1d4735ed
1 zmenil súbory, kde vykonal 12 pridanie a 2 odobranie
  1. 12 2
      src/telegram_bot.py

+ 12 - 2
src/telegram_bot.py

@@ -2115,9 +2115,19 @@ This will place a limit {exit_side} order at ${profit_price:,.2f} to capture pro
                 self.last_deposit_withdrawal_check = current_time
                 return
             
+            # Set up user parameter for Hyperliquid API calls
+            params = {}
+            if Config.HYPERLIQUID_PRIVATE_KEY:
+                wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
+                params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
+            else:
+                logger.warning("⚠️ No private key configured for deposit/withdrawal checking")
+                self.last_deposit_withdrawal_check = current_time
+                return
+            
             # Check for deposits
             try:
-                deposits = self.client.sync_client.fetch_deposits(code='USDC', since=since_timestamp)
+                deposits = self.client.sync_client.fetch_deposits(code='USDC', since=since_timestamp, params=params)
                 if deposits:
                     for deposit in deposits:
                         amount = float(deposit.get('amount', 0))
@@ -2136,7 +2146,7 @@ This will place a limit {exit_side} order at ${profit_price:,.2f} to capture pro
             
             # Check for withdrawals
             try:
-                withdrawals = self.client.sync_client.fetch_withdrawals(code='USDC', since=since_timestamp)
+                withdrawals = self.client.sync_client.fetch_withdrawals(code='USDC', since=since_timestamp, params=params)
                 if withdrawals:
                     for withdrawal in withdrawals:
                         amount = float(withdrawal.get('amount', 0))