Spaces:
Sleeping
Sleeping
feat: Added new @tool for fetch HYPE price on Hyperliquid Spot Market
Browse files32 unmodified lines33343536373832 unmodified linesexcept Exception as e:return f"Error fetching time for timezone '{timezone}': {str(e)}"final_answer = FinalAnswerTool()32 unmodified lines333435363738394041424344454647484950515253545556575859606162636465666768697071727332 unmodified linesexcept 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 endpointurl = "https://api.hyperliquid.xyz/info"# Payload for the POST requestpayload = {"type": "spotMarket"}# Make the POST requestresponse = requests.post(url, json=payload)if response.status_code == 200:data = response.json()# Find the HYPE market datafor market in data:if market["name"] == symbol:# The price is in USDC termsprice = 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