vendettaMonthly BenQI Inflow and Outflow
    Updated 2024-09-01
    with submit as (select trunc(block_timestamp,'month') as monthly,
    sum(DECODED_LOG:"avaxAmount"/pow(10,18)) as "Deposited Amount"
    from avalanche.core.ez_decoded_event_logs
    where EVENT_NAME = 'Submitted'
    and CONTRACT_ADDRESS = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    group by 1)
    ,
    redeem as (select trunc(block_timestamp,'month') as monthly,
    sum((DECODED_LOG:"avaxAmount")/pow(10,18)) as redeemed_amount
    from avalanche.core.ez_decoded_event_logs
    where EVENT_NAME = 'Redeem'
    and CONTRACT_ADDRESS = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    group by 1)
    ,
    withdraw_request as (select trunc(block_timestamp,'month') as monthly,
    sum((DECODED_LOG:"shareAmount")/pow(10,18))*-1 as "Withdraw Request Amount"
    from avalanche.core.ez_decoded_event_logs
    where EVENT_NAME = 'UnlockRequested'
    and contract_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    group by 1)
    ,
    remaining as ( select a.monthly,
    redeemed_amount,
    sum(redeemed_amount) over (order by a.monthly asc) as cum_redem
    from withdraw_request a left outer join redeem b on a.monthly = b.monthly)
    ,
    cancel_withdraw as ( select trunc(block_timestamp,'month') as monthly,
    sum(DECODED_LOG:"shareAmount"/pow(10,18))*-1 as "Cancel Withdraw"
    from avalanche.core.ez_decoded_event_logs
    where EVENT_NAME = 'UnlockCancelled'
    and contract_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    group by 1)


    select a.monthly,
    "Deposited Amount",
    QueryRunArchived: QueryRun has been archived