LTirrell123. [Easy] Anchor Borrows and Deposits
    Updated 2021-12-28
    -- Some inspiration taken from the example "Latest Borrows on Anchor":
    -- https://app.flipsidecrypto.com/velocity/queries/c1606e91-eea4-4686-80ac-f7212a0437c7
    SELECT
    block_timestamp :: date as datetime,
    sum(
    msg_value :execute_msg :borrow_stable :borrow_amount / POW(10, 6)
    ) as borrow_amount,
    sum(msg_value :coins [0] :amount / POW(10, 6)) as deposit_amount,
    avg(
    msg_value :execute_msg :borrow_stable :borrow_amount / POW(10, 6)
    ) as borrow_avg,
    avg(msg_value :coins [0] :amount / POW(10, 6)) as deposit_avg,
    median(
    msg_value :execute_msg :borrow_stable :borrow_amount / POW(10, 6)
    ) as borrow_median,
    median(msg_value :coins [0] :amount / POW(10, 6)) as deposit_median
    FROM
    terra.msgs
    WHERE
    msg_value :contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    AND datetime > '2021-03-20' -- Weird large deposits happen in the beginning of the date
    GROUP BY
    datetime
    ORDER BY
    datetime DESC
    Run a query to Download Data