scottincryptoAave CRV Bad Debt Repayment Purchase Events
    Updated 2023-01-26
    with purchase_events as (
    select
    block_number
    , block_timestamp
    , tx_hash
    , origin_from_address
    , topics[1] as token_in_raw
    , topics[2] as token_out_raw
    , data
    from ethereum.core.fact_event_logs
    where 1=1
    -- and tx_hash = '0x7327bb1b21a7301a6a7f8a4c5ad22fcf16b4062c443cbfa818918fd2e07b05e3'
    and topics[0] = '0x46661dab58311a6838247afecbee792192b4f27fc8b3e7168c66bc55ec2e404e'
    and block_timestamp > '2023-01-25'
    and contract_address = lower('0x46A1B7d4a2920270c7eB2C2Db4DF2259A109bcb4')
    union all
    select
    block_number
    , block_timestamp
    , tx_hash
    , origin_from_address
    , topics[1] as token_in_raw
    , topics[2] as token_out_raw
    , data
    from ethereum.core.fact_event_logs
    where 1=1
    -- and tx_hash = '0x7327bb1b21a7301a6a7f8a4c5ad22fcf16b4062c443cbfa818918fd2e07b05e3'
    and topics[0] = '0x46661dab58311a6838247afecbee792192b4f27fc8b3e7168c66bc55ec2e404e'
    and block_timestamp > '2023-01-25'
    and contract_address = lower('0x46A1B7d4a2920270c7eB2C2Db4DF2259A109bcb4')
    )
    , eth_prices as (
    select
    block_number
    , latest_answer_unadj / 1e8 as eth_usd
    from ethereum.chainlink.ez_oracle_feeds
    Run a query to Download Data