本頁面為社群翻譯版本,僅供參考;內容以英文原版為準。
查看英文原版 ↗

L1 數據結構

節點將數據寫入 ~/hl/data。在預設設定下,網路每天大約會產生 100 GB 的日誌,因此建議歸檔或刪除舊文件。

用於生成以下輔助數據的命令行標誌可在 https://github.com/hyperliquid-dex/node 找到

交易區塊

被解析爲交易的區塊將流式寫入到

~/hl/data/replica_cmds/{start_time}/{date}/{height}

狀態快照

狀態快照每 10,000 個區塊保存到

~/hl/data/periodic_abci_states/{date}/{height}.rmp

成交

成交數據保存到

~/hl/data/node_trades/hourly/{date}/{hour}
// Example trade
{
  "coin": "COMP",
  "side": "B",
  "time": "2024-07-26T08:26:25.899",
  "px": "51.367",
  "sz": "0.31",
  "hash": "0xad8e0566e813bdf98176040e6d51bd011100efa789e89430cdf17964235f55d8",
  "trade_dir_override":"Na",
  // side_info always has length 2
  // side_info[0] is the buyer
  // side_info[1] is the seller
  "side_info": [
    {
      "user": "0xc64cc00b46101bd40aa1c3121195e85c0b0918d8",
      "start_pos": "996.67",
      "oid": 12212201265,
      "twap_id": null,
      "cloid": null
    },
    {
      "user": "0x768484f7e2ebb675c57838366c02ae99ba2a9b08",
      "start_pos": "-996.7",
      "oid": 12212198275,
      "twap_id": null,
      "cloid": null
    }
  ]
}

成交明細

成交明細數據保存到

~/hl/data/node_fills/hourly/{date}/{hour}
// Example fill
[                                                                              18:18:32 [11/1124]
  "0x1111111111111111111111111111111111111111",
  {
    "coin": "BTC",
    "px": "100000.0",
    "sz": "0.01",
    "side": "B",
    "time": 1721982385899,
    "startPosition": "0.0",
    "dir": "Open Long",
    "closedPnl": "0.0",
    "hash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "oid": 123456789,
    "crossed": true,
    "fee": "0.55",
    "builderFee": "0.10",
    "builder": "0x2222222222222222222222222222222222222222",
    "subBuilders": [
      {
        "b": "0x3333333333333333333333333333333333333333",
        "s": 25000
      }
    ],
    "tid": 123456789012345,
    "feeToken": "USDC",
    "twapId": null
  }
]

訂單狀態

訂單狀態數據保存到

~/hl/data/node_order_statuses/hourly/{date}/{hour}
// Example order status
{
  "time": "2024-07-26T08:31:48.717",
  "user": "0xc64cc00b46101bd40aa1c3121195e85c0b0918d8",
  "status": "canceled",
  "order": {
    "coin": "INJ",
    "side": "A",
    "limitPx": "25.381",
    // filled size
    "sz": "257.0",
    "oid": 12212359592,
    "timestamp": 1721982700270,
    "triggerCondition": "N/A",
    "isTrigger": false,
    "triggerPx": "0.0",
    "children": [],
    "isPositionTpsl": false,
    "reduceOnly": false,
    "orderType": "Limit",
    // original order size
    "origSz": "257.0",
    "tif": "Alo",
    "cloid": null
  }
}

原始訂單簿差異

原始訂單簿差異數據保存到

~/hl/data/node_raw_book_diffs/hourly/{date}/{hour}
// Example raw book diffs
// new resting order
{
  "user":"0x768484f7e2ebb675c57838366c02ae99ba2a9b08",
  "oid":35061046831,
  "coin":"CHILLGUY",
  "side": "Bid",
  "px": "1.36",
  "raw_book_diff": {
    "new":{"sz":"186910.0"}
  }
}
// resting order update
{
  "user":"0x768484f7e2ebb675c57838366c02ae99ba2a9b08",
  "oid":35061055064,
  "coin":"BTC",
  "side": "Bid",
  "px": "115323.2",
  "raw_book_diff": {
    "update":{"origSz":"0.2086","newSz":"0.2076"}
  }
}
// order removal
{
  "user":"0xc64cc00b46101bd40aa1c3121195e85c0b0918d8",
  "oid":35061057543,
  "side": "Ask",
  "px": "115200.2"
  "coin":"HYPE",
  "raw_book_diff":"remove"
}

雜項事件

雜項事件數據保存到

~/hl/data/misc_events/hourly/{date}/{hour}

雜項事件目前包括以下內容

  • 質押存入
  • 質押委託
  • 質押提取
  • 驗證者獎勵
  • 賬本更新(資金費分配、現貨轉賬等)
type MiscEvent = {
  time: string;
  hash: string;
  inner: MiscEventInner;
}

type MiscEventInner = CDeposit | Delegation | CWithdrawal | ValidatorRewards | Funding | LedgerUpdate;

type CDeposit = {
  user: string;
  amount: number;
}

type Delegation = {
  user: string;
  validator: string;
  amount: number;
  is_undelegate: boolean;
}

type CWithdrawal = {
  user: string;
  amount: number;
  is_finalized: boolean;
}

type ValidatorRewards = {
  validator_to_reward: Array<[string, number]>;
}

type Funding {
  coin: string;
  usdc: number;
  szi: number;
  fundingRate: number;
  nSamples: number;
}

type LedgerUpdate = {
  users: Array<string>;
  delta: LedgerDelta;
}

// InternalTransfer means Perp USDC transfer
// RewardsClaim is for builder and referrer fees
// Deposit/Withdraw refer to Arbitrum USDC bridge
type LedgerDelta = Withdraw 
  | Deposit
  | VaultCreate
  | VaultDeposit
  | VaultWithdraw
  | VaultDistribution
  | VaultLeaderCommission
  | Liquidation
  | InternalTransfer
  | SubAccountTransfer
  | SpotTransfer
  | SpotGenesis
  | RewardsClaim
  | AccountActivationGas
  | PerpDexClassTransfer
  | DeployGasAuction;

type Withdraw = {
  usdc: number;
  nonce: number;
  fee: number;
}

type Deposit = {
  usdc: number;
}

type VaultCreate {
  vault: string;
  usdc: number;
  fee: number;
}

type VaultWithdraw {
  vault: string;
  user: string;
  requestedUsd: number;
  commission: number;
  closingCost: number;
  basis: number;
}

type VaultDistribution {
  vault: string;
  usdc: number;
}

type Liquidation {
  liquidatedNtlPos: number;
  accountValue: number;
  leverageType: string;
  liquidatedPositions: Array<LiquidatedPosition>;
}

type LiquidatedPosition {
  coin: string;
  szi: number;
}

type InternalTransfer {
  usdc: number;
  user: string;
  destination: string;
  fee: number;
}

type AccountClassTransfer {
  usdc: number;
  toPerp: boolean;
}

type SubAccountTransfer {
  usdc: number;
  user: string;
  destination: string;
}

type SpotTransfer {
  token: string;
  amount: number;
  usdcValue: number;
  user: string;
  destination: string;
  fee: number;
  nativeTokenFee: number;
}

type SpotGenesis {
  token: string;
  amount: number;
}

type RewardsClaim {
  amount: number;
}

type AccountActivationGas {
  amount: number;
  token: string;
}

type PerpDexClassTransfer {
  amount: number;
  token: string;
  dex: string;
  toPerp: boolean;
}

type DeployGasAuction {
  token: string;
  amount: number;
}

L4 快照

給定一個 abci 狀態,節點可以計算出 L4 訂單簿快照,即包含每個價位訂單完整資訊的整個訂單簿。該快照可用作檢查點,在其之上可以應用訂單狀態流,從而讓用戶實時流式獲取 L4 訂單簿。

快照中的訂單在同一價位按時間先後排序。觸發訂單排在末尾,可通過 isTrigger 加以區分。

[
  [
    "BTC", // coin
    [
      [ // bids
        {
          "coin": "BTC",
          "side": "B",
          "limitPx": "103988.0",
          "sz": "0.2782",
          "oid": 30112287571,
          "timestamp": 1747157301016,
          "triggerCondition": "N/A",
          "isTrigger": false,
          "triggerPx": "0.0",
          "children": [],
          "isPositionTpsl": false,
          "reduceOnly": false,
          "orderType": "Limit",
          "origSz": "0.2782",
          "tif": "Alo",
          "cloid": null
        },
        ..
      ],
      [ // asks
        {
          "coin": "BTC",
          "side": "A",
          "limitPx": "93708.0",
          "sz": "0.00047",
          "oid": 30073539988,
          "timestamp": 1747128626867,
          "triggerCondition": "Price below 101856",
          "isTrigger": true,
          "triggerPx": "101856.0",
          "children": [],
          "isPositionTpsl": false,
          "reduceOnly": true,
          "orderType": "Stop Market",
          "origSz": "0.00047",
          "tif": null,
          "cloid": null
        },
        ..
      ]
    ]
  ],
  [
    "ETH",
    ..
  ],
  [
    "SOL",
    ..
  ]
]
英文官方來源: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/l1-data-schemas
原文擷取日期: · 鏡像建置日期: · 社群翻譯,以英文原版為準
非官方社群鏡像與翻譯,內容版權歸 Hyperliquid 所有,以英文原版為準。 來源: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/l1-data-schemas