Hessishturkey - stake total
    Updated 2023-09-11
    -- forked from turkey - stake hour @ https://flipsidecrypto.xyz/edit/queries/f7e581f4-c373-46bb-ae09-e31acf145c81

    with
    prices as (SELECT HOUR::date as datex,
    case when symbol = 'USDT' then '0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8'
    when symbol = 'USDC' then '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8'
    when symbol = 'DAI' then '0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3'
    when symbol = 'WBTC' then '0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac'
    when symbol = 'wstETH' then '0x042b8f0484674ca266ac5d08e4ac6a3fe65bd3129795def2dca5c34ecc5f96d2'
    when symbol = 'WETH' then '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7'
    end as addy,
    case when symbol = 'WETH' then 'ETH' else SYMBOL end as token,
    DECIMALS , avg(PRICE) as pr
    from crosschain.core.ez_hourly_prices
    where HOUR::date >= current_date - 730
    and SYMBOL in ('USDT','USDC','DAI','WBTC','WETH','wstETH')
    and BLOCKCHAIN = 'ethereum'
    GROUP by 1,2,3,4),

    st_all as (SELECT TIMESTAMP, CALLER as user , tx_hash,
    INPUTS[0]:value[0]:value/pow(10,18) as volume, volume*pr as usd
    from external.tokenflow_starknet.decoded_traces join prices on TIMESTAMP::date=datex
    where TIMESTAMP::date >= '2023-06-22' and
    FUNCTION = 'stake'
    and contract = '0x05abfa46fe9bf3323dfe801da51174729c2b3dd060b80575b29c015245899d74'
    and token = 'ETH'),

    t1 as (SELECT TIMESTAMP , CALLER, tx_hash as hash1, INPUTS[0]:value as id
    from external.tokenflow_starknet.decoded_traces
    where TIMESTAMP::date >= '2023-07-01'
    and
    CONTRACT = '0x0106c94dc954944b3893e2102d9ad5065d04a0ec9b08910891d8eedb75965334' and
    FUNCTION = 'mint' and
    INPUTS[0]:name = 'campaign_id'
    Run a query to Download Data