maybeyonasaave-dash-repay-fees
    Updated 2021-09-15
    with aaveRepays as (
    select block_timestamp, tx_id, repayed_tokens, repayed_usd, payer, token_price, symbol, aave_token
    from aave.repayments
    where aave_version = 'Aave V2'
    ),
    repayFee as(
    select tx_id, event_inputs:amount0 as fee, tx_from_address as payer, contract_address
    from ethereum.events_emitted
    where event_name = 'Mint' and event_removed = FALSE
    ),
    aaveFees as(
    select
    block_timestamp,
    a.tx_id,
    repayed_tokens,
    repayed_usd,
    a.payer,
    token_price,
    symbol,
    fee
    from aaveRepays a
    join repayFee f on a.tx_id = f.tx_id and aave_token = contract_address
    ),
    noNullerc20Deci as(
    select symbol,decimals from ethereum.token_prices_hourly
    where decimals is not null
    ),
    erc20Deci as(
    select symbol,min(decimals) as decimals
    from noNullerc20Deci
    group by symbol
    ),
    aaveEvents as(
    select
    block_timestamp,
    tx_id,
    Run a query to Download Data