Anchor Repayments

    How much is being repaid in loans on Anchor? How much UST debt is outstanding?

    As at 4:12 PM GMT, July 11, 2021;

    • Total UST loans stand at $1,171,316,819.1888149
    • Total repaid loans amount to $909,621,910.865778
    • Outstanding UST debt stands at $275,087,650.352667. This figure is higher than what you get when you directly subtract repaid total from borrowed total because part of the repaid amount is used to settle the interest accrued.

    Findings

    Loading...

    Results

    The results are presented below.

    After reconciliation, we go ahead, to sum up, all loans, repaid loans, and all outstanding debt.

    outstanding_debt AS (
      SELECT SUM(outstanding_debt) AS debt_outstanding_usd
      FROM recons
      WHERE outstanding_debt > 0
    ),
    
    totals AS (
        SELECT SUM(borrow_amount) AS borrowed_total_usd, SUM(repay_amount) AS repaid_total_usd
        FROM recons 
        LEFT JOIN outstanding_debt AS d
    )
    
    SELECT t.borrowed_total_usd, t.repaid_total_usd, d.debt_outstanding_usd
    FROM outstanding_debt AS d 
    LEFT JOIN totals AS t
    

    The next step is to reconcile. For every address, subtract the total repaid amount from the total borrowed amount. Where there is a result less than or equal to 0, we conclude that there is no outstanding debt.

    recons AS (
      SELECT b.borrower AS borrower, b.borrow_amount AS borrow_amount, r.repay_amount AS 
        repay_amount, 
          (b.borrow_amount - r.repay_amount) AS outstanding_debt
      FROM anchor_borrows AS b
      LEFT JOIN anchor_repays AS r ON b.borrower = r.borrower
    ), 
    

    Next, we need to get loan amounts repaid by every borrower. We write a query similar to the one above. We modify the query to get the repay amount instead of the borrowed amount. The repaid amount is also summed up for every user.

    anchor_repays AS (
      SELECT msg_value:sender::string AS borrower, SUM(msg_value:coins[0].amount/POW(10,6)) AS 
        repay_amount
      FROM terra.msgs
      WHERE msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s' 
        AND msg_value:execute_msg:repay_stable IS NOT NULL 
      GROUP BY 1
    ) 
    

    Method

    The first step is to get a sense of how much has been borrowed on Anchor. To do this, we get a list of all addresses that have borrowed and their total borrows. We get this from the terra.msgs table by specifying the Anchor Market smart contract deployed at terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s.

    WITH anchor_borrows AS (
      SELECT msg_value:sender::string AS borrower, 
        SUM(msg_value:execute_msg:borrow_stable:borrow_amount/POW(10,6)) AS borrow_amount 
      FROM terra.msgs 
      WHERE msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s' 
        AND msg_value:execute_msg:borrow_stable IS NOT NULL
      GROUP BY 1 
    ),
    

    Introduction

    Anchor is a savings protocol that accepts Terra deposits and pays depositors low-volatility interest rates. To generate yield, Anchor lends out deposits to borrowers who put down liquid-stake Proof of Stake assets as collateral. Users can borrow UST on Anchor by supplying bLUNA.

    This dashboard presents a summary of loans, repayments, and debt outstanding on Anchor.