scottincryptoAave Safety Module Rewards Subsequent Actions
    Updated 2023-04-13
    with claims as (
    -- claims transactions from the safety module contracts
    select
    block_timestamp
    , contract_address
    , case
    when contract_address = '0xa1116930326d21fb917d5a27f1e9943a9595fb47' then 'stkABPT'
    when contract_address = '0x4da27a545c0c5b758a6ba100e3a049001de870f5' then 'stkAAVE'
    end as contract_name
    , event_inputs:to as token_recipient
    , event_inputs:amount/1e18 as amount_claimed
    , tx_hash
    from ethereum.core.fact_event_logs
    where event_name = 'RewardsClaimed'
    and block_timestamp >= '2021-08-01'
    and contract_address in ('0xa1116930326d21fb917d5a27f1e9943a9595fb47', '0x4da27a545c0c5b758a6ba100e3a049001de870f5') --stkABPT, stkAAVE
    and tx_status = 'SUCCESS'
    )
    , aave_xfers as (
    -- transfers out of AAVE tokens from accounts who have claimed
    select
    block_timestamp
    , from_address
    , to_address
    , tx_hash
    , amount as amount_transferred
    from ethereum.core.ez_token_transfers
    where from_address in (select token_recipient from claims)
    and block_timestamp >= '2021-08-01'
    and contract_address = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9' -- AAVE token
    )

    , tx_count as (
    -- count of Transfer() events on each transfer out transaction above
    select
    Run a query to Download Data