 0.5);
            return t > 0 ? 1 - probability : probability;
        }

        async function fetchMarketData(slug) {
            const response = await fetch(`${API_URL}/slug/${slug}`);
            const market = await response.json();
            const betsResponse = await fetch(`${API_URL}/bets?contractSlug=${slug}&limit=1000`);
            const bets = await betsResponse.json();

            return bets.map(bet => ({
                timestamp: new Date(bet.createdTime).getTime(),
                pr