UNPKG

rsshub

Version:
18 lines (17 loc) 1 kB
//#region lib/routes/polymarket/utils.ts function formatOddsDisplay(market) { const outcomes = market.outcomes ? JSON.parse(market.outcomes) : []; const prices = market.outcomePrices ? JSON.parse(market.outcomePrices) : []; return prices.length > 0 ? outcomes.map((o, i) => `${o}: ${(Number(prices[i]) * 100).toFixed(1)}%`).join(" | ") : outcomes.join(" | ") || "N/A"; } function formatEventDescription(event) { 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%;">` : ""} `; } //#endregion export { formatOddsDisplay as n, formatEventDescription as t };