SajjadiiiUntitled Query
    Updated 2022-08-25
    with base as (select distinct (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 ,
    tokenflow_eth.hextoint(substr(data,3+17*64,64)) as sport_code
    from optimism.core.fact_event_logs
    where topics[0] = '0x889e2060e46779287c2fcbf489c195ef20f5b44a74e3dcb58d491ae073c1370f'
    and contract_address = '0x2b91c14ce9aa828ed124d12541452a017d8a2148' -- game maker contract
    and sport_code >= 9000
    and sport_code <= 9050

    ),

    games as (
    select tx_hash , game_contract , home_team , away_team , sport_code
    from optimism.core.fact_event_logs a
    left join base b
    on a.EVENT_INPUTS:to = b.game_contract
    where contract_address = '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9' --Synthetix: sUSD Token
    and ORIGIN_TO_ADDRESS = EVENT_INPUTS:from
    and EVENT_INPUTS:to in (select game_contract from base )
    ),

    volumes_bet as (
    select ORIGIN_FROM_ADDRESS as user_address , game_contract , home_team || ' vs ' || away_team as game ,
    case
    when sport_code = '9001' then 'NCAA Mens Football'
    when sport_code = '9002' then 'NFL'
    Run a query to Download Data