Spaces:
Sleeping
Sleeping
feat: Added new @tool for fetch HYPE price on Hyperliquid Spot Market
Browse files32 unmodified lines333435363738394041424344454647484950515253545556575859606162636465666768697071727332 unmodified lines except Exception as e: return f"Error fetching time for timezone '{timezone}': {str(e)}"
@tooldef get_hyperliquid_price(symbol: str = "HYPE") -> str: """A tool that fetches the current price of the HYPE token from Hyperliquid Spot market. Args: symbol: The trading symbol (defaults to 'HYPE' for HYPE/USDC pair). """ try: # Hyperliquid Spot API endpoint url = "https://api.hyperliquid.xyz/info" # Payload for the POST request payload = { "type": "spotMarket" } # Make the POST request response = requests.post(url, json=payload) if response.status_code == 200: data = response.json() # Find the HYPE market data for market in data: if market["name"] == symbol: # The price is in USDC terms price = float(market["markPrice"]) return f"Current {symbol}/USDC price on Hyperliquid is: {price} USD" return f"Error: {symbol} market not found on Hyperliquid" else: return f"Error: Unable to fetch price. Status code: {response.status_code}" except Exception as e: return f"Error fetching Hyperliquid price: {str(e)}"
final_answer = FinalAnswerTool()
app.py+35