/
ikratkiy
/
Hyperliquid
Обзор
Документация
Войти
/
ikratkiy
/
Hyperliquid
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/shared/hyperliquid/examples.ts
210 строк
6 KB
ikratkiy
feat(spot): add fail-closed reconciliation contracts
15 июл 2026, 02:22
15 июл 2026, 02:22
eb972fb
Код
Авторство
О чём код?
export type HyperliquidExampleKey = | "allMids" | "spotMetaAndAssetCtxs" | "l2Book" | "recentTrades" | "spotClearinghouseState" | "userRateLimit" | "orderAction" | "orderAccepted" | "orderRejected" | "usdSendAction" | "spotSendAction" | "withdraw3Action" | "transferAccepted" | "unitBtcDepositAddress" | "unitOperations" | "sendToEvmWithDataAction"; export type HyperliquidExample = { label: string; json: string; }; function pretty(value: unknown) { return JSON.stringify(value, null, 2); } export const hyperliquidExamples: Record<HyperliquidExampleKey, HyperliquidExample> = { allMids: { label: "allMids", json: pretty({ BTC: "65000.0", ETH: "3500.0", "@142": "65010.5" }), }, spotMetaAndAssetCtxs: { label: "spotMetaAndAssetCtxs", json: pretty([ { tokens: [ { name: "USDC", szDecimals: 8, weiDecimals: 8, index: 0, tokenId: "0x6d1e7cde53ba9467b783cb7c530ce054", isCanonical: true, evmContract: { address: "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", evm_extra_wei_decimals: -2, }, fullName: null, deployerTradingFeeShare: "0.0", }, { name: "UBTC", szDecimals: 5, weiDecimals: 10, index: 197, tokenId: "0x8f254b963e8468305d409b33aa137c67", isCanonical: false, evmContract: { address: "0x9fdbda0a5e284c32744d2f17ee5c74b284993463", evm_extra_wei_decimals: -2, }, fullName: "Unit Bitcoin", deployerTradingFeeShare: "1.0", }, ], universe: [{ name: "@142", tokens: [197, 0], index: 142, isCanonical: false }], }, [{ midPx: "65010.5", markPx: "65010.5", dayNtlVlm: "1250000.0" }], ]), }, l2Book: { label: "l2Book", json: pretty({ coin: "@142", levels: [ [{ px: "65000", sz: "0.05", n: 2 }], [{ px: "65020", sz: "0.04", n: 1 }], ], time: 1710000000000, }), }, recentTrades: { label: "recentTrades", json: pretty([{ coin: "@142", side: "B", px: "65010", sz: "0.001", time: 1710000000000, hash: "0xabc" }]), }, spotClearinghouseState: { label: "spotClearinghouseState", json: pretty({ balances: [{ coin: "USDC", token: 0, hold: "0.0", total: "100.0" }] }), }, userRateLimit: { label: "userRateLimit", json: pretty({ cumVlm: "2854574.593578", nRequestsUsed: 2890, nRequestsCap: 2864574, nRequestsSurplus: 0 }), }, orderAction: { label: "order action", json: pretty({ type: "order", orders: [ { a: 10142, b: false, p: "65000", s: "0.001", r: false, t: { limit: { tif: "Ioc" } }, c: "0x00000000000000000000000000000001", }, ], grouping: "na", }), }, orderAccepted: { label: "order accepted", json: pretty({ status: "ok", response: { type: "order", data: { statuses: [{ filled: { totalSz: "0.001", avgPx: "65020", oid: 77747314 } }] } } }), }, orderRejected: { label: "order rejected", json: pretty({ status: "ok", response: { type: "order", data: { statuses: [{ error: "Order must have minimum value of $10." }] } } }), }, usdSendAction: { label: "usdSend action", json: pretty({ type: "usdSend", hyperliquidChain: "Testnet", signatureChainId: "0x66eee", destination: "0x1111111111111111111111111111111111111111", amount: "10", time: 1710000000000, }), }, spotSendAction: { label: "spotSend action", json: pretty({ type: "spotSend", hyperliquidChain: "Testnet", signatureChainId: "0x66eee", destination: "0x1111111111111111111111111111111111111111", token: "UNIT:0x5314ecc85ee6059955409e0da8d2bd31", amount: "0.001", time: 1710000000000, }), }, withdraw3Action: { label: "withdraw3 action", json: pretty({ type: "withdraw3", hyperliquidChain: "Testnet", signatureChainId: "0x66eee", destination: "0x1111111111111111111111111111111111111111", amount: "25", time: 1710000000000, }), }, transferAccepted: { label: "transfer accepted", json: pretty({ status: "ok", response: { type: "default" } }), }, unitBtcDepositAddress: { label: "Unit BTC deposit address", json: pretty({ address: "tb1p4gpqn3undz6zh7w5aj24pdatjevpdg8kqs4ccdu65ddvjr88ljsssjjsdp", signatures: { "field-node": "base64-signature", "hl-node-testnet": "base64-signature", "node-1": "base64-signature", }, status: "OK", }), }, unitOperations: { label: "Unit operations", json: pretty({ operations: [ { operationId: `${"a".repeat(64)}:0`, opCreatedAt: "2026-07-14T08:00:00Z", protocolAddress: "tb1p4gpqn3undz6zh7w5aj24pdatjevpdg8kqs4ccdu65ddvjr88ljsssjjsdp", destinationAddress: "0x99a5F7202c4983a6f0Ca9d8F0526Fcd9d2be9e1D", sourceChain: "bitcoin", destinationChain: "hyperliquid", asset: "btc", state: "waitForSrcTxFinalization", sourceTxHash: `${"a".repeat(64)}:0`, }, ], }), }, sendToEvmWithDataAction: { label: "sendToEvmWithData action", json: pretty({ type: "sendToEvmWithData", hyperliquidChain: "Testnet", signatureChainId: "0x66eee", token: "USDC", amount: "12.5", sourceDex: "spot", destinationRecipient: "0x1111111111111111111111111111111111111111", addressEncoding: "hex", destinationChainId: 3, gasLimit: 200000, data: "0x", nonce: 1710000000000, }), }, }; export function getHyperliquidExample(key: HyperliquidExampleKey) { return hyperliquidExamples[key]; }