/
ikratkiy
/
Hyperliquid
Обзор
Документация
Войти
/
ikratkiy
/
Hyperliquid
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/shared/hyperliquid/types.ts
299 строк
6 KB
ikratkiy
feat(spot): add fail-closed reconciliation contracts
15 июл 2026, 02:22
15 июл 2026, 02:22
eb972fb
Код
Авторство
О чём код?
export type EnvironmentMode = "testnet" | "mainnet"; export type HyperEvmConfig = { chainId: number; hexChainId: `0x${string}`; name: string; rpcUrl: string; rpcUrls: string[]; explorerUrls: string[]; nativeCurrency: { name: "HYPE"; symbol: "HYPE"; decimals: 18; }; }; export type EnvironmentConfig = { mode: EnvironmentMode; label: string; apiUrl: string; apiUrls: string[]; wsUrl: string; wsUrls: string[]; unitApiUrl: string; bitcoinApiUrl: string; bitcoinSignetApiUrl: string; hyperEvm: HyperEvmConfig; isMainnet: boolean; writeMode: "enabled" | "scenario-only" | "disabled"; }; export type SpotToken = { name: string; szDecimals: number; weiDecimals: number; index: number; tokenId: string; isCanonical: boolean; fullName?: string | null; evmContract: null | { address: `0x${string}` | string; evm_extra_wei_decimals?: number; }; }; export type SpotUniverseItem = { tokens: [number, number] | number[]; name: string; index: number; isCanonical?: boolean; }; export type SpotMeta = { tokens: SpotToken[]; universe: SpotUniverseItem[]; }; export type PerpMeta = { universe: Array<{ name: string; szDecimals: number; maxLeverage?: number; onlyIsolated?: boolean; }>; }; export type AllMids = Record<string, string>; export type SpotAssetCtx = { dayNtlVlm?: string; markPx?: string; midPx?: string; prevDayPx?: string; }; export type SpotMetaAndAssetCtxs = [SpotMeta, SpotAssetCtx[]]; export type L2Level = { px: string; sz: string; n: number; }; export type L2Book = { coin: string; levels: [L2Level[], L2Level[]]; time: number; }; export type Trade = { coin: string; side: "A" | "B" | string; px: string; sz: string; time: number; hash?: string; }; export type HyperliquidCloid = `0x${string}`; /** * Hyperliquid documents oid as uint64, while the browser JSON stack exposes it as a number. * Runtime reconciliation therefore accepts only non-negative safe integers and fails closed * instead of comparing a value that may already have lost precision. */ export type HyperliquidOid = number; export type UserFill = { coin: string; px: string; sz: string; side: "A" | "B"; time: number; startPosition: string; dir: string; closedPnl: string; hash: `0x${string}`; oid: HyperliquidOid; crossed: boolean; fee: string; feeToken: string; builderFee?: string; tid: number; twapId?: number | null; cloid?: HyperliquidCloid; }; export type HyperliquidOrderProcessingStatus = | "open" | "filled" | "canceled" | "triggered" | "rejected" | "marginCanceled" | "vaultWithdrawalCanceled" | "openInterestCapCanceled" | "selfTradeCanceled" | "reduceOnlyCanceled" | "siblingFilledCanceled" | "delistedCanceled" | "liquidatedCanceled" | "scheduledCancel" | "tickRejected" | "minTradeNtlRejected" | "perpMarginRejected" | "reduceOnlyRejected" | "badAloPxRejected" | "iocCancelRejected" | "badTriggerPxRejected" | "marketOrderNoLiquidityRejected" | "positionIncreaseAtOpenInterestCapRejected" | "positionFlipAtOpenInterestCapRejected" | "tooAggressiveAtOpenInterestCapRejected" | "openInterestIncreaseRejected" | "insufficientSpotBalanceRejected" | "oracleRejected" | "perpMaxPositionRejected"; export type HyperliquidFrontendOrder = { coin: string; side: "A" | "B"; limitPx: string; sz: string; oid: HyperliquidOid; timestamp: number; origSz: string; triggerCondition: string; isTrigger: boolean; triggerPx: string; children: unknown[]; isPositionTpsl: boolean; reduceOnly: boolean; orderType: "Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit"; tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket" | null; cloid: HyperliquidCloid | null; }; export type OrderStatusResponse = | { status: "order"; order: { order: HyperliquidFrontendOrder; status: HyperliquidOrderProcessingStatus; statusTimestamp: number; }; } | { status: "unknownOid" }; export type UserFees = { dailyUserVlm: Array<{ date: string; userCross: string; userAdd: string; exchange: string; }>; feeSchedule: { cross: string; add: string; spotCross: string; spotAdd: string; tiers: { vip: Array<{ ntlCutoff: string; cross: string; add: string; spotCross: string; spotAdd: string; }>; mm: Array<{ makerFractionCutoff: string; add: string; }>; }; referralDiscount: string; stakingDiscountTiers: Array<{ bpsOfMaxSupply: string; discount: string; }>; }; userCrossRate: string; userAddRate: string; userSpotCrossRate: string; userSpotAddRate: string; activeReferralDiscount: string; trial: unknown | null; feeTrialReward?: string; feeTrialEscrow?: string; nextTrialAvailableTimestamp: number | null; stakingLink: { type: "requested" | "stakingUser" | "tradingUser"; stakingUser: `0x${string}`; } | null; activeStakingDiscount: { bpsOfMaxSupply: string; discount: string; } | null; }; export type UserOpenOrder = { coin: string; limitPx?: string; sz: string; side: string; oid: number; timestamp: number; }; export type SpotBalance = { coin: string; token: number; hold: string; total: string; entryNtl?: string; }; export type SpotClearinghouseState = { balances: SpotBalance[]; }; export type UserAbstraction = "unifiedAccount" | "portfolioMargin" | "disabled" | "default" | "dexAbstraction"; export type HyperliquidInfoType = | "allMids" | "meta" | "spotMeta" | "spotMetaAndAssetCtxs" | "l2Book" | "recentTrades" | "openOrders" | "frontendOpenOrders" | "userFills" | "userFillsByTime" | "orderStatus" | "userFees" | "userRateLimit" | "userAbstraction" | "spotClearinghouseState" | "clearinghouseState"; export type InfoRequest = Record<string, unknown> & { type: HyperliquidInfoType; }; export type ExchangeEnvelope = { action: Record<string, unknown>; nonce: number; signature: unknown; vaultAddress?: string; expiresAfter?: number; }; export type MarketSnapshot = { mids: AllMids | null; perpMeta: PerpMeta | null; spotMeta: SpotMeta | null; spotContexts: SpotAssetCtx[]; book: L2Book | null; trades: Trade[]; };