Skip to content
Closed
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
3 changes: 3 additions & 0 deletions core/src/exchanges/hyperliquid/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export class HyperliquidNormalizer implements IExchangeNormalizer<HyperliquidRaw
normalizePosition(raw: HyperliquidRawPosition): Position {
if (!isOutcomeCoin(raw.coin)) {
return {
info: raw,
marketId: raw.coin,
outcomeId: raw.coin,
outcomeLabel: raw.coin,
Expand All @@ -378,6 +379,7 @@ export class HyperliquidNormalizer implements IExchangeNormalizer<HyperliquidRaw
}

return {
info: raw,
marketId: this.coinToMarketId(raw.coin),
outcomeId: this.coinToOutcomeId(raw.coin),
outcomeLabel: raw.coin,
Expand All @@ -394,6 +396,7 @@ export class HyperliquidNormalizer implements IExchangeNormalizer<HyperliquidRaw
const locked = parseFloat(summary.totalMarginUsed);

return [{
info: raw,
currency: 'USDH',
total,
available: total - locked,
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/kalshi/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export class KalshiNormalizer implements IExchangeNormalizer<KalshiRawEvent, Kal
const entryPrice = absPosition > 0 ? raw.total_cost / absPosition / 100 : 0;

return {
info: raw,
marketId: raw.ticker,
outcomeId: raw.ticker,
outcomeLabel: raw.ticker,
Expand All @@ -266,6 +267,7 @@ export class KalshiNormalizer implements IExchangeNormalizer<KalshiRawEvent, Kal
const available = raw.balance / 100;
const total = raw.portfolio_value / 100;
return [{
info: raw,
currency: 'USD',
total,
available,
Expand Down
1 change: 1 addition & 0 deletions core/src/exchanges/limitless/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class LimitlessNormalizer implements IExchangeNormalizer<LimitlessRawMark
throw new Error(`Position missing market.slug (conditionId=${p.conditionId})`);
}
return {
info: raw,
marketId: slug,
outcomeId: p.asset,
outcomeLabel: p.outcome || 'Unknown',
Expand Down
1 change: 1 addition & 0 deletions core/src/exchanges/myriad/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export class MyriadNormalizer implements IExchangeNormalizer<MyriadRawMarket, My
}

return [{
info: rawItems,
currency: 'USDC',
total: totalValue,
available: 0,
Expand Down
1 change: 1 addition & 0 deletions core/src/exchanges/polymarket/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class PolymarketNormalizer implements IExchangeNormalizer<PolymarketRawEv

normalizePosition(raw: PolymarketRawPosition): Position {
return {
info: raw,
marketId: raw.resolvedMarketId || '',
outcomeId: raw.asset || '',
outcomeLabel: raw.outcome || 'Unknown',
Expand Down
1 change: 1 addition & 0 deletions core/src/exchanges/smarkets/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export class SmarketsNormalizer implements IExchangeNormalizer<SmarketsRawEventW
const available = parseFloat(raw.available_balance || '0');

return [{
info: raw,
currency: raw.currency || 'GBP',
total: balance,
available,
Expand Down
4 changes: 4 additions & 0 deletions core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export interface Order {
}

export interface Position {
/** Raw exchange response for this position. */
info: any;
/** The market this position is held in. */
marketId: string;
/** The outcome this position is held in. */
Expand All @@ -222,6 +224,8 @@ export interface Position {
}

export interface Balance {
/** Raw exchange response for this balance entry. */
info: any;
currency: string; // e.g., 'USDC'
/** Total balance including funds locked in open orders. */
total: number;
Expand Down
Loading