princefarzamThe top ten games which received the most activity in total users in the last two weeks
    Updated 2022-08-22
    WITH txns as (SELECT
    regexp_substr_all( SUBSTR(DATA, 3, len(DATA)), '.{64}' ) AS segmented_data,
    CASE
    WHEN concat('0x',SUBSTR(segmented_data[2], 25, 40))='0x0000000000000000000000000000000000000000' THEN 'HOME'
    WHEN concat('0x',SUBSTR(segmented_data[2], 25, 40))='0x0000000000000000000000000000000000000001' THEN 'AWAY'
    WHEN concat('0x',SUBSTR(segmented_data[2], 25, 40))='0x0000000000000000000000000000000000000002' THEN 'DRAW'
    END AS Position,
    concat('0x',SUBSTR(segmented_data[1], 25, 40)) AS market,
    ethereum.public.udf_hex_to_int(concat('0x',SUBSTR(segmented_data[3], 25, 40)))/pow(10,18) AS Token_Amount,
    ethereum.public.udf_hex_to_int(concat('0x',SUBSTR(segmented_data[4], 25, 40)))/pow(10,18) AS Expected_Payout,
    concat('0x',SUBSTR(segmented_data[5], 25, 40)) AS Stable_coin,
    concat('0x',SUBSTR(segmented_data[6], 25, 40)) AS Ticket,
    *
    FROM optimism.core.fact_event_logs
    WHERE CONTRACT_ADDRESS='0x170a5714112daeff20e798b6e92e25b86ea603c1'
    AND ORIGIN_TO_ADDRESS='0x170a5714112daeff20e798b6e92e25b86ea603c1'
    AND BLOCK_TIMESTAMP::DATE >= CURRENT_DATE - 14
    AND TX_STATUS='SUCCESS'
    AND EVENT_NAME IS NULL)

    SELECT
    MARKET,
    CASE
    WHEN MARKET='0xce01adb39cb9864020fe4e77b1f5a6f01305ae95' THEN 'Baseball game 1 between Baltimore Orioles Vs. Boston Red Sox'
    WHEN MARKET='0x40ce1a576ef8c67145a4cc0e3cda198b9dd13de6' THEN 'Baseball game 2 between Baltimore Orioles Vs. Boston Red Sox'
    WHEN MARKET='0x07fb8f06addf5bf57eaae34e21cf505ab2afaf21' THEN 'Soccer between Manchester United Vs. Liverpool'
    WHEN MARKET='0x17351dd7d1e92ce0cf97efab61ebe3f6d4ff6015' THEN 'Soccer between Brentford FC Vs. Manchester United'
    WHEN MARKET='0xae0d0e7c5d9f8d8c17eb48b8d00a823c14dda3e2' THEN 'Soccer between Arsenal FC Vs. Leicester City'
    WHEN MARKET='0x3be64d5c16f81a9dd7a431446a7f0a3e9b51fbaf' THEN 'Soccer between Newcastle United Vs. Manchester City'
    WHEN MARKET='0x47362c82f537935f64e60ca6bd3f16583e11b5ca' THEN 'Soccer between Liverpool Vs. Crystal Palace'
    WHEN MARKET='0x274e9d883c101509805b163eaa806ef6628581a2' THEN 'Soccer between Tottenham Hotspur Vs. Wolverhampton'
    WHEN MARKET='0xa7e41e8d5cabf63eea144af3bed65487a5d283bd' THEN 'Soccer between Chelsea Vs. Tottenham Hotspur'
    WHEN MARKET='0xf8324027132935dc5f20478e543b980300462ef0' THEN 'Soccer La Liga between Getafe Vs. Atletico Madrid'
    END AS Market_Name,
    COUNT(DISTINCT TX_HASH) NUMBER_OF_BETS,
    --SUM(EXPECTED_PAYOUT)::INT AS THE_TOTAL_VOLUME,
    Run a query to Download Data