rajsKashi Borrowing Collateral Asset Polygon
    Updated 2022-07-11
    SELECT
    date_trunc('day', block_timestamp) as date,
    collateral_address,
    sum(collateral_amount) as collateral_amount,
    count(*) as no_of_txs
    FROM
    (
    SELECT
    event_inputs:token as collateral_address,
    case when event_inputs:token = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then event_inputs:amount/pow(10,6)
    when event_inputs:token = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' then event_inputs:amount/pow(10,18)
    end as collateral_amount,
    block_timestamp,
    tx_hash
    from polygon.core.fact_event_logs
    where tx_hash IN
    (
    SELECT
    tx_hash
    from flipside_prod_db.crosschain.ez_borrowing
    where action = 'Borrow'
    and blockchain = 'polygon'
    and collateral_symbol in ('DAI', 'USDC')
    )
    and event_name = 'LogDeposit'
    )
    group by 1,2
    order by 1,3 desc
    Run a query to Download Data