drone-mostafa2023-05-27 02:36 PM copy
    Updated 2023-05-27
    -- forked from 2023-05-27 02:36 PM @ https://flipsidecrypto.xyz/edit/queries/153156a7-6944-42f2-b0ba-00ebe44b74ef

    SELECT

    count (DISTINCT TX_ID) as Txn,
    count (DISTINCT (case when EVENT_TYPE = 'Borrow' then EVENT_DATA:borrower else NULL end)) as BUsers,
    count (DISTINCT (case when EVENT_TYPE = 'Repay' then EVENT_DATA:borrower else NULL end)) as RUsers,

    sum (EVENT_DATA:scaledBorrowAmount /pow(10,18)) as USD,
    avg (EVENT_DATA:scaledBorrowAmount /pow(10,18)) as AVG_USD,
    USD / Users as USD_Per_User,
    Txn / Users as Txn_Per_User

    FROM flow.core.fact_events t1
    JOIN flow.core.fact_transactions using (TX_ID)
    WHERE (PAYER = '0x55ad22f01ef568a1' or PROPOSER = '0x55ad22f01ef568a1')
    and EVENT_TYPE in ( 'Borrow','Repay')
    and TX_SUCCEEDED = 'true'

    /*
    RepayBorrow
    Borrow
    ForLend
    LendOut




    A.67539e86cbe9b261.LendingPool
    */


    Run a query to Download Data