freemartianDaily & Cumulative Bet Amount
    Updated 2022-08-25
    with bet_action as (
    select
    distinct tx_hash as tx,
    from_address as bettor,
    regexp_substr_all(SUBSTR(input_data, 11, len(input_data)), '.{64}') AS segmented_data,
    concat('0x', substr(segmented_data[0], 25, 40)) as game,
    ethereum.public.udf_hex_to_int(segmented_data[3] :: STRING) :: FLOAT as paid_bet,
    block_timestamp
    from optimism.core.fact_transactions
    where tx_hash in (
    select distinct tx_hash
    from optimism.core.fact_token_transfers
    where to_address = '0x170a5714112daeff20e798b6e92e25b86ea603c1'
    and from_address != '0x0000000000000000000000000000000000000000'
    and from_address != '0x061b87122ed14b9526a813209c8a59a633257bab'
    and origin_function_signature in ('0x6cc5a6ff', '0x8875eb84')
    and block_timestamp >= CURRENT_DATE - 14)
    ),
    currency as (
    select tx_hash, contract_address, decimals
    from optimism.core.fact_token_transfers t
    inner join optimism.core.dim_contracts c on c.address = t.contract_address
    where tx_hash in (select distinct tx from bet_action)
    )
    select
    sum(paid_bet/pow(10, decimals))/3 as bet_amount,
    date_trunc('day', block_timestamp::date) as TIME,
    sum(bet_amount) over (order by TIME) as cumulative_bet_amount
    from bet_action b
    inner join currency c on c.tx_hash = b.tx
    group by TIME


    Run a query to Download Data