Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/exchanges/kalshi/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ export class KalshiNormalizer implements IExchangeNormalizer<KalshiRawEvent, Kal

private deriveEventDescription(markets: any[]): string {
const texts = markets
.map((m) => 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];
Expand Down
12 changes: 8 additions & 4 deletions core/src/exchanges/limitless/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/subscriber/external/goldsky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
Loading