import { BookChange, BookTicker, DerivativeTicker, Exchange, Liquidation, NormalizedData, OptionSummary, Trade } from '../types.ts' import { ascendexMappers } from './ascendex.ts' import { asterMappers } from './aster.ts' import { backpackMappers } from './backpack.ts' import { binanceMappers } from './binance.ts' import { binanceDexMappers } from './binancedex.ts' import { binanceEuropeanOptionsMappers } from './binanceeuropeanoptions.ts' import { bitfinexMappers } from './bitfinex.ts' import { bitflyerMappers } from './bitflyer.ts' import { bitgetMappers } from './bitget.ts' import { bithumbMappers } from './bithumb.ts' import { bitmexMappers } from './bitmex.ts' import { bitnomialMappers } from './bitnomial.ts' import { bitstampMappers } from './bitstamp.ts' import { bitvavoMappers } from './bitvavo.ts' import { blockchainComMappers } from './blockchaincom.ts' import { bullishMappers } from './bullish.ts' import { bybitMappers } from './bybit.ts' import { coinbaseMappers } from './coinbase.ts' import { coinbaseDerivativesMappers } from './coinbasederivatives.ts' import { coinbaseInternationalMappers } from './coinbaseinternational.ts' import { coinflexMappers } from './coinflex.ts' import { cryptoComMappers } from './cryptocom.ts' import { cryptofacilitiesMappers } from './cryptofacilities.ts' import { deltaMappers } from './delta.ts' import { deltaIndiaMappers } from './delta_india.ts' import { deribitMappers } from './deribit.ts' import { dydxMappers } from './dydx.ts' import { dydxV4Mappers } from './dydxv4.ts' import { ftxMappers } from './ftx.ts' import { gateIOMappers } from './gateio.ts' import { gateIOFuturesMappers } from './gateiofutures.ts' import { geminiMappers } from './gemini.ts' import { hitBtcMappers } from './hitbtc.ts' import { huobiMappers } from './huobi.ts' import { hyperliquidMappers } from './hyperliquid.ts' import { krakenMappers } from './kraken.ts' import { kucoinMappers } from './kucoin.ts' import { kucoinFuturesMappers } from './kucoinfutures.ts' import { lighterMappers } from './lighter.ts' import { Mapper } from './mapper.ts' import { mexcFuturesMappers } from './mexcfutures.ts' import { mexcMappers } from './mexc.ts' import { okexMappers } from './okex.ts' import { phemexMappers } from './phemex.ts' import { poloniexMappers } from './poloniex.ts' import { polymarketMappers } from './polymarket.ts' import { serumMappers } from './serum.ts' import { MapperCollection, mergeExchangeMappers } from './registry.ts' import { upbitMappers } from './upbit.ts' import { wooxMappers } from './woox.ts' import { whitebitMappers } from './whitebit.ts' export * from './mapper.ts' type Normalizer = (( exchange: T, localTimestamp: Date ) => Mapper) & { getSwitchDates: (exchange: keyof M & Exchange) => readonly Date[] } const registeredMappers = mergeExchangeMappers( ascendexMappers, asterMappers, backpackMappers, binanceMappers, binanceDexMappers, binanceEuropeanOptionsMappers, bitfinexMappers, bitflyerMappers, bitgetMappers, bithumbMappers, bitmexMappers, bitnomialMappers, bitstampMappers, bitvavoMappers, blockchainComMappers, bullishMappers, bybitMappers, coinbaseMappers, coinbaseDerivativesMappers, coinbaseInternationalMappers, coinflexMappers, cryptoComMappers, cryptofacilitiesMappers, deltaMappers, deltaIndiaMappers, deribitMappers, dydxMappers, dydxV4Mappers, ftxMappers, gateIOMappers, gateIOFuturesMappers, geminiMappers, hitBtcMappers, huobiMappers, hyperliquidMappers, krakenMappers, kucoinMappers, kucoinFuturesMappers, lighterMappers, mexcFuturesMappers, mexcMappers, okexMappers, phemexMappers, poloniexMappers, polymarketMappers, serumMappers, upbitMappers, wooxMappers, whitebitMappers ) export const normalizeTrades = createNormalizer('normalizeTrades', registeredMappers.trades) export const normalizeBookChanges = createNormalizer( 'normalizeBookChanges', registeredMappers.bookChanges ) export const normalizeDerivativeTickers = createNormalizer( 'normalizeDerivativeTickers', registeredMappers.derivativeTickers ) export const normalizeOptionsSummary = createNormalizer( 'normalizeOptionsSummary', registeredMappers.optionsSummary ) export const normalizeLiquidations = createNormalizer( 'normalizeLiquidations', registeredMappers.liquidations ) export const normalizeBookTickers = createNormalizer( 'normalizeBookTickers', registeredMappers.bookTickers ) function createNormalizer(name: string, mappers: M): Normalizer { const normalize = ((exchange: T, localTimestamp: Date) => { const createMapper = mappers[exchange] if (createMapper === undefined) { throw new Error(`${name}: ${exchange} not supported`) } return createMapper(localTimestamp) as Mapper }) as Normalizer normalize.getSwitchDates = (exchange) => getMapperSwitchDates(mappers, exchange) return normalize } function getMapperSwitchDates(mappers: MapperCollection, exchange: string) { return mappers[exchange]?.switchDates ?? [] }