John_GaltPercent of Naked Prism Claimed Pledged by Address, Date
    Updated 2022-07-07
    with table1 as (select
    date(block_timestamp) as date,
    event_attributes:user as address,
    sum(event_attributes:amount) / pow(10, 6) as xprism_pledged
    from terra.msg_events
    where date > '2022-04-06'
    and event_attributes:action = 'send'
    and event_attributes:"1_contract_address" = 'terra1pa4amk66q8punljptzmmftf6ylq3ezyzx6kl9m'
    and event_index = 3
    group by date, address
    ),

    table2 as (select
    date(block_timestamp) as date,
    sum(event_attributes:prism_reward_claimed) / pow(10, 6) as Claimed,
    event_attributes:to as address
    from terra.msg_events
    where date(block_timestamp) > '2022-04-06'
    and event_attributes:"0_contract_address" = 'terra1ns5nsvtdxu53dwdthy3yxs6x3w2hf3fclhzllc'
    and event_attributes:"0_action" = 'claim_withdrawn_rewards'
    and event_attributes:claim_type = 'Prism'
    and event_index = 3
    group by date, address
    ),

    final as (select table2.date, table2.address, table2.claimed, table1.xprism_pledged,
    case
    when table1.xprism_pledged > table2.claimed then table2.claimed
    end as xprism_pledged_of_claimed,
    (coalesce(xprism_pledged_of_claimed, 0) / table2.claimed) * 100 as percent_pledged
    from table2
    left outer join table1 on table1.date = table2.date and table1.address = table2.address
    ),

    final2 as (select date, sum(claimed) as naked_prism_claimed, sum(xPrism_pledged_of_claimed) as pledged,
    (pledged / naked_prism_claimed) * 100 as ppercent_ppledged
    Run a query to Download Data