Class: Honeymaker::Exchanges::Hyperliquid

Inherits:
Honeymaker::Exchange show all
Defined in:
lib/honeymaker/exchanges/hyperliquid.rb

Constant Summary collapse

BASE_URL =
"https://api.hyperliquid.xyz"
MINIMUM_QUOTE_SIZE =

Hyperliquid enforces a hard 10-USDC minimum order value on every spot pair (spotMeta exposes no per-token base floor). Surfaced as minimum_quote_size so consumers skip/reject sub-10 orders up front instead of having the exchange reject them.

10

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



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/honeymaker/exchanges/hyperliquid.rb', line 46

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_infoObject



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
39
40
41
42
43
44
# File 'lib/honeymaker/exchanges/hyperliquid.rb', line 13

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: MINIMUM_QUOTE_SIZE,
        maximum_base_size: nil,
        maximum_quote_size: nil,
        base_decimals: base_token["szDecimals"] || 0,
        quote_decimals: 2,
        price_decimals: 5,
        available: true,
        trading_enabled: true
      }
    end
  end
end