kakamoraStaking Metrics
    Updated 2022-09-21
    with addys as (
    SELECT lower('0x9ee91f9f426fa633d227f7a9b000e28b9dfd8599') as contract_address, 'Lido Liquid Staking' as provider
    UNION
    SELECT lower('0x38b7bf4eecf3eb530b1529c9401fc37d2a71a912') as contract_address, 'ClayStack Liquid Staking' as provider
    UNION
    SELECT lower('0xf03a7eb46d01d9ecaa104558c732cf82f6b6b645') as contract_address, 'Stader Liquid Staking' as provider
    ),
    stake_evnts as (
    SELECT
    tx_hash,
    block_timestamp,
    date_trunc(day, block_timestamp) as date,
    raw_amount / 1e18 as tokens,
    provider,
    ORIGIN_FROM_ADDRESS as wallet,
    case
    when from_address = '0x0000000000000000000000000000000000000000' then 'Stake'
    when to_address = '0x0000000000000000000000000000000000000000' then 'Unstake'
    end as action,
    case
    when from_address = '0x0000000000000000000000000000000000000000' then raw_amount / 1e18
    end as staked_tokens,
    case
    when to_address = '0x0000000000000000000000000000000000000000' then -1 * (raw_amount / 1e18)
    end as unstaked_tokens
    FROM ethereum.core.ez_token_transfers
    INNER JOIN addys USING (contract_address)
    WHERE ( from_address = '0x0000000000000000000000000000000000000000' or to_address = '0x0000000000000000000000000000000000000000')
    ),
    results as (
    SELECT
    date,
    provider,
    count(distinct wallet) as wallets,
    count(distinct tx_hash) as events,
    sum(NVL(staked_tokens, 0)) as staked_token_vol,
    Run a query to Download Data