Moeaave borrow
    Updated 2023-03-01
    select
    date_trunc({{scale}},BLOCK_TIMESTAMP)::date as date ,
    'Borrow' as action ,
    -- AAVE_VERSION, SYMBOL,
    count (distinct TX_HASH) as txns ,
    sum(BORROWED_USD) as amount_USD
    from
    ethereum.aave.ez_borrows
    where
    BORROWER_ADDRESS = '{{user_address}}'
    group by 1,2

    union all

    select
    date_trunc({{scale}},BLOCK_TIMESTAMP)::date as date ,
    'Repay' as action ,
    -- AAVE_VERSION, SYMBOL,
    count (distinct TX_HASH) as txns ,
    sum(REPAYED_USD) as amount_USD
    from
    ethereum.aave.ez_repayments
    where
    PAYER = '{{user_address}}'
    group by 1,2

    Run a query to Download Data