Eman-RazBorrowing Analysis
    Updated 2023-03-15
    with arbitrum as (select date_trunc('month',block_timestamp) as "Date", sum(amount_usd) as volume_usd, count(distinct tx_hash) as borrowing_count
    , count(distinct BORROWER) as borrower_count, 'Arbitrum' as "Chain"
    from arbitrum.sushi.ez_borrowing
    where action='Borrow'
    group by 1
    order by 1),
    avalanche as (select date_trunc('month',block_timestamp) as "Date", sum(amount_usd) as volume_usd, count(distinct tx_hash) as borrowing_count
    , count(distinct BORROWER) as borrower_count, 'Avalanche' as "Chain"
    from avalanche.sushi.ez_borrowing
    where action='Borrow'
    group by 1
    order by 1),
    ethereum as (select date_trunc('month',block_timestamp) as "Date", sum(amount_usd) as volume_usd, count(distinct tx_hash) as borrowing_count
    , count(distinct BORROWER) as borrower_count, 'Ethereum' as "Chain"
    from ethereum.sushi.ez_borrowing
    where action='Borrow'
    group by 1
    order by 1),
    gnosis as (select date_trunc('month',block_timestamp) as "Date", sum(amount_usd) as volume_usd, count(distinct tx_hash) as borrowing_count
    , count(distinct BORROWER) as borrower_count, 'Gnosis' as "Chain"
    from gnosis.sushi.ez_borrowing
    where action='Borrow'
    group by 1
    order by 1),
    polygon as (select date_trunc('month',block_timestamp) as "Date", sum(amount_usd) as volume_usd, count(distinct tx_hash) as borrowing_count
    , count(distinct BORROWER) as borrower_count, 'Polygon' as "Chain"
    from polygon.sushi.ez_borrowing
    where action='Borrow'
    and tx_hash not in ('0x0c9a289e6a092e40f0c6e774c7f144a9ef741a5be86f776ea3578e32e3c191aa','0xfda2866df4232d1aa82ac2bda046bc5ee5a2485825c08b4ab3bbfb3e7b85ca14'
    , '0x960308538932442149b5599e18f234256015456967a9e3b2778fd4598338fb44','0xbd46f6231c3aaae3fd915429192ecb0cc7b5308af2a11f2095a2433a019df7f0')
    group by 1
    order by 1)

    select * from arbitrum union all
    select * from avalanche union all
    select * from ethereum union all
    Run a query to Download Data