@avalabs/hypercore-module 0.0.0-feat-add-hyperliquid-modules-20260714192934

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/module.ts","../manifest.json","../src/env.ts","../src/utils/schemas.ts","../src/utils/info-client.ts","../src/utils/unsupported.ts","../src/handlers/get-balances/get-balances.ts","../src/utils/build-hypercore-tokens.ts","../src/constants.ts","../src/utils/hyperliquid-coin-svg-url.ts","../src/utils/spot-tokens.ts","../src/handlers/get-tokens/get-tokens.ts","../src/utils/activity/types.ts","../src/utils/activity/fetch-hypercore-activity.ts","../src/utils/activity/map-hypercore-activity-to-transactions.ts","../src/utils/activity/get-hypercore-ledger-display.ts","../src/utils/activity/hypercore-fill-meta.ts","../src/handlers/get-transaction-history/get-transaction-history.ts","../src/handlers/get-address/get-address.ts","../src/handlers/derive-address/derive-address.ts","../../../packages-internal/utils/src/utils/address-derivation.ts","../src/handlers/build-derivation-path/build-derivation-path.ts","../src/handlers/derive-addresses/derive-addresses.ts"],"names":["parseManifest","rpcErrors","manifest_default","Environment","INFO_PATH","PUBLIC_ACTIVITY_INFO_URL","prodEnv","devEnv","getEnv","__name","environment","z","tokenIndexSchema","spotMetaResponseSchema","spotBalanceSchema","spotClearinghouseStateSchema","marginSummarySchema","clearinghouseStateSchema","userAbstractionSchema","value","userFillSchema","userFillsSchema","hypercoreLedgerDeltaSchema","hypercoreLedgerUpdateSchema","hypercoreLedgerUpdatesSchema","lowercaseUser","user","_infoUrl","_activityInfoUrl","_fetch","_HypercoreInfoClient","config","__privateAdd","__privateSet","body","schema","options","response","__privateGet","json","startTime","HypercoreInfoClient","unsupportedHypercoreCapabilityMessage","capability","TokenType","Big","HYPERCORE_CAIP_ID","HYPERCORE_CHAIN_ID","HYPERCORE_USDC_SYMBOL","HYPERCORE_USDC_NAME","HYPERCORE_USDC_DECIMALS","BIG_ZERO","spotCountsAsPerpCollateral","mode","toRawBalance","humanAmount","decimals","getPerpCollateralUsd","perp","accountValue","unrealizedPnl","sum","position","collateral","buildHypercoreTokens","spotBalances","perpState","abstractionMode","spotTokens","tokensByIndex","token","perpCollateralUsd","spotUsdc","balance","usdcTotal","tokens","meta","total","HYPERLIQUID_COIN_SVG_BASE","hyperliquidCoinSvgKey","coin","trimmed","separatorIndex","hyperliquidCoinSvgUrl","isValidEvmAddress","address","toHypercoreSpotTokens","toTokenWithBalance","networkToken","balanceInCurrency","native","spot","getBalances","addresses","network","infoClient","spotMeta","spotState","bySymbol","key","err","acc","curr","getTokens","toTimeMs","time","MAX_LEDGER_PAGES","LEDGER_LOOKBACK_MS","isAbortError","softFail","promise","fallback","fetchLedgerUpdates","client","evmAddress","all","pages","page","last","next","fetchHypercoreActivity","fills","ledgerUpdates","fill","update","b","TransactionType","formatAmount","parsed","toUsd","sign","getHypercoreLedgerDisplay","delta","owner","isOutgoing","METHOD_PREFIX","FILL_ARROW_UP","FILL_ARROW_DOWN","tickerOfCoin","i","closedPnlTone","closedPnl","n","fillLabel","dir","tone","d","formatHypercoreFillPx","px","encodeHypercoreFillMethod","parseHypercoreFillMethod","method","explorerTxLink","hash","base","chainIdForNetwork","mapFillToTransaction","timeMs","isBuy","ticker","mapLedgerToTransaction","display","isIncoming","txType","amount","mapHypercoreActivityToTransactions","items","item","getTransactionHistory","NetworkVMType","WalletType","getAddressFromXPub","getEvmAddressFromPubKey","getAddress","accountIndex","xpub","walletType","pubKeyBuffer","computeAddress","hasDerivationDetails","params","buildDerivationPath","derivationPathType","deriveAddress","secretId","approvalController","derivationPath","publicKeyHex","deriveAddressesForEvm","init","deriveAddresses","accountIndices","publicKeys","_approvalController","_infoClient","_HypercoreModule","runtime","infoUrl","activityInfoUrl","_network","result","request","HypercoreModule"],"mappings":"oaAiBA,OAAS,iBAAAA,OAAqB,2BAC9B,OAAS,aAAAC,OAAiB,uBClB1B,IAAAC,EAAA,CACE,KAAQ,YACR,YAAe,uEACf,QAA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AEA,cAAcK,EAAiD,CAC7D,OAAO,QAAQ,OAAO,IAAI,MAAM7J,EAAsC,eAAe,CAAC,CAAC,CACzF,CAEA,WAAW0I,EAAuD,CAChE,OAAOP,GAAWO,CAAM,CAC1B,CAEA,oBAAoBA,EAAmC,CACrD,OAAOC,EAAoBD,CAAM,CACnC,CAEA,cAAcA,EAA6B,CACzC,OAAOG,GAAc,CACnB,GAAGH,EACH,mBAAoB9I,EAAA,KAAK2J,EAC3B,CAAC,CACH,CAEA,gBAAgBb,EAA+B,CAC7C,OAAOU,GAAgB,CACrB,GAAGV,EACH,mBAAoB9I,EAAA,KAAK2J,EAC3B,CAAC,CACH,CAEA,UAAUnG,EAAkB,CAC1B,OAAOS,GAAU,CAAE,QAAAT,EAAS,WAAYxD,EAAA,KAAK4J,EAAY,CAAC,CAC5D,CAEA,MAAM,aAAaO,EAAqBF,EAAmB,CACzD,MAAO,CACL,MAAOtM,GAAU,mBAAmB,kCAAkCwM,EAAQ,MAAM,mBAAmB,CACzG,CACF,CACF,EAxEER,EAAA,YACAC,EAAA,YAF6CzL,EAAA0L,EAAA,mBAAxC,IAAMO,GAANP","sourcesContent":["import type {\n Module,\n Manifest,\n ConstructorParams,\n ApprovalController,\n RpcRequest,\n Network,\n NetworkFees,\n GetBalancesParams,\n GetAddressParams,\n GetAddressResponse,\n DeriveAddressParams,\n DeriveAddressesParams,\n BuildDerivationPathParams,\n GetTransactionHistory,\n NetworkFeeParam,\n} from '@avalabs/vm-module-types';\nimport { parseManifest } from '@avalabs/vm-module-types';\nimport { rpcErrors } from '@metamask/rpc-errors';\n\nimport ManifestJson from '../manifest.json';\nimport { getEnv } from './env';\nimport { HypercoreInfoClient } from './utils/info-client';\nimport { unsupportedHypercoreCapabilityMessage } from './utils/unsupported';\nimport { getBalances } from './handlers/get-balances/get-balances';\nimport { getTokens } from './handlers/get-tokens/get-tokens';\nimport { getTransactionHistory } from './handlers/get-transaction-history/get-transaction-history';\nimport { getAddress } from './handlers/get-address/get-address';\nimport { deriveAddress } from './handlers/derive-address/derive-address';\nimport { deriveAddresses } from './handlers/derive-addresses/derive-addresses';\nimport { buildDerivationPath } from './handlers/build-derivation-path/build-derivation-path';\n\nexport class HypercoreModule implements Module {\n #approvalController: ApprovalController;\n #infoClient: HypercoreInfoClient;\n\n constructor({ environment, approvalController, runtime }: ConstructorParams) {\n const { infoUrl, activityInfoUrl } = getEnv(environment);\n\n this.#approvalController = approvalController;\n this.#infoClient = new HypercoreInfoClient({\n infoUrl,\n activityInfoUrl,\n fetch: runtime?.fetch,\n });\n }\n\n getProvider(_network: Network): Promise<never> {\n return Promise.reject(new Error(unsupportedHypercoreCapabilityMessage('getProvider')));\n }\n\n getManifest(): Manifest | undefined {\n const result = parseManifest(ManifestJson);\n return result.success ? result.data : undefined;\n }\n\n getBalances(params: GetBalancesParams) {\n return getBalances({\n ...params,\n infoClient: this.#infoClient,\n });\n }\n\n getTransactionHistory(params: GetTransactionHistory) {\n return getTransactionHistory({\n ...params,\n infoClient: this.#infoClient,\n });\n }\n\n getNetworkFee(_network: NetworkFeeParam): Promise<NetworkFees> {\n return Promise.reject(new Error(unsupportedHypercoreCapabilityMessage('getNetworkFee')));\n }\n\n getAddress(params: GetAddressParams): Promise<GetAddressResponse> {\n return getAddress(params);\n }\n\n buildDerivationPath(params: BuildDerivationPathParams) {\n return buildDerivationPath(params);\n }\n\n deriveAddress(params: DeriveAddressParams) {\n return deriveAddress({\n ...params,\n approvalController: this.#approvalController,\n });\n }\n\n deriveAddresses(params: DeriveAddressesParams) {\n return deriveAddresses({\n ...params,\n approvalController: this.#approvalController,\n });\n }\n\n getTokens(network: Network) {\n return getTokens({ network, infoClient: this.#infoClient });\n }\n\n async onRpcRequest(request: RpcRequest, _network: Network) {\n return {\n error: rpcErrors.methodNotSupported(`HyperCore is read-only; method ${request.method} is not supported`),\n };\n }\n}\n","{\n \"name\": \"HyperCore\",\n \"description\": \"Read-only Hyperliquid HyperCore module (balances, tokens, activity).\",\n \"version\": \"0.0.1\",\n \"sources\": {\n \"module\": {\n \"checksum\": \"\",\n \"location\": {\n \"npm\": {\n \"filePath\": \"dist/index.js\",\n \"packageName\": \"@avalabs/hypercore-module\",\n \"registry\": \"https://registry.npmjs.org\"\n }\n }\n }\n },\n \"network\": {\n \"chainIds\": [\"hlcore:mainnet\"],\n \"namespaces\": [\"hlcore\"]\n },\n \"cointype\": \"60\",\n \"permissions\": {\n \"rpc\": {\n \"dapps\": false,\n \"methods\": [],\n \"nonRestrictedMethods\": []\n }\n },\n \"manifestVersion\": \"0.1\"\n}\n","import { Environment } from '@avalabs/vm-module-types';\n\ntype Env = {\n proxyApiUrl: string;\n /** Proxy-first Hyperliquid `/info` endpoint. */\n infoUrl: string;\n /**\n * Fallback for activity endpoints if the proxy does not support fills/ledger.\n * Prefer `infoUrl` when possible.\n */\n activityInfoUrl: string;\n};\n\nconst INFO_PATH = '/proxy/nownodes/hype/info';\nconst PUBLIC_ACTIVITY_INFO_URL = 'https://api.hyperliquid.xyz/info';\n\nexport const prodEnv: Env = {\n proxyApiUrl: 'https://proxy-api.avax.network',\n infoUrl: `https://proxy-api.avax.network${INFO_PATH}`,\n activityInfoUrl: PUBLIC_ACTIVITY_INFO_URL,\n};\n\nexport const devEnv: Env = {\n proxyApiUrl: 'https://proxy-api-dev.avax.network',\n infoUrl: `https://proxy-api-dev.avax.network${INFO_PATH}`,\n activityInfoUrl: PUBLIC_ACTIVITY_INFO_URL,\n};\n\nexport const getEnv = (environment: Environment): Env => {\n switch (environment) {\n case Environment.PRODUCTION:\n return prodEnv;\n case Environment.DEV:\n return devEnv;\n }\n};\n","import { z } from 'zod';\n\nconst tokenIndexSchema = z.coerce.number();\n\n/** `type: \"spotMeta\"` — registry mapping spot token index → display metadata. */\nexport const spotMetaResponseSchema = z.object({\n tokens: z.array(\n z.object({\n name: z.string(),\n index: z.number(),\n weiDecimals: z.number(),\n fullName: z.string().nullish(),\n evmContract: z.object({ address: z.string() }).nullish(),\n }),\n ),\n});\n\nconst spotBalanceSchema = z.object({\n coin: z.string(),\n token: tokenIndexSchema,\n total: z.string(),\n hold: z.string(),\n entryNtl: z.string().optional(),\n});\n\n/** `type: \"spotClearinghouseState\"` */\nexport const spotClearinghouseStateSchema = z.object({\n balances: z.array(spotBalanceSchema),\n});\n\nconst marginSummarySchema = z.object({\n accountValue: z.string(),\n totalMarginUsed: z.string().optional(),\n totalNtlPos: z.string().optional(),\n totalRawUsd: z.string().optional(),\n});\n\n/**\n * `type: \"clearinghouseState\"` — only fields needed for PnL-excluded\n * perp collateral fold-in.\n */\nexport const clearinghouseStateSchema = z.object({\n assetPositions: z.array(\n z.object({\n position: z.object({\n unrealizedPnl: z.string(),\n }),\n }),\n ),\n crossMarginSummary: marginSummarySchema,\n});\n\nexport type UserAbstractionMode = 'unifiedAccount' | 'portfolioMargin' | 'dexAbstraction' | 'disabled' | 'default';\n\n/**\n * `type: \"userAbstraction\"` — bare JSON string. Unknown future values coerce\n * to `\"default\"` so balance math stays conservative.\n */\nexport const userAbstractionSchema = z.string().transform((value): UserAbstractionMode => {\n switch (value) {\n case 'unifiedAccount':\n case 'portfolioMargin':\n case 'dexAbstraction':\n case 'disabled':\n case 'default':\n return value;\n default:\n return 'default';\n }\n});\n\n/** `type: \"userFills\"` */\nexport const userFillSchema = z.object({\n closedPnl: z.string(),\n coin: z.string(),\n crossed: z.boolean(),\n dir: z.string(),\n hash: z.string(),\n oid: z.number(),\n px: z.string(),\n side: z.string(),\n startPosition: z.string(),\n sz: z.string(),\n time: z.number(),\n fee: z.string().optional(),\n tid: z.number().optional(),\n});\n\nexport const userFillsSchema = z.array(userFillSchema);\n\n/**\n * `userNonFundingLedgerUpdates` deltas — permissive so unknown delta types\n * still parse and can render generically later.\n */\nexport const hypercoreLedgerDeltaSchema = z.object({\n type: z.string(),\n usdc: z.string().optional(),\n amount: z.string().optional(),\n usdcValue: z.string().optional(),\n token: z.string().optional(),\n user: z.string().optional(),\n destination: z.string().optional(),\n fee: z.string().optional(),\n toPerp: z.boolean().optional(),\n});\n\nexport const hypercoreLedgerUpdateSchema = z.object({\n time: z.number(),\n hash: z.string(),\n delta: hypercoreLedgerDeltaSchema,\n});\n\nexport const hypercoreLedgerUpdatesSchema = z.array(hypercoreLedgerUpdateSchema);\n\nexport type SpotMetaResponse = z.infer<typeof spotMetaResponseSchema>;\nexport type SpotBalance = {\n coin: string;\n token: number;\n total: string;\n hold: string;\n entryNtl?: string;\n};\nexport type SpotClearinghouseState = {\n balances: SpotBalance[];\n};\nexport type ClearinghouseState = z.infer<typeof clearinghouseStateSchema>;\nexport type UserFill = z.infer<typeof userFillSchema>;\nexport type HypercoreLedgerUpdate = z.infer<typeof hypercoreLedgerUpdateSchema>;\n","import type { z } from 'zod';\nimport {\n clearinghouseStateSchema,\n hypercoreLedgerUpdatesSchema,\n spotClearinghouseStateSchema,\n spotMetaResponseSchema,\n userAbstractionSchema,\n userFillsSchema,\n type ClearinghouseState,\n type HypercoreLedgerUpdate,\n type SpotClearinghouseState,\n type SpotMetaResponse,\n type UserAbstractionMode,\n type UserFill,\n} from './schemas';\n\nexport type HypercoreInfoRequest =\n | { type: 'spotMeta' }\n | { type: 'spotClearinghouseState'; user: string; dex?: string }\n | { type: 'clearinghouseState'; user: string; dex?: string }\n | { type: 'userAbstraction'; user: string }\n | { type: 'userFills'; user: string }\n | {\n type: 'userNonFundingLedgerUpdates';\n user: string;\n startTime: number;\n };\n\nexport type HypercoreInfoClientConfig = {\n /** Proxy-first `/info` URL used for balances and spot meta. */\n infoUrl: string;\n /**\n * Activity URL. Defaults to `infoUrl`; may be the public HL endpoint when\n * the proxy does not yet support fills/ledger types.\n */\n activityInfoUrl?: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport type PostInfoOptions = {\n signal?: AbortSignal;\n /** Overrides the client default URL for this call. */\n url?: string;\n};\n\nconst lowercaseUser = (user: string) => user.toLowerCase();\n\nexport class HypercoreInfoClient {\n readonly #infoUrl: string;\n readonly #activityInfoUrl: string;\n readonly #fetch: typeof globalThis.fetch;\n\n constructor(config: HypercoreInfoClientConfig) {\n this.#infoUrl = config.infoUrl;\n this.#activityInfoUrl = config.activityInfoUrl ?? config.infoUrl;\n this.#fetch = config.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n async postInfo<T>(body: HypercoreInfoRequest, schema: z.ZodType<T>, options?: PostInfoOptions) {\n const response = await this.#fetch(options?.url ?? this.#infoUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal: options?.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Hyperliquid /info failed: ${response.status} ${response.statusText}`);\n }\n\n const json: unknown = await response.json();\n return schema.parse(json);\n }\n\n getSpotMeta(options?: PostInfoOptions): Promise<SpotMetaResponse> {\n return this.postInfo({ type: 'spotMeta' }, spotMetaResponseSchema, options);\n }\n\n getSpotClearinghouseState(user: string, options?: PostInfoOptions): Promise<SpotClearinghouseState> {\n return this.postInfo(\n {\n type: 'spotClearinghouseState',\n user: lowercaseUser(user),\n dex: '',\n },\n spotClearinghouseStateSchema,\n options,\n ) as Promise<SpotClearinghouseState>;\n }\n\n getClearinghouseState(user: string, options?: PostInfoOptions): Promise<ClearinghouseState> {\n return this.postInfo(\n {\n type: 'clearinghouseState',\n user: lowercaseUser(user),\n dex: '',\n },\n clearinghouseStateSchema,\n options,\n );\n }\n\n getUserAbstraction(user: string, options?: PostInfoOptions): Promise<UserAbstractionMode> {\n return this.postInfo(\n { type: 'userAbstraction', user: lowercaseUser(user) },\n userAbstractionSchema,\n options,\n ) as Promise<UserAbstractionMode>;\n }\n\n getUserFills(user: string, options?: PostInfoOptions): Promise<UserFill[]> {\n return this.postInfo({ type: 'userFills', user: lowercaseUser(user) }, userFillsSchema, {\n ...options,\n url: options?.url ?? this.#activityInfoUrl,\n });\n }\n\n getUserNonFundingLedgerUpdates(\n user: string,\n startTime: number,\n options?: PostInfoOptions,\n ): Promise<HypercoreLedgerUpdate[]> {\n return this.postInfo(\n {\n type: 'userNonFundingLedgerUpdates',\n user: lowercaseUser(user),\n startTime,\n },\n hypercoreLedgerUpdatesSchema,\n {\n ...options,\n url: options?.url ?? this.#activityInfoUrl,\n },\n );\n }\n}\n","/**\n * Loud failure message for HyperCore capabilities that do not exist (no RPC, no gas).\n * Prefer rejecting with this over empty success so clients and agents see intentional gaps.\n */\nexport const unsupportedHypercoreCapabilityMessage = (capability: string) =>\n `HyperCore does not support ${capability}: read-only module (balances, tokens, activity).`;\n\nexport const unsupportedHypercoreCapability = (capability: string): never => {\n throw new Error(unsupportedHypercoreCapabilityMessage(capability));\n};\n","import {\n TokenType,\n type GetBalancesParams,\n type GetBalancesResponse,\n type NetworkTokenWithBalance,\n type TokenWithBalance,\n type TokenWithBalanceHypercoreSpot,\n} from '@avalabs/vm-module-types';\nimport type { HypercoreInfoClient } from '../../utils/info-client';\nimport { buildHypercoreTokens, type HypercoreTokenBalance } from '../../utils/build-hypercore-tokens';\nimport { hyperliquidCoinSvgUrl } from '../../utils/hyperliquid-coin-svg-url';\nimport { toHypercoreSpotTokens } from '../../utils/spot-tokens';\n\ntype GetHypercoreBalancesParams = Omit<GetBalancesParams, 'currency' | 'customTokens' | 'tokenTypes'> & {\n infoClient: HypercoreInfoClient;\n};\n\nconst toTokenWithBalance = (\n token: HypercoreTokenBalance,\n networkToken: GetBalancesParams['network']['networkToken'],\n): { key: string; value: TokenWithBalance } => {\n if (token.kind === 'native') {\n const balance = BigInt(token.balanceRaw);\n const balanceInCurrency = Number(token.balanceUsd);\n const native: NetworkTokenWithBalance = {\n ...networkToken,\n name: token.name,\n symbol: token.symbol,\n decimals: token.decimals,\n logoUri: networkToken.logoUri ?? hyperliquidCoinSvgUrl(token.symbol),\n coingeckoId: 'usd-coin',\n type: TokenType.NATIVE,\n balance,\n balanceDisplayValue: token.balance,\n balanceInCurrency: Number.isFinite(balanceInCurrency) ? balanceInCurrency : 0,\n balanceCurrencyDisplayValue: token.balanceUsd,\n priceInCurrency: token.priceUsd,\n };\n return { key: token.symbol, value: native };\n }\n\n const balance = BigInt(token.balanceRaw);\n const spot: TokenWithBalanceHypercoreSpot = {\n type: TokenType.HYPERCORE_SPOT,\n name: token.name,\n symbol: token.symbol,\n decimals: token.decimals,\n index: token.index,\n evmContract: token.evmContract,\n logoUri: hyperliquidCoinSvgUrl(token.symbol),\n reputation: null,\n balance,\n balanceDisplayValue: token.balance,\n };\n return { key: `spot:${token.index}`, value: spot };\n};\n\nexport const getBalances = async ({\n addresses,\n network,\n infoClient,\n}: GetHypercoreBalancesParams): Promise<GetBalancesResponse> => {\n const spotMeta = await infoClient.getSpotMeta();\n const spotTokens = toHypercoreSpotTokens(spotMeta.tokens);\n\n const results = await Promise.allSettled(\n addresses.map(async (address) => {\n try {\n const [spotState, perpState, abstractionMode] = await Promise.all([\n infoClient.getSpotClearinghouseState(address),\n infoClient.getClearinghouseState(address).catch(() => undefined),\n infoClient.getUserAbstraction(address).catch(() => undefined),\n ]);\n\n const tokens = buildHypercoreTokens({\n spotBalances: spotState.balances,\n perpState,\n abstractionMode,\n spotTokens,\n });\n\n const bySymbol = Object.fromEntries(\n tokens.map((token) => {\n const { key, value } = toTokenWithBalance(token, network.networkToken);\n return [key, value];\n }),\n );\n\n return { [address]: bySymbol };\n } catch (err) {\n return { [address]: { error: (err as Error).toString() } };\n }\n }),\n );\n\n return results.reduce((acc, curr) => {\n if (curr.status === 'fulfilled') {\n return { ...acc, ...curr.value };\n }\n return acc;\n }, {} as GetBalancesResponse);\n};\n","import Big from 'big.js';\nimport type { HypercoreSpotToken } from '@avalabs/vm-module-types';\nimport { HYPERCORE_USDC_DECIMALS, HYPERCORE_USDC_NAME, HYPERCORE_USDC_SYMBOL } from '../constants';\nimport type { ClearinghouseState, SpotBalance, UserAbstractionMode } from './schemas';\n\nconst BIG_ZERO = new Big(0);\n\nexport type HypercoreNativeTokenBalance = {\n kind: 'native';\n name: string;\n symbol: typeof HYPERCORE_USDC_SYMBOL;\n decimals: number;\n /** Human-readable amount (decimal string). */\n balance: string;\n /** Integer raw amount as a decimal string (no fractional part). */\n balanceRaw: string;\n priceUsd: 1;\n balanceUsd: string;\n};\n\nexport type HypercoreSpotTokenBalance = {\n kind: 'spot';\n name: string;\n symbol: string;\n decimals: number;\n balance: string;\n balanceRaw: string;\n index: number;\n evmContract?: string;\n};\n\nexport type HypercoreTokenBalance = HypercoreNativeTokenBalance | HypercoreSpotTokenBalance;\n\n/**\n * `true` when spot balances already back perps for this account mode\n * (`unifiedAccount`). Other modes keep perp collateral on a separate ledger.\n */\nexport const spotCountsAsPerpCollateral = (mode: UserAbstractionMode | undefined) => mode === 'unifiedAccount';\n\n/** Tokens carry no native gas balance on HyperCore — amounts are human decimals. */\nconst toRawBalance = (humanAmount: Big, decimals: number) =>\n humanAmount.times(new Big(10).pow(decimals)).round(0, Big.roundDown).toFixed(0);\n\n/**\n * Perp collateral in USDC, excluding unrealized PnL.\n * `crossMarginSummary.accountValue` is collateral ± PnL; we back PnL out.\n */\nexport const getPerpCollateralUsd = (perp: ClearinghouseState | undefined) => {\n if (!perp) {\n return BIG_ZERO;\n }\n\n const accountValue = new Big(perp.crossMarginSummary.accountValue ?? '0');\n const unrealizedPnl = perp.assetPositions.reduce((sum, { position }) => sum.plus(position.unrealizedPnl), BIG_ZERO);\n const collateral = accountValue.minus(unrealizedPnl);\n\n return collateral.gt(BIG_ZERO) ? collateral : BIG_ZERO;\n};\n\n/**\n * USDC merges spot + (non-unified) PnL-excluded perp collateral at $1.\n * Other spot inventory is `HYPERCORE_SPOT` (no synthetic ERC20 addresses).\n */\nexport const buildHypercoreTokens = ({\n spotBalances,\n perpState,\n abstractionMode,\n spotTokens,\n}: {\n spotBalances: readonly SpotBalance[];\n perpState: ClearinghouseState | undefined;\n abstractionMode: UserAbstractionMode | undefined;\n spotTokens: HypercoreSpotToken[];\n}): HypercoreTokenBalance[] => {\n const tokensByIndex = new Map(spotTokens.map((token) => [token.index, token]));\n\n const perpCollateralUsd = spotCountsAsPerpCollateral(abstractionMode) ? BIG_ZERO : getPerpCollateralUsd(perpState);\n\n const spotUsdc = spotBalances.find((balance) => balance.coin.toUpperCase() === HYPERCORE_USDC_SYMBOL);\n const usdcTotal = new Big(spotUsdc?.total ?? '0').plus(perpCollateralUsd);\n\n const tokens: HypercoreTokenBalance[] = [];\n\n if (usdcTotal.gt(BIG_ZERO)) {\n tokens.push({\n kind: 'native',\n name: HYPERCORE_USDC_NAME,\n symbol: HYPERCORE_USDC_SYMBOL,\n decimals: HYPERCORE_USDC_DECIMALS,\n balance: usdcTotal.toString(),\n balanceRaw: toRawBalance(usdcTotal, HYPERCORE_USDC_DECIMALS),\n priceUsd: 1,\n balanceUsd: usdcTotal.toString(),\n });\n }\n\n for (const balance of spotBalances) {\n if (balance.coin.toUpperCase() === HYPERCORE_USDC_SYMBOL) {\n continue;\n }\n\n const meta = tokensByIndex.get(balance.token);\n const total = new Big(balance.total);\n if (!meta || !total.gt(BIG_ZERO)) {\n continue;\n }\n\n tokens.push({\n kind: 'spot',\n name: meta.name,\n symbol: meta.symbol,\n decimals: meta.decimals,\n balance: total.toString(),\n balanceRaw: toRawBalance(total, meta.decimals),\n index: meta.index,\n evmContract: meta.evmContract,\n });\n }\n\n return tokens;\n};\n","/** CAIP-2 id for HyperCore mainnet. Namespace must be 3–8 chars (CAIP-2). */\nexport const HYPERCORE_CAIP_ID = 'hlcore:mainnet';\n\n/**\n * Synthetic numeric id used by Core network lists / storage keys.\n * Not an EVM chain id — module routing uses {@link HYPERCORE_CAIP_ID}.\n */\nexport const HYPERCORE_CHAIN_ID = 9999;\n\nexport const HYPERCORE_USDC_SYMBOL = 'USDC';\nexport const HYPERCORE_USDC_NAME = 'USD Coin';\nexport const HYPERCORE_USDC_DECIMALS = 8;\n","export const HYPERLIQUID_COIN_SVG_BASE = 'https://app.hyperliquid.xyz/coins';\n\nexport const hyperliquidCoinSvgKey = (coin: string) => {\n const trimmed = coin.trim();\n const separatorIndex = trimmed.indexOf(':');\n if (separatorIndex === -1) {\n return trimmed.toUpperCase();\n }\n // HIP-3 logos are keyed as `marketname:TICKER` (dex prefix is case-significant).\n return `${trimmed.slice(0, separatorIndex)}:${trimmed.slice(separatorIndex + 1).toUpperCase()}`;\n};\n\nexport const hyperliquidCoinSvgUrl = (coin: string) =>\n `${HYPERLIQUID_COIN_SVG_BASE}/${encodeURIComponent(hyperliquidCoinSvgKey(coin))}.svg`;\n","import { TokenType, type HypercoreSpotToken } from '@avalabs/vm-module-types';\nimport type { SpotMetaResponse } from './schemas';\n\nconst isValidEvmAddress = (address: string) => /^0x[a-fA-F0-9]{40}$/.test(address);\n\n/**\n * Maps `spotMeta` tokens to the registry used when resolving spot balances.\n * Keeps every spot token (including HyperCore-only ones without an EVM contract).\n */\nexport const toHypercoreSpotTokens = (tokens: SpotMetaResponse['tokens']): HypercoreSpotToken[] =>\n tokens.map((token) => {\n const address = token.evmContract?.address.toLowerCase();\n\n return {\n type: TokenType.HYPERCORE_SPOT,\n index: token.index,\n name: token.fullName ?? token.name,\n symbol: token.name,\n decimals: token.weiDecimals,\n evmContract: address && isValidEvmAddress(address) ? address : undefined,\n };\n });\n","import type { HypercoreSpotToken, Network } from '@avalabs/vm-module-types';\nimport type { HypercoreInfoClient } from '../../utils/info-client';\nimport { hyperliquidCoinSvgUrl } from '../../utils/hyperliquid-coin-svg-url';\nimport { toHypercoreSpotTokens } from '../../utils/spot-tokens';\n\nexport const getTokens = async ({\n infoClient,\n}: {\n network: Network;\n infoClient: HypercoreInfoClient;\n}): Promise<HypercoreSpotToken[]> => {\n const spotMeta = await infoClient.getSpotMeta();\n return toHypercoreSpotTokens(spotMeta.tokens).map((token) => ({\n ...token,\n logoUri: token.logoUri ?? hyperliquidCoinSvgUrl(token.symbol),\n }));\n};\n","import type { HypercoreLedgerUpdate, UserFill } from '../schemas';\n\nexport type HypercoreActivityItem =\n | {\n readonly kind: 'fill';\n readonly timeMs: number;\n readonly hash: string;\n readonly fill: UserFill;\n }\n | {\n readonly kind: 'ledger';\n readonly timeMs: number;\n readonly hash: string;\n readonly update: HypercoreLedgerUpdate;\n };\n\n/** Normalize a Unix timestamp to milliseconds. */\nexport const toTimeMs = (time: number) => (time < 10_000_000_000 ? time * 1000 : time);\n","import type { HypercoreInfoClient } from '../info-client';\nimport type { HypercoreLedgerUpdate } from '../schemas';\nimport type { HypercoreActivityItem } from './types';\nimport { toTimeMs } from './types';\n\n/** Bound ledger pagination so busy accounts cannot trigger unbounded requests. */\nexport const MAX_LEDGER_PAGES = 20;\n\n/** Prefer recent ledger history; paging from `0` would return the oldest pages first. */\nexport const LEDGER_LOOKBACK_MS = 365 * 24 * 60 * 60 * 1000;\n\ntype FetchHypercoreActivityOptions = {\n signal?: AbortSignal;\n};\n\nconst isAbortError = (err: unknown) =>\n (err instanceof DOMException && err.name === 'AbortError') || (err instanceof Error && err.name === 'AbortError');\n\nconst softFail = async <T>(promise: Promise<T>, fallback: T): Promise<T> => {\n try {\n return await promise;\n } catch (err) {\n if (isAbortError(err)) {\n throw err;\n }\n return fallback;\n }\n};\n\n/**\n * `userNonFundingLedgerUpdates` returns an ascending, capped page (~500) from\n * `startTime`. Start within a lookback window and page forward until empty,\n * aborted, or `MAX_LEDGER_PAGES`, so recent activity is included without an\n * unbounded crawl from epoch.\n */\nconst fetchLedgerUpdates = async (\n client: HypercoreInfoClient,\n evmAddress: string,\n options?: FetchHypercoreActivityOptions,\n) => {\n const all: HypercoreLedgerUpdate[] = [];\n let startTime = Date.now() - LEDGER_LOOKBACK_MS;\n let pages = 0;\n\n while (pages < MAX_LEDGER_PAGES) {\n if (options?.signal?.aborted) {\n throw new DOMException('The operation was aborted.', 'AbortError');\n }\n\n const page = await client.getUserNonFundingLedgerUpdates(evmAddress, startTime, options);\n pages += 1;\n if (page.length === 0) {\n break;\n }\n all.push(...page);\n const last = page[page.length - 1];\n if (!last) {\n break;\n }\n const next = last.time + 1;\n if (next <= startTime) {\n break;\n }\n startTime = next;\n }\n\n return all;\n};\n\n/**\n * Fetches HyperCore fills + non-funding ledger updates and sorts newest-first.\n * Soft-fails individual endpoints so a flaky fills or ledger call still yields\n * partial history (abort errors are rethrown).\n */\nexport const fetchHypercoreActivity = async (\n client: HypercoreInfoClient,\n evmAddress: string,\n options?: FetchHypercoreActivityOptions,\n): Promise<HypercoreActivityItem[]> => {\n const [fills, ledgerUpdates] = await Promise.all([\n softFail(client.getUserFills(evmAddress, options), []),\n softFail(fetchLedgerUpdates(client, evmAddress, options), []),\n ]);\n\n const items: HypercoreActivityItem[] = [\n ...fills.map((fill) => ({\n kind: 'fill' as const,\n timeMs: toTimeMs(fill.time),\n hash: fill.hash,\n fill,\n })),\n ...ledgerUpdates.map((update) => ({\n kind: 'ledger' as const,\n timeMs: toTimeMs(update.time),\n hash: update.hash,\n update,\n })),\n ];\n\n return items.sort((a, b) => b.timeMs - a.timeMs);\n};\n","import { TokenType, TransactionType, type Network, type Transaction, type TxToken } from '@avalabs/vm-module-types';\nimport { HYPERCORE_CAIP_ID } from '../../constants';\nimport { hyperliquidCoinSvgUrl } from '../hyperliquid-coin-svg-url';\nimport type { HypercoreLedgerUpdate, UserFill } from '../schemas';\nimport { getHypercoreLedgerDisplay } from './get-hypercore-ledger-display';\nimport { encodeHypercoreFillMethod, tickerOfCoin } from './hypercore-fill-meta';\nimport type { HypercoreActivityItem } from './types';\nimport { toTimeMs } from './types';\n\nconst explorerTxLink = (network: Pick<Network, 'explorerUrl'>, hash: string) => {\n const base = (network.explorerUrl ?? '').replace(/\\/$/, '');\n return base ? `${base}/tx/${hash}` : hash;\n};\n\nconst chainIdForNetwork = (network: Pick<Network, 'caipId' | 'chainId'>) => network.caipId ?? HYPERCORE_CAIP_ID;\n\nconst mapFillToTransaction = (\n fill: UserFill,\n timeMs: number,\n network: Pick<Network, 'explorerUrl' | 'caipId' | 'chainId'>,\n): Transaction => {\n const isBuy = fill.side === 'B';\n const ticker = tickerOfCoin(fill.coin);\n\n const token: TxToken = {\n type: TokenType.NATIVE,\n name: fill.coin,\n symbol: ticker,\n amount: fill.sz,\n imageUri: hyperliquidCoinSvgUrl(fill.coin),\n };\n\n return {\n isContractCall: false,\n isIncoming: isBuy,\n isOutgoing: !isBuy,\n isSender: !isBuy,\n timestamp: timeMs,\n hash: fill.hash,\n from: '',\n to: '',\n tokens: [token],\n gasUsed: '0',\n txType: TransactionType.FILL_ORDER,\n method: encodeHypercoreFillMethod({\n dir: fill.dir ?? '',\n px: fill.px,\n closedPnl: fill.closedPnl,\n coin: fill.coin,\n }),\n chainId: chainIdForNetwork(network),\n explorerLink: explorerTxLink(network, fill.hash),\n };\n};\n\nconst mapLedgerToTransaction = (\n update: HypercoreLedgerUpdate,\n evmAddress: string,\n network: Pick<Network, 'explorerUrl' | 'caipId' | 'chainId'>,\n): Transaction => {\n const display = getHypercoreLedgerDisplay(update, evmAddress);\n const isIncoming = display.direction === 'positive';\n const isOutgoing = display.direction === 'negative';\n\n let txType: TransactionType = TransactionType.TRANSFER;\n switch (display.label) {\n case 'deposit':\n case 'received':\n txType = TransactionType.RECEIVE;\n break;\n case 'withdraw':\n case 'sent':\n txType = TransactionType.SEND;\n break;\n case 'liquidation':\n txType = TransactionType.UNKNOWN;\n break;\n default:\n txType = TransactionType.TRANSFER;\n }\n\n const amount = display.amount || '0';\n const token: TxToken = {\n type: TokenType.NATIVE,\n name: display.symbol,\n symbol: display.symbol,\n amount,\n imageUri: hyperliquidCoinSvgUrl(display.symbol),\n };\n\n return {\n isContractCall: false,\n isIncoming,\n isOutgoing,\n isSender: isOutgoing,\n timestamp: toTimeMs(update.time),\n hash: update.hash,\n from: display.from ?? (isOutgoing ? evmAddress : ''),\n to: display.to ?? (isIncoming ? evmAddress : ''),\n tokens: [token],\n gasUsed: '0',\n txType,\n chainId: chainIdForNetwork(network),\n explorerLink: explorerTxLink(network, update.hash),\n };\n};\n\nexport const mapHypercoreActivityToTransactions = (\n items: readonly HypercoreActivityItem[],\n evmAddress: string,\n network: Pick<Network, 'explorerUrl' | 'caipId' | 'chainId'>,\n): Transaction[] =>\n items.map((item) =>\n item.kind === 'fill'\n ? mapFillToTransaction(item.fill, item.timeMs, network)\n : mapLedgerToTransaction(item.update, evmAddress, network),\n );\n","import type { HypercoreLedgerUpdate } from '../schemas';\n\n/**\n * Semantic label key for a ledger row.\n */\nexport type HypercoreLedgerLabel =\n | 'deposit'\n | 'withdraw'\n | 'sent'\n | 'received'\n | 'transferToPerp'\n | 'transferToSpot'\n | 'transfer'\n | 'liquidation'\n | 'other';\n\nexport type HypercoreLedgerDisplay = {\n readonly label: HypercoreLedgerLabel;\n /** Unsigned token amount, e.g. `0.1`. */\n readonly amount: string;\n readonly symbol: string;\n /** Signed USD value for the fiat line; undefined when there's nothing to show. */\n readonly usdValue?: number;\n readonly direction: 'positive' | 'negative' | 'neutral';\n readonly from?: string;\n readonly to?: string;\n readonly rawType: string;\n};\n\nconst formatAmount = (value: string | undefined) => {\n if (value === undefined || value === '') {\n return '';\n }\n const parsed = Number.parseFloat(value);\n if (!Number.isFinite(parsed)) {\n return value;\n }\n return new Intl.NumberFormat('en-US', { maximumFractionDigits: 6 }).format(parsed);\n};\n\nconst toUsd = (value: string | undefined, sign: 1 | -1 | 0) => {\n if (value === undefined || value === '') {\n return undefined;\n }\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? parsed * (sign === 0 ? 1 : sign) : undefined;\n};\n\n/**\n * Derives label, amount, signed USD value, and counterparties for a HyperCore\n * ledger update from the owner's perspective.\n */\nexport const getHypercoreLedgerDisplay = (\n update: HypercoreLedgerUpdate,\n evmAddress: string,\n): HypercoreLedgerDisplay => {\n const { delta } = update;\n const owner = evmAddress.toLowerCase();\n const isOutgoing = delta.user?.toLowerCase() === owner;\n\n switch (delta.type) {\n case 'deposit':\n return {\n label: 'deposit',\n amount: formatAmount(delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdc, 1),\n direction: 'positive',\n to: evmAddress,\n rawType: delta.type,\n };\n case 'withdraw':\n return {\n label: 'withdraw',\n amount: formatAmount(delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdc, -1),\n direction: 'negative',\n from: evmAddress,\n rawType: delta.type,\n };\n case 'send':\n case 'spotTransfer':\n return {\n label: isOutgoing ? 'sent' : 'received',\n amount: formatAmount(delta.amount),\n symbol: delta.token ?? 'USDC',\n usdValue: toUsd(delta.usdcValue, isOutgoing ? -1 : 1),\n direction: isOutgoing ? 'negative' : 'positive',\n from: delta.user,\n to: delta.destination,\n rawType: delta.type,\n };\n case 'internalTransfer':\n return {\n label: 'transfer',\n amount: formatAmount(delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdc, isOutgoing ? -1 : 1),\n direction: isOutgoing ? 'negative' : 'positive',\n from: delta.user,\n to: delta.destination,\n rawType: delta.type,\n };\n case 'accountClassTransfer':\n return {\n label: delta.toPerp ? 'transferToPerp' : 'transferToSpot',\n amount: formatAmount(delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdc, 0),\n direction: 'neutral',\n rawType: delta.type,\n };\n case 'liquidation':\n return {\n label: 'liquidation',\n amount: formatAmount(delta.usdcValue ?? delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdcValue ?? delta.usdc, -1),\n direction: 'negative',\n rawType: delta.type,\n };\n default:\n return {\n label: 'other',\n amount: formatAmount(delta.usdcValue ?? delta.usdc),\n symbol: 'USDC',\n usdValue: toUsd(delta.usdcValue ?? delta.usdc, 0),\n direction: 'neutral',\n rawType: delta.type,\n };\n }\n};\n","const METHOD_PREFIX = 'hypercoreFill:v1:';\n\nexport const FILL_ARROW_UP = '\\u25B2';\nexport const FILL_ARROW_DOWN = '\\u25BC';\n\nexport type HypercoreFillMeta = {\n readonly dir: string;\n readonly px: string;\n readonly closedPnl: string;\n readonly coin: string;\n};\n\nexport type FillLabel = {\n readonly text: string;\n readonly arrow?: typeof FILL_ARROW_UP | typeof FILL_ARROW_DOWN;\n readonly tone?: 'profit' | 'loss';\n};\n\n/** Display ticker with any `dex:` prefix stripped (`xyz:GOLD` → `GOLD`). */\nexport const tickerOfCoin = (coin: string) => {\n const i = coin.indexOf(':');\n return i === -1 ? coin : coin.slice(i + 1);\n};\n\n/** PnL tone from `closedPnl` — `dir` alone does not indicate profit vs loss. */\nexport const closedPnlTone = (closedPnl: string | undefined): 'profit' | 'loss' | undefined => {\n if (closedPnl === undefined) {\n return undefined;\n }\n const n = Number.parseFloat(closedPnl);\n if (!Number.isFinite(n) || n === 0) {\n return undefined;\n }\n return n > 0 ? 'profit' : 'loss';\n};\n\n/**\n * Map a fill's `dir` into a display label. Arrow direction follows side\n * (long ▲ / short ▼); success/error tone comes from `closedPnl` when provided.\n */\nexport const fillLabel = (dir: string, closedPnl?: string): FillLabel => {\n const tone = closedPnlTone(closedPnl);\n const d = dir.toLowerCase();\n if (d.includes('close') && d.includes('long')) {\n return { text: 'Long closed', arrow: FILL_ARROW_UP, tone };\n }\n if (d.includes('close') && d.includes('short')) {\n return { text: 'Short closed', arrow: FILL_ARROW_DOWN, tone };\n }\n if (d.includes('open') && (d.includes('long') || d.includes('short'))) {\n return { text: 'Order opened' };\n }\n if (d.includes('cancel')) {\n return { text: 'Order cancelled' };\n }\n return { text: dir };\n};\n\n/** Compact USD price for fill rows (`$1,684.7`). */\nexport const formatHypercoreFillPx = (px: string) => {\n const n = Number.parseFloat(px);\n if (!Number.isFinite(n)) {\n return px;\n }\n return `$${n.toLocaleString(undefined, { maximumFractionDigits: 8 })}`;\n};\n\nexport const encodeHypercoreFillMethod = (meta: HypercoreFillMeta) =>\n `${METHOD_PREFIX}${encodeURIComponent(JSON.stringify(meta))}`;\n\nexport const parseHypercoreFillMethod = (method: string | undefined): HypercoreFillMeta | undefined => {\n if (!method?.startsWith(METHOD_PREFIX)) {\n return undefined;\n }\n try {\n const parsed: unknown = JSON.parse(decodeURIComponent(method.slice(METHOD_PREFIX.length)));\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n !('dir' in parsed) ||\n !('px' in parsed) ||\n !('closedPnl' in parsed) ||\n !('coin' in parsed)\n ) {\n return undefined;\n }\n const { dir, px, closedPnl, coin } = parsed as Record<string, unknown>;\n if (\n typeof dir !== 'string' ||\n typeof px !== 'string' ||\n typeof closedPnl !== 'string' ||\n typeof coin !== 'string'\n ) {\n return undefined;\n }\n return { dir, px, closedPnl, coin };\n } catch {\n return undefined;\n }\n};\n","import type { GetTransactionHistory, TransactionHistoryResponse } from '@avalabs/vm-module-types';\nimport type { HypercoreInfoClient } from '../../utils/info-client';\nimport { fetchHypercoreActivity } from '../../utils/activity/fetch-hypercore-activity';\nimport { mapHypercoreActivityToTransactions } from '../../utils/activity/map-hypercore-activity-to-transactions';\n\nexport const getTransactionHistory = async ({\n address,\n network,\n infoClient,\n}: GetTransactionHistory & {\n infoClient: HypercoreInfoClient;\n}): Promise<TransactionHistoryResponse> => {\n const items = await fetchHypercoreActivity(infoClient, address);\n return {\n transactions: mapHypercoreActivityToTransactions(items, address, network),\n };\n};\n","import { NetworkVMType, WalletType, type GetAddressParams, type GetAddressResponse } from '@avalabs/vm-module-types';\nimport { getAddressFromXPub, getEvmAddressFromPubKey } from '@avalabs/core-wallets-sdk';\nimport { rpcErrors } from '@metamask/rpc-errors';\n\ntype GetAddress = Omit<GetAddressParams, 'isTestnet' | 'xpubXP' | 'network'>;\n\nexport const getAddress = async ({ accountIndex, xpub, walletType }: GetAddress): Promise<GetAddressResponse> => {\n switch (walletType) {\n case WalletType.Mnemonic:\n case WalletType.Ledger:\n case WalletType.Keystone: {\n return {\n [NetworkVMType.HYPERCORE]: getAddressFromXPub(xpub, accountIndex),\n };\n }\n case WalletType.LedgerLive:\n case WalletType.Seedless: {\n const pubKeyBuffer = Buffer.from(xpub, 'hex');\n return {\n [NetworkVMType.HYPERCORE]: getEvmAddressFromPubKey(pubKeyBuffer),\n };\n }\n default:\n throw rpcErrors.invalidParams(`Unsupported wallet type: ${walletType}`);\n }\n};\n","import {\n NetworkVMType,\n type ApprovalController,\n type DeriveAddressParams,\n type DeriveAddressResponse,\n} from '@avalabs/vm-module-types';\nimport { computeAddress } from 'ethers';\nimport { hasDerivationDetails } from '@internal/utils/src/utils/address-derivation';\nimport { buildDerivationPath } from '../build-derivation-path/build-derivation-path';\n\nexport const deriveAddress = async (\n params: DeriveAddressParams & { approvalController: ApprovalController },\n): Promise<DeriveAddressResponse> => {\n const { secretId, approvalController } = params;\n\n // Narrow before calling buildDerivationPath — the type guard alone is not\n // enough when `params` is intersected with `{ approvalController }`.\n const derivationPath = hasDerivationDetails(params)\n ? buildDerivationPath({\n accountIndex: params.accountIndex,\n derivationPathType: params.derivationPathType,\n addressIndex: params.addressIndex,\n }).HYPERCORE\n : undefined;\n const publicKeyHex = await approvalController.requestPublicKey({\n curve: 'secp256k1',\n secretId,\n derivationPath,\n });\n\n return {\n [NetworkVMType.HYPERCORE]: computeAddress(`0x${publicKeyHex}`),\n };\n};\n","import type { DeriveAddressParams, DetailedDeriveAddressParams } from '@avalabs/vm-module-types';\n\nexport const hasDerivationDetails = (params: DeriveAddressParams): params is DetailedDeriveAddressParams =>\n 'derivationPathType' in params &&\n 'accountIndex' in params &&\n typeof params.accountIndex === 'number' &&\n typeof params.derivationPathType === 'string';\n","import { rpcErrors } from '@metamask/rpc-errors';\nimport {\n NetworkVMType,\n type BuildDerivationPathParams,\n type BuildDerivationPathResponse,\n} from '@avalabs/vm-module-types';\n\n/**\n * HyperCore identity is an EVM address (cointype 60). Paths match the EVM module;\n * the result is keyed as `HYPERCORE`.\n */\nexport const buildDerivationPath = ({\n accountIndex,\n derivationPathType,\n}: BuildDerivationPathParams): Pick<BuildDerivationPathResponse, NetworkVMType.HYPERCORE> => {\n if (accountIndex < 0) {\n throw rpcErrors.invalidParams('Account index must be a non-negative integer');\n }\n\n switch (derivationPathType) {\n case 'bip44':\n return {\n [NetworkVMType.HYPERCORE]: `m/44'/60'/0'/0/${accountIndex}`,\n };\n\n case 'ledger_live':\n return {\n [NetworkVMType.HYPERCORE]: `m/44'/60'/${accountIndex}'/0/0`,\n };\n\n default:\n throw rpcErrors.invalidParams(`Unsupported derivation path type: ${derivationPathType}`);\n }\n};\n","import {\n NetworkVMType,\n type ApprovalController,\n type DeriveAddressesParams,\n type DeriveAddressesResponse,\n} from '@avalabs/vm-module-types';\nimport { deriveAddressesForEvm, init } from '@avalabs/crypto-sdk';\nimport { buildDerivationPath } from '../build-derivation-path/build-derivation-path';\n\nexport const deriveAddresses = async (\n params: DeriveAddressesParams & { approvalController: ApprovalController },\n): Promise<DeriveAddressesResponse> => {\n const { approvalController, secretId, accountIndices, derivationPathType } = params;\n\n if (accountIndices.length === 0) {\n return [];\n }\n\n await init();\n\n const publicKeys = await Promise.all(\n accountIndices.map(async (accountIndex) => {\n const derivationPath = buildDerivationPath({ accountIndex, derivationPathType }).HYPERCORE;\n const publicKeyHex = await approvalController.requestPublicKey({\n curve: 'secp256k1',\n secretId,\n derivationPath,\n });\n return Uint8Array.from(Buffer.from(publicKeyHex, 'hex'));\n }),\n );\n\n const addresses = await deriveAddressesForEvm(publicKeys);\n\n return addresses.map((address) => ({ [NetworkVMType.HYPERCORE]: address }));\n};\n"]}
package/manifest.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "HyperCore",
3
+ "description": "Read-only Hyperliquid HyperCore module (balances, tokens, activity).",
4
+ "version": "0.0.1",
5
+ "sources": {
6
+ "module": {
7
+ "checksum": "",
8
+ "location": {
9
+ "npm": {
10
+ "filePath": "dist/index.js",
11
+ "packageName": "@avalabs/hypercore-module",
12
+ "registry": "https://registry.npmjs.org"
13
+ }
14
+ }
15
+ }
16
+ },
17
+ "network": {
18
+ "chainIds": ["hlcore:mainnet"],
19
+ "namespaces": ["hlcore"]
20
+ },
21
+ "cointype": "60",
22
+ "permissions": {
23
+ "rpc": {
24
+ "dapps": false,
25
+ "methods": [],
26
+ "nonRestrictedMethods": []
27
+ }
28
+ },
29
+ "manifestVersion": "0.1"
30
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@avalabs/hypercore-module",
3
+ "version": "0.0.0-feat-add-hyperliquid-modules-20260714192934",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/ava-labs/core-vm-modules",
7
+ "directory": "packages/hypercore-module"
8
+ },
9
+ "main": "dist/index.cjs",
10
+ "module": "dist/index.js",
11
+ "typings": "dist/index.d.ts",
12
+ "type": "module",
13
+ "files": [
14
+ "dist",
15
+ "manifest.json"
16
+ ],
17
+ "license": "Limited Ecosystem License",
18
+ "dependencies": {
19
+ "@avalabs/core-wallets-sdk": "3.1.0-alpha.87",
20
+ "@avalabs/crypto-sdk": "1.0.0",
21
+ "@metamask/rpc-errors": "6.3.0",
22
+ "big.js": "6.2.1",
23
+ "zod": "3.23.8",
24
+ "@avalabs/vm-module-types": "0.0.0-feat-add-hyperliquid-modules-20260714192934"
25
+ },
26
+ "devDependencies": {
27
+ "@types/big.js": "6.2.2",
28
+ "@types/jest": "29.5.7",
29
+ "ethers": "6.13.5",
30
+ "jest": "29.7.0",
31
+ "ts-jest": "29.1.1",
32
+ "tsup": "7.2.0",
33
+ "@internal/tsup-config": "0.1.1",
34
+ "@internal/utils": "0.8.0",
35
+ "eslint-config-custom": "0.1.0"
36
+ },
37
+ "peerDependencies": {
38
+ "ethers": "6.13.5"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "dev": "tsup --watch",
43
+ "lint": "eslint \"src/**/*.ts\"",
44
+ "test": "jest",
45
+ "test:watch": "jest --watch"
46
+ }
47
+ }