Moe5 mkr flsh
    Updated 2022-10-09
    with base as (
    select
    tx_hash
    from ethereum.maker.ez_flash_loans
    where block_timestamp >= CURRENT_DATE - {{days_back}}
    )
    ,fin as (select

    ORIGIN_FROM_ADDRESS
    from ethereum.core.ez_token_transfers
    where tx_hash in (select tx_hash from base)
    and block_timestamp >= CURRENT_DATE - {{days_back}})
    select
    Label,
    count(tx_hash) as num_usage
    from Ethereum.core.fact_transactions t
    inner join ethereum.core.dim_labels l on t.TO_ADDRESS= l.address
    where label_subtype != 'token_contract'
    and LABEL_TYPE in ('dapp','defi')
    and STATUS = 'SUCCESS'
    and label not ilike '%Aave%'
    and label not ilike '%makerdao%'
    and label not ilike '%mev bot%'
    and FROM_ADDRESS in (select origin_from_address from fin)
    group by 1
    order by 2 desc


    Run a query to Download Data