Class: Hyperliquid::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperliquid/info.rb

Overview

Client for read-only Info API endpoints

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Info

Returns a new instance of Info.



6
7
8
# File 'lib/hyperliquid/info.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#active_asset_data(user, coin) ⇒ Hash

Retrieve User’s Active Asset Data

Parameters:

  • user (String)
  • coin (String)

Returns:

  • (Hash)


300
301
302
# File 'lib/hyperliquid/info.rb', line 300

def active_asset_data(user, coin)
  @client.post(Constants::INFO_ENDPOINT, { type: 'activeAssetData', user: user, coin: coin })
end

#all_mids(dex: nil) ⇒ Hash

Get all market mid prices

Parameters:

  • dex (String, nil) (defaults to: nil)

    Optional perp dex name (defaults to first perp dex; spot mids only included with first perp dex)

Returns:

  • (Hash)

    Hash containing mid prices for all markets



18
19
20
21
22
# File 'lib/hyperliquid/info.rb', line 18

def all_mids(dex: nil)
  body = { type: 'allMids' }
  body[:dex] = dex if dex
  @client.post(Constants::INFO_ENDPOINT, body)
end

#candles_snapshot(coin, interval, start_time, end_time) ⇒ Array

Get candlestick data

Parameters:

  • coin (String)

    Coin symbol

  • interval (String)

    Time interval (e.g., “1m”, “1h”, “1d”)

  • start_time (Integer)

    Start timestamp in milliseconds

  • end_time (Integer)

    End timestamp in milliseconds

Returns:

  • (Array)

    Array of candlestick data



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/hyperliquid/info.rb', line 98

def candles_snapshot(coin, interval, start_time, end_time)
  @client.post(Constants::INFO_ENDPOINT, {
                 type: 'candleSnapshot',
                 req: {
                   coin: coin,
                   interval: interval,
                   startTime: start_time,
                   endTime: end_time
                 }
               })
end

#delegations(user) ⇒ Array

Query a user’s staking delegations

Parameters:

  • user (String)

Returns:

  • (Array)


197
198
199
# File 'lib/hyperliquid/info.rb', line 197

def delegations(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'delegations', user: user })
end

#delegator_history(user) ⇒ Array

Query a user’s staking history

Parameters:

  • user (String)

Returns:

  • (Array)


211
212
213
# File 'lib/hyperliquid/info.rb', line 211

def delegator_history(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'delegatorHistory', user: user })
end

#delegator_rewards(user) ⇒ Array

Query a user’s staking rewards

Parameters:

  • user (String)

Returns:

  • (Array)


218
219
220
# File 'lib/hyperliquid/info.rb', line 218

def delegator_rewards(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'delegatorRewards', user: user })
end

#delegator_summary(user) ⇒ Hash

Query a user’s staking summary

Parameters:

  • user (String)

Returns:

  • (Hash)


204
205
206
# File 'lib/hyperliquid/info.rb', line 204

def delegator_summary(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'delegatorSummary', user: user })
end

#extra_agents(user) ⇒ Array

Get authorized agent addresses for a user

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Array)

    Array of authorized agent addresses



225
226
227
# File 'lib/hyperliquid/info.rb', line 225

def extra_agents(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'extraAgents', user: user })
end

#frontend_open_orders(user, dex: nil) ⇒ Array

Get a user’s open orders with additional frontend info

Parameters:

  • user (String)

    Wallet address

  • dex (String, nil) (defaults to: nil)

    Optional perp dex name

Returns:

  • (Array)


38
39
40
41
42
# File 'lib/hyperliquid/info.rb', line 38

def frontend_open_orders(user, dex: nil)
  body = { type: 'frontendOpenOrders', user: user }
  body[:dex] = dex if dex
  @client.post(Constants::INFO_ENDPOINT, body)
end

#funding_history(coin, start_time, end_time = nil) ⇒ Array

Retrieve historical funding rates

Parameters:

  • coin (String)
  • start_time (Integer)
  • end_time (Integer, nil) (defaults to: nil)

Returns:

  • (Array)


338
339
340
341
342
# File 'lib/hyperliquid/info.rb', line 338

def funding_history(coin, start_time, end_time = nil)
  body = { type: 'fundingHistory', coin: coin, startTime: start_time }
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#historical_orders(user, start_time = nil, end_time = nil) ⇒ Array

Retrieve a user’s historical orders

Parameters:

  • user (String)

    Wallet address

  • start_time (Integer, nil) (defaults to: nil)

    Optional start timestamp in milliseconds

  • end_time (Integer, nil) (defaults to: nil)

    Optional end timestamp in milliseconds

Returns:

  • (Array)


123
124
125
126
127
128
# File 'lib/hyperliquid/info.rb', line 123

def historical_orders(user, start_time = nil, end_time = nil)
  body = { type: 'historicalOrders', user: user }
  body[:startTime] = start_time if start_time
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#l2_book(coin) ⇒ Hash

Get L2 order book for a coin

Parameters:

  • coin (String)

    Coin symbol (e.g., “BTC”, “ETH”)

Returns:

  • (Hash)

    L2 order book data with bids and asks



88
89
90
# File 'lib/hyperliquid/info.rb', line 88

def l2_book(coin)
  @client.post(Constants::INFO_ENDPOINT, { type: 'l2Book', coin: coin })
end

#max_builder_fee(user, builder) ⇒ Hash

Check builder fee approval

Parameters:

  • user (String)

    Wallet address

  • builder (String)

    Builder address

Returns:

  • (Hash)


114
115
116
# File 'lib/hyperliquid/info.rb', line 114

def max_builder_fee(user, builder)
  @client.post(Constants::INFO_ENDPOINT, { type: 'maxBuilderFee', user: user, builder: builder })
end

#meta(dex: nil) ⇒ Hash

Get metadata for all assets

Parameters:

  • dex (String, nil) (defaults to: nil)

    Optional perp dex name (defaults to first perp dex when not provided)

Returns:

  • (Hash)

    Metadata for all tradable assets



256
257
258
259
260
# File 'lib/hyperliquid/info.rb', line 256

def meta(dex: nil)
  body = { type: 'meta' }
  body[:dex] = dex if dex
  @client.post(Constants::INFO_ENDPOINT, body)
end

#meta_and_asset_ctxsHash

Get metadata for all assets including universe info

Returns:

  • (Hash)

    Extended metadata for all assets with universe information



264
265
266
# File 'lib/hyperliquid/info.rb', line 264

def meta_and_asset_ctxs
  @client.post(Constants::INFO_ENDPOINT, { type: 'metaAndAssetCtxs' })
end

#open_orders(user, dex: nil) ⇒ Array

Get a user’s open orders

Parameters:

  • user (String)

    Wallet address

  • dex (String, nil) (defaults to: nil)

    Optional perp dex name

Returns:

  • (Array)

    Array of open orders for the user



28
29
30
31
32
# File 'lib/hyperliquid/info.rb', line 28

def open_orders(user, dex: nil)
  body = { type: 'openOrders', user: user }
  body[:dex] = dex if dex
  @client.post(Constants::INFO_ENDPOINT, body)
end

#order_status(user, oid) ⇒ Hash

Get order status by order ID

Parameters:

  • user (String)

    Wallet address

  • oid (Integer)

    Order ID

Returns:

  • (Hash)

    Order status information



73
74
75
# File 'lib/hyperliquid/info.rb', line 73

def order_status(user, oid)
  @client.post(Constants::INFO_ENDPOINT, { type: 'orderStatus', user: user, oid: oid })
end

#order_status_by_cloid(user, cloid) ⇒ Hash

Get order status by client order ID (cloid)

Parameters:

  • user (String)

    Wallet address

  • cloid (String)

    Client order ID

Returns:

  • (Hash)

    Order status information



81
82
83
# File 'lib/hyperliquid/info.rb', line 81

def order_status_by_cloid(user, cloid)
  @client.post(Constants::INFO_ENDPOINT, { type: 'orderStatus', user: user, cloid: cloid })
end

#perp_deploy_auction_statusHash

Retrieve information about the Perp Deploy Auction

Returns:

  • (Hash)


292
293
294
# File 'lib/hyperliquid/info.rb', line 292

def perp_deploy_auction_status
  @client.post(Constants::INFO_ENDPOINT, { type: 'perpDeployAuctionStatus' })
end

#perp_dex_limits(dex) ⇒ Hash

Retrieve Builder-Deployed Perp Market Limits

Parameters:

  • dex (String)

Returns:

  • (Hash)


307
308
309
# File 'lib/hyperliquid/info.rb', line 307

def perp_dex_limits(dex)
  @client.post(Constants::INFO_ENDPOINT, { type: 'perpDexLimits', dex: dex })
end

#perp_dexsArray

Retrieve all perpetual dexs

Returns:

  • (Array)


249
250
251
# File 'lib/hyperliquid/info.rb', line 249

def perp_dexs
  @client.post(Constants::INFO_ENDPOINT, { type: 'perpDexs' })
end

#perps_at_open_interest_capArray

Query perps at open interest caps

Returns:

  • (Array)


286
287
288
# File 'lib/hyperliquid/info.rb', line 286

def perps_at_open_interest_cap
  @client.post(Constants::INFO_ENDPOINT, { type: 'perpsAtOpenInterestCap' })
end

#portfolio(user) ⇒ Array

Query a user’s portfolio time series

Parameters:

  • user (String)

Returns:

  • (Array)


176
177
178
# File 'lib/hyperliquid/info.rb', line 176

def portfolio(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'portfolio', user: user })
end

#predicted_fundingsArray

Retrieve predicted funding rates for different venues

Returns:

  • (Array)


280
281
282
# File 'lib/hyperliquid/info.rb', line 280

def predicted_fundings
  @client.post(Constants::INFO_ENDPOINT, { type: 'predictedFundings' })
end

#referral(user) ⇒ Hash

Query a user’s referral information

Parameters:

  • user (String)

Returns:

  • (Hash)


183
184
185
# File 'lib/hyperliquid/info.rb', line 183

def referral(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'referral', user: user })
end

#spot_balances(user) ⇒ Hash

Get a user’s spot token balances

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Hash)

    Object containing balances array



363
364
365
# File 'lib/hyperliquid/info.rb', line 363

def spot_balances(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'spotClearinghouseState', user: user })
end

#spot_deploy_state(user) ⇒ Hash

Get Spot Deploy Auction state for a user

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Hash)

    Spot deploy state



370
371
372
# File 'lib/hyperliquid/info.rb', line 370

def spot_deploy_state(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'spotDeployState', user: user })
end

#spot_metaHash

Get spot metadata

Returns:

  • (Hash)

    Spot tokens and universe metadata



350
351
352
# File 'lib/hyperliquid/info.rb', line 350

def spot_meta
  @client.post(Constants::INFO_ENDPOINT, { type: 'spotMeta' })
end

#spot_meta_and_asset_ctxsArray

Get spot metadata and asset contexts

Returns:

  • (Array)
    spot_meta, spot_asset_ctxs


356
357
358
# File 'lib/hyperliquid/info.rb', line 356

def spot_meta_and_asset_ctxs
  @client.post(Constants::INFO_ENDPOINT, { type: 'spotMetaAndAssetCtxs' })
end

#spot_pair_deploy_auction_statusHash

Get Spot Pair Deploy Auction status

Returns:

  • (Hash)

    Auction timing and gas parameters



376
377
378
# File 'lib/hyperliquid/info.rb', line 376

def spot_pair_deploy_auction_status
  @client.post(Constants::INFO_ENDPOINT, { type: 'spotPairDeployAuctionStatus' })
end

#token_details(token_id) ⇒ Hash

Get token details by tokenId

Parameters:

  • token_id (String)

    34-character hexadecimal token id

Returns:

  • (Hash)

    Token details



383
384
385
# File 'lib/hyperliquid/info.rb', line 383

def token_details(token_id)
  @client.post(Constants::INFO_ENDPOINT, { type: 'tokenDetails', tokenId: token_id })
end

#user_dex_abstraction(user) ⇒ Hash

Get dex abstraction config for a user

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Hash)

    Dex abstraction configuration



239
240
241
# File 'lib/hyperliquid/info.rb', line 239

def user_dex_abstraction(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userDexAbstraction', user: user })
end

#user_fees(user) ⇒ Hash

Query a user’s effective fee rates and schedule

Parameters:

  • user (String)

Returns:

  • (Hash)


190
191
192
# File 'lib/hyperliquid/info.rb', line 190

def user_fees(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userFees', user: user })
end

#user_fills(user) ⇒ Array

Get a user’s fill history

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Array)

    Array of fill history for the user



47
48
49
# File 'lib/hyperliquid/info.rb', line 47

def user_fills(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userFills', user: user })
end

#user_fills_by_time(user, start_time, end_time = nil) ⇒ Array

Get a user’s fills within a time range

Parameters:

  • user (String)

    Wallet address

  • start_time (Integer)

    Start timestamp in milliseconds

  • end_time (Integer, nil) (defaults to: nil)

    Optional end timestamp in milliseconds

Returns:

  • (Array)


56
57
58
59
60
# File 'lib/hyperliquid/info.rb', line 56

def user_fills_by_time(user, start_time, end_time = nil)
  body = { type: 'userFillsByTime', user: user, startTime: start_time }
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#user_funding(user, start_time, end_time = nil) ⇒ Array

Retrieve a user’s funding history

Parameters:

  • user (String)
  • start_time (Integer)
  • end_time (Integer, nil) (defaults to: nil)

Returns:

  • (Array)


316
317
318
319
320
# File 'lib/hyperliquid/info.rb', line 316

def user_funding(user, start_time, end_time = nil)
  body = { type: 'userFunding', user: user, startTime: start_time }
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#user_non_funding_ledger_updates(user, start_time, end_time = nil) ⇒ Array

Retrieve a user’s non-funding ledger updates

Parameters:

  • user (String)
  • start_time (Integer)
  • end_time (Integer, nil) (defaults to: nil)

Returns:

  • (Array)


327
328
329
330
331
# File 'lib/hyperliquid/info.rb', line 327

def user_non_funding_ledger_updates(user, start_time, end_time = nil)
  body = { type: 'userNonFundingLedgerUpdates', user: user, startTime: start_time }
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#user_rate_limit(user) ⇒ Hash

Query user rate limits and usage

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Hash)


65
66
67
# File 'lib/hyperliquid/info.rb', line 65

def user_rate_limit(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userRateLimit', user: user })
end

#user_role(user) ⇒ Hash

Query a user’s role

Parameters:

  • user (String)

Returns:

  • (Hash)


169
170
171
# File 'lib/hyperliquid/info.rb', line 169

def user_role(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userRole', user: user })
end

#user_state(user, dex: nil) ⇒ Hash

Get user’s trading state

Parameters:

  • user (String)

    Wallet address

  • dex (String, nil) (defaults to: nil)

    Optional perp dex name

Returns:

  • (Hash)

    User’s trading state including positions and balances



272
273
274
275
276
# File 'lib/hyperliquid/info.rb', line 272

def user_state(user, dex: nil)
  body = { type: 'clearinghouseState', user: user }
  body[:dex] = dex if dex
  @client.post(Constants::INFO_ENDPOINT, body)
end

#user_subaccounts(user) ⇒ Array

Retrieve a user’s subaccounts

Parameters:

  • user (String)

Returns:

  • (Array)


145
146
147
# File 'lib/hyperliquid/info.rb', line 145

def user_subaccounts(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'subaccounts', user: user })
end

#user_to_multi_sig_signers(user) ⇒ Hash

Get multi-sig signer mappings for a user

Parameters:

  • user (String)

    Multi-sig wallet address

Returns:

  • (Hash)

    Multi-sig signer information



232
233
234
# File 'lib/hyperliquid/info.rb', line 232

def user_to_multi_sig_signers(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userToMultiSigSigners', user: user })
end

#user_twap_slice_fills(user, start_time = nil, end_time = nil) ⇒ Array

Retrieve a user’s TWAP slice fills

Parameters:

  • user (String)

    Wallet address

  • start_time (Integer, nil) (defaults to: nil)

    Optional start timestamp in milliseconds

  • end_time (Integer, nil) (defaults to: nil)

    Optional end timestamp in milliseconds

Returns:

  • (Array)


135
136
137
138
139
140
# File 'lib/hyperliquid/info.rb', line 135

def user_twap_slice_fills(user, start_time = nil, end_time = nil)
  body = { type: 'userTwapSliceFills', user: user }
  body[:startTime] = start_time if start_time
  body[:endTime] = end_time if end_time
  @client.post(Constants::INFO_ENDPOINT, body)
end

#user_vault_equities(user) ⇒ Array

Retrieve a user’s vault deposits

Parameters:

  • user (String)

    Wallet address

Returns:

  • (Array)


162
163
164
# File 'lib/hyperliquid/info.rb', line 162

def user_vault_equities(user)
  @client.post(Constants::INFO_ENDPOINT, { type: 'userVaultEquities', user: user })
end

#vault_details(vault_address, user = nil) ⇒ Hash

Retrieve details for a vault

Parameters:

  • vault_address (String)

    Vault address

  • user (String, nil) (defaults to: nil)

    Optional wallet address

Returns:

  • (Hash)


153
154
155
156
157
# File 'lib/hyperliquid/info.rb', line 153

def vault_details(vault_address, user = nil)
  body = { type: 'vaultDetails', vaultAddress: vault_address }
  body[:user] = user if user
  @client.post(Constants::INFO_ENDPOINT, body)
end