* feat: add Polymarket * feat(route): add Polymarket routes using Gamma API Routes: - /polymarket/events/:tag_slug? - List events by category - /polymarket/event/:slug - Event details with markets - /polymarket/search/:query - Keyword subscription - /polymarket/series/:slug? - Recurring event series - /polymarket/user/:address - User trading activity - /polymarket/positions/:address - User positions - /polymarket/leaderboard/:category?/:timePeriod? - Trader rankings APIs used: - Gamma API (gamma-api.polymarket.com): events, series - Data API (data-api.polymarket.com): activity, positions, leaderboard Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(route): add Polymarket routes using Gamma API and Data API Routes: - /polymarket/events/:tagSlug? - List events by category - /polymarket/event/:slug - Event details with markets - /polymarket/search/:query - Keyword subscription - /polymarket/series/:slug? - Recurring event series - /polymarket/user/:address - User trading activity - /polymarket/positions/:address - User positions - /polymarket/leaderboard/:category?/:timePeriod? - Trader rankings APIs used: - Gamma API (gamma-api.polymarket.com): /events/pagination, /events/slug, /series, /public-search - Data API (data-api.polymarket.com): /activity, /positions, /v1/leaderboard --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
1.0 KiB
TypeScript
22 lines
1.0 KiB
TypeScript
import type { Event, Market } from './types';
|
|
|
|
export function formatOddsDisplay(market: Market): string {
|
|
const outcomes = market.outcomes ? JSON.parse(market.outcomes) : [];
|
|
const prices = market.outcomePrices ? JSON.parse(market.outcomePrices) : [];
|
|
return prices.length > 0 ? outcomes.map((o: string, i: number) => `${o}: ${(Number(prices[i]) * 100).toFixed(1)}%`).join(' | ') : outcomes.join(' | ') || 'N/A';
|
|
}
|
|
|
|
export function formatEventDescription(event: Event): string {
|
|
const marketsHtml = (event.markets || [])
|
|
.slice(0, 3)
|
|
.map((market) => `<li><strong>${market.question}</strong><br>${formatOddsDisplay(market)}</li>`)
|
|
.join('');
|
|
|
|
return `
|
|
${event.description ? `<p>${event.description}</p>` : ''}
|
|
<p><strong>Volume:</strong> $${Number(event.volume || 0).toLocaleString()}</p>
|
|
${marketsHtml ? `<h4>Markets:</h4><ul>${marketsHtml}</ul>` : ''}
|
|
${event.image ? `<img src="${event.image}" alt="${event.title}" style="max-width: 100%;">` : ''}
|
|
`;
|
|
}
|