mo115Governance Delegation Reward
    Updated 2024-01-26
    with total as (
    with final as(
    with data as(
    with delegations as
    (with delegations_be as (
    select NONCE, date_trunc('day',block_timestamp)as date
    from optimism.core.fact_transactions
    where ORIGIN_FUNCTION_SIGNATURE = '0x5c19a95c'
    and FROM_ADDRESS = lower('{{address}}')
    )

    select case when date <= '2023-07-20' then '2023-07-20' else null end as date
    from delegations_be

    UNION

    select date_trunc('day',block_timestamp)as date
    from optimism.core.fact_transactions
    where ORIGIN_FUNCTION_SIGNATURE = '0x5c19a95c'
    and FROM_ADDRESS = lower('{{address}}')
    and block_timestamp > '2023-07-20'),

    amount_in1 as (with dates as (select date_trunc('day',block_timestamp)as date
    from optimism.core.ez_token_transfers
    where block_timestamp > '2022-05-30'),
    amount_in as(
    select date_trunc('day',block_timestamp)as date, sum(AMOUNT) as amount_in,
    (sum(amount_in) over (order by date)) as cumulative_amount_in
    from optimism.core.ez_token_transfers
    where To_ADDRESS = lower('{{address}}')
    and CONTRACT_ADDRESS ='0x4200000000000000000000000000000000000042'
    group by date)
    select distinct d.date,amount_in,cumulative_amount_in,
    coalesce( cumulative_amount_in, lag(cumulative_amount_in) ignore nulls over (order by d.date asc), lead(cumulative_amount_in) ignore nulls over (order by d.date asc) ) as cumulative_amount_in_fill
    from dates d left join amount_in i on d.date=i.date
    Last run: over 1 year ago
    Governance Delegation Reward
    1
    7785.623476214
    1
    18B
    222s