CryptoIcicleOvertime Markets - Volume
    Updated 2022-08-23
    -- Payout 75 USDC
    -- Grand Prize 225 USDC
    -- Payout Network Ethereum
    -- Level Beginner
    -- Difficulty Medium
    -- Thales is a protocol that allows for the creation of peer-to-peer parimutuel markets that anyone can join.
    -- A Parimutuel Market is a market where the collateral is locked in a pool and the final payout to participants is not determined until after
    -- the market-settling event finalizes.
    -- There are several types of markets, including Up and Down markets, ranged markets, exotic markets, and Overtime Markets.
    -- Overtime markets is a fully on-chain sports AMM with Chainlink sport feeds, allowing users to bet on Soccer, Football, MMA, and Baseball.
    -- For this bounty we will be focused on the Overtime volume on Optimism.
    -- Single tx example: https://optimistic.etherscan.io/tx/0x2072d57af9eb255993f0307d9713a2518ba7686cee15a47d6af1ba07031fa865
    -- For more information on Thales and Overtime Markets, see https://thalesmarket.io/ & https://overtimemarkets.xyz/#/markets
    -- Analyze the total volume on Overtime Markets over the past two weeks.
    -- Which games received the most activity, both in total users and total $ volume?
    -- Which sports are receiving the most bets in total dollar volume on a daily basis? Explain your findings.
    -- SQL Credit: https://app.flipsidecrypto.com/velocity/queries/01fffd66-6f99-4d22-8b8a-b2ffb248afa6
    with txns as (
    select
    game_contract,
    Tags,
    concat(home_team, away_team) as game
    from
    (
    SELECT
    concat('0x', substr(data, 27, 40)) as game_contract,
    HEX_DECODE_STRING(substr(data, 3 + 13 * 64, 64)) as home_team,
    HEX_DECODE_STRING(substr(data, 3 + 15 * 64, 64)) as away_team,
    regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
    ethereum.public.udf_hex_to_int(concat('0x', SUBSTR(segmented_data [17], 25, 40))) AS tags
    from
    optimism.core.fact_event_logs
    where
    block_timestamp >= CURRENT_DATE - {{ n_days }}
    and topics [0] = '0x889e2060e46779287c2fcbf489c195ef20f5b44a74e3dcb58d491ae073c1370f'
    and contract_address = '0x2b91c14ce9aa828ed124d12541452a017d8a2148'
    Run a query to Download Data