| 29 | } |
| 30 | |
| 31 | export class LimitlessNormalizer implements IExchangeNormalizer<LimitlessRawMarket, LimitlessRawEvent> { |
| 32 | |
| 33 | normalizeMarket(raw: LimitlessRawMarket): UnifiedMarket | null { |
| 34 | return mapMarketToUnified(raw); |
| 35 | } |
| 36 | |
| 37 | normalizeEvent(raw: LimitlessRawEvent): UnifiedEvent | null { |
| 38 | if (!raw) return null; |
| 39 | |
| 40 | let marketsList: UnifiedMarket[] = []; |
| 41 | |
| 42 | if (raw.markets && Array.isArray(raw.markets)) { |
| 43 | const eventTitle = raw.title || raw.question || ''; |
| 44 | marketsList = raw.markets |
| 45 | .map((child: any) => mapMarketToUnified(child, { |
| 46 | eventId: raw.slug, |
| 47 | eventTitle, |
| 48 | eventDescription: raw.description, |
| 49 | categories: raw.categories, |
| 50 | tags: raw.tags, |
| 51 | })) |
| 52 | .filter((m: any): m is UnifiedMarket => m !== null); |
| 53 | } else { |
| 54 | const unifiedMarket = mapMarketToUnified(raw); |
| 55 | if (unifiedMarket) marketsList = [unifiedMarket]; |
| 56 | } |
| 57 | |
| 58 | return { |
| 59 | id: raw.slug, |
| 60 | title: raw.title || raw.question || '', |
| 61 | description: raw.description || '', |
| 62 | slug: raw.slug, |
| 63 | markets: marketsList, |
| 64 | volume24h: marketsList.reduce((sum, m) => sum + m.volume24h, 0), |
| 65 | volume: marketsList.some(m => m.volume !== undefined) |
| 66 | ? marketsList.reduce((sum, m) => sum + (m.volume ?? 0), 0) |
| 67 | : undefined, |
| 68 | url: `https://limitless.exchange/markets/${raw.slug}`, |
| 69 | image: raw.logo || `https://limitless.exchange/api/og?slug=${raw.slug}`, |
| 70 | category: raw.categories?.[0], |
| 71 | tags: raw.tags || [], |
| 72 | sourceMetadata: buildSourceMetadata( |
| 73 | raw as unknown as Record<string, unknown>, |
| 74 | LIMITLESS_PROMOTED_EVENT_KEYS, |
| 75 | ), |
| 76 | } as UnifiedEvent; |
| 77 | } |
| 78 | |
| 79 | normalizeOHLCV(rawPrices: LimitlessRawPricePoint[], params: OHLCVParams): PriceCandle[] { |
| 80 | let candles = rawPrices.map((p) => { |
| 81 | const price = Number(p.price); |
| 82 | const ts = Number(p.timestamp); |
| 83 | |
| 84 | return { |
| 85 | timestamp: ts, |
| 86 | open: price, |
| 87 | high: price, |
| 88 | low: price, |
nothing calls this directly
no outgoing calls
no test coverage detected