diff --git a/core/src/exchanges/kalshi/normalizer.ts b/core/src/exchanges/kalshi/normalizer.ts index 3a837d64..eaf23f82 100644 --- a/core/src/exchanges/kalshi/normalizer.ts +++ b/core/src/exchanges/kalshi/normalizer.ts @@ -288,8 +288,8 @@ export class KalshiNormalizer implements IExchangeNormalizer m.rules_primary as string) - .filter((t) => typeof t === 'string' && t.length > 0); + .map((m) => m.rules_primary) + .filter((t): t is string => typeof t === 'string' && t.length > 0); if (texts.length === 0) return ''; if (texts.length === 1) return texts[0]; diff --git a/core/src/exchanges/limitless/utils.ts b/core/src/exchanges/limitless/utils.ts index 8521a073..920d2430 100644 --- a/core/src/exchanges/limitless/utils.ts +++ b/core/src/exchanges/limitless/utils.ts @@ -14,25 +14,29 @@ export function mapMarketToUnified(market: any): UnifiedMarket | null { // Use explicit key lookup — Object.entries order is not guaranteed to // match the prices array. if (market.tokens) { + if (!market.tokens.yes || !market.tokens.no) { + throw new Error(`[limitless] Market "${market.slug}" is missing token addresses`); + } + const prices = Array.isArray(market.prices) ? market.prices : []; const yesPrice = prices[0] || 0; const noPrice = prices[1] || 0; outcomes.push({ - outcomeId: market.tokens.yes as string, + outcomeId: market.tokens.yes, marketId: market.slug, label: 'Yes', price: yesPrice, priceChange24h: 0, - metadata: { clobTokenId: market.tokens.yes as string }, + metadata: { clobTokenId: market.tokens.yes }, }); outcomes.push({ - outcomeId: market.tokens.no as string, + outcomeId: market.tokens.no, marketId: market.slug, label: 'No', price: noPrice, priceChange24h: 0, - metadata: { clobTokenId: market.tokens.no as string }, + metadata: { clobTokenId: market.tokens.no }, }); } diff --git a/core/src/subscriber/external/goldsky.ts b/core/src/subscriber/external/goldsky.ts index 419aedf2..daf3c2f1 100644 --- a/core/src/subscriber/external/goldsky.ts +++ b/core/src/subscriber/external/goldsky.ts @@ -191,7 +191,7 @@ export const buildPolymarketTradesActivity: SubscribedActivityBuilder = (data, a const addr = address.toLowerCase(); const trades: Trade[] = filled.map((f: any): Trade => { - const isMaker = (f.maker as string)?.toLowerCase() === addr; + const isMaker = f.maker?.toLowerCase() === addr; const currAssetId = BigInt(isMaker ? f.makerAssetId : f.takerAssetId); const isBuying = currAssetId === 0n; @@ -253,7 +253,7 @@ export const buildLimitlessBalanceActivity: SubscribedActivityBuilder = (data, a const t = transfers[0]; const addr = address.toLowerCase(); - const isIncoming = (t.to as string)?.toLowerCase() === addr; + const isIncoming = t.to?.toLowerCase() === addr; const delta = parseFloat(t.value) / 1e6; const newTotal = Math.max(0, isIncoming ? prev.total + delta : prev.total - delta);