|
@@ -108,8 +108,8 @@ class HyperliquidClient:
|
|
|
# Try to fetch balance to test authentication
|
|
|
# Use the same logic as get_balance for consistency
|
|
|
params = {}
|
|
|
- if Config.HYPERLIQUID_PRIVATE_KEY:
|
|
|
- wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
|
|
|
+ if Config.HYPERLIQUID_WALLET_ADDRESS:
|
|
|
+ wallet_address = Config.HYPERLIQUID_WALLET_ADDRESS
|
|
|
params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
|
|
|
|
|
|
balance = self.sync_client.fetch_balance(params=params)
|
|
@@ -129,18 +129,17 @@ class HyperliquidClient:
|
|
|
# The user parameter should be the wallet address derived from private key
|
|
|
params = {}
|
|
|
|
|
|
- # If we have a private key, derive the wallet address
|
|
|
- if Config.HYPERLIQUID_PRIVATE_KEY:
|
|
|
- # Extract the wallet address from the private key
|
|
|
+ # If we have a wallet address, use it as the user parameter
|
|
|
+ if Config.HYPERLIQUID_WALLET_ADDRESS:
|
|
|
+ # Extract the wallet address
|
|
|
# For CCXT Hyperliquid, the user parameter should be the wallet address
|
|
|
- wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
|
|
|
+ wallet_address = Config.HYPERLIQUID_WALLET_ADDRESS
|
|
|
if wallet_address.startswith('0x'):
|
|
|
# Use the address as the user parameter
|
|
|
params['user'] = wallet_address
|
|
|
else:
|
|
|
- # If it's just the private key, we might need to derive the address
|
|
|
- # For now, try using the private key directly
|
|
|
- params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
|
|
|
+ # Add 0x prefix if missing
|
|
|
+ params['user'] = f"0x{wallet_address}"
|
|
|
|
|
|
logger.debug(f"🔍 Fetching balance with params: {params}")
|
|
|
balance = self.sync_client.fetch_balance(params=params)
|
|
@@ -162,10 +161,10 @@ class HyperliquidClient:
|
|
|
approaches = [
|
|
|
# Approach 1: No params (original)
|
|
|
{},
|
|
|
- # Approach 2: Private key as user
|
|
|
- {'user': Config.HYPERLIQUID_PRIVATE_KEY},
|
|
|
- # Approach 3: Private key with 0x prefix
|
|
|
- {'user': f"0x{Config.HYPERLIQUID_PRIVATE_KEY}" if not Config.HYPERLIQUID_PRIVATE_KEY.startswith('0x') else Config.HYPERLIQUID_PRIVATE_KEY},
|
|
|
+ # Approach 2: Wallet address as user
|
|
|
+ {'user': Config.HYPERLIQUID_WALLET_ADDRESS},
|
|
|
+ # Approach 3: Wallet address with 0x prefix
|
|
|
+ {'user': f"0x{Config.HYPERLIQUID_WALLET_ADDRESS}" if Config.HYPERLIQUID_WALLET_ADDRESS and not Config.HYPERLIQUID_WALLET_ADDRESS.startswith('0x') else Config.HYPERLIQUID_WALLET_ADDRESS},
|
|
|
# Approach 4: Empty user
|
|
|
{'user': ''},
|
|
|
]
|
|
@@ -196,8 +195,8 @@ class HyperliquidClient:
|
|
|
|
|
|
# Add user parameter for Hyperliquid CCXT compatibility
|
|
|
params = {}
|
|
|
- if Config.HYPERLIQUID_PRIVATE_KEY:
|
|
|
- wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
|
|
|
+ if Config.HYPERLIQUID_WALLET_ADDRESS:
|
|
|
+ wallet_address = Config.HYPERLIQUID_WALLET_ADDRESS
|
|
|
params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
|
|
|
|
|
|
logger.debug(f"🔍 Fetching positions with params: {params}")
|
|
@@ -295,8 +294,8 @@ class HyperliquidClient:
|
|
|
|
|
|
# Add user parameter for Hyperliquid CCXT compatibility
|
|
|
params = {}
|
|
|
- if Config.HYPERLIQUID_PRIVATE_KEY:
|
|
|
- wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
|
|
|
+ if Config.HYPERLIQUID_WALLET_ADDRESS:
|
|
|
+ wallet_address = Config.HYPERLIQUID_WALLET_ADDRESS
|
|
|
params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
|
|
|
|
|
|
logger.debug(f"🔍 Fetching open orders with params: {params}")
|
|
@@ -449,8 +448,8 @@ class HyperliquidClient:
|
|
|
|
|
|
# Add user parameter for Hyperliquid CCXT compatibility
|
|
|
params = {}
|
|
|
- if Config.HYPERLIQUID_PRIVATE_KEY:
|
|
|
- wallet_address = Config.HYPERLIQUID_PRIVATE_KEY
|
|
|
+ if Config.HYPERLIQUID_WALLET_ADDRESS:
|
|
|
+ wallet_address = Config.HYPERLIQUID_WALLET_ADDRESS
|
|
|
params['user'] = f"0x{wallet_address}" if not wallet_address.startswith('0x') else wallet_address
|
|
|
|
|
|
# Fetch recent trades/fills for the account
|