CryptoIcicleSolana-% of Solana Staked
    Updated 2022-02-12
    -- Using the "Events" table, what percentage of Solana that has been transacted is staked?
    -- How has that percentage changed throughout the month of January?
    -- Create a visualization showing % SOL staked over time.
    -- What is the average amount of Solana staked during a staking transaction?


    with solana_txns as (
    select
    date_trunc('day', block_timestamp) as date,
    tx_id,
    instruction:parsed:info:lamports / pow(10,9) as amount,
    CASE
    WHEN event_type = 'split' THEN 'stake'
    ELSE 'other'
    END as type
    from solana.events
    where (block_timestamp between '2022-01-01' and '2022-01-30') and amount > 0
    and succeeded = 'TRUE'
    limit 900000000
    ),
    stake_txns as (
    select date, sum(amount) as amount, avg(amount) as avg_amount, count(tx_id) as n_txns from solana_txns where type = 'stake' group by date
    ),
    other_txns as (
    select date, sum(amount) as amount, avg(amount) as avg_amount, count(tx_id) as n_txns from solana_txns where type = 'other' group by date
    )


    select
    s.date,
    s.n_txns as staked_n_txns,
    o.n_txns as other_n_txns,
    staked_n_txns * 100/(other_n_txns+ staked_n_txns) as staked_n_txns_pct,
    s.amount as staked_amount,
    o.amount as other_amount,
    staked_amount * 100/(other_amount+ staked_amount) as staked_amount_pct,
    Run a query to Download Data