binhachonUntitled Query
    Updated 2022-03-18
    with pool_allocation_transaction as (
    select
    distinct tx_id
    from ethereum.events_emitted
    where event_name = 'PoolAllocation'
    and tx_succeeded = 'TRUE'
    ),
    deposit_transaction as (
    select
    block_id,
    block_timestamp,
    event_inputs:to::string as pool_address,
    contract_address,
    case
    when pool_address = '0x5d3a536e4d6dbd6114cc1ead35777bab948e3643' then 'Compound'
    when pool_address = '0x7322b10db09687fe8889ad8e87f333f95104839f' then 'Fuse 7'
    when pool_address = '0x989273ec41274c4227bcb878c2c26fdd3afbe70d' then 'Fuse 6'
    when pool_address = '0x8e4e0257a4759559b4b1ac087fe8d80c63f20d19' then 'Fuse 18'
    when pool_address = '0x3dfd23a6c5e8bbcfc9581d2e864a68feb6a076d3' then 'AAVE'
    else 'Other' end as pool_name,
    event_inputs:value::float/1e18 as deposit_amount
    from ethereum.events_emitted
    where 1 = 1 --tx_id = '0x469efe5313b96cd895995fc11e41c2b76ec86a39e2a5e4ce01b7ee113ce8fdab'
    and event_name = 'Transfer'
    and tx_id in (select tx_id from pool_allocation_transaction)
    -- and tx_succeeded = 'TRUE'
    -- and tx_to_address = '0xafd2aade64e6ea690173f6de59fc09f5c9190d74' --Rari DAI pool controller
    -- and contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f' --DAI
    and event_inputs:from::string = '0xafd2aade64e6ea690173f6de59fc09f5c9190d74' --Rari DAI pool controller
    ),
    withdraw_transaction as (
    select
    block_id,
    block_timestamp,
    event_inputs:from::string as pool_address,
    case
    Run a query to Download Data