alirezamoosavi-blvckETH stake per Platforms (with parameters)
    Updated 2022-09-08
    with am as
    (with abc as (
    with a as (
    with c as (
    select HOUR as h1, PRICE as token_price
    from ethereum.core.fact_hourly_token_prices
    where TOKEN_ADDRESS = lower('0x49d72e3973900a195a155a46441f0c08179fdb64'))
    ,d as (
    select HOUR as h2 , PRICE as eth_price
    from ethereum.core.fact_hourly_token_prices
    where SYMBOL='WETH')
    select token_price / eth_price as p1 , h1
    from c join d on c.h1 = d.h2
    ),
    b as (
    select date_trunc('hour', BLOCK_TIMESTAMP) as h , RAW_AMOUNT/1e18 as ra
    from ethereum.core.fact_token_transfers
    where CONTRACT_ADDRESS = lower('0x49d72e3973900a195a155a46441f0c08179fdb64')
    )
    select 'Cream'as platform_name , sum (a.p1 * b.ra) as eth_val
    from a join b on a.h1 = b.h
    union
    select 'Stakewise' as platform_name ,sum (ETH_VALUE)
    from ethereum.core.fact_transactions
    where TX_HASH in (select TX_HASH
    from ethereum.core.fact_token_transfers
    where TX_HASH in (select TX_HASH
    from ethereum.core.fact_event_logs
    where CONTRACT_ADDRESS = '0xc874b064f465bdd6411d45734b56fac750cda29a'
    and ORIGIN_FUNCTION_SIGNATURE = '0x040dee8a')
    and CONTRACT_ADDRESS = '0xfe2e637202056d30016725477c5da089ab0a043a')
    and STATUS= 'SUCCESS'
    union
    Run a query to Download Data