0xtableauAAVE MATIC Flashloan Fees
    Updated 2021-10-27
    with flashloans as (
    select
    date_trunc('day',block_timestamp) as dly_d,
    asset_contract,
    asset_name,
    sum(flashloan_quantity_clean) as flashloan_amount,
    sum(premium_quantity_clean) as premium_quantity

    from (
    SELECT
    DISTINCT block_id,
    block_timestamp,
    tx_id,
    event_index,
    event_inputs:asset::string as asset_contract,
    case -- could move to a join in token prices were available for polygon contracts
    when lower(event_inputs:asset::string) = lower('0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') then 'WETH'
    when lower(event_inputs:asset::string) = lower('0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270') then 'MATIC'
    when lower(event_inputs:asset::string) = lower('0x8f3cf7ad23cd3cadbd9735aff958023239c6a063') then 'DAI'
    when lower(event_inputs:asset::string) = lower('0xc2132d05d31c914a87c6611c10748aeb04b58e8f') then 'USDT'
    when lower(event_inputs:asset::string) = lower('0x2791bca1f2de4661ed88a30c99a7a9449aa84174') then 'USDC'
    when lower(event_inputs:asset::string) = lower('0xd6df932a45c0f255f85145f286ea0b292b21c90b') then 'AAVE'
    when lower(event_inputs:asset::string) = lower('0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6') then 'WBTC'
    END AS asset_name,
    event_inputs:amount::float AS flashloan_quantity_raw,
    case
    when lower(event_inputs:asset::string) = lower('0xc2132d05d31c914a87c6611c10748aeb04b58e8f') then event_inputs:amount::float/1e6
    when lower(event_inputs:asset::string) = lower('0x2791bca1f2de4661ed88a30c99a7a9449aa84174') then event_inputs:amount::float/1e6
    when lower(event_inputs:asset::string) = lower('0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6') then event_inputs:amount::float/1e8
    else event_inputs:amount::float/1e18
    end as flashloan_quantity_clean,
    event_inputs:initiator::string AS initiator_address,
    event_inputs:target::string AS target_address,
    event_inputs:premium::float AS premium_quantity_raw,
    case
    when lower(event_inputs:asset::string) = lower('0xc2132d05d31c914a87c6611c10748aeb04b58e8f') then event_inputs:premium::float/1e6
    Run a query to Download Data