DiamondFunded Loan copy
    Updated 2024-08-05
    -- forked from Ario / Funded Loan @ https://flipsidecrypto.xyz/Ario/q/UJKDN5DH-30W/funded-loan

    -- Funding Loans
    select
    date_trunc(week, BLOCK_TIMESTAMP) as week,
    count(distinct EVENT_DATA:borrower) as "# Borrower",
    sum("# Borrower") over(order by week) as "Cum # Borrower",
    count(distinct EVENT_DATA:lender) as "# Lender",
    sum("# Lender") over(order by week) as "Cum # Lender",
    count(DISTINCT TX_ID) as "# Loan Count",
    sum("# Loan Count") over(order by week) as "Cum. Loan Count",
    sum(EVENT_DATA:repaymentAmount) as "Loan Volume",
    sum("Loan Volume") over(order by week) as "Cum. Loan Volume"
    select *
    from
    flow.core.fact_events
    where
    EVENT_CONTRACT = 'A.5c57f79c6694797f.Flowty'
    and EVENT_TYPE = 'FundingAvailable'
    and TX_SUCCEEDED = 'true'
    group by
    1
    order by 1 desc


    QueryRunArchived: QueryRun has been archived