Class: Honeymaker::Exchanges::Hyperliquid
- Inherits:
-
Honeymaker::Exchange
- Object
- Honeymaker::Exchange
- Honeymaker::Exchanges::Hyperliquid
- Defined in:
- lib/honeymaker/exchanges/hyperliquid.rb
Constant Summary collapse
- BASE_URL =
"https://api.hyperliquid.xyz"
Constants inherited from Honeymaker::Exchange
Honeymaker::Exchange::ERROR_PATTERNS, Honeymaker::Exchange::OPTIONS
Instance Method Summary collapse
Methods inherited from Honeymaker::Exchange
#cache_ttl, #classify_error, #find_ticker, #get_price, #symbols, #tickers_info
Instance Method Details
#get_bid_ask(symbol) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/honeymaker/exchanges/hyperliquid.rb', line 40 def get_bid_ask(symbol) with_rescue do response = connection.post("/info") do |req| req.body = { type: "allMids" }.to_json end price = BigDecimal(response.body[symbol]) { bid: price, ask: price } end end |
#get_tickers_info ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/honeymaker/exchanges/hyperliquid.rb', line 8 def get_tickers_info with_rescue do response = connection.post("/info") do |req| req.body = { type: "spotMeta" }.to_json end tokens = response.body["tokens"] universe = response.body["universe"] token_map = tokens.each_with_object({}) { |t, h| h[t["index"]] = t } universe.filter_map do |pair| base_token = token_map[pair["tokens"][0]] quote_token = token_map[pair["tokens"][1]] next unless base_token && quote_token { ticker: pair["name"], base: base_token["name"], quote: quote_token["name"], minimum_base_size: nil, minimum_quote_size: nil, maximum_base_size: nil, maximum_quote_size: nil, base_decimals: base_token["szDecimals"] || 0, quote_decimals: 2, price_decimals: 5, available: true } end end end |