0xtableauAAVE-Polygon Highest Premium Flashloans
    Updated 2021-11-01
    -- Top 10 flashloans in last 5 days

    with flashloans as (
    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,
    case
    when lower(event_inputs:asset::string) = lower('0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') then '0x28424507fefb6f7f8E9D3860F56504E4e5f5f390'
    when lower(event_inputs:asset::string) = lower('0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270') then '0x8dF3aad3a84da6b69A4DA8aeC3eA40d9091B2Ac4'
    when lower(event_inputs:asset::string) = lower('0x8f3cf7ad23cd3cadbd9735aff958023239c6a063') then '0x27F8D03b3a2196956ED754baDc28D73be8830A6e'
    when lower(event_inputs:asset::string) = lower('0xc2132d05d31c914a87c6611c10748aeb04b58e8f') then '0x60D55F02A771d515e077c9C2403a1ef324885CeC'
    when lower(event_inputs:asset::string) = lower('0x2791bca1f2de4661ed88a30c99a7a9449aa84174') then '0x1a13F4Ca1d028320A707D99520AbFefca3998b7F'
    when lower(event_inputs:asset::string) = lower('0xd6df932a45c0f255f85145f286ea0b292b21c90b') then '0x1d2a0E5EC8E5bBDCA5CB219e649B565d8e5c3360'
    when lower(event_inputs:asset::string) = lower('0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6') then '0x5c2ed810328349100A66B82b78a1791B101C9D61'
    end as atoken_address,
    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,
    Run a query to Download Data