@kinetiq-research/markets-assets
Version:
Asset metadata (descriptions, oracle references) for Kinetiq markets
30 lines (27 loc) • 1.46 kB
text/typescript
import en from '../messages/en.json'
import type { LocaleMessages } from './_/types'
const messages = en as LocaleMessages
// English `description_short` is the canonical asset DESCRIPTION for backend
// (non-localized) contexts like Pulse briefs: `'NVIDIA'` for `NVDA`, `'Top 100
// US tech stocks'` for `USTECH`. For what the trade app CALLS a market —
// `'QQQ'` for `USTECH` — use `toDisplaySymbol` instead.
//
// KEYED BY BARE SYMBOL, DELIBERATELY. The messages files carry no dex
// dimension: all 121 `asset-metadata` entries are bare lowercase symbols, and
// `apps/markets` reads them the same way (`asset-metadata.${symbol
// .toLowerCase()}`, four call sites). This used to build a dex-prefixed key via
// `toAssetKey`, which matched nothing for HIP-3 listings — so every equity and
// index silently fell back to its raw ticker while crypto perps, whose keys are
// bare, looked fine. There is no `dex` parameter now precisely so that mistake
// cannot be made again; `toAssetKey` remains correct for the maps that ARE
// dex-keyed (`assetNewsKeywords`).
//
// The trade-off it accepts: one clean symbol listed on two dexes shares an
// entry. Callers resolve dex collisions to a single listing before asking, so
// there is nothing left to disambiguate by the time this is called.
export const getAssetName = ({
symbol,
}: {
symbol: string
}): string | undefined =>
messages['asset-metadata'][symbol.toLowerCase()]?.description_short